svn commit: r736896 - in /ofbiz/trunk: framework/common/src/org/ofbiz/common/ framework/images/ runtime/tempfiles/ specialpurpose/myportal/script/org/ofbiz/myportal/ specialpurpose/myportal/widget/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r736896 - in /ofbiz/trunk: framework/common/src/org/ofbiz/common/ framework/images/ runtime/tempfiles/ specialpurpose/myportal/script/org/ofbiz/myportal/ specialpurpose/myportal/widget/

hansbak-2
Author: hansbak
Date: Thu Jan 22 19:14:27 2009
New Revision: 736896

URL: http://svn.apache.org/viewvc?rev=736896&view=rev
Log:
move temporary captcha to /runtime/tempfiles, this directory can now now read via the /tempfiles mountpoint in the browser, make it work on windows (not tested), reduced the size of the registration screen

Added:
    ofbiz/trunk/runtime/tempfiles/   (with props)
Modified:
    ofbiz/trunk/framework/common/src/org/ofbiz/common/Captcha.java
    ofbiz/trunk/framework/images/ofbiz-component.xml
    ofbiz/trunk/specialpurpose/myportal/script/org/ofbiz/myportal/Events.xml
    ofbiz/trunk/specialpurpose/myportal/widget/CommonScreens.xml
    ofbiz/trunk/specialpurpose/myportal/widget/MyPortalForms.xml

Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/Captcha.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/Captcha.java?rev=736896&r1=736895&r2=736896&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/src/org/ofbiz/common/Captcha.java (original)
+++ ofbiz/trunk/framework/common/src/org/ofbiz/common/Captcha.java Thu Jan 22 19:14:27 2009
@@ -24,6 +24,7 @@
 import javax.imageio.ImageIO;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import org.ofbiz.base.util.UtilHttp;
 import java.awt.*;
 import java.awt.geom.AffineTransform;
 import java.awt.image.BufferedImage;
@@ -33,8 +34,11 @@
 public class Captcha {
 
     public static String ID_KEY = null;
+    public static String CAPTCHA_FILE_NAME = null;
+ public static String CAPTCHA_FILE_PATH = null;
 
     public static String getCodeCaptcha(HttpServletRequest request,HttpServletResponse response) {
+     if(CAPTCHA_FILE_PATH != null) deleteFile();
      StringBuffer finalString = new StringBuffer();
         String elegibleChars = "ABCDEFGHJKLMPQRSTUVWXYabcdefhjkmnpqrstuvwxy23456789";
         int charsToPrint = 6;
@@ -125,32 +129,44 @@
             g.setColor(borderColor);
             g.drawRect(0, 0, width - 1, height - 1);
             g.dispose();
-            Captcha.writeImage(bufferedImage, "captchaImage.png");
+            Captcha.writeImage(bufferedImage, request);
 
         } catch (Exception ioe) {
             return false;
         }
-    //Adding this because we called response.getOutputStream() above. This will prevent and illegal state exception being thrown
+        //Adding this because we called response.getOutputStream() above. This will prevent and illegal state exception being thrown
         return true;
     }
     
- public static void writeImage(BufferedImage image, String fileName)
+ public static void writeImage(BufferedImage image, HttpServletRequest request)
  {
- if (fileName == null) return;
- int offset = fileName.lastIndexOf( "." );
- String type = offset == -1 ? "png" : fileName.substring(offset + 1);
- String path;
+ String fileName = UtilHttp.getSessionId(request).substring(0,6);
+ fileName += "_"+UtilHttp.getSessionId(request).substring(UtilHttp.getSessionId(request).length()-11,UtilHttp.getSessionId(request).indexOf("."));
  try {
- path = new java.io.File(".").getCanonicalPath();
- path += "/framework/images/webapp/images/";
- path += fileName;
- System.out.println("\n\nPath =  "+path+"\n");
+ CAPTCHA_FILE_PATH = new java.io.File(".").getCanonicalPath();
+ CAPTCHA_FILE_PATH += File.separator + "runtime" + File.separator + "tempfiles";
+ CAPTCHA_FILE_PATH += File.separator + "captcha" + File.separator;
+ File test = new File(CAPTCHA_FILE_PATH);
+ if (!test.exists()) {
+ test.mkdir();
+ }
+ CAPTCHA_FILE_PATH += fileName + ".png";
+ CAPTCHA_FILE_NAME = fileName + ".png";
+ request.setAttribute("fileName", CAPTCHA_FILE_NAME);
+ System.out.println("\n\nPath =  "+CAPTCHA_FILE_PATH+"\n");
  System.out.println("Captcha Key =  "+ID_KEY+"\n\n");
- ImageIO.write(image, type, new File( path ));
+ ImageIO.write(image, "png", new File( CAPTCHA_FILE_PATH ));
  } catch (IOException e) {
  return;
  }
  }
+
+ public static void deleteFile() {
+ if(CAPTCHA_FILE_PATH != null){
+       File file = new File(CAPTCHA_FILE_PATH);
+       file.delete();
+ }
+ }
 
     public static String paramString(HttpServletRequest request, String paramName,
             String defaultString) {

Modified: ofbiz/trunk/framework/images/ofbiz-component.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/ofbiz-component.xml?rev=736896&r1=736895&r2=736896&view=diff
==============================================================================
--- ofbiz/trunk/framework/images/ofbiz-component.xml (original)
+++ ofbiz/trunk/framework/images/ofbiz-component.xml Thu Jan 22 19:14:27 2009
@@ -28,5 +28,11 @@
         location="webapp/images"
         mount-point="/images"
         app-bar-display="false"/>
+    <webapp name="tempfiles"
+        title="temporary files"
+        server="default-server"
+        location="../../runtime/tempfiles"
+        mount-point="/tempfiles"
+        app-bar-display="false"/>
 </ofbiz-component>
 

Propchange: ofbiz/trunk/runtime/tempfiles/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Jan 22 19:14:27 2009
@@ -0,0 +1 @@
+captcha

Modified: ofbiz/trunk/specialpurpose/myportal/script/org/ofbiz/myportal/Events.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/myportal/script/org/ofbiz/myportal/Events.xml?rev=736896&r1=736895&r2=736896&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/myportal/script/org/ofbiz/myportal/Events.xml (original)
+++ ofbiz/trunk/specialpurpose/myportal/script/org/ofbiz/myportal/Events.xml Thu Jan 22 19:14:27 2009
@@ -220,8 +220,7 @@
         <set field="data._uploadedFile_fileName" from-field="formInput.imageFileName"/>
         <set field="data._uploadedFile_contentType" from-field="formInput.formInput.mimeTypeId"/>
         <call-service service-name="createDataResource" in-map-name="data">
-            <result-to-field result-name="dataResourceId" field="dataResourceId"
-                map-name="parameters"/>
+            <result-to-field result-name="dataResourceId" field="parameters.dataResourceId"/>
         </call-service>
         <log level="always" message=" DataResource : ${parameters.dataResourceId}"/>
 
@@ -321,12 +320,12 @@
         <if-empty field="parameters.PASSWORD"><property-to-field field="errorMessage" resource="PartyUiLabels" property="PartyPasswordMissing"/><field-to-list field="errorMessage" list="error_list"/></if-empty>
         <call-bsh><![CDATA[
             parameters.put("captchaCode",org.ofbiz.common.Captcha.ID_KEY);
-        ]]></call-bsh>
-        <call-object-method obj-field="PASSWORD" obj-map-name="parameters" method-name="toLowerCase" ret-field="PASSWORD" ret-map-name="parameters"/>
-        <call-object-method obj-field="CONFIRM_PASSWORD" obj-map-name="parameters" method-name="toLowerCase" ret-field="CONFIRM_PASSWORD" ret-map-name="parameters"/>
+            ]]></call-bsh>
+        <call-object-method obj-field="parameters.PASSWORD" method-name="toLowerCase" ret-field="parameters.PASSWORD"/>
+        <call-object-method obj-field="parameters.CONFIRM_PASSWORD" method-name="toLowerCase" ret-field="parameters.CONFIRM_PASSWORD"/>
         <if-compare field="parameters.PASSWORD" value="${parameters.CONFIRM_PASSWORD}" operator="equals">
-            <call-object-method obj-field="captcha" obj-map-name="parameters" method-name="toLowerCase" ret-field="captcha" ret-map-name="parameters"/>
-            <call-object-method obj-field="captchaCode" obj-map-name="parameters" method-name="toLowerCase" ret-field="captchaCode" ret-map-name="parameters"/>
+            <call-object-method obj-field="parameters.captcha" method-name="toLowerCase" ret-field="parameters.captcha"/>
+            <call-object-method obj-field="parameters.captchaCode" method-name="toLowerCase" ret-field="parameters.captchaCode"/>
             <if-compare field="parameters.captcha" value="${parameters.captchaCode}" operator="equals">                
   
                 <!-- Create Person -->
@@ -394,5 +393,6 @@
             </else>
         </if-compare>      
         <check-errors error-list-name="error_list" error-code="resultPage"/>
+        <call-class-method class-name="org.ofbiz.common.Captcha" method-name="deleteFile"/>
     </simple-method>
 </simple-methods>

Modified: ofbiz/trunk/specialpurpose/myportal/widget/CommonScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/myportal/widget/CommonScreens.xml?rev=736896&r1=736895&r2=736896&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/myportal/widget/CommonScreens.xml (original)
+++ ofbiz/trunk/specialpurpose/myportal/widget/CommonScreens.xml Thu Jan 22 19:14:27 2009
@@ -223,6 +223,9 @@
                                     </container>
                                     <container style="screenlet-body">
                                         <section>
+                                            <actions>
+                                                <set field="fileName" from-field="parameters.fileName"/>
+                                            </actions>
                                             <widgets>
                                                 <include-form name="RegisterPerson" location="component://myportal/widget/MyPortalForms.xml"/>
                                             </widgets>

Modified: ofbiz/trunk/specialpurpose/myportal/widget/MyPortalForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/myportal/widget/MyPortalForms.xml?rev=736896&r1=736895&r2=736896&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/myportal/widget/MyPortalForms.xml (original)
+++ ofbiz/trunk/specialpurpose/myportal/widget/MyPortalForms.xml Thu Jan 22 19:14:27 2009
@@ -362,13 +362,41 @@
                 </entity-options>
             </drop-down>
         </field>
+        <field name="personalTitle"><ignored/></field>
+        <field name="suffix"><ignored/></field>
+        <field name="nickname"><ignored/></field>
+        <field name="firstNameLocal"><ignored/></field>
+        <field name="middleNameLocal"><ignored/></field>        
+        <field name="lastNameLocal"><ignored/></field>
+        <field name="otherLocal"><ignored/></field>        
+        <field name="memberId"><ignored/></field>
+        <field name="gender"><ignored/></field>
+        <field name="birthDate"><ignored/></field>
+        <field name="height"><ignored/></field>
+        <field name="weight"><ignored/></field>
+        <field name="mothersMaidenName"><ignored/></field>
+        <field name="maritalStatus"><ignored/></field>
+        <field name="socialSecurityNumber"><ignored/></field>
+        <field name="passportNumber"><ignored/></field>
+        <field name="passportExpireDate"><ignored/></field>
+        <field name="totalYearsWorkExperience"><ignored/></field>
+        <field name="employmentStatusEnumId"><ignored/></field>
+        <field name="residenceStatusEnumId"><ignored/></field>
+        <field name="occupation"><ignored/></field>
+        <field name="yearsWithEmployer"><ignored/></field>
+        <field name="monthsWithEmployer"><ignored/></field>
+        <field name="preferredCurrencyUomId"><ignored/></field>
+        <field name="description"><ignored/></field>
+        <field name="externalId"><ignored/></field>
+        <field name="existingCustomer"><ignored/></field>
+        <field name="comments" title="Why you would like a Log in?"/>
         <field name="UserLogin" title="${uiLabelMap.UserLogin}" title-area-style="group-label"><display description=" " also-hidden="false"/></field>
         <field name="USERNAME" title="${uiLabelMap.CommonUsername}" tooltip="${uiLabelMap.CommonRequired}" widget-style="required"><text size="30" maxlength="250"/></field>
         <field name="PASSWORD" title="${uiLabelMap.CommonPassword}" tooltip="${uiLabelMap.CommonRequired}" widget-style="required"><password size="15" maxlength="250"/></field>
         <field name="CONFIRM_PASSWORD" title="${uiLabelMap.CommonPassword}" tooltip="* ${uiLabelMap.CommonConfirm}" widget-style="required"><password size="15" maxlength="250"/></field>
         <field name="VerifyCaptchaTitle" title="${uiLabelMap.VerifyCaptcha}" title-area-style="group-label"><display description=" " also-hidden="false"/></field>
-        <field name="picOfcaptcha" title="${uiLabelMap.PicCaptcha}"><image value="/images/captchaImage.png"></image></field>
-        <field name="reload" title=" "><image value="/images/feed-icon-14x14.png"><sub-hyperlink target="newRegisterLogin" description="reload image"/></image></field>
+        <field name="picOfcaptcha" title="${uiLabelMap.PicCaptcha}"><image value="/tempfiles/captcha/${parameters.fileName}"></image></field>
+        <field name="reload" title=" "><hyperlink target="newRegisterLogin" description="reload image"/></field>
         <field name="captcha" title="${uiLabelMap.VerifyCaptcha}" tooltip="${uiLabelMap.CommonRequired}" widget-style="required"><text size="23" maxlength="30"/></field>
         <field name="submitButton" title="${uiLabelMap.CommonSave}" title-area-style="group-label"><submit button-type="button"/></field>
     </form>