Author: doogie
Date: Tue Jun 24 00:23:54 2014 New Revision: 1604973 URL: http://svn.apache.org/r1604973 Log: encryptConditionFields now returns a new EntityCondition, if it did anything. Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityCondition.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionFunction.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionListBase.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionSubSelect.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionValue.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityDateFilterCondition.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldValue.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFunction.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityWhereString.java Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java?rev=1604973&r1=1604972&r2=1604973&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java Tue Jun 24 00:23:54 2014 @@ -1770,11 +1770,11 @@ public class GenericDelegator implements if (whereEntityCondition != null) { whereEntityCondition.checkCondition(modelEntity); - whereEntityCondition.encryptConditionFields(modelEntity, this); + whereEntityCondition = whereEntityCondition.encryptConditionFields(modelEntity, this); } if (havingEntityCondition != null) { havingEntityCondition.checkCondition(modelEntity); - havingEntityCondition.encryptConditionFields(modelEntity, this); + havingEntityCondition = havingEntityCondition.encryptConditionFields(modelEntity, this); } ecaRunner.evalRules(EntityEcaHandler.EV_RUN, EntityEcaHandler.OP_FIND, dummyValue, false); @@ -1878,11 +1878,11 @@ public class GenericDelegator implements if (whereEntityCondition != null) { whereEntityCondition.checkCondition(modelEntity); - whereEntityCondition.encryptConditionFields(modelEntity, this); + whereEntityCondition = whereEntityCondition.encryptConditionFields(modelEntity, this); } if (havingEntityCondition != null) { havingEntityCondition.checkCondition(modelEntity); - havingEntityCondition.encryptConditionFields(modelEntity, this); + havingEntityCondition = havingEntityCondition.encryptConditionFields(modelEntity, this); } ecaRunner.evalRules(EntityEcaHandler.EV_RUN, EntityEcaHandler.OP_FIND, dummyValue, false); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityCondition.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityCondition.java?rev=1604973&r1=1604972&r2=1604973&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityCondition.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityCondition.java Tue Jun 24 00:23:54 2014 @@ -135,7 +135,7 @@ public abstract class EntityCondition ex abstract public EntityCondition freeze(); - abstract public void encryptConditionFields(ModelEntity modelEntity, Delegator delegator); + abstract public EntityCondition encryptConditionFields(ModelEntity modelEntity, Delegator delegator); public void visit(EntityConditionVisitor visitor) { throw new IllegalArgumentException(getClass().getName() + ".visit not implemented"); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionFunction.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionFunction.java?rev=1604973&r1=1604972&r2=1604973&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionFunction.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionFunction.java Tue Jun 24 00:23:54 2014 @@ -47,8 +47,9 @@ public abstract class EntityConditionFun return new NOT(condition.freeze()); } @Override - public void encryptConditionFields(ModelEntity modelEntity, Delegator delegator) { + public EntityCondition encryptConditionFields(ModelEntity modelEntity, Delegator delegator) { // nothing to do here... + return this; } } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionListBase.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionListBase.java?rev=1604973&r1=1604972&r2=1604973&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionListBase.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionListBase.java Tue Jun 24 00:23:54 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; @@ -96,9 +97,18 @@ public abstract class EntityConditionLis } @Override - public void encryptConditionFields(ModelEntity modelEntity, Delegator delegator) { + public EntityCondition encryptConditionFields(ModelEntity modelEntity, Delegator delegator) { + List<T> newList = new ArrayList<T>(this.conditionList.size()); + boolean changed = false; for (T cond: this.conditionList) { - cond.encryptConditionFields(modelEntity, delegator); + EntityCondition newCondition = cond.encryptConditionFields(modelEntity, delegator); + changed |= newCondition != cond; + newList.add((T) newCondition); + } + if (changed) { + return operator.freeze(newList); + } else { + return this; } } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionSubSelect.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionSubSelect.java?rev=1604973&r1=1604972&r2=1604973&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionSubSelect.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionSubSelect.java Tue Jun 24 00:23:54 2014 @@ -118,8 +118,12 @@ public class EntityConditionSubSelect ex } @Override - public void encryptConditionFields(ModelEntity modelEntity, Delegator delegator) { - whereCond.encryptConditionFields(modelEntity, delegator); + public EntityConditionValue encryptConditionFields(ModelEntity modelEntity, Delegator delegator) { + EntityCondition newWhereCond = whereCond.encryptConditionFields(modelEntity, delegator); + if (newWhereCond != whereCond) { + return new EntityConditionSubSelect(localModelEntity, keyFieldName, newWhereCond, requireAll); + } + return this; } public String getKeyFieldName() { Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionValue.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionValue.java?rev=1604973&r1=1604972&r2=1604973&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionValue.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionValue.java Tue Jun 24 00:23:54 2014 @@ -60,7 +60,8 @@ public abstract class EntityConditionVal } @Override - public void encryptConditionFields(ModelEntity modelEntity, Delegator delegator) { + public EntityConditionValue encryptConditionFields(ModelEntity modelEntity, Delegator delegator) { + return this; } @Override @@ -106,7 +107,7 @@ public abstract class EntityConditionVal public abstract EntityConditionValue freeze(); - public abstract void encryptConditionFields(ModelEntity modelEntity, Delegator delegator); + public abstract EntityConditionValue encryptConditionFields(ModelEntity modelEntity, Delegator delegator); public abstract void visit(EntityConditionVisitor visitor); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityDateFilterCondition.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityDateFilterCondition.java?rev=1604973&r1=1604972&r2=1604973&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityDateFilterCondition.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityDateFilterCondition.java Tue Jun 24 00:23:54 2014 @@ -95,8 +95,9 @@ public final class EntityDateFilterCondi } @Override - public void encryptConditionFields(ModelEntity modelEntity, Delegator delegator) { + public EntityCondition encryptConditionFields(ModelEntity modelEntity, Delegator delegator) { // nothing to do here... + return this; } protected EntityCondition makeCondition() { Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java?rev=1604973&r1=1604972&r2=1604973&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java Tue Jun 24 00:23:54 2014 @@ -153,15 +153,25 @@ public class EntityExpr extends EntityCo } @Override - public void encryptConditionFields(ModelEntity modelEntity, Delegator delegator) { + public EntityCondition encryptConditionFields(ModelEntity modelEntity, Delegator delegator) { + if (rhs == null) { + return this; + } if (operator.getClass().equals(EntityJoinOperator.class)) { - ((EntityCondition) lhs).encryptConditionFields(modelEntity, delegator); - ((EntityCondition) rhs).encryptConditionFields(modelEntity, delegator); - return; + EntityCondition newLhs = ((EntityCondition) lhs).encryptConditionFields(modelEntity, delegator); + EntityCondition newRhs = ((EntityCondition) rhs).encryptConditionFields(modelEntity, delegator); + if (newLhs != lhs || newRhs != rhs) { + return EntityCondition.makeCondition(newLhs, UtilGenerics.<EntityJoinOperator>cast(this.operator), newRhs); + } + return this; } if (rhs instanceof EntityConditionValue) { - ((EntityConditionValue) rhs).encryptConditionFields(modelEntity, delegator); - return; + EntityConditionValue newRhs = ((EntityConditionValue) rhs).encryptConditionFields(modelEntity, delegator); + if (newRhs != rhs) { + return EntityCondition.makeCondition(this.lhs, (EntityComparisonOperator) this.operator, newRhs); + } else { + return this; + } } ModelField modelField; if (this.lhs instanceof String) { @@ -169,15 +179,16 @@ public class EntityExpr extends EntityCo } else if (this.lhs instanceof EntityFieldValue) { modelField = ((EntityFieldValue) this.lhs).getModelField(modelEntity); } else { - return; + return this; } if (modelField != null && modelField.getEncryptMethod().isEncrypted()) { try { - this.rhs = delegator.encryptFieldValue(modelEntity.getEntityName(), modelField.getEncryptMethod(), this.rhs); + return EntityCondition.makeCondition(this.lhs, (EntityComparisonOperator) this.operator, delegator.encryptFieldValue(modelEntity.getEntityName(), modelField.getEncryptMethod(), this.rhs)); } catch (EntityCryptoException e) { Debug.logWarning(e, "Error encrypting field [" + modelEntity.getEntityName() + "." + modelField.getName() + "] with value: " + this.rhs, module); } } + return this; } @Override Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldValue.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldValue.java?rev=1604973&r1=1604972&r2=1604973&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldValue.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldValue.java Tue Jun 24 00:23:54 2014 @@ -196,6 +196,7 @@ public class EntityFieldValue extends En } @Override - public void encryptConditionFields(ModelEntity modelEntity, Delegator delegator) { + public EntityConditionValue encryptConditionFields(ModelEntity modelEntity, Delegator delegator) { + return this; } } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFunction.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFunction.java?rev=1604973&r1=1604972&r2=1604973&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFunction.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFunction.java Tue Jun 24 00:23:54 2014 @@ -120,7 +120,16 @@ public abstract class EntityFunction<T e super(fetcher, function, value); } - public void encryptConditionFields(ModelEntity modelEntity, Delegator delegator) { + public EntityConditionValue encryptConditionFields(ModelEntity modelEntity, Delegator delegator) { + if (nested != null) { + EntityConditionValue newNested = nested.encryptConditionFields(modelEntity, delegator); + if (newNested != nested) { + return new EntityFunctionSingle<T>(fetcher, function, newNested) {}; + } + } else { + // FIXME + } + return this; } } @@ -129,7 +138,12 @@ public abstract class EntityFunction<T e super(fetcher, function, nested); } - public void encryptConditionFields(ModelEntity modelEntity, Delegator delegator) { + public EntityConditionValue encryptConditionFields(ModelEntity modelEntity, Delegator delegator) { + EntityConditionValue newNested = nested.encryptConditionFields(modelEntity, delegator); + if (newNested != nested) { + return new EntityFunctionSingle<T>(fetcher, function, newNested) {}; + } + return this; } } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityWhereString.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityWhereString.java?rev=1604973&r1=1604972&r2=1604973&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityWhereString.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityWhereString.java Tue Jun 24 00:23:54 2014 @@ -82,8 +82,9 @@ public final class EntityWhereString ext } @Override - public void encryptConditionFields(ModelEntity modelEntity, Delegator delegator) { + public EntityCondition encryptConditionFields(ModelEntity modelEntity, Delegator delegator) { // nothing to do here... + return this; } @Override |
Free forum by Nabble | Edit this page |