You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2019/10/19 06:58:15 UTC

svn commit: r1868614 - in /ofbiz/branches/release16.11: ./ framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java

Author: jleroux
Date: Sat Oct 19 06:58:15 2019
New Revision: 1868614

URL: http://svn.apache.org/viewvc?rev=1868614&view=rev
Log:
"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
------------------------------------------------------------------------


Modified:
    ofbiz/branches/release16.11/   (props changed)
    ofbiz/branches/release16.11/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java

Propchange: ofbiz/branches/release16.11/
------------------------------------------------------------------------------
  Merged /ofbiz/ofbiz-framework/trunk:r1868611

Modified: ofbiz/branches/release16.11/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release16.11/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java?rev=1868614&r1=1868613&r2=1868614&view=diff
==============================================================================
--- ofbiz/branches/release16.11/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java (original)
+++ ofbiz/branches/release16.11/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java Sat Oct 19 06:58:15 2019
@@ -75,7 +75,6 @@ import org.apache.ofbiz.webapp.control.C
 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 class XmlRpcEventHandler extends
 
     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 @@ public class XmlRpcEventHandler extends
     }
 
     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 @@ public class XmlRpcEventHandler extends
     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 class XmlRpcEventHandler extends
         }
 
         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 @@ public class XmlRpcEventHandler extends
 
         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 @@ public class XmlRpcEventHandler extends
             response.getOutputStream().close();
         }
     }
+
+    class OFBizXmlRpcHttpRequestConfigImpl extends XmlRpcHttpRequestConfigImpl  {
+        private LocalDispatcher dispatcher;
+
+        public OFBizXmlRpcHttpRequestConfigImpl  (HttpServletRequest request) {
+        dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
+        }
+    
+        public LocalDispatcher getDispatcher() {
+        return dispatcher;
+        }
+    }
+    
+
 }