"Applied fix from trunk framework for revision: 1868611" 
------------------------------------------------------------------------
r1868611 | jleroux | 2019-10-19 08:42:07 +0200 (sam. 19 oct. 2019) | 11 lignes

Improved: Handling tenant in XmlRpcEventHandler
(OFBIZ-10284)

The XMLRPC service does not support tenants. Even if the tenant domain is 
included in the HTTP request the call does not affect the correct tenant. 
The issue and fix has been discussed in  in the thread
https://markmail.org/message/bz4dofrxqp6i7ove

jleroux: I was able to port the R16 patch provided by Rajesh to the trunk. 

Thanks: Rajesh Kumar Mallah
------------------------------------------------------------------------


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/branches/release16.11@1868614 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java
index 71abc94..d622407 100644
--- a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java
+++ b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java
@@ -75,7 +75,6 @@
 public class XmlRpcEventHandler extends XmlRpcHttpServer implements EventHandler {
 
     public static final String module = XmlRpcEventHandler.class.getName();
-    protected Delegator delegator;
     protected LocalDispatcher dispatcher;
 
     private Boolean enabledForExtensions = null;
@@ -83,7 +82,7 @@
 
     public void init(ServletContext context) throws EventHandlerException {
         String delegatorName = context.getInitParameter("entityDelegatorName");
-        this.delegator = DelegatorFactory.getDelegator(delegatorName);
+        Delegator delegator = DelegatorFactory.getDelegator(delegatorName);
         this.dispatcher = ServiceContainer.getLocalDispatcher(delegator.getDelegatorName(), delegator);
         this.setHandlerMapping(new ServiceRpcHandler());
 
@@ -159,7 +158,7 @@
     }
 
     protected XmlRpcHttpRequestConfig getXmlRpcConfig(HttpServletRequest req) {
-        XmlRpcHttpRequestConfigImpl result = new XmlRpcHttpRequestConfigImpl();
+        OFBizXmlRpcHttpRequestConfigImpl result = new OFBizXmlRpcHttpRequestConfigImpl(req);
         XmlRpcHttpServerConfig serverConfig = (XmlRpcHttpServerConfig) getConfig();
 
         result.setBasicEncoding(serverConfig.getBasicEncoding());
@@ -184,7 +183,8 @@
     class OfbizRpcAuthHandler implements AbstractReflectiveHandlerMapping.AuthenticationHandler {
 
         public boolean isAuthorized(XmlRpcRequest xmlRpcReq) throws XmlRpcException {
-            XmlRpcHttpRequestConfig config = (XmlRpcHttpRequestConfig) xmlRpcReq.getConfig();
+        OFBizXmlRpcHttpRequestConfigImpl config = (OFBizXmlRpcHttpRequestConfigImpl) xmlRpcReq.getConfig();
+        LocalDispatcher dispatcher = config.getDispatcher();
 
             ModelService model;
             try {
@@ -324,6 +324,10 @@
         }
 
         public Object execute(XmlRpcRequest xmlRpcReq) throws XmlRpcException {
+
+        OFBizXmlRpcHttpRequestConfigImpl requestConfig = (OFBizXmlRpcHttpRequestConfigImpl) xmlRpcReq.getConfig();
+        LocalDispatcher dispatcher = requestConfig.getDispatcher();
+        
             DispatchContext dctx = dispatcher.getDispatchContext();
             String serviceName = xmlRpcReq.getMethodName();
             ModelService model = null;
@@ -373,6 +377,8 @@
 
         protected Map<String, Object> getContext(XmlRpcRequest xmlRpcReq, String serviceName) throws XmlRpcException {
             ModelService model;
+        OFBizXmlRpcHttpRequestConfigImpl requestConfig = (OFBizXmlRpcHttpRequestConfigImpl) xmlRpcReq.getConfig();
+        LocalDispatcher dispatcher = requestConfig.getDispatcher();
             try {
                 model = dispatcher.getDispatchContext().getModelService(serviceName);
             } catch (GenericServiceException e) {
@@ -451,4 +457,18 @@
             response.getOutputStream().close();
         }
     }
+
+    class OFBizXmlRpcHttpRequestConfigImpl extends XmlRpcHttpRequestConfigImpl  {
+        private LocalDispatcher dispatcher;
+
+        public OFBizXmlRpcHttpRequestConfigImpl  (HttpServletRequest request) {
+        dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
+        }
+    
+        public LocalDispatcher getDispatcher() {
+        return dispatcher;
+        }
+    }
+    
+
 }