This is an automated email from the ASF dual-hosted git repository.

nmalin pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/trunk by this push:
     new d30d362  Fixed: Element condition-[expr/list/object] doesn't work with 
compound (OFBIZ-12546)
d30d362 is described below

commit d30d362aa6df78f0470c4d053c968299804fb1ef
Author: Nicolas Malin <nicolas.ma...@nereide.fr>
AuthorDate: Mon Jan 31 14:39:57 2022 +0100

    Fixed: Element condition-[expr/list/object] doesn't work with compound 
(OFBIZ-12546)
    
    When you create an entity-condition in a form or grid under a compound 
element, to write a valid xml you write it with the namespace like this :
    
        <wf:actions>
            <wf:entity-condition entity-name="PartyRelationship"...>
                <wf:condition-list>
                    <wf:condition-expr field-name="partyIdFrom" 
from-field="parameters.partyIdFrom"/>
                    <wf:condition-expr field-name="partyIdTo" 
from-field="parameters.partyIdTo"/>
                </wf:condition-list>
            </wf:entity-condition>
        </wf:actions>
    
    This failed when OFBiz execute the search with error Invalid element with 
name '[wf:condition-expr]' found under a condition-list element.
    
    The error came from the class EntityFinderUtil.ConditionList who analyze 
the condition-list's children with the namespace + node name instead take only 
the node name.
    
        if ("condition-expr".equals(subElement.getNodeName()))
    
    To solve this issue we only check the local node name regardless from the 
namespace used.
---
 .../org/apache/ofbiz/entity/finder/EntityFinderUtil.java     | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git 
a/framework/entity/src/main/java/org/apache/ofbiz/entity/finder/EntityFinderUtil.java
 
b/framework/entity/src/main/java/org/apache/ofbiz/entity/finder/EntityFinderUtil.java
index 409eb96..121ad09 100644
--- 
a/framework/entity/src/main/java/org/apache/ofbiz/entity/finder/EntityFinderUtil.java
+++ 
b/framework/entity/src/main/java/org/apache/ofbiz/entity/finder/EntityFinderUtil.java
@@ -282,13 +282,17 @@ public final class EntityFinderUtil {
             } else {
                 List<Condition> conditionList = new 
ArrayList<>(subElements.size());
                 for (Element subElement : subElements) {
-                    if ("condition-expr".equals(subElement.getNodeName())) {
+                    switch (subElement.getLocalName()) {
+                    case "condition-expr":
                         conditionList.add(new ConditionExpr(subElement));
-                    } else if 
("condition-list".equals(subElement.getNodeName())) {
+                        break;
+                    case "condition-list":
                         conditionList.add(new ConditionList(subElement));
-                    } else if 
("condition-object".equals(subElement.getNodeName())) {
+                        break;
+                    case "condition-object":
                         conditionList.add(new ConditionObject(subElement));
-                    } else {
+                        break;
+                    default:
                         throw new IllegalArgumentException("Invalid element 
with name [" + subElement.getNodeName()
                                 + "] found under a condition-list element.");
                     }

Reply via email to