svn commit: r1608347 [2/3] - in /ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23: ./ applications/accounting/widget/ applications/marketing/script/org/ofbiz/marketing/campaign/ applications/marketing/script/org/ofbiz/marketing/contact/ applica...

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

svn commit: r1608347 [2/3] - in /ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23: ./ applications/accounting/widget/ applications/marketing/script/org/ofbiz/marketing/campaign/ applications/marketing/script/org/ofbiz/marketing/contact/ applica...

jleroux@apache.org
Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java?rev=1608347&r1=1608346&r2=1608347&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java Mon Jul  7 06:50:24 2014
@@ -66,6 +66,7 @@ import freemarker.template.TemplateExcep
 import freemarker.template.TemplateExceptionHandler;
 import freemarker.template.TemplateModel;
 import freemarker.template.TemplateModelException;
+import freemarker.template.Version;
 
 /** FreeMarkerWorker - Freemarker Template Engine Utilities.
  *
@@ -74,9 +75,11 @@ public class FreeMarkerWorker {
 
     public static final String module = FreeMarkerWorker.class.getName();
 
+    public static final Version version = new Version(2, 3, 21);
+
     // use soft references for this so that things from Content records don't kill all of our memory, or maybe not for performance reasons... hmmm, leave to config file...
     private static final UtilCache<String, Template> cachedTemplates = UtilCache.createUtilCache("template.ftl.general", 0, 0, false);
-    private static final BeansWrapper defaultOfbizWrapper = configureBeansWrapper(new BeansWrapper());
+    private static final BeansWrapper defaultOfbizWrapper = configureBeansWrapper(new BeansWrapper(version));
     private static final Configuration defaultOfbizConfig = makeConfiguration(defaultOfbizWrapper);
 
     public static BeansWrapper getDefaultOfbizWrapper() {
@@ -84,12 +87,11 @@ public class FreeMarkerWorker {
     }
 
     public static <T extends BeansWrapper> T configureBeansWrapper(T wrapper) {
-        wrapper.setNullWildcards(true);
         return wrapper;
     }
 
     public static Configuration makeConfiguration(BeansWrapper wrapper) {
-        Configuration newConfig = new Configuration();
+        Configuration newConfig = new Configuration(version);
 
         newConfig.setObjectWrapper(wrapper);
         newConfig.setSharedVariable("Static", wrapper.getStaticModels());

Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/base/src/org/ofbiz/base/util/test/UtilIOTests.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/base/src/org/ofbiz/base/util/test/UtilIOTests.java?rev=1608347&r1=1608346&r2=1608347&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/base/src/org/ofbiz/base/util/test/UtilIOTests.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/base/src/org/ofbiz/base/util/test/UtilIOTests.java Mon Jul  7 06:50:24 2014
@@ -138,6 +138,8 @@ public class UtilIOTests extends Generic
     }
 
     protected void checkBasicReadWriteObject(Object value, String text) throws Exception {
+        String lineEnding = System.getProperty("line.separator");
+        text = text.replaceAll("\n", lineEnding);
         byte[] bytes = text.getBytes("UTF-8");
         assertEquals("read bytes " + value.getClass().getName(), value, UtilIO.readObject(new ByteArrayInputStream(bytes)));
         assertEquals("read chars " + value.getClass().getName(), value, UtilIO.readObject(text.toCharArray()));
@@ -147,7 +149,7 @@ public class UtilIOTests extends Generic
         assertEquals("write stream " + value.getClass().getName(), text, new String(baos.toByteArray(), "UTF-8"));
         StringBuilder sb = new StringBuilder();
         UtilIO.writeObject(sb, value);
-        sb.append('\n');
+        sb.append(lineEnding);
         assertEquals("write builder " + value.getClass().getName(), text, sb.toString());
     }
 

Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/bi/build.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/bi/build.xml?rev=1608347&r1=1608346&r2=1608347&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/bi/build.xml (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/bi/build.xml Mon Jul  7 06:50:24 2014
@@ -46,6 +46,6 @@ under the License.
     <!-- ================================================================== -->
 
     <target name="classes" depends="prepare">
-        <javac16 classpathref="local.class.path"/>
+        <javac17 classpathref="local.class.path"/>
     </target>
 </project>

Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/common/src/org/ofbiz/common/email/EmailServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/common/src/org/ofbiz/common/email/EmailServices.java?rev=1608347&r1=1608346&r2=1608347&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/common/src/org/ofbiz/common/email/EmailServices.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/common/src/org/ofbiz/common/email/EmailServices.java Mon Jul  7 06:50:24 2014
@@ -143,6 +143,9 @@ public class EmailServices {
             sendTo = redirectAddress;
             sendCc = null;
             sendBcc = null;
+            if (subject.length() > 255) {
+                subject = subject.substring(0, 255);
+            }
         }
 
         String sendFrom = (String) context.get("sendFrom");

Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/dtd/entitymodel.xsd
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/dtd/entitymodel.xsd?rev=1608347&r1=1608346&r2=1608347&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/dtd/entitymodel.xsd (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/dtd/entitymodel.xsd Mon Jul  7 06:50:24 2014
@@ -135,7 +135,15 @@ under the License.
         <xs:attribute name="name" type="xs:string" use="required"/>
         <xs:attribute name="col-name" type="xs:string"/>
         <xs:attribute name="type" type="xs:string" use="required"/>
-        <xs:attribute name="encrypt" default="false" type="boolean"/>
+        <xs:attribute name="encrypt" default="false">
+            <xs:simpleType>
+                <xs:restriction base="xs:token">
+                    <xs:enumeration value="true"/>
+                    <xs:enumeration value="false"/>
+                    <xs:enumeration value="salt"/>
+                </xs:restriction>
+            </xs:simpleType>
+        </xs:attribute>
         <xs:attribute name="enable-audit-log" default="false" type="boolean">
             <xs:annotation>
                 <xs:documentation>

Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/entitydef/entitymodel_test.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/entitydef/entitymodel_test.xml?rev=1608347&r1=1608346&r2=1608347&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/entitydef/entitymodel_test.xml (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/entitydef/entitymodel_test.xml Mon Jul  7 06:50:24 2014
@@ -186,4 +186,41 @@ under the License.
         <key-map field-name="testingId"/>
       </relation>
     </view-entity>
+
+    <!-- =========================================================
+    The testing entity is a basic entity with a type
+    ========================================================= -->
+    <entity entity-name="TestingCrypto"
+        package-name="org.ofbiz.entity.test"
+        title="Testing Crypto Entity">
+        <field name="testingCryptoId" type="id-ne"/>
+        <field name="testingCryptoTypeId" type="id-ne"/>
+        <field name="unencryptedValue" type="description"/>
+        <field name="encryptedValue" type="description" encrypt="true"/>
+        <field name="saltedEncryptedValue" type="description" encrypt="salt"/>
+        <prim-key field="testingCryptoId"/>
+    </entity>
+    <view-entity entity-name="TestingCryptoRawView"
+            package-name="org.ofbiz.entity.test"
+            title="TestingCrypto Raw View">
+      <member-entity entity-alias="TC" entity-name="TestingCrypto"/>
+      <alias-all entity-alias="TC"/>
+      <alias name="rawEncryptedValue">
+        <complex-alias operator="+">
+          <complex-alias-field entity-alias="TC" field="encryptedValue"/>
+        </complex-alias>
+      </alias>
+      <alias name="rawSaltedEncryptedValue">
+        <complex-alias operator="+">
+          <complex-alias-field entity-alias="TC" field="saltedEncryptedValue"/>
+        </complex-alias>
+      </alias>
+    </view-entity>
+    <entity entity-name="TestingRemoveAll"
+        package-name="org.ofbiz.entity.test"
+        title="Testing Entity">
+        <field name="testingRemoveAllId" type="id-ne"/>
+        <field name="description" type="description"/>
+        <prim-key field="testingRemoveAllId"/>
+    </entity>
 </entitymodel>

Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/Delegator.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/Delegator.java?rev=1608347&r1=1608346&r2=1608347&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/Delegator.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/Delegator.java Mon Jul  7 06:50:24 2014
@@ -33,6 +33,7 @@ import org.ofbiz.entity.datasource.Gener
 import org.ofbiz.entity.eca.EntityEcaHandler;
 import org.ofbiz.entity.model.DynamicViewEntity;
 import org.ofbiz.entity.model.ModelEntity;
+import org.ofbiz.entity.model.ModelField;
 import org.ofbiz.entity.model.ModelFieldType;
 import org.ofbiz.entity.model.ModelFieldTypeReader;
 import org.ofbiz.entity.model.ModelGroupReader;
@@ -256,16 +257,25 @@ public interface Delegator {
      */
     public GenericValue createSingle(String entityName, Object singlePkValue) throws GenericEntityException;
 
+    @Deprecated
     public void decryptFields(GenericEntity entity) throws GenericEntityException;
 
+    @Deprecated
     public void decryptFields(List<? extends GenericEntity> entities) throws GenericEntityException;
 
+    @Deprecated
     public void encryptFields(GenericEntity entity) throws GenericEntityException;
 
+    @Deprecated
     public void encryptFields(List<? extends GenericEntity> entities) throws GenericEntityException;
 
+    public Object decryptFieldValue(String entityName, String encValue) throws EntityCryptoException;
+
+    @Deprecated
     public Object encryptFieldValue(String entityName, Object fieldValue) throws EntityCryptoException;
 
+    public Object encryptFieldValue(String entityName, ModelField.EncryptMethod encryptMethod, Object fieldValue) throws EntityCryptoException;
+
     /**
      * Finds GenericValues by the conditions specified in the EntityCondition
      * object, the the EntityCondition javadoc for more details. NOTE 20080502:

Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/GenericDelegator.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/GenericDelegator.java?rev=1608347&r1=1608346&r2=1608347&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/GenericDelegator.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/GenericDelegator.java Mon Jul  7 06:50:24 2014
@@ -798,7 +798,6 @@ public class GenericDelegator implements
             ecaRunner.evalRules(EntityEcaHandler.EV_RUN, EntityEcaHandler.OP_CREATE, value, false);
 
             value.setDelegator(this);
-            this.encryptFields(value);
 
             // if audit log on for any fields, save new value with no old value because it's a create
             if (value != null && value.getModelEntity().getHasFieldWithAuditLog()) {
@@ -892,7 +891,6 @@ public class GenericDelegator implements
             ecaRunner.evalRules(EntityEcaHandler.EV_RUN, EntityEcaHandler.OP_CREATE, value, false);
 
             value.setDelegator(this);
-            this.encryptFields(value);
 
             // if audit log on for any fields, save new value with no old value because it's a create
             if (value != null && value.getModelEntity().getHasFieldWithAuditLog()) {
@@ -1196,7 +1194,7 @@ public class GenericDelegator implements
                 removedEntities = this.findList(entityName, condition, null, null, null, false);
             }
 
-            int rowsAffected = helper.removeByCondition(modelEntity, condition);
+            int rowsAffected = helper.removeByCondition(this, modelEntity, condition);
 
             if (testMode) {
                 for (GenericValue entity : removedEntities) {
@@ -1310,7 +1308,7 @@ public class GenericDelegator implements
                 updatedEntities = this.findList(entityName, condition, null, null, null, false);
             }
 
-            int rowsAffected =  helper.storeByCondition(modelEntity, fieldsToSet, condition);
+            int rowsAffected =  helper.storeByCondition(this, modelEntity, fieldsToSet, condition);
 
             if (testMode) {
                 for (GenericValue entity : updatedEntities) {
@@ -1353,7 +1351,6 @@ public class GenericDelegator implements
             GenericHelper helper = getEntityHelper(value.getEntityName());
 
             ecaRunner.evalRules(EntityEcaHandler.EV_RUN, EntityEcaHandler.OP_STORE, value, false);
-            this.encryptFields(value);
 
             // if audit log on for any fields, save old value before the update so we still have both
             if (value.getModelEntity().getHasFieldWithAuditLog()) {
@@ -1439,7 +1436,6 @@ public class GenericDelegator implements
                 GenericValue existing = null;
                 try {
                     existing = helper.findByPrimaryKey(primaryKey);
-                    this.decryptFields(existing);
                 } catch (GenericEntityNotFoundException e) {
                     existing = null;
                 }
@@ -1586,7 +1582,6 @@ public class GenericDelegator implements
             }
             if (value != null) {
                 value.setDelegator(this);
-                this.decryptFields(value);
             }
 
             if (useCache) {
@@ -1770,16 +1765,14 @@ public class GenericDelegator implements
 
         if (whereEntityCondition != null) {
             whereEntityCondition.checkCondition(modelEntity);
-            whereEntityCondition.encryptConditionFields(modelEntity, this);
         }
         if (havingEntityCondition != null) {
             havingEntityCondition.checkCondition(modelEntity);
-            havingEntityCondition.encryptConditionFields(modelEntity, this);
         }
 
         ecaRunner.evalRules(EntityEcaHandler.EV_RUN, EntityEcaHandler.OP_FIND, dummyValue, false);
         GenericHelper helper = getEntityHelper(modelEntity.getEntityName());
-        EntityListIterator eli = helper.findListIteratorByCondition(modelEntity, whereEntityCondition, havingEntityCondition, fieldsToSelect, orderBy, findOptions);
+        EntityListIterator eli = helper.findListIteratorByCondition(this, modelEntity, whereEntityCondition, havingEntityCondition, fieldsToSelect, orderBy, findOptions);
         eli.setDelegator(this);
 
         ecaRunner.evalRules(EntityEcaHandler.EV_RETURN, EntityEcaHandler.OP_FIND, dummyValue, false);
@@ -1851,7 +1844,7 @@ public class GenericDelegator implements
         if (havingEntityCondition != null) havingEntityCondition.checkCondition(modelViewEntity);
 
         GenericHelper helper = getEntityHelper(dynamicViewEntity.getOneRealEntityName());
-        EntityListIterator eli = helper.findListIteratorByCondition(modelViewEntity, whereEntityCondition,
+        EntityListIterator eli = helper.findListIteratorByCondition(this, modelViewEntity, whereEntityCondition,
                 havingEntityCondition, fieldsToSelect, orderBy, findOptions);
         eli.setDelegator(this);
         //TODO: add decrypt fields
@@ -1878,16 +1871,14 @@ public class GenericDelegator implements
 
             if (whereEntityCondition != null) {
                 whereEntityCondition.checkCondition(modelEntity);
-                whereEntityCondition.encryptConditionFields(modelEntity, this);
             }
             if (havingEntityCondition != null) {
                 havingEntityCondition.checkCondition(modelEntity);
-                havingEntityCondition.encryptConditionFields(modelEntity, this);
             }
 
             ecaRunner.evalRules(EntityEcaHandler.EV_RUN, EntityEcaHandler.OP_FIND, dummyValue, false);
             GenericHelper helper = getEntityHelper(modelEntity.getEntityName());
-            long count = helper.findCountByCondition(modelEntity, whereEntityCondition, havingEntityCondition, findOptions);
+            long count = helper.findCountByCondition(this, modelEntity, whereEntityCondition, havingEntityCondition, findOptions);
 
             ecaRunner.evalRules(EntityEcaHandler.EV_RETURN, EntityEcaHandler.OP_FIND, dummyValue, false);
             TransactionUtil.commit(beganTransaction);
@@ -2625,94 +2616,66 @@ public class GenericDelegator implements
      * @see org.ofbiz.entity.Delegator#encryptFields(java.util.List)
      */
     @Override
+    @Deprecated
     public void encryptFields(List<? extends GenericEntity> entities) throws GenericEntityException {
-        if (entities != null) {
-            for (GenericEntity entity: entities) {
-                this.encryptFields(entity);
-            }
-        }
     }
 
     /* (non-Javadoc)
      * @see org.ofbiz.entity.Delegator#encryptFields(org.ofbiz.entity.GenericEntity)
      */
     @Override
+    @Deprecated
     public void encryptFields(GenericEntity entity) throws GenericEntityException {
-        ModelEntity model = entity.getModelEntity();
-        String entityName = model.getEntityName();
-
-        Iterator<ModelField> i = model.getFieldsIterator();
-        while (i.hasNext()) {
-            ModelField field = i.next();
-            if (field.getEncrypt()) {
-                Object obj = entity.get(field.getName());
-                if (obj != null) {
-                    if (obj instanceof String && UtilValidate.isEmpty(obj)) {
-                        continue;
-                    }
-                    entity.dangerousSetNoCheckButFast(field, this.encryptFieldValue(entityName, obj));
-                }
-            }
-        }
     }
 
     /* (non-Javadoc)
      * @see org.ofbiz.entity.Delegator#encryptFieldValue(java.lang.String, java.lang.Object)
      */
     @Override
+    @Deprecated
     public Object encryptFieldValue(String entityName, Object fieldValue) throws EntityCryptoException {
+        return encryptFieldValue(entityName, null, fieldValue);
+    }
+
+    @Override
+    public Object encryptFieldValue(String entityName, ModelField.EncryptMethod encryptMethod, Object fieldValue) throws EntityCryptoException {
+        if (encryptMethod == null) {
+            encryptMethod = ModelField.EncryptMethod.TRUE;
+        }
         if (fieldValue != null) {
             if (fieldValue instanceof String && UtilValidate.isEmpty(fieldValue)) {
                 return fieldValue;
             }
-            return this.crypto.encrypt(entityName, fieldValue);
+            return this.crypto.encrypt(entityName, encryptMethod, fieldValue);
         }
         return fieldValue;
     }
 
     /* (non-Javadoc)
+     * @see org.ofbiz.entity.Delegator#encryptFieldValue(java.lang.String, java.lang.Object)
+     */
+    @Override
+    public Object decryptFieldValue(String entityName, String encValue) throws EntityCryptoException {
+        if (UtilValidate.isNotEmpty(encValue)) {
+            return this.crypto.decrypt(entityName, encValue);
+        }
+        return null;
+    }
+
+    /* (non-Javadoc)
      * @see org.ofbiz.entity.Delegator#decryptFields(java.util.List)
      */
     @Override
+    @Deprecated
     public void decryptFields(List<? extends GenericEntity> entities) throws GenericEntityException {
-        if (entities != null) {
-            for (GenericEntity entity: entities) {
-                this.decryptFields(entity);
-            }
-        }
     }
 
     /* (non-Javadoc)
      * @see org.ofbiz.entity.Delegator#decryptFields(org.ofbiz.entity.GenericEntity)
      */
     @Override
+    @Deprecated
     public void decryptFields(GenericEntity entity) throws GenericEntityException {
-        ModelEntity model = entity.getModelEntity();
-        String entityName = model.getEntityName();
-
-        Iterator<ModelField> i = model.getFieldsIterator();
-        while (i.hasNext()) {
-            ModelField field = i.next();
-            if (field.getEncrypt()) {
-                String keyName = entityName;
-                if (model instanceof ModelViewEntity) {
-                    ModelViewEntity modelView = (ModelViewEntity) model;
-                    keyName = modelView.getAliasedEntity(modelView.getAlias(field.getName()).getEntityAlias(), modelReader).getEntityName();
-                }
-
-                String encValue = (String) entity.get(field.getName());
-                if (UtilValidate.isNotEmpty(encValue)) {
-                    try {
-                        entity.dangerousSetNoCheckButFast(field, crypto.decrypt(keyName, encValue));
-                    } catch (EntityCryptoException e) {
-                        // not fatal -- allow returning of the encrypted value
-                        if (Debug.warningOn()) {
-                            Debug.logWarning(e, "Problem decrypting field [" + entityName + " / " + field.getName() + "]", module);
-                        }
-                    }
-                }
-            }
-        }
     }
 
     /* (non-Javadoc)

Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/GenericEntity.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/GenericEntity.java?rev=1608347&r1=1608346&r2=1608347&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/GenericEntity.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/GenericEntity.java Mon Jul  7 06:50:24 2014
@@ -1335,7 +1335,7 @@ public class GenericEntity implements Ma
         for (String curKey: new TreeSet<String>(fields.keySet())) {
             Object curValue = fields.get(curKey);
             ModelField field = this.getModelEntity().getField(curKey);
-            if (field.getEncrypt() && curValue instanceof String) {
+            if (field.getEncryptMethod().isEncrypted() && curValue instanceof String) {
                 String encryptField = (String) curValue;
                 // the encryptField may not actually be UTF8, it could be any
                 // random encoding; just treat it as a series of raw bytes.

Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityCondition.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityCondition.java?rev=1608347&r1=1608346&r2=1608347&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityCondition.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityCondition.java Mon Jul  7 06:50:24 2014
@@ -21,11 +21,10 @@ package org.ofbiz.entity.condition;
 import static org.ofbiz.base.util.UtilGenerics.cast;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 
-import javolution.lang.Reusable;
-
 import org.ofbiz.base.lang.IsEmpty;
 import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.GenericEntity;
@@ -45,96 +44,66 @@ import org.ofbiz.entity.model.ModelEntit
  *
  */
 @SuppressWarnings("serial")
-public abstract class EntityCondition extends EntityConditionBase implements IsEmpty, Reusable {
+public abstract class EntityCondition extends EntityConditionBase implements IsEmpty {
 
     public static <L,R,LL,RR> EntityExpr makeCondition(L lhs, EntityComparisonOperator<LL,RR> operator, R rhs) {
-        EntityExpr expr = new EntityExpr();
-        expr.init(lhs, operator, rhs);
-        return expr;
+        return new EntityExpr(lhs, operator, rhs);
     }
 
     public static <R> EntityExpr makeCondition(String fieldName, R value) {
-        EntityExpr expr = new EntityExpr();
-        expr.init(fieldName, EntityOperator.EQUALS, value);
-        return expr;
+        return new EntityExpr(fieldName, EntityOperator.EQUALS, value);
     }
 
     public static EntityExpr makeCondition(EntityCondition lhs, EntityJoinOperator operator, EntityCondition rhs) {
-        EntityExpr expr = new EntityExpr();
-        expr.init(lhs, operator, rhs);
-        return expr;
+        return new EntityExpr(lhs, operator, rhs);
     }
 
     public static <T extends EntityCondition> EntityConditionList<T> makeCondition(EntityJoinOperator operator, T... conditionList) {
-        EntityConditionList<T> ecl = cast(new EntityConditionList<T>());
-        ecl.init(operator, conditionList);
-        return ecl;
+        return new EntityConditionList<T>(Arrays.<T>asList(conditionList), operator);
     }
 
     public static <T extends EntityCondition> EntityConditionList<T> makeCondition(T... conditionList) {
-        EntityConditionList<T> ecl = cast(new EntityConditionList<T>());
-        ecl.init(EntityOperator.AND, conditionList);
-        return ecl;
+        return new EntityConditionList<T>(Arrays.<T>asList(conditionList), EntityOperator.AND);
     }
 
     public static <T extends EntityCondition> EntityConditionList<T> makeCondition(List<T> conditionList, EntityJoinOperator operator) {
-        EntityConditionList<T> ecl = cast(new EntityConditionList<T>());
-        ecl.init(conditionList, operator);
-        return ecl;
+        return new EntityConditionList<T>(conditionList, operator);
     }
 
     public static <T extends EntityCondition> EntityConditionList<T> makeCondition(List<T> conditionList) {
-        EntityConditionList<T> ecl = cast(new EntityConditionList<T>());
-        ecl.init(conditionList, EntityOperator.AND);
-        return ecl;
+        return new EntityConditionList<T>(conditionList, EntityOperator.AND);
     }
 
     public static <L,R> EntityFieldMap makeCondition(Map<String, ? extends Object> fieldMap, EntityComparisonOperator<L,R> compOp, EntityJoinOperator joinOp) {
-        EntityFieldMap efm = new EntityFieldMap();
-        efm.init(fieldMap, compOp, joinOp);
-        return efm;
+        return new EntityFieldMap(fieldMap, compOp, joinOp);
     }
 
     public static EntityFieldMap makeCondition(Map<String, ? extends Object> fieldMap, EntityJoinOperator joinOp) {
-        EntityFieldMap efm = new EntityFieldMap();
-        efm.init(fieldMap, EntityOperator.EQUALS, joinOp);
-        return efm;
+        return new EntityFieldMap(fieldMap, EntityOperator.EQUALS, joinOp);
     }
 
     public static EntityFieldMap makeCondition(Map<String, ? extends Object> fieldMap) {
-        EntityFieldMap efm = new EntityFieldMap();
-        efm.init(fieldMap, EntityOperator.EQUALS, EntityOperator.AND);
-        return efm;
+        return new EntityFieldMap(fieldMap, EntityOperator.EQUALS, EntityOperator.AND);
     }
 
     public static <L,R> EntityFieldMap makeCondition(EntityComparisonOperator<L,R> compOp, EntityJoinOperator joinOp, Object... keysValues) {
-        EntityFieldMap efm = new EntityFieldMap();
-        efm.init(compOp, joinOp, keysValues);
-        return efm;
+        return new EntityFieldMap(compOp, joinOp, keysValues);
     }
 
     public static EntityFieldMap makeCondition(EntityJoinOperator joinOp, Object... keysValues) {
-        EntityFieldMap efm = new EntityFieldMap();
-        efm.init(EntityOperator.EQUALS, joinOp, keysValues);
-        return efm;
+        return new EntityFieldMap(EntityOperator.EQUALS, joinOp, keysValues);
     }
 
     public static EntityFieldMap makeConditionMap(Object... keysValues) {
-        EntityFieldMap efm = new EntityFieldMap();
-        efm.init(EntityOperator.EQUALS, EntityOperator.AND, keysValues);
-        return efm;
+        return new EntityFieldMap(EntityOperator.EQUALS, EntityOperator.AND, keysValues);
     }
 
     public static EntityDateFilterCondition makeConditionDate(String fromDateName, String thruDateName) {
-        EntityDateFilterCondition edfc = new EntityDateFilterCondition();
-        edfc.init(fromDateName, thruDateName);
-        return edfc;
+        return new EntityDateFilterCondition(fromDateName, thruDateName);
     }
 
     public static EntityWhereString makeConditionWhere(String sqlString) {
-        EntityWhereString ews = new EntityWhereString();
-        ews.init(sqlString);
-        return ews;
+        return new EntityWhereString(sqlString);
     }
 
     @Override
@@ -166,8 +135,6 @@ public abstract class EntityCondition ex
 
     abstract public EntityCondition freeze();
 
-    abstract public void encryptConditionFields(ModelEntity modelEntity, Delegator delegator);
-
     public void visit(EntityConditionVisitor visitor) {
         throw new IllegalArgumentException(getClass().getName() + ".visit not implemented");
     }

Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityConditionBuilder.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityConditionBuilder.java?rev=1608347&r1=1608346&r2=1608347&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityConditionBuilder.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityConditionBuilder.java Mon Jul  7 06:50:24 2014
@@ -26,16 +26,62 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
+import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.UtilGenerics;
+import org.ofbiz.entity.Delegator;
+import org.ofbiz.entity.GenericModelException;
+import org.ofbiz.entity.config.model.Datasource;
+import org.ofbiz.entity.model.ModelEntity;
 
 public class EntityConditionBuilder extends BuilderSupport {
+    public static final String module = EntityConditionBuilder.class.getName();
+
+    private static class ConditionHolder extends EntityCondition {
+        protected EntityCondition condition;
+
+        protected ConditionHolder(EntityCondition condition) {
+            this.condition = condition;
+        }
+
+        public Object asType(Class clz) {
+            Debug.logInfo("asType(%s): %s", module, clz, condition);
+            if (clz == EntityCondition.class) {
+                return condition;
+            }
+            return this;
+        }
+
+        public EntityCondition build() {
+            return condition;
+        }
+
+        public boolean isEmpty() {
+            return condition.isEmpty();
+        }
+
+        public String makeWhereString(ModelEntity modelEntity, List<EntityConditionParam> entityConditionParams, Datasource datasourceInfo) {
+            return condition.makeWhereString(modelEntity, entityConditionParams, datasourceInfo);
+        }
+
+        public void checkCondition(ModelEntity modelEntity) throws GenericModelException {
+            condition.checkCondition(modelEntity);
+        }
+
+        public boolean mapMatches(Delegator delegator, Map<String, ? extends Object> map) {
+            return condition.mapMatches(delegator, map);
+        }
+
+        public EntityCondition freeze() {
+            return condition.freeze();
+        }
+    }
 
     @Override
     protected Object createNode(Object methodName) {
         String operatorName = ((String)methodName).toLowerCase();
         EntityJoinOperator operator = EntityOperator.lookupJoin(operatorName);
         List<EntityCondition> condList = new LinkedList<EntityCondition>();
-        return EntityCondition.makeCondition(condList, operator);
+        return new ConditionHolder(EntityCondition.makeCondition(condList, operator));
     }
 
     @Override
@@ -55,9 +101,9 @@ public class EntityConditionBuilder exte
             conditionList.add(EntityCondition.makeCondition(entry.getKey(), operator, entry.getValue()));
         }
         if (conditionList.size() == 1) {
-            return conditionList.get(0);
+            return new ConditionHolder(conditionList.get(0));
         } else {
-            return EntityCondition.makeCondition(conditionList);
+            return new ConditionHolder(EntityCondition.makeCondition(conditionList));
         }
     }
 
@@ -68,8 +114,8 @@ public class EntityConditionBuilder exte
 
     @Override
     protected void setParent(Object parent, Object child) {
-        // No add method on EntityConditionList?
-        EntityConditionList<EntityCondition> parentConList = UtilGenerics.cast(parent);
+        ConditionHolder holder = (ConditionHolder) parent;
+        EntityConditionList<EntityCondition> parentConList = UtilGenerics.cast(holder.condition);
         Iterator<EntityCondition> iterator = parentConList.getConditionIterator();
         List<EntityCondition> tempList = new LinkedList<EntityCondition>();
         while (iterator.hasNext()) {
@@ -77,10 +123,12 @@ public class EntityConditionBuilder exte
         }
         if (child instanceof EntityCondition) {
             tempList.add((EntityCondition)child);
-        } else if (child instanceof List<?>) {
+        } else if (child instanceof ConditionHolder) {
+            tempList.add(((ConditionHolder)child).condition);
+        } else {
             tempList.addAll(UtilGenerics.<EntityCondition>checkList(child));
         }
-        parentConList.init(tempList, parentConList.getOperator());
+        holder.condition = EntityCondition.makeCondition(tempList, parentConList.getOperator());
     }
 
 }

Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityConditionFunction.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityConditionFunction.java?rev=1608347&r1=1608346&r2=1608347&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityConditionFunction.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityConditionFunction.java Mon Jul  7 06:50:24 2014
@@ -46,10 +46,6 @@ public abstract class EntityConditionFun
         public EntityCondition freeze() {
             return new NOT(condition.freeze());
         }
-        @Override
-        public void encryptConditionFields(ModelEntity modelEntity, Delegator delegator) {
-            // nothing to do here...
-        }
     }
 
     protected Integer idInt = null;

Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityConditionList.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityConditionList.java?rev=1608347&r1=1608346&r2=1608347&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityConditionList.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityConditionList.java Mon Jul  7 06:50:24 2014
@@ -19,6 +19,7 @@
 package org.ofbiz.entity.condition;
 
 import java.util.Iterator;
+import java.util.List;
 
 /**
  * Encapsulates a list of EntityConditions to be used as a single EntityCondition combined as specified
@@ -26,6 +27,9 @@ import java.util.Iterator;
  */
 @SuppressWarnings("serial")
 public class EntityConditionList<T extends EntityCondition> extends EntityConditionListBase<T> {
+    public EntityConditionList(List<T> conditionList, EntityJoinOperator operator) {
+        super(conditionList, operator);
+    }
 
     @Override
     public int getConditionListSize() {

Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityConditionListBase.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityConditionListBase.java?rev=1608347&r1=1608346&r2=1608347&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityConditionListBase.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityConditionListBase.java Mon Jul  7 06:50:24 2014
@@ -18,6 +18,7 @@
  *******************************************************************************/
 package org.ofbiz.entity.condition;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
@@ -37,34 +38,14 @@ import org.ofbiz.entity.model.ModelEntit
 public abstract class EntityConditionListBase<T extends EntityCondition> extends EntityCondition {
     public static final String module = EntityConditionListBase.class.getName();
 
-    protected List<T> conditionList = null;
-    protected EntityJoinOperator operator = null;
+    protected final List<T> conditionList;
+    protected final EntityJoinOperator operator;
 
-    protected EntityConditionListBase() {}
-
-    public EntityConditionListBase(EntityJoinOperator operator, T... conditionList) {
-        this.init(operator, conditionList);
-    }
-
-    public EntityConditionListBase(List<T> conditionList, EntityJoinOperator operator) {
-        this.init(conditionList, operator);
-    }
-
-    public void init(EntityJoinOperator operator, T... conditionList) {
-        this.conditionList = Arrays.asList(conditionList);
-        this.operator = operator;
-    }
-
-    public void init(List<T> conditionList, EntityJoinOperator operator) {
+    protected EntityConditionListBase(List<T> conditionList, EntityJoinOperator operator) {
         this.conditionList = conditionList;
         this.operator = operator;
     }
 
-    public void reset() {
-        this.conditionList = null;
-        this.operator = null;
-    }
-
     public EntityJoinOperator getOperator() {
         return this.operator;
     }
@@ -116,13 +97,6 @@ public abstract class EntityConditionLis
     }
 
     @Override
-    public void encryptConditionFields(ModelEntity modelEntity, Delegator delegator) {
-        for (T cond: this.conditionList) {
-            cond.encryptConditionFields(modelEntity, delegator);
-        }
-    }
-
-    @Override
     public boolean equals(Object obj) {
         if (!(obj instanceof EntityConditionListBase<?>)) return false;
         EntityConditionListBase<?> other = UtilGenerics.cast(obj);

Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityConditionValue.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityConditionValue.java?rev=1608347&r1=1608346&r2=1608347&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityConditionValue.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityConditionValue.java Mon Jul  7 06:50:24 2014
@@ -22,9 +22,6 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
-import javolution.context.ObjectFactory;
-import javolution.lang.Reusable;
-
 import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.GenericEntity;
 import org.ofbiz.entity.GenericModelException;
@@ -39,22 +36,11 @@ import org.ofbiz.entity.model.ModelField
 @SuppressWarnings("serial")
 public abstract class EntityConditionValue extends EntityConditionBase {
 
-    public static EntityConditionValue CONSTANT_NUMBER(Number value) { return ConstantNumberValue.createConstantNumberValue(value); }
-    public static class ConstantNumberValue extends EntityConditionValue implements Reusable {
-        protected static ConstantNumberValue createConstantNumberValue(Number value) {
-            ConstantNumberValue cnv = factory.object();
-            cnv.init(value);
-            return cnv;
-        }
-        protected static final ObjectFactory<ConstantNumberValue> factory = new ObjectFactory<ConstantNumberValue>() {
-            protected ConstantNumberValue create() {
-                return new ConstantNumberValue();
-            }
-        };
-
+    public static EntityConditionValue CONSTANT_NUMBER(Number value) { return new ConstantNumberValue(value); }
+    public static final class ConstantNumberValue extends EntityConditionValue {
         private Number value;
 
-        protected void init(Number value) {
+        private ConstantNumberValue(Number value) {
             this.value = value;
         }
 
@@ -84,11 +70,6 @@ public abstract class EntityConditionVal
         }
 
         @Override
-        public void reset() {
-            this.value = value;
-        }
-
-        @Override
         public void validateSql(org.ofbiz.entity.model.ModelEntity modelEntity) {
         }
 

Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityDateFilterCondition.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityDateFilterCondition.java?rev=1608347&r1=1608346&r2=1608347&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityDateFilterCondition.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityDateFilterCondition.java Mon Jul  7 06:50:24 2014
@@ -34,21 +34,16 @@ import org.ofbiz.entity.model.ModelEntit
  *
  */
 @SuppressWarnings("serial")
-public class EntityDateFilterCondition extends EntityCondition {
+public final class EntityDateFilterCondition extends EntityCondition {
 
-    protected String fromDateName = null;
-    protected String thruDateName = null;
+    protected final String fromDateName;
+    protected final String thruDateName;
 
-    public void init(String fromDateName, String thruDateName) {
+    public EntityDateFilterCondition(String fromDateName, String thruDateName) {
         this.fromDateName = fromDateName;
         this.thruDateName = thruDateName;
     }
 
-    public void reset() {
-        this.fromDateName = null;
-        this.thruDateName = null;
-    }
-
     @Override
     public boolean isEmpty() {
         return false;
@@ -99,11 +94,6 @@ public class EntityDateFilterCondition e
         return this;
     }
 
-    @Override
-    public void encryptConditionFields(ModelEntity modelEntity, Delegator delegator) {
-        // nothing to do here...
-    }
-
     protected EntityCondition makeCondition() {
         return makeCondition(UtilDateTime.nowTimestamp(), fromDateName, thruDateName);
     }

Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java?rev=1608347&r1=1608346&r2=1608347&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java Mon Jul  7 06:50:24 2014
@@ -41,14 +41,14 @@ import org.ofbiz.entity.model.ModelField
  *
  */
 @SuppressWarnings("serial")
-public class EntityExpr extends EntityCondition {
+public final class EntityExpr extends EntityCondition {
     public static final String module = EntityExpr.class.getName();
 
-    private Object lhs = null;
-    private EntityOperator<Object, Object, ?> operator = null;
-    private Object rhs = null;
+    private final Object lhs;
+    private final EntityOperator<Object, Object, ?> operator;
+    private final Object rhs;
 
-    public <L,R,LL,RR> void init(L lhs, EntityComparisonOperator<LL,RR> operator, R rhs) {
+    public <L,R,LL,RR> EntityExpr(L lhs, EntityComparisonOperator<LL,RR> operator, R rhs) {
         if (lhs == null) {
             throw new IllegalArgumentException("The field name/value cannot be null");
         }
@@ -79,7 +79,7 @@ public class EntityExpr extends EntityCo
         //Debug.logInfo("new EntityExpr internal field=" + lhs + ", value=" + rhs + ", value type=" + (rhs == null ? "null object" : rhs.getClass().getName()), module);
     }
 
-    public void init(EntityCondition lhs, EntityJoinOperator operator, EntityCondition rhs) {
+    public EntityExpr(EntityCondition lhs, EntityJoinOperator operator, EntityCondition rhs) {
         if (lhs == null) {
             throw new IllegalArgumentException("The left EntityCondition argument cannot be null");
         }
@@ -95,12 +95,6 @@ public class EntityExpr extends EntityCo
         this.rhs = rhs;
     }
 
-    public void reset() {
-        this.lhs = null;
-        this.operator = null;
-        this.rhs = null;
-    }
-
     public Object getLhs() {
         return lhs;
     }
@@ -159,22 +153,6 @@ public class EntityExpr extends EntityCo
     }
 
     @Override
-    public void encryptConditionFields(ModelEntity modelEntity, Delegator delegator) {
-        if (this.lhs instanceof String) {
-            ModelField modelField = modelEntity.getField((String) this.lhs);
-            if (modelField != null && modelField.getEncrypt()) {
-                if (!(rhs instanceof EntityConditionValue)) {
-                    try {
-                        this.rhs = delegator.encryptFieldValue(modelEntity.getEntityName(), this.rhs);
-                    } catch (EntityCryptoException e) {
-                        Debug.logWarning(e, "Error encrypting field [" + modelEntity.getEntityName() + "." + modelField.getName() + "] with value: " + this.rhs, module);
-                    }
-                }
-            }
-        }
-    }
-
-    @Override
     public void visit(EntityConditionVisitor visitor) {
         visitor.acceptEntityOperator(operator, lhs, rhs);
     }

Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityFieldMap.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityFieldMap.java?rev=1608347&r1=1608346&r2=1608347&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityFieldMap.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityFieldMap.java Mon Jul  7 06:50:24 2014
@@ -32,13 +32,9 @@ import org.ofbiz.entity.util.EntityUtil;
  *
  */
 @SuppressWarnings("serial")
-public class EntityFieldMap extends EntityConditionListBase<EntityExpr> {
+public final class EntityFieldMap extends EntityConditionListBase<EntityExpr> {
 
-    protected Map<String, ? extends Object> fieldMap = null;
-
-    public static <V> List<EntityExpr> makeConditionList(EntityComparisonOperator<?,V> op, V... keysValues) {
-        return makeConditionList(EntityUtil.makeFields(keysValues), op);
-    }
+    protected final Map<String, ? extends Object> fieldMap;
 
     public static <V> List<EntityExpr> makeConditionList(Map<String, V> fieldMap, EntityComparisonOperator<?,V> op) {
         if (fieldMap == null) {
@@ -51,23 +47,13 @@ public class EntityFieldMap extends Enti
         return list;
     }
 
-    public <V> void init(EntityComparisonOperator<?,?> compOp, EntityJoinOperator joinOp, V... keysValues) {
-        super.init(makeConditionList(EntityUtil.makeFields(keysValues), UtilGenerics.<EntityComparisonOperator<String,V>>cast(compOp)), joinOp);
-        Map<String, ? extends Object>  fieldMap = EntityUtil.makeFields(keysValues);
-        this.fieldMap = fieldMap == null ? Collections.<String, Object>emptyMap() : fieldMap;
-        this.operator = joinOp;
+    public <V> EntityFieldMap(EntityComparisonOperator<?,?> compOp, EntityJoinOperator joinOp, V... keysValues) {
+        this(EntityUtil.makeFields(keysValues), UtilGenerics.<EntityComparisonOperator<String,V>>cast(compOp), joinOp);
     }
 
-    public <V> void init(Map<String, V> fieldMap, EntityComparisonOperator<?,?> compOp, EntityJoinOperator joinOp) {
-        super.init(makeConditionList(fieldMap, UtilGenerics.<EntityComparisonOperator<String,V>>cast(compOp)), joinOp);
+    public <V> EntityFieldMap(Map<String, V> fieldMap, EntityComparisonOperator<?,?> compOp, EntityJoinOperator joinOp) {
+        super(makeConditionList(fieldMap, UtilGenerics.<EntityComparisonOperator<String,V>>cast(compOp)), joinOp);
         this.fieldMap = fieldMap == null ? Collections.<String, Object>emptyMap() : fieldMap;
-        this.operator = joinOp;
-    }
-
-    @Override
-    public void reset() {
-        super.reset();
-        this.fieldMap = null;
     }
 
     public Object getField(String name) {

Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityFunction.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityFunction.java?rev=1608347&r1=1608346&r2=1608347&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityFunction.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityFunction.java Mon Jul  7 06:50:24 2014
@@ -22,9 +22,6 @@ package org.ofbiz.entity.condition;
 import java.util.List;
 import java.util.Map;
 
-import javolution.context.ObjectFactory;
-import javolution.lang.Reusable;
-
 import org.ofbiz.base.util.UtilGenerics;
 import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.GenericModelException;
@@ -37,28 +34,12 @@ import org.ofbiz.entity.model.ModelField
  *
  */
 @SuppressWarnings("serial")
-public abstract class EntityFunction<T extends Comparable<?>> extends EntityConditionValue implements Reusable {
+public abstract class EntityFunction<T extends Comparable<?>> extends EntityConditionValue {
 
     public static interface Fetcher<T> {
         T getValue(Object value);
     }
 
-    public abstract static class SQLFunctionFactory<T extends Comparable<T>, F extends EntityFunction<T>> extends ObjectFactory<F> {
-        protected abstract void init(F function, Object value);
-
-        protected F createFunction(EntityConditionValue nested) {
-            F ef = object();
-            init(ef, nested);
-            return ef;
-        }
-
-        protected F createFunction(Object value) {
-            F ef = object();
-            init(ef, value);
-            return ef;
-        }
-    }
-
     public static enum SQLFunction {
         LENGTH, TRIM, UPPER, LOWER;
     }
@@ -68,38 +49,27 @@ public abstract class EntityFunction<T e
     public static final int ID_UPPER = SQLFunction.UPPER.ordinal();
     public static final int ID_LOWER = SQLFunction.LOWER.ordinal();
 
-    public static EntityFunction<Integer> LENGTH(EntityConditionValue nested) { return LENGTH.lengthFactory.createFunction(nested); }
-    public static EntityFunction<Integer> LENGTH(Object value) { return LENGTH.lengthFactory.createFunction(value); }
-    public static EntityFunction<String> TRIM(EntityConditionValue nested) { return TRIM.trimFactory.createFunction(nested); }
-    public static EntityFunction<String> TRIM(Object value) { return TRIM.trimFactory.createFunction(value); }
-    public static EntityFunction<String> UPPER(EntityConditionValue nested) { return UPPER.upperFactory.createFunction(nested); }
-    public static EntityFunction<String> UPPER(Object value) { return UPPER.upperFactory.createFunction(value); }
-    public static EntityFunction<String> UPPER_FIELD(String fieldName) { return UPPER.upperFactory.createFunction(EntityFieldValue.makeFieldValue(fieldName)); }
-    public static EntityFunction<String> LOWER(EntityConditionValue nested) { return LOWER.lowerFactory.createFunction(nested); }
-    public static EntityFunction<String> LOWER(Object value) { return LOWER.lowerFactory.createFunction(value); }
+    public static EntityFunction<Integer> LENGTH(EntityConditionValue nested) { return new LENGTH(nested); }
+    public static EntityFunction<Integer> LENGTH(Object value) { return new LENGTH(value); }
+    public static EntityFunction<String> TRIM(EntityConditionValue nested) { return new TRIM(nested); }
+    public static EntityFunction<String> TRIM(Object value) { return new TRIM(value); }
+    public static EntityFunction<String> UPPER(EntityConditionValue nested) { return new UPPER(nested); }
+    public static EntityFunction<String> UPPER(Object value) { return new UPPER(value); }
+    public static EntityFunction<String> UPPER_FIELD(String fieldName) { return new UPPER(EntityFieldValue.makeFieldValue(fieldName)); }
+    public static EntityFunction<String> LOWER(EntityConditionValue nested) { return new LOWER(nested); }
+    public static EntityFunction<String> LOWER(Object value) { return new LOWER(value); }
 
     /**
      * Length() entity function.
      *
      */
-    public static class LENGTH extends EntityFunction<Integer> {
+    public static class LENGTH extends EntityFunctionSingle<Integer> {
         public static Fetcher<Integer> FETCHER = new Fetcher<Integer>() {
             public Integer getValue(Object value) { return value.toString().length(); }
         };
-        protected static final SQLFunctionFactory<Integer, LENGTH> lengthFactory = new SQLFunctionFactory<Integer, LENGTH>() {
-            @Override
-            protected LENGTH create() {
-                return new LENGTH();
-            }
-
-            @Override
-            protected void init(LENGTH function, Object value) {
-                function.init(value);
-            }
-        };
-        protected LENGTH() {}
-        public void init(Object value) {
-            super.init(FETCHER, SQLFunction.LENGTH, value);
+
+        private LENGTH(Object value) {
+            super(FETCHER, SQLFunction.LENGTH, value);
         }
     }
 
@@ -107,24 +77,13 @@ public abstract class EntityFunction<T e
      * Trim() entity function.
      *
      */
-    public static class TRIM extends EntityFunction<String> {
+    public static class TRIM extends EntityFunctionSingle<String> {
         public static Fetcher<String> FETCHER = new Fetcher<String>() {
             public String getValue(Object value) { return value.toString().trim(); }
         };
-        protected static final SQLFunctionFactory<String, TRIM> trimFactory = new SQLFunctionFactory<String, TRIM>() {
-            @Override
-            protected TRIM create() {
-                return new TRIM();
-            }
-
-            @Override
-            protected void init(TRIM function, Object value) {
-                function.init(value);
-            }
-        };
-        protected TRIM() {}
-        public void init(Object value) {
-            super.init(FETCHER, SQLFunction.TRIM, value);
+
+        private TRIM(Object value) {
+            super(FETCHER, SQLFunction.TRIM, value);
         }
     }
 
@@ -132,24 +91,13 @@ public abstract class EntityFunction<T e
      * Upper() entity function.
      *
      */
-    public static class UPPER extends EntityFunction<String> {
+    public static class UPPER extends EntityFunctionSingle<String> {
         public static Fetcher<String> FETCHER = new Fetcher<String>() {
             public String getValue(Object value) { return value.toString().toUpperCase(); }
         };
-        protected static final SQLFunctionFactory<String, UPPER> upperFactory = new SQLFunctionFactory<String, UPPER>() {
-            @Override
-            protected UPPER create() {
-                return new UPPER();
-            }
-
-            @Override
-            protected void init(UPPER function, Object value) {
-                function.init(value);
-            }
-        };
-        protected UPPER() {}
-        public void init(Object value) {
-            super.init(FETCHER, SQLFunction.UPPER, value);
+
+        private UPPER(Object value) {
+            super(FETCHER, SQLFunction.UPPER, value);
         }
     }
 
@@ -157,65 +105,58 @@ public abstract class EntityFunction<T e
      * Lower() entity function.
      *
      */
-    public static class LOWER extends EntityFunction<String> {
+    public static class LOWER extends EntityFunctionSingle<String> {
         public static Fetcher<String> FETCHER = new Fetcher<String>() {
             public String getValue(Object value) { return value.toString().toLowerCase(); }
         };
-        protected static final SQLFunctionFactory<String, LOWER> lowerFactory = new SQLFunctionFactory<String, LOWER>() {
-            @Override
-            protected LOWER create() {
-                return new LOWER();
-            }
-
-            @Override
-            protected void init(LOWER function, Object value) {
-                function.init(value);
-            }
-        };
-        protected LOWER() {}
-        public void init(Object value) {
-            super.init(FETCHER, SQLFunction.LOWER, value);
+
+        private LOWER(Object value) {
+            super(FETCHER, SQLFunction.LOWER, value);
         }
     }
 
-    protected SQLFunction function;
-    protected EntityConditionValue nested = null;
-    protected Object value = null;
-    protected Fetcher<T> fetcher = null;
+    public static abstract class EntityFunctionSingle<T extends Comparable<?>> extends EntityFunction<T> {
+        protected EntityFunctionSingle(Fetcher<T> fetcher, SQLFunction function, Object value) {
+            super(fetcher, function, value);
+        }
+    }
 
-    protected EntityFunction() {}
+    public static abstract class EntityFunctionNested<T extends Comparable<?>> extends EntityFunction<T> {
+        protected EntityFunctionNested(Fetcher<T> fetcher, SQLFunction function, EntityConditionValue nested) {
+            super(fetcher, function, nested);
+        }
+    }
+
+    protected final SQLFunction function;
+    protected final EntityConditionValue nested;
+    protected final Object value;
+    protected final Fetcher<T> fetcher;
 
     protected EntityFunction(Fetcher<T> fetcher, SQLFunction function, EntityConditionValue nested) {
-        this.init(fetcher, function, nested);
+        this.fetcher = fetcher;
+        this.function = function;
+        this.nested = nested;
+        this.value = null;
     }
 
     protected EntityFunction(Fetcher<T> fetcher, SQLFunction function, Object value) {
-        this.init(fetcher, function, value);
-    }
-
-    public void init(Fetcher<T> fetcher, SQLFunction function, Object value) {
         this.fetcher = fetcher;
         this.function = function;
         if (value instanceof EntityConditionValue) {
             this.nested = (EntityConditionValue) value;
+            this.value = null;
         } else {
+            this.nested = null;
             this.value = value;
         }
     }
 
-    public void reset() {
-        this.function = null;
-        this.nested = null;
-        this.value = null;
-        this.fetcher = null;
-    }
-
     @Override
     public EntityConditionValue freeze() {
         if (nested != null) {
-            return new EntityFunction<T>(fetcher, function, nested.freeze()) {};
+            return new EntityFunctionNested<T>(fetcher, function, nested.freeze()) {};
         } else {
-            return new EntityFunction<T>(fetcher, function, value) {};
+            return new EntityFunctionSingle<T>(fetcher, function, value) {};
         }
     }
 

Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityWhereString.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityWhereString.java?rev=1608347&r1=1608346&r2=1608347&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityWhereString.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/condition/EntityWhereString.java Mon Jul  7 06:50:24 2014
@@ -40,18 +40,14 @@ import org.ofbiz.entity.model.ModelEntit
  *
  */
 @SuppressWarnings("serial")
-public class EntityWhereString extends EntityCondition {
+public final class EntityWhereString extends EntityCondition {
 
-    protected String sqlString;
+    protected final String sqlString;
 
-    public void init(String sqlString) {
+    public EntityWhereString(String sqlString) {
         this.sqlString = sqlString;
     }
 
-    public void reset() {
-        this.sqlString = null;
-    }
-
     @Override
     public boolean isEmpty() {
         return UtilValidate.isEmpty(sqlString);
@@ -86,11 +82,6 @@ public class EntityWhereString extends E
     }
 
     @Override
-    public void encryptConditionFields(ModelEntity modelEntity, Delegator delegator) {
-        // nothing to do here...
-    }
-
-    @Override
     public void visit(EntityConditionVisitor visitor) {
         visitor.acceptEntityWhereString(this);
     }

Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java?rev=1608347&r1=1608346&r2=1608347&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java Mon Jul  7 06:50:24 2014
@@ -120,7 +120,7 @@ public class GenericDAO {
             throw new GenericModelException("Could not find ModelEntity record for entityName: " + entity.getEntityName());
         }
 
-        SQLProcessor sqlP = new SQLProcessor(helperInfo);
+        SQLProcessor sqlP = new SQLProcessor(entity.getDelegator(), helperInfo);
 
         try {
             return singleInsert(entity, modelEntity, modelEntity.getFieldsUnmodifiable(), sqlP);
@@ -225,7 +225,7 @@ public class GenericDAO {
     }
 
     private int customUpdate(GenericEntity entity, ModelEntity modelEntity, List<ModelField> fieldsToSave) throws GenericEntityException {
-        SQLProcessor sqlP = new SQLProcessor(helperInfo);
+        SQLProcessor sqlP = new SQLProcessor(entity.getDelegator(), helperInfo);
         try {
             return singleUpdate(entity, modelEntity, fieldsToSave, sqlP);
         } catch (GenericEntityException e) {
@@ -302,8 +302,8 @@ public class GenericDAO {
         return retVal;
     }
 
-    public int updateByCondition(ModelEntity modelEntity, Map<String, ? extends Object> fieldsToSet, EntityCondition condition) throws GenericEntityException {
-        SQLProcessor sqlP = new SQLProcessor(helperInfo);
+    public int updateByCondition(Delegator delegator, ModelEntity modelEntity, Map<String, ? extends Object> fieldsToSet, EntityCondition condition) throws GenericEntityException {
+        SQLProcessor sqlP = new SQLProcessor(delegator, helperInfo);
 
         try {
             return updateByCondition(modelEntity, fieldsToSet, condition, sqlP);
@@ -497,7 +497,7 @@ public class GenericDAO {
     /* ====================================================================== */
 
     public void select(GenericEntity entity) throws GenericEntityException {
-        SQLProcessor sqlP = new SQLProcessor(helperInfo);
+        SQLProcessor sqlP = new SQLProcessor(entity.getDelegator(), helperInfo);
 
         try {
             select(entity, sqlP);
@@ -597,7 +597,7 @@ public class GenericDAO {
         sqlBuffer.append(SqlJdbcUtil.makeFromClause(modelEntity, modelFieldTypeReader, datasource));
         sqlBuffer.append(SqlJdbcUtil.makeWhereClause(modelEntity, modelEntity.getPkFieldsUnmodifiable(), entity, "AND", datasource.getJoinStyle()));
 
-        SQLProcessor sqlP = new SQLProcessor(helperInfo);
+        SQLProcessor sqlP = new SQLProcessor(entity.getDelegator(), helperInfo);
 
         try {
             sqlP.prepareStatement(sqlBuffer.toString(), true, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
@@ -633,7 +633,7 @@ public class GenericDAO {
      *@return EntityListIterator representing the result of the query: NOTE THAT THIS MUST BE CLOSED WHEN YOU ARE
      *      DONE WITH IT, AND DON'T LEAVE IT OPEN TOO LONG BEACUSE IT WILL MAINTAIN A DATABASE CONNECTION.
      */
-    public EntityListIterator selectListIteratorByCondition(ModelEntity modelEntity, EntityCondition whereEntityCondition,
+    public EntityListIterator selectListIteratorByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition,
             EntityCondition havingEntityCondition, Collection<String> fieldsToSelect, List<String> orderBy, EntityFindOptions findOptions)
             throws GenericEntityException {
         if (modelEntity == null) {
@@ -769,7 +769,7 @@ public class GenericDAO {
         // make the final SQL String
         String sql = sqlBuffer.toString();
 
-        SQLProcessor sqlP = new SQLProcessor(helperInfo);
+        SQLProcessor sqlP = new SQLProcessor(delegator, helperInfo);
         sqlP.prepareStatement(sql, findOptions.getSpecifyTypeAndConcur(), findOptions.getResultSetType(),
                 findOptions.getResultSetConcurrency(), findOptions.getFetchSize(), findOptions.getMaxRows());
 
@@ -912,7 +912,7 @@ public class GenericDAO {
 
     public List<GenericValue> selectByMultiRelation(GenericValue value, ModelRelation modelRelationOne, ModelEntity modelEntityOne,
         ModelRelation modelRelationTwo, ModelEntity modelEntityTwo, List<String> orderBy) throws GenericEntityException {
-        SQLProcessor sqlP = new SQLProcessor(helperInfo);
+        SQLProcessor sqlP = new SQLProcessor(value.getDelegator(), helperInfo);
 
         // get the tables names
         String atable = modelEntityOne.getTableName(datasource);
@@ -1013,11 +1013,11 @@ public class GenericDAO {
         return retlist;
     }
 
-    public long selectCountByCondition(ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, EntityFindOptions findOptions) throws GenericEntityException {
-        return selectCountByCondition(modelEntity, whereEntityCondition, havingEntityCondition, null, findOptions);
+    public long selectCountByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, EntityFindOptions findOptions) throws GenericEntityException {
+        return selectCountByCondition(delegator, modelEntity, whereEntityCondition, havingEntityCondition, null, findOptions);
     }
 
-    public long selectCountByCondition(ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, List<ModelField> selectFields, EntityFindOptions findOptions) throws GenericEntityException {
+    public long selectCountByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, List<ModelField> selectFields, EntityFindOptions findOptions) throws GenericEntityException {
         if (modelEntity == null) {
             return 0;
         }
@@ -1112,7 +1112,7 @@ public class GenericDAO {
         String sql = sqlBuffer.toString();
         if (Debug.verboseOn()) Debug.logVerbose("Count select sql: " + sql, module);
 
-        SQLProcessor sqlP = new SQLProcessor(helperInfo);
+        SQLProcessor sqlP = new SQLProcessor(delegator, helperInfo);
         sqlP.prepareStatement(sql, findOptions.getSpecifyTypeAndConcur(), findOptions.getResultSetType(),
                 findOptions.getResultSetConcurrency(), findOptions.getFetchSize(), findOptions.getMaxRows());
         if (verboseOn) {
@@ -1154,7 +1154,7 @@ public class GenericDAO {
     /* ====================================================================== */
 
     public int delete(GenericEntity entity) throws GenericEntityException {
-        SQLProcessor sqlP = new SQLProcessor(helperInfo);
+        SQLProcessor sqlP = new SQLProcessor(entity.getDelegator(), helperInfo);
 
         try {
             return delete(entity, sqlP);
@@ -1191,8 +1191,8 @@ public class GenericDAO {
         return retVal;
     }
 
-    public int deleteByCondition(ModelEntity modelEntity, EntityCondition condition) throws GenericEntityException {
-        SQLProcessor sqlP = new SQLProcessor(helperInfo);
+    public int deleteByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition condition) throws GenericEntityException {
+        SQLProcessor sqlP = new SQLProcessor(delegator, helperInfo);
 
         try {
             return deleteByCondition(modelEntity, condition, sqlP);

Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/datasource/GenericHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/datasource/GenericHelper.java?rev=1608347&r1=1608346&r2=1608347&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/datasource/GenericHelper.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/datasource/GenericHelper.java Mon Jul  7 06:50:24 2014
@@ -27,6 +27,7 @@ import java.util.Set;
 import java.util.concurrent.Callable;
 import java.util.concurrent.Future;
 
+import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericPK;
 import org.ofbiz.entity.GenericValue;
@@ -93,11 +94,11 @@ public interface GenericHelper {
      *@return EntityListIterator representing the result of the query: NOTE THAT THIS MUST BE CLOSED WHEN YOU ARE
      *      DONE WITH IT, AND DON'T LEAVE IT OPEN TOO LONG BEACUSE IT WILL MAINTAIN A DATABASE CONNECTION.
      */
-    public EntityListIterator findListIteratorByCondition(ModelEntity modelEntity, EntityCondition whereEntityCondition,
+    public EntityListIterator findListIteratorByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition,
         EntityCondition havingEntityCondition, Collection<String> fieldsToSelect, List<String> orderBy, EntityFindOptions findOptions)
         throws GenericEntityException;
 
-    public long findCountByCondition(ModelEntity modelEntity, EntityCondition whereEntityCondition,
+    public long findCountByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition,
             EntityCondition havingEntityCondition, EntityFindOptions findOptions) throws GenericEntityException;
 
     /** Removes/deletes Generic Entity records found by all the specified condition
@@ -105,7 +106,7 @@ public interface GenericHelper {
      *@param condition The condition that restricts the list of removed values
      *@return int representing number of rows effected by this operation
      */
-    public int removeByCondition(ModelEntity modelEntity, EntityCondition condition) throws GenericEntityException;
+    public int removeByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition condition) throws GenericEntityException;
 
     /** Stores a group of values in a single query
      *@param modelEntity The ModelEntity of the Entity as defined in the entity XML file
@@ -114,7 +115,7 @@ public interface GenericHelper {
      *@return int representing number of rows effected by this operation
      *@throws GenericEntityException
      */
-    public int storeByCondition(ModelEntity modelEntity, Map<String, ? extends Object> fieldsToSet, EntityCondition condition) throws GenericEntityException;
+    public int storeByCondition(Delegator delegator, ModelEntity modelEntity, Map<String, ? extends Object> fieldsToSet, EntityCondition condition) throws GenericEntityException;
 
     /** Store the Entity from the GenericValue to the persistent store
      *@param value GenericValue instance containing the entity

Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/datasource/GenericHelperDAO.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/datasource/GenericHelperDAO.java?rev=1608347&r1=1608346&r2=1608347&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/datasource/GenericHelperDAO.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/datasource/GenericHelperDAO.java Mon Jul  7 06:50:24 2014
@@ -27,6 +27,7 @@ import java.util.concurrent.Callable;
 import java.util.concurrent.Future;
 
 import org.ofbiz.base.util.Debug;
+import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericPK;
 import org.ofbiz.entity.GenericValue;
@@ -139,10 +140,10 @@ public class GenericHelperDAO implements
      *@return EntityListIterator representing the result of the query: NOTE THAT THIS MUST BE CLOSED WHEN YOU ARE
      *      DONE WITH IT, AND DON'T LEAVE IT OPEN TOO LONG BEACUSE IT WILL MAINTAIN A DATABASE CONNECTION.
      */
-    public EntityListIterator findListIteratorByCondition(ModelEntity modelEntity, EntityCondition whereEntityCondition,
+    public EntityListIterator findListIteratorByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition,
         EntityCondition havingEntityCondition, Collection<String> fieldsToSelect, List<String> orderBy, EntityFindOptions findOptions)
         throws GenericEntityException {
-        return genericDAO.selectListIteratorByCondition(modelEntity, whereEntityCondition, havingEntityCondition, fieldsToSelect, orderBy, findOptions);
+        return genericDAO.selectListIteratorByCondition(delegator, modelEntity, whereEntityCondition, havingEntityCondition, fieldsToSelect, orderBy, findOptions);
     }
 
     public List<GenericValue> findByMultiRelation(GenericValue value, ModelRelation modelRelationOne, ModelEntity modelEntityOne,
@@ -150,8 +151,8 @@ public class GenericHelperDAO implements
         return genericDAO.selectByMultiRelation(value, modelRelationOne, modelEntityOne, modelRelationTwo, modelEntityTwo, orderBy);
     }
 
-    public long findCountByCondition(ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, EntityFindOptions findOptions) throws GenericEntityException {
-        return genericDAO.selectCountByCondition(modelEntity, whereEntityCondition, havingEntityCondition, findOptions);
+    public long findCountByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, EntityFindOptions findOptions) throws GenericEntityException {
+        return genericDAO.selectCountByCondition(delegator, modelEntity, whereEntityCondition, havingEntityCondition, findOptions);
     }
 
     /** Removes/deletes Generic Entity records found by all the specified condition
@@ -159,11 +160,11 @@ public class GenericHelperDAO implements
      *@param condition The condition that restricts the list of removed values
      *@return int representing number of rows effected by this operation
      */
-    public int removeByCondition(ModelEntity modelEntity, EntityCondition condition) throws GenericEntityException {
+    public int removeByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition condition) throws GenericEntityException {
         if (modelEntity == null || condition == null) {
             return 0;
         }
-        return genericDAO.deleteByCondition(modelEntity, condition);
+        return genericDAO.deleteByCondition(delegator, modelEntity, condition);
     }
 
     /** Store the Entity from the GenericValue to the persistent store
@@ -184,11 +185,11 @@ public class GenericHelperDAO implements
      *@return int representing number of rows effected by this operation
      *@throws GenericEntityException
      */
-    public int storeByCondition(ModelEntity modelEntity, Map<String, ? extends Object> fieldsToSet, EntityCondition condition) throws GenericEntityException {
+    public int storeByCondition(Delegator delegator, ModelEntity modelEntity, Map<String, ? extends Object> fieldsToSet, EntityCondition condition) throws GenericEntityException {
         if (modelEntity == null || condition == null) {
             return 0;
         }
-        return genericDAO.updateByCondition(modelEntity, fieldsToSet, condition);
+        return genericDAO.updateByCondition(delegator, modelEntity, fieldsToSet, condition);
     }
 
     /** Check the datasource to make sure the entity definitions are correct, optionally adding missing entities or fields on the server

Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/datasource/MemoryHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/datasource/MemoryHelper.java?rev=1608347&r1=1608346&r2=1608347&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/datasource/MemoryHelper.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/datasource/MemoryHelper.java Mon Jul  7 06:50:24 2014
@@ -33,6 +33,7 @@ import java.util.concurrent.ExecutorServ
 
 import org.ofbiz.base.concurrent.ExecutionPool;
 import org.ofbiz.base.util.Debug;
+import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericNotImplementedException;
 import org.ofbiz.entity.GenericPK;
@@ -382,13 +383,13 @@ public class MemoryHelper implements Gen
         return null;
     }
 
-    public EntityListIterator findListIteratorByCondition(ModelEntity modelEntity, EntityCondition whereEntityCondition,
+    public EntityListIterator findListIteratorByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition,
                                                           EntityCondition havingEntityCondition, Collection<String> fieldsToSelect, List<String> orderBy, EntityFindOptions findOptions)
             throws GenericEntityException {
         return null;
     }
 
-    public long findCountByCondition(ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, EntityFindOptions findOptions) throws GenericEntityException {
+    public long findCountByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, EntityFindOptions findOptions) throws GenericEntityException {
         return 0;
     }
 
@@ -409,11 +410,11 @@ public class MemoryHelper implements Gen
         return removeAll(removeList);
     }
 
-    public int removeByCondition(ModelEntity modelEntity, EntityCondition condition) throws GenericEntityException {
+    public int removeByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition condition) throws GenericEntityException {
         return removeFromCache(modelEntity.getEntityName(), condition);
     }
 
-    public int storeByCondition(ModelEntity modelEntity, Map<String, ? extends Object> fieldsToSet, EntityCondition condition) throws GenericEntityException {
+    public int storeByCondition(Delegator delegator, ModelEntity modelEntity, Map<String, ? extends Object> fieldsToSet, EntityCondition condition) throws GenericEntityException {
         return 0;
     }
 

Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/jdbc/SQLProcessor.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/jdbc/SQLProcessor.java?rev=1608347&r1=1608346&r2=1608347&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/jdbc/SQLProcessor.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/jdbc/SQLProcessor.java Mon Jul  7 06:50:24 2014
@@ -36,6 +36,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.ofbiz.base.util.Debug;
+import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.GenericDataSourceException;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.config.model.Datasource;
@@ -58,6 +59,8 @@ public class SQLProcessor {
     public static int MAX_CONNECTIONS = 1000;
     public static boolean ENABLE_TEST = false;
 
+    private final Delegator delegator;
+
     /** The datasource helper (see entityengine.xml <datasource name="..">) */
     private GenericHelperInfo helperInfo;
 
@@ -89,7 +92,8 @@ public class SQLProcessor {
      *
      * @param helperInfo  The datasource helper (see entityengine.xml &lt;datasource name=".."&gt;)
      */
-    public SQLProcessor(GenericHelperInfo helperInfo) {
+    public SQLProcessor(Delegator delegator, GenericHelperInfo helperInfo) {
+        this.delegator = delegator;
         this.helperInfo = helperInfo;
         this._manualTX = true;
     }
@@ -101,7 +105,8 @@ public class SQLProcessor {
      * @param helperInfo  The datasource helper (see entityengine.xml &lt;datasource name=".."&gt;)
      * @param connection  The connection to be used
      */
-    public SQLProcessor(GenericHelperInfo helperInfo, Connection connection) {
+    public SQLProcessor(Delegator delegator, GenericHelperInfo helperInfo, Connection connection) {
+        this.delegator = delegator;
         this.helperInfo = helperInfo;
         this._connection = connection;
 
@@ -111,6 +116,10 @@ public class SQLProcessor {
         }
     }
 
+    public Delegator getDelegator() {
+        return delegator;
+    }
+
     ResultSetMetaData getResultSetMetaData() {
         if (_rsmd == null) {
             // try the ResultSet, if not null, or try the PreparedStatement, also if not null

Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java?rev=1608347&r1=1608346&r2=1608347&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java Mon Jul  7 06:50:24 2014
@@ -526,12 +526,23 @@ public class SqlJdbcUtil {
                     entity.getEntityName() + "." + curField.getName() + ".");
         }
 
+        ModelEntity model = entity.getModelEntity();
+        String encryptionKeyName = entity.getEntityName();
+        if (curField.getEncryptMethod().isEncrypted() && model instanceof ModelViewEntity) {
+            ModelViewEntity modelView = (ModelViewEntity) model;
+            encryptionKeyName = modelView.getAliasedEntity(modelView.getAlias(curField.getName()).getEntityAlias(), entity.getDelegator().getModelReader()).getEntityName();
+        }
+
         // ----- Try out the new handler code -----
 
         JdbcValueHandler<?> handler = mft.getJdbcValueHandler();
         if (handler != null) {
             try {
-                entity.dangerousSetNoCheckButFast(curField, handler.getValue(rs, ind));
+                Object jdbcValue = handler.getValue(rs, ind);
+                if (jdbcValue instanceof String && curField.getEncryptMethod().isEncrypted()) {
+                    jdbcValue = entity.getDelegator().decryptFieldValue(encryptionKeyName, (String) jdbcValue);
+                }
+                entity.dangerousSetNoCheckButFast(curField, jdbcValue);
                 return;
             } catch (Exception e) {
                 Debug.logError(e, module);
@@ -585,6 +596,9 @@ public class SqlJdbcUtil {
                         }
                     } else {
                         String value = rs.getString(ind);
+                        if (value instanceof String && curField.getEncryptMethod().isEncrypted()) {
+                            value = (String) entity.getDelegator().decryptFieldValue(encryptionKeyName, value);
+                        }
                         entity.dangerousSetNoCheckButFast(curField, value);
                     }
                     break;
@@ -777,6 +791,10 @@ public class SqlJdbcUtil {
 
         // ----- Try out the new handler code -----
 
+        ModelField.EncryptMethod encryptMethod = modelField.getEncryptMethod();
+        if (encryptMethod.isEncrypted()) {
+            fieldValue = sqlP.getDelegator().encryptFieldValue(entityName, encryptMethod, fieldValue);
+        }
         JdbcValueHandler<T> handler = UtilGenerics.cast(mft.getJdbcValueHandler());
         if (handler != null) {
             try {