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

jleroux 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 e7ea8ecdbb Fixed: Link Party feature stop the EECA rules globally 
(OFBIZ-12424)
e7ea8ecdbb is described below

commit e7ea8ecdbb97fef749a491735fd2526d3e7ec312
Author: Jacques Le Roux <jacques.le.r...@les7arts.com>
AuthorDate: Sat Feb 4 14:36:15 2023 +0100

    Fixed: Link Party feature stop the EECA rules globally (OFBIZ-12424)
    
    In the Link Party Feature(partymgr > profile > Link Party) there is a code 
that
    stops EECA rules globally in the system and as a result it caused major 
issues
    in the process which are driven from EECA's.
    
    PartyServices.java
    public static Map<String, Object> linkParty(DispatchContext dctx, 
Map<String,...
        Delegator delegator = dctx.getDelegator();
        Locale locale = (Locale) context.get("locale");
        delegator.setEntityEcaHandler(null);
    ...
    }
    
    In the above code you can see that we are updating EntityEcaHandler on 
delegator
    object to null.
    
    GenericDelegator.java
    
    protected void evalRules(String event, String currentOperation, 
GenericEntity...
        if (entityEcaHandler == null) {
            return;
        }
        entityEcaHandler.evalRules(currentOperation, eventMap, event, value, 
isError);
    }
    
    On any DB operation(find, create and store) using delegator above method 
run and
    due to null EntityEcaHandler object it won't execute any EECA's globally in 
the
    system
    
    Thanks: Rohit Koushal
---
 .../java/org/apache/ofbiz/party/party/PartyServices.java     | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git 
a/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java
 
b/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java
index fe0dbf3494..929a41368f 100644
--- 
a/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java
+++ 
b/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java
@@ -43,6 +43,7 @@ import org.apache.ofbiz.base.util.UtilMisc;
 import org.apache.ofbiz.base.util.UtilProperties;
 import org.apache.ofbiz.base.util.UtilValidate;
 import org.apache.ofbiz.entity.Delegator;
+import org.apache.ofbiz.entity.DelegatorFactory;
 import org.apache.ofbiz.entity.GenericEntity;
 import org.apache.ofbiz.entity.GenericEntityException;
 import org.apache.ofbiz.entity.GenericValue;
@@ -1947,9 +1948,8 @@ public class PartyServices {
      * @return the result of the service execution
      */
     public static Map<String, Object> linkParty(DispatchContext dctx, 
Map<String, ? extends Object> context) {
-        Delegator delegator = dctx.getDelegator();
+        Delegator delegator = DelegatorFactory.getDelegator("default-no-eca");
         Locale locale = (Locale) context.get("locale");
-        delegator.setEntityEcaHandler(null);
 
         String partyIdTo = (String) context.get("partyIdTo");
         String partyId = (String) context.get("partyId");
@@ -2127,14 +2127,6 @@ public class PartyServices {
             return ServiceUtil.returnError(e.getMessage());
         }
 
-        // remove all previous party roles
-        try {
-            delegator.removeByAnd("PartyRole", UtilMisc.toMap("partyId", 
partyId));
-        } catch (GenericEntityException e) {
-            Debug.logWarning(e, MODULE);
-            // if this fails no problem
-        }
-
         // update the non-existing attributes
         List<GenericValue> attrsToMove;
         try {

Reply via email to