Cool. When can we expect to see that change?

-Adrian

On 9/28/2012 11:55 AM, Jacques Le Roux wrote:
Yes I wondered about that too, I have no problem to change it

Jacques


From: "Adrian Crum" <adrian.c...@sandglass-software.com>
Can we put the property in the webapp component? It seems to me it belongs in the same component as the code it is configuring.

-Adrian

On 9/28/2012 8:08 AM, Jacques Le Roux wrote:
Indeed with this change you can't have that.

If you used throwRequestHandlerExceptionOnMissingLocalRequest=Y
You will have the "Going to external page: " + request.getPathInfo() message in log and then a blank screen if you don't handle the request with another specific servlet

Of course if you use the default throwRequestHandlerExceptionOnMissingLocalRequest=Y

You will still get the same behaviour than before this change (exception thrown)

Jacques

From: "Adrian Crum" <adrian.c...@sandglass-software.com>
I'm confused. I want to have external requests and I want to throw exceptions when I have missing controller entries. How does this change accommodate that?

-Adrian


On 9/27/2012 3:49 PM, jler...@apache.org wrote:
Author: jleroux
Date: Thu Sep 27 14:49:20 2012
New Revision: 1391037

URL: http://svn.apache.org/viewvc?rev=1391037&view=rev
Log:
Closes "ControlServlet - Exception thrown for requests not defined by controller.xml" https://issues.apache.org/jira/browse/OFBIZ-5037

This has been tested in a custom project and work as expected it does not add any functional features for OFBiz if you don't use external requests in controllers. So should have any impacts OOTB

Added:
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandlerExceptionAllowExternalRequests.java (with props)
Modified:
ofbiz/trunk/framework/common/config/general.properties
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java

Modified: ofbiz/trunk/framework/common/config/general.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/config/general.properties?rev=1391037&r1=1391036&r2=1391037&view=diff ==============================================================================
--- ofbiz/trunk/framework/common/config/general.properties (original)
+++ ofbiz/trunk/framework/common/config/general.properties Thu Sep 27 14:49:20 2012
@@ -143,3 +143,6 @@ multitenant=N
# -- Y if you use a cluster. Most of the time this should not be needed. Setting distributed-cache-clear-enabled="true" is enough # -- to guarantee no sequenceIds duplicates. See OFBIZ-2353 for details
  cluster=N
+
+# -- N if you want to use external requests (not in available in current controller), see OFBIZ-5037
+throwRequestHandlerExceptionOnMissingLocalRequest=Y
\ No newline at end of file

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java?rev=1391037&r1=1391036&r2=1391037&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java Thu Sep 27 14:49:20 2012
@@ -225,6 +225,9 @@ public class ControlServlet extends Http
request.setAttribute("_ERROR_MESSAGE_", encoder.encode(throwable.toString())); errorPage = requestHandler.getDefaultErrorPage(request);
              }
+         } catch (RequestHandlerExceptionAllowExternalRequests e) {
+ errorPage = requestHandler.getDefaultErrorPage(request); + Debug.logInfo("Going to external page: " + request.getPathInfo(), module);
          } catch (Exception e) {
Debug.logError(e, "Error in request handler: ", module); StringUtil.HtmlEncoder encoder = new StringUtil.HtmlEncoder();

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java?rev=1391037&r1=1391036&r2=1391037&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java Thu Sep 27 14:49:20 2012
@@ -65,6 +65,8 @@ import org.ofbiz.webapp.website.WebSiteW
  public class RequestHandler {
  public static final String module = RequestHandler.class.getName();
+ private static final Boolean THROW_REQUEST_HANDLER_EXCEPTION_ON_MISSING_LOCAL_REQUEST = + UtilProperties.propertyValueEqualsIgnoreCase("general.properties", "throwRequestHandlerExceptionOnMissingLocalRequest", "Y"); public static RequestHandler getRequestHandler(ServletContext servletContext) { RequestHandler rh = (RequestHandler) servletContext.getAttribute("_REQUEST_HANDLER_");
@@ -96,7 +98,7 @@ public class RequestHandler {
return ConfigXMLReader.getControllerConfig(this.controllerConfigURL);
      }
- public void doRequest(HttpServletRequest request, HttpServletResponse response, String requestUri) throws RequestHandlerException { + public void doRequest(HttpServletRequest request, HttpServletResponse response, String requestUri) throws RequestHandlerException, RequestHandlerExceptionAllowExternalRequests {
          HttpSession session = request.getSession();
Delegator delegator = (Delegator) request.getAttribute("delegator"); GenericValue userLogin = (GenericValue) session.getAttribute("userLogin");
@@ -104,7 +106,7 @@ public class RequestHandler {
      }
public void doRequest(HttpServletRequest request, HttpServletResponse response, String chain, - GenericValue userLogin, Delegator delegator) throws RequestHandlerException { + GenericValue userLogin, Delegator delegator) throws RequestHandlerException, RequestHandlerExceptionAllowExternalRequests {
  long startTime = System.currentTimeMillis();
          HttpSession session = request.getSession();
@@ -152,10 +154,13 @@ public class RequestHandler {
              }
          }
  -        // still not found so stop
+ // if no matching request is found in the controller, depending on THROW_REQUEST_HANDLER_EXCEPTION_ON_MISSING_LOCAL_REQUEST + // we throw a RequestHandlerException or RequestHandlerExceptionAllowExternalRequests
          if (requestMap == null) {
- throw new RequestHandlerException(requestMissingErrorMessage);
-        }
+ if (THROW_REQUEST_HANDLER_EXCEPTION_ON_MISSING_LOCAL_REQUEST) throw new RequestHandlerException(requestMissingErrorMessage); + else throw new RequestHandlerExceptionAllowExternalRequests();
+         }
+
          String eventReturn = null;
if (requestMap.metrics != null && requestMap.metrics.getThreshold() != 0.0 && requestMap.metrics.getTotalEvents() > 3 && requestMap.metrics.getThreshold() < requestMap.metrics.getServiceRate()) {
              eventReturn = "threshold-exceeded";

Added: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandlerExceptionAllowExternalRequests.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandlerExceptionAllowExternalRequests.java?rev=1391037&view=auto ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandlerExceptionAllowExternalRequests.java (added) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandlerExceptionAllowExternalRequests.java Thu Sep 27 14:49:20 2012
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *******************************************************************************/
+package org.ofbiz.webapp.control;
+
+/**
+ * RequestHandlerExceptionAllowExternalRequests
+ */
+@SuppressWarnings("serial")
+public class RequestHandlerExceptionAllowExternalRequests extends org.ofbiz.base.util.GeneralException {
+
+ public RequestHandlerExceptionAllowExternalRequests(String str, Throwable t) {
+        super(str, t);
+    }
+
+ public RequestHandlerExceptionAllowExternalRequests(String str) {
+        super(str);
+    }
+
+    public RequestHandlerExceptionAllowExternalRequests() {
+        super();
+    }
+}
+

Propchange: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandlerExceptionAllowExternalRequests.java ------------------------------------------------------------------------------
     svn:eol-style = native

Propchange: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandlerExceptionAllowExternalRequests.java ------------------------------------------------------------------------------
     svn:keywords = Date Rev Author URL Id

Propchange: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandlerExceptionAllowExternalRequests.java ------------------------------------------------------------------------------
     svn:mime-type = text/plain





Reply via email to