Author: adrianc
Date: Tue Oct 22 06:50:05 2013
New Revision: 1534517

URL: http://svn.apache.org/r1534517
Log:
Refactored ConfigXMLReader.java - added exception handling. The class swallowed 
exceptions like controller.xml file is missing or invalid - making debugging 
difficult. This commit introduces a WebAppConfigurationException and it 
propagates that exception farther up the stack.

Added:
    
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/WebAppConfigurationException.java
   (with props)
Modified:
    
ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/SurveyEvents.java
    
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ConfigXMLReader.java
    
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java
    
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandlerException.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/EventFactory.java
    
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceMultiEventHandler.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/ViewFactory.java
    
ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java

Modified: 
ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/SurveyEvents.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/SurveyEvents.java?rev=1534517&r1=1534516&r2=1534517&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/SurveyEvents.java 
(original)
+++ 
ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/SurveyEvents.java 
Tue Oct 22 06:50:05 2013
@@ -28,6 +28,7 @@ import org.ofbiz.base.util.UtilHttp;
 import org.ofbiz.webapp.control.ConfigXMLReader;
 import org.ofbiz.webapp.control.RequestHandler;
 import org.ofbiz.webapp.control.ConfigXMLReader.RequestMap;
+import org.ofbiz.webapp.control.WebAppConfigurationException;
 import org.ofbiz.webapp.event.EventHandlerException;
 
 /**
@@ -43,7 +44,12 @@ public class SurveyEvents {
         RequestHandler rh = (RequestHandler) 
request.getAttribute("_REQUEST_HANDLER_");
         ConfigXMLReader.ControllerConfig controllerConfig = 
rh.getControllerConfig();
         String requestUri = (String) request.getAttribute("thisRequestUri");
-        RequestMap requestMap = 
controllerConfig.getRequestMapMap().get(requestUri);
+        RequestMap requestMap = null;
+        try {
+            requestMap = controllerConfig.getRequestMapMap().get(requestUri);
+        } catch (WebAppConfigurationException e) {
+            Debug.logError(e, "Exception thrown while parsing controller.xml 
file: ", module);
+        }
         String eventResponse = null;
         try {
             eventResponse = rh.runEvent(request, response, 
createSurveyResponseEvent, requestMap, null);

Modified: 
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ConfigXMLReader.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ConfigXMLReader.java?rev=1534517&r1=1534516&r2=1534517&view=diff
==============================================================================
--- 
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ConfigXMLReader.java 
(original)
+++ 
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ConfigXMLReader.java 
Tue Oct 22 06:50:05 2013
@@ -127,7 +127,7 @@ public class ConfigXMLReader {
         }
     }
 
-    public static ControllerConfig getControllerConfig(URL url) {
+    public static ControllerConfig getControllerConfig(URL url) throws 
WebAppConfigurationException {
         ControllerConfig controllerConfig = controllerCache.get(url);
         if (controllerConfig == null) {
             controllerConfig = controllerCache.putIfAbsentAndGet(url, new 
ControllerConfig(url));
@@ -144,20 +144,19 @@ public class ConfigXMLReader {
         }
     }
 
-    /** Loads the XML file and returns the root element */
-    public static Element loadDocument(URL location) {
-        Document document;
+    /** Loads the XML file and returns the root element 
+     * @throws WebAppConfigurationException */
+    private static Element loadDocument(URL location) throws 
WebAppConfigurationException {
         try {
-            document = UtilXml.readXmlDocument(location, true);
+            Document document = UtilXml.readXmlDocument(location, true);
             Element rootElement = document.getDocumentElement();
-            // rootElement.normalize();
             if (Debug.verboseOn())
                 Debug.logVerbose("Loaded XML Config - " + location, module);
             return rootElement;
         } catch (Exception e) {
             Debug.logError(e, module);
+            throw new WebAppConfigurationException(e);
         }
-        return null;
     }
 
     public static class ControllerConfig {
@@ -179,7 +178,7 @@ public class ConfigXMLReader {
         private Map<String, RequestMap> requestMapMap = FastMap.newInstance();
         private Map<String, ViewMap> viewMapMap = FastMap.newInstance();
 
-        public ControllerConfig(URL url) {
+        public ControllerConfig(URL url) throws WebAppConfigurationException {
             this.url = url;
             Element rootElement = loadDocument(url);
             if (rootElement != null) {
@@ -197,7 +196,7 @@ public class ConfigXMLReader {
             }
         }
 
-        public Map<String, Event> getAfterLoginEventList() {
+        public Map<String, Event> getAfterLoginEventList() throws 
WebAppConfigurationException {
             MapContext<String, Event> result = MapContext.getMapContext();
             for (URL includeLocation : includes) {
                 ControllerConfig controllerConfig = 
getControllerConfig(includeLocation);
@@ -207,7 +206,7 @@ public class ConfigXMLReader {
             return result;
         }
 
-        public Map<String, Event> getBeforeLogoutEventList() {
+        public Map<String, Event> getBeforeLogoutEventList() throws 
WebAppConfigurationException {
             MapContext<String, Event> result = MapContext.getMapContext();
             for (URL includeLocation : includes) {
                 ControllerConfig controllerConfig = 
getControllerConfig(includeLocation);
@@ -217,7 +216,7 @@ public class ConfigXMLReader {
             return result;
         }
 
-        public String getDefaultRequest() {
+        public String getDefaultRequest() throws WebAppConfigurationException {
             if (defaultRequest != null) {
                 return defaultRequest;
             }
@@ -231,7 +230,7 @@ public class ConfigXMLReader {
             return null;
         }
 
-        public String getErrorpage() {
+        public String getErrorpage() throws WebAppConfigurationException {
             if (errorpage != null) {
                 return errorpage;
             }
@@ -245,7 +244,7 @@ public class ConfigXMLReader {
             return null;
         }
 
-        public Map<String, String> getEventHandlerMap() {
+        public Map<String, String> getEventHandlerMap() throws 
WebAppConfigurationException {
             MapContext<String, String> result = MapContext.getMapContext();
             for (URL includeLocation : includes) {
                 ControllerConfig controllerConfig = 
getControllerConfig(includeLocation);
@@ -255,7 +254,7 @@ public class ConfigXMLReader {
             return result;
         }
 
-        public Map<String, Event> getFirstVisitEventList() {
+        public Map<String, Event> getFirstVisitEventList() throws 
WebAppConfigurationException {
             MapContext<String, Event> result = MapContext.getMapContext();
             for (URL includeLocation : includes) {
                 ControllerConfig controllerConfig = 
getControllerConfig(includeLocation);
@@ -265,7 +264,7 @@ public class ConfigXMLReader {
             return result;
         }
 
-        public String getOwner() {
+        public String getOwner() throws WebAppConfigurationException {
             if (owner != null) {
                 return owner;
             }
@@ -279,7 +278,7 @@ public class ConfigXMLReader {
             return null;
         }
 
-        public Map<String, Event> getPostprocessorEventList() {
+        public Map<String, Event> getPostprocessorEventList() throws 
WebAppConfigurationException {
             MapContext<String, Event> result = MapContext.getMapContext();
             for (URL includeLocation : includes) {
                 ControllerConfig controllerConfig = 
getControllerConfig(includeLocation);
@@ -289,7 +288,7 @@ public class ConfigXMLReader {
             return result;
         }
 
-        public Map<String, Event> getPreprocessorEventList() {
+        public Map<String, Event> getPreprocessorEventList() throws 
WebAppConfigurationException {
             MapContext<String, Event> result = MapContext.getMapContext();
             for (URL includeLocation : includes) {
                 ControllerConfig controllerConfig = 
getControllerConfig(includeLocation);
@@ -299,7 +298,7 @@ public class ConfigXMLReader {
             return result;
         }
 
-        public String getProtectView() {
+        public String getProtectView() throws WebAppConfigurationException {
             if (protectView != null) {
                 return protectView;
             }
@@ -313,7 +312,7 @@ public class ConfigXMLReader {
             return null;
         }
 
-        public Map<String, RequestMap> getRequestMapMap() {
+        public Map<String, RequestMap> getRequestMapMap() throws 
WebAppConfigurationException {
             MapContext<String, RequestMap> result = MapContext.getMapContext();
             for (URL includeLocation : includes) {
                 ControllerConfig controllerConfig = 
getControllerConfig(includeLocation);
@@ -323,7 +322,7 @@ public class ConfigXMLReader {
             return result;
         }
 
-        public String getSecurityClass() {
+        public String getSecurityClass() throws WebAppConfigurationException {
             if (securityClass != null) {
                 return securityClass;
             }
@@ -337,7 +336,7 @@ public class ConfigXMLReader {
             return null;
         }
 
-        public String getStatusCode() {
+        public String getStatusCode() throws WebAppConfigurationException {
             if (statusCode != null) {
                 return statusCode;
             }
@@ -351,7 +350,7 @@ public class ConfigXMLReader {
             return null;
         }
 
-        public Map<String, String> getViewHandlerMap() {
+        public Map<String, String> getViewHandlerMap() throws 
WebAppConfigurationException {
             MapContext<String, String> result = MapContext.getMapContext();
             for (URL includeLocation : includes) {
                 ControllerConfig controllerConfig = 
getControllerConfig(includeLocation);
@@ -361,7 +360,7 @@ public class ConfigXMLReader {
             return result;
         }
 
-        public Map<String, ViewMap> getViewMapMap() {
+        public Map<String, ViewMap> getViewMapMap() throws 
WebAppConfigurationException {
             MapContext<String, ViewMap> result = MapContext.getMapContext();
             for (URL includeLocation : includes) {
                 ControllerConfig controllerConfig = 
getControllerConfig(includeLocation);
@@ -371,10 +370,7 @@ public class ConfigXMLReader {
             return result;
         }
 
-        protected void loadGeneralConfig(Element rootElement) {
-            if (rootElement == null) {
-                rootElement = loadDocument(this.url);
-            }
+        private void loadGeneralConfig(Element rootElement) {
             this.errorpage = UtilXml.childElementValue(rootElement, 
"errorpage");
             this.statusCode = UtilXml.childElementValue(rootElement, 
"status-code");
             Element protectElement = UtilXml.firstChildElement(rootElement, 
"protect");
@@ -444,12 +440,7 @@ public class ConfigXMLReader {
             }
         }
 
-        public void loadHandlerMap(Element rootElement) {
-            if (rootElement == null) {
-                rootElement = loadDocument(this.url);
-            }
-            if (rootElement == null)
-                return;
+        private void loadHandlerMap(Element rootElement) {
             for (Element handlerElement : 
UtilXml.childElementList(rootElement, "handler")) {
                 String name = handlerElement.getAttribute("name");
                 String type = handlerElement.getAttribute("type");
@@ -477,24 +468,14 @@ public class ConfigXMLReader {
             }
         }
 
-        public void loadRequestMap(Element root) {
-            if (root == null) {
-                root = loadDocument(this.url);
-            }
-            if (root == null)
-                return;
+        private void loadRequestMap(Element root) {
             for (Element requestMapElement : UtilXml.childElementList(root, 
"request-map")) {
                 RequestMap requestMap = new RequestMap(requestMapElement);
                 this.requestMapMap.put(requestMap.uri, requestMap);
             }
         }
 
-        public void loadViewMap(Element rootElement) {
-            if (rootElement == null) {
-                rootElement = loadDocument(this.url);
-            }
-            if (rootElement == null)
-                return;
+        private void loadViewMap(Element rootElement) {
             for (Element viewMapElement : 
UtilXml.childElementList(rootElement, "view-map")) {
                 ViewMap viewMap = new ViewMap(viewMapElement);
                 this.viewMapMap.put(viewMap.name, viewMap);

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=1534517&r1=1534516&r2=1534517&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 
Tue Oct 22 06:50:05 2013
@@ -89,13 +89,24 @@ public class RequestHandler {
 
         // init the ControllerConfig, but don't save it anywhere
         this.controllerConfigURL = 
ConfigXMLReader.getControllerConfigURL(context);
-        ConfigXMLReader.getControllerConfig(this.controllerConfigURL);
+        try {
+            ConfigXMLReader.getControllerConfig(this.controllerConfigURL);
+        } catch (WebAppConfigurationException e) {
+            // FIXME: controller.xml errors should throw an exception.
+            Debug.logError(e, "Exception thrown while parsing controller.xml 
file: ", module);
+        }
         this.viewFactory = new ViewFactory(this);
         this.eventFactory = new EventFactory(this);
     }
 
     public ConfigXMLReader.ControllerConfig getControllerConfig() {
-        return ConfigXMLReader.getControllerConfig(this.controllerConfigURL);
+        try {
+            return 
ConfigXMLReader.getControllerConfig(this.controllerConfigURL);
+        } catch (WebAppConfigurationException e) {
+            // FIXME: controller.xml errors should throw an exception.
+            Debug.logError(e, "Exception thrown while parsing controller.xml 
file: ", module);
+        }
+        return null;
     }
 
     public void doRequest(HttpServletRequest request, HttpServletResponse 
response, String requestUri) throws RequestHandlerException, 
RequestHandlerExceptionAllowExternalRequests {
@@ -113,8 +124,15 @@ public class RequestHandler {
 
         // get the controllerConfig once for this method so we don't have to 
get it over and over inside the method
         ConfigXMLReader.ControllerConfig controllerConfig = 
this.getControllerConfig();
-        Map<String, ConfigXMLReader.RequestMap> requestMapMap = 
controllerConfig.getRequestMapMap();
-        String controllerStatusCodeString = controllerConfig.getStatusCode();
+        Map<String, ConfigXMLReader.RequestMap> requestMapMap = null;
+        String controllerStatusCodeString = null;
+        try {
+            requestMapMap = controllerConfig.getRequestMapMap();
+            controllerStatusCodeString = controllerConfig.getStatusCode();
+        } catch (WebAppConfigurationException e) {
+            Debug.logError(e, "Exception thrown while parsing controller.xml 
file: ", module);
+            throw new RequestHandlerException(e);
+        }
         if(UtilValidate.isNotEmpty(controllerStatusCodeString != null)) 
             statusCodeString = controllerStatusCodeString;
 
@@ -140,7 +158,13 @@ public class RequestHandler {
         }
         // check for default request
         if (requestMap == null) {
-            String defaultRequest = controllerConfig.getDefaultRequest();
+            String defaultRequest;
+            try {
+                defaultRequest = controllerConfig.getDefaultRequest();
+            } catch (WebAppConfigurationException e) {
+                Debug.logError(e, "Exception thrown while parsing 
controller.xml file: ", module);
+                throw new RequestHandlerException(e);
+            }
             if (defaultRequest != null) { // required! to avoid a null pointer 
exception and generate a requesthandler exception if default request not found.
                 requestMap = requestMapMap.get(defaultRequest);
             }
@@ -148,12 +172,18 @@ public class RequestHandler {
 
         // check for override view
         if (overrideViewUri != null) {
-            ConfigXMLReader.ViewMap viewMap = 
getControllerConfig().getViewMapMap().get(overrideViewUri);
-            if (viewMap == null) {
-                String defaultRequest = controllerConfig.getDefaultRequest();
-                if (defaultRequest != null) { // required! to avoid a null 
pointer exception and generate a requesthandler exception if default request 
not found.
-                    requestMap = requestMapMap.get(defaultRequest);
+            ConfigXMLReader.ViewMap viewMap;
+            try {
+                viewMap = 
getControllerConfig().getViewMapMap().get(overrideViewUri);
+                if (viewMap == null) {
+                    String defaultRequest = 
controllerConfig.getDefaultRequest();
+                    if (defaultRequest != null) { // required! to avoid a null 
pointer exception and generate a requesthandler exception if default request 
not found.
+                        requestMap = requestMapMap.get(defaultRequest);
+                    }
                 }
+            } catch (WebAppConfigurationException e) {
+                Debug.logError(e, "Exception thrown while parsing 
controller.xml file: ", module);
+                throw new RequestHandlerException(e);
             }
         }
 
@@ -200,7 +230,13 @@ public class RequestHandler {
             // Check to make sure we are allowed to access this request 
directly. (Also checks if this request is defined.)
             // If the request cannot be called, or is not defined, check and 
see if there is a default-request we can process
             if (!requestMap.securityDirectRequest) {
-                String defaultRequest = controllerConfig.getDefaultRequest();
+                String defaultRequest;
+                try {
+                    defaultRequest = controllerConfig.getDefaultRequest();
+                } catch (WebAppConfigurationException e) {
+                    Debug.logError(e, "Exception thrown while parsing 
controller.xml file: ", module);
+                    throw new RequestHandlerException(e);
+                }
                 if (defaultRequest == null || 
!requestMapMap.get(defaultRequest).securityDirectRequest) {
                     // use the same message as if it was missing for security 
reasons, ie so can't tell if it is missing or direct request is not allowed
                     throw new 
RequestHandlerException(requestMissingErrorMessage);
@@ -308,53 +344,63 @@ public class RequestHandler {
                 if (Debug.infoOn())
                     Debug.logInfo("This is the first request in this visit." + 
" sessionId=" + UtilHttp.getSessionId(request), module);
                 session.setAttribute("_FIRST_VISIT_EVENTS_", "complete");
-                for (ConfigXMLReader.Event event: 
controllerConfig.getFirstVisitEventList().values()) {
-                    try {
-                        String returnString = this.runEvent(request, response, 
event, null, "firstvisit");
-                        if (returnString == null || 
"none".equalsIgnoreCase(returnString)) {
-                            interruptRequest = true;
-                        } else if (!returnString.equalsIgnoreCase("success")) {
-                            throw new EventHandlerException("First-Visit event 
did not return 'success'.");
+                try {
+                    for (ConfigXMLReader.Event event: 
controllerConfig.getFirstVisitEventList().values()) {
+                        try {
+                            String returnString = this.runEvent(request, 
response, event, null, "firstvisit");
+                            if (returnString == null || 
"none".equalsIgnoreCase(returnString)) {
+                                interruptRequest = true;
+                            } else if 
(!returnString.equalsIgnoreCase("success")) {
+                                throw new EventHandlerException("First-Visit 
event did not return 'success'.");
+                            }
+                        } catch (EventHandlerException e) {
+                            Debug.logError(e, module);
                         }
-                    } catch (EventHandlerException e) {
-                        Debug.logError(e, module);
                     }
+                } catch (WebAppConfigurationException e) {
+                    Debug.logError(e, "Exception thrown while parsing 
controller.xml file: ", module);
+                    throw new RequestHandlerException(e);
                 }
             }
 
             // Invoke the pre-processor (but NOT in a chain)
-            for (ConfigXMLReader.Event event: 
controllerConfig.getPreprocessorEventList().values()) {
-                try {
-                    String returnString = this.runEvent(request, response, 
event, null, "preprocessor");
-                    if (returnString == null || 
"none".equalsIgnoreCase(returnString)) {
-                        interruptRequest = true;
-                    } else if (!returnString.equalsIgnoreCase("success")) {
-                        if (!returnString.contains(":_protect_:")) {
-                            throw new EventHandlerException("Pre-Processor 
event [" + event.invoke + "] did not return 'success'.");
-                        } else { // protect the view normally rendered and 
redirect to error response view
-                            returnString = returnString.replace(":_protect_:", 
"");
-                            if (returnString.length() > 0) {
-                                request.setAttribute("_ERROR_MESSAGE_", 
returnString);
-                            }
-                            eventReturn = null;
-                            // check to see if there is a "protect" response, 
if so it's ok else show the default_error_response_view
-                            if 
(!requestMap.requestResponseMap.containsKey("protect")) {
-                                String protectView = 
controllerConfig.getProtectView();
-                                if (protectView != null) {
-                                    overrideViewUri = protectView;
-                                } else {
-                                    overrideViewUri = 
UtilProperties.getPropertyValue("security.properties", 
"default.error.response.view");
-                                    overrideViewUri = 
overrideViewUri.replace("view:", "");
-                                    if ("none:".equals(overrideViewUri)) {
-                                        interruptRequest = true;
+            try {
+                for (ConfigXMLReader.Event event: 
controllerConfig.getPreprocessorEventList().values()) {
+                    try {
+                        String returnString = this.runEvent(request, response, 
event, null, "preprocessor");
+                        if (returnString == null || 
"none".equalsIgnoreCase(returnString)) {
+                            interruptRequest = true;
+                        } else if (!returnString.equalsIgnoreCase("success")) {
+                            if (!returnString.contains(":_protect_:")) {
+                                throw new EventHandlerException("Pre-Processor 
event [" + event.invoke + "] did not return 'success'.");
+                            } else { // protect the view normally rendered and 
redirect to error response view
+                                returnString = 
returnString.replace(":_protect_:", "");
+                                if (returnString.length() > 0) {
+                                    request.setAttribute("_ERROR_MESSAGE_", 
returnString);
+                                }
+                                eventReturn = null;
+                                // check to see if there is a "protect" 
response, if so it's ok else show the default_error_response_view
+                                if 
(!requestMap.requestResponseMap.containsKey("protect")) {
+                                    String protectView = 
controllerConfig.getProtectView();
+                                    if (protectView != null) {
+                                        overrideViewUri = protectView;
+                                    } else {
+                                        overrideViewUri = 
UtilProperties.getPropertyValue("security.properties", 
"default.error.response.view");
+                                        overrideViewUri = 
overrideViewUri.replace("view:", "");
+                                        if ("none:".equals(overrideViewUri)) {
+                                            interruptRequest = true;
+                                        }
                                     }
                                 }
                             }
                         }
+                    } catch (EventHandlerException e) {
+                        Debug.logError(e, module);
                     }
-                } catch (EventHandlerException e) {
-                    Debug.logError(e, module);
                 }
+            } catch (WebAppConfigurationException e) {
+                Debug.logError(e, "Exception thrown while parsing 
controller.xml file: ", module);
+                throw new RequestHandlerException(e);
             }
         }
 
@@ -575,15 +621,20 @@ public class RequestHandler {
             // ======== handle views ========
 
             // first invoke the post-processor events.
-            for (ConfigXMLReader.Event event: 
controllerConfig.getPostprocessorEventList().values()) {
-                try {
-                    String returnString = this.runEvent(request, response, 
event, requestMap, "postprocessor");
-                    if (returnString != null && 
!returnString.equalsIgnoreCase("success")) {
-                        throw new EventHandlerException("Post-Processor event 
did not return 'success'.");
+            try {
+                for (ConfigXMLReader.Event event: 
controllerConfig.getPostprocessorEventList().values()) {
+                    try {
+                        String returnString = this.runEvent(request, response, 
event, requestMap, "postprocessor");
+                        if (returnString != null && 
!returnString.equalsIgnoreCase("success")) {
+                            throw new EventHandlerException("Post-Processor 
event did not return 'success'.");
+                        }
+                    } catch (EventHandlerException e) {
+                        Debug.logError(e, module);
                     }
-                } catch (EventHandlerException e) {
-                    Debug.logError(e, module);
                 }
+            } catch (WebAppConfigurationException e) {
+                Debug.logError(e, "Exception thrown while parsing 
controller.xml file: ", module);
+                throw new RequestHandlerException(e);
             }
 
             String responseStatusCode  = nextRequestResponse.statusCode;
@@ -698,14 +749,24 @@ public class RequestHandler {
 
     /** Returns the default error page for this request. */
     public String getDefaultErrorPage(HttpServletRequest request) {
-        String errorpage = getControllerConfig().getErrorpage();
+        String errorpage = null;
+        try {
+            errorpage = getControllerConfig().getErrorpage();
+        } catch (WebAppConfigurationException e) {
+            Debug.logError(e, "Exception thrown while parsing controller.xml 
file: ", module);
+        }
         if (UtilValidate.isNotEmpty(errorpage)) return errorpage;
         return "/error/error.jsp";
     }
 
     /** Returns the default status-code for this request. */
     public String getStatusCode(HttpServletRequest request) {
-        String statusCode = getControllerConfig().getStatusCode();
+        String statusCode = null;
+        try {
+            statusCode = getControllerConfig().getStatusCode();
+        } catch (WebAppConfigurationException e) {
+            Debug.logError(e, "Exception thrown while parsing controller.xml 
file: ", module);
+        }
         if (UtilValidate.isNotEmpty(statusCode)) return statusCode;
         return null;
     }
@@ -845,7 +906,13 @@ public class RequestHandler {
             req.getSession().removeAttribute("_SAVED_VIEW_PARAMS_");
         }
 
-        ConfigXMLReader.ViewMap viewMap = (view == null ? null : 
getControllerConfig().getViewMapMap().get(view));
+        ConfigXMLReader.ViewMap viewMap = null;
+        try {
+            viewMap = (view == null ? null : 
getControllerConfig().getViewMapMap().get(view));
+        } catch (WebAppConfigurationException e) {
+            Debug.logError(e, "Exception thrown while parsing controller.xml 
file: ", module);
+            throw new RequestHandlerException(e);
+        }
         if (viewMap == null) {
             throw new RequestHandlerException("No definition found for view 
with name [" + view + "]");
         }
@@ -1093,7 +1160,11 @@ public class RequestHandler {
         String requestUri = RequestHandler.getRequestUri(url);
         ConfigXMLReader.RequestMap requestMap = null;
         if (requestUri != null) {
-            requestMap = 
getControllerConfig().getRequestMapMap().get(requestUri);
+            try {
+                requestMap = 
getControllerConfig().getRequestMapMap().get(requestUri);
+            } catch (WebAppConfigurationException e) {
+                Debug.logError(e, "Exception thrown while parsing 
controller.xml file: ", module);
+            }
         }
 
         StringBuilder newURL = new StringBuilder();
@@ -1202,28 +1273,36 @@ public class RequestHandler {
     }
 
     public void runAfterLoginEvents(HttpServletRequest request, 
HttpServletResponse response) {
-        for (ConfigXMLReader.Event event: 
getControllerConfig().getAfterLoginEventList().values()) {
-            try {
-                String returnString = this.runEvent(request, response, event, 
null, "after-login");
-                if (returnString != null && 
!returnString.equalsIgnoreCase("success")) {
-                    throw new EventHandlerException("Pre-Processor event did 
not return 'success'.");
+        try {
+            for (ConfigXMLReader.Event event: 
getControllerConfig().getAfterLoginEventList().values()) {
+                try {
+                    String returnString = this.runEvent(request, response, 
event, null, "after-login");
+                    if (returnString != null && 
!returnString.equalsIgnoreCase("success")) {
+                        throw new EventHandlerException("Pre-Processor event 
did not return 'success'.");
+                    }
+                } catch (EventHandlerException e) {
+                    Debug.logError(e, module);
                 }
-            } catch (EventHandlerException e) {
-                Debug.logError(e, module);
             }
+        } catch (WebAppConfigurationException e) {
+            Debug.logError(e, "Exception thrown while parsing controller.xml 
file: ", module);
         }
     }
 
     public void runBeforeLogoutEvents(HttpServletRequest request, 
HttpServletResponse response) {
-        for (ConfigXMLReader.Event event: 
getControllerConfig().getBeforeLogoutEventList().values()) {
-            try {
-                String returnString = this.runEvent(request, response, event, 
null, "before-logout");
-                if (returnString != null && 
!returnString.equalsIgnoreCase("success")) {
-                    throw new EventHandlerException("Pre-Processor event did 
not return 'success'.");
+        try {
+            for (ConfigXMLReader.Event event: 
getControllerConfig().getBeforeLogoutEventList().values()) {
+                try {
+                    String returnString = this.runEvent(request, response, 
event, null, "before-logout");
+                    if (returnString != null && 
!returnString.equalsIgnoreCase("success")) {
+                        throw new EventHandlerException("Pre-Processor event 
did not return 'success'.");
+                    }
+                } catch (EventHandlerException e) {
+                    Debug.logError(e, module);
                 }
-            } catch (EventHandlerException e) {
-                Debug.logError(e, module);
             }
+        } catch (WebAppConfigurationException e) {
+            Debug.logError(e, "Exception thrown while parsing controller.xml 
file: ", module);
         }
     }
 
@@ -1233,7 +1312,12 @@ public class RequestHandler {
             if (uriString == null) {
                 uriString="";
             }
-            ConfigXMLReader.RequestMap requestMap = 
getControllerConfig().getRequestMapMap().get(uriString);
+            ConfigXMLReader.RequestMap requestMap = null;
+            try {
+                requestMap = 
getControllerConfig().getRequestMapMap().get(uriString);
+            } catch (WebAppConfigurationException e) {
+                Debug.logError(e, "Exception thrown while parsing 
controller.xml file: ", module);
+            }
             if (requestMap == null) return false;
             return requestMap.trackServerHit;
         } else {
@@ -1247,7 +1331,12 @@ public class RequestHandler {
             if (uriString == null) {
                 uriString="";
             }
-            ConfigXMLReader.RequestMap requestMap = 
getControllerConfig().getRequestMapMap().get(uriString);
+            ConfigXMLReader.RequestMap requestMap = null;
+            try {
+                requestMap = 
getControllerConfig().getRequestMapMap().get(uriString);
+            } catch (WebAppConfigurationException e) {
+                Debug.logError(e, "Exception thrown while parsing 
controller.xml file: ", module);
+            }
             if (requestMap == null) return false;
             return requestMap.trackVisit;
         } else {

Modified: 
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandlerException.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandlerException.java?rev=1534517&r1=1534516&r2=1534517&view=diff
==============================================================================
--- 
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandlerException.java
 (original)
+++ 
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandlerException.java
 Tue Oct 22 06:50:05 2013
@@ -28,6 +28,10 @@ public class RequestHandlerException ext
         super(str, t);
     }
 
+    public RequestHandlerException(Throwable t) {
+        super(t);
+    }
+
     public RequestHandlerException(String str) {
         super(str);
     }

Added: 
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/WebAppConfigurationException.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/WebAppConfigurationException.java?rev=1534517&view=auto
==============================================================================
--- 
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/WebAppConfigurationException.java
 (added)
+++ 
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/WebAppConfigurationException.java
 Tue Oct 22 06:50:05 2013
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * 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;
+
+/**
+ * Web application configuration exception.
+ * 
+ * @see <code>site-conf.xsd</code>
+ */
+@SuppressWarnings("serial")
+public class WebAppConfigurationException extends 
org.ofbiz.base.util.GeneralException {
+
+    public WebAppConfigurationException(Throwable t) {
+        super(t);
+    }
+}
+

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

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

Modified: 
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/EventFactory.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/EventFactory.java?rev=1534517&r1=1534516&r2=1534517&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/EventFactory.java 
(original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/EventFactory.java 
Tue Oct 22 06:50:05 2013
@@ -32,6 +32,7 @@ import org.ofbiz.base.util.GeneralRuntim
 import org.ofbiz.base.util.ObjectType;
 import org.ofbiz.webapp.control.ConfigXMLReader;
 import org.ofbiz.webapp.control.RequestHandler;
+import org.ofbiz.webapp.control.WebAppConfigurationException;
 
 /**
  * EventFactory - Event Handler Factory
@@ -59,7 +60,12 @@ public class EventFactory {
     }
 
     private void preLoadAll() throws EventHandlerException {
-        Set<String> handlers = 
this.requestHandler.getControllerConfig().getEventHandlerMap().keySet();
+        Set<String> handlers = null;
+        try {
+            handlers = 
this.requestHandler.getControllerConfig().getEventHandlerMap().keySet();
+        } catch (WebAppConfigurationException e) {
+            Debug.logError(e, "Exception thrown while parsing controller.xml 
file: ", module);
+        }
         if (handlers != null) {
             for (String type: handlers) {
                 this.handlers.put(type, this.loadEventHandler(type));
@@ -96,7 +102,12 @@ public class EventFactory {
 
     private EventHandler loadEventHandler(String type) throws 
EventHandlerException {
         EventHandler handler = null;
-        String handlerClass = 
this.requestHandler.getControllerConfig().getEventHandlerMap().get(type);
+        String handlerClass = null;
+        try {
+            handlerClass = 
this.requestHandler.getControllerConfig().getEventHandlerMap().get(type);
+        } catch (WebAppConfigurationException e) {
+            Debug.logError(e, "Exception thrown while parsing controller.xml 
file: ", module);
+        }
         if (handlerClass == null) {
             throw new EventHandlerException("Unknown handler type: " + type);
         }
@@ -121,7 +132,13 @@ public class EventFactory {
         ServletContext application = ((ServletContext) 
request.getAttribute("servletContext"));
         RequestHandler handler = (RequestHandler) 
application.getAttribute("_REQUEST_HANDLER_");
         ConfigXMLReader.ControllerConfig controllerConfig = 
handler.getControllerConfig();
-        ConfigXMLReader.RequestMap requestMap = 
controllerConfig.getRequestMapMap().get(requestUri);
+        ConfigXMLReader.RequestMap requestMap;
+        try {
+            requestMap = controllerConfig.getRequestMapMap().get(requestUri);
+        } catch (WebAppConfigurationException e) {
+            Debug.logError(e, "Exception thrown while parsing controller.xml 
file: ", module);
+            throw new EventHandlerException(e);
+        }
         return handler.runEvent(request, response, requestMap.event, 
requestMap, "unknown");
     }
 }

Modified: 
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceMultiEventHandler.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceMultiEventHandler.java?rev=1534517&r1=1534516&r2=1534517&view=diff
==============================================================================
--- 
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceMultiEventHandler.java
 (original)
+++ 
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceMultiEventHandler.java
 Tue Oct 22 06:50:05 2013
@@ -53,6 +53,7 @@ import org.ofbiz.webapp.control.ConfigXM
 import org.ofbiz.webapp.control.RequestHandler;
 import org.ofbiz.webapp.control.ConfigXMLReader.Event;
 import org.ofbiz.webapp.control.ConfigXMLReader.RequestMap;
+import org.ofbiz.webapp.control.WebAppConfigurationException;
 
 /**
  * ServiceMultiEventHandler - Event handler for running a service multiple 
times; for bulk forms
@@ -160,8 +161,18 @@ public class ServiceMultiEventHandler im
         // Check the global-transaction attribute of the event from the 
controller to see if the
         //  event should be wrapped in a transaction
         String requestUri = 
RequestHandler.getRequestUri(request.getPathInfo());
-        ConfigXMLReader.ControllerConfig controllerConfig = 
ConfigXMLReader.getControllerConfig(ConfigXMLReader.getControllerConfigURL(servletContext));
-        boolean eventGlobalTransaction = 
controllerConfig.getRequestMapMap().get(requestUri).event.globalTransaction;
+        ConfigXMLReader.ControllerConfig controllerConfig;
+        try {
+            controllerConfig = 
ConfigXMLReader.getControllerConfig(ConfigXMLReader.getControllerConfigURL(servletContext));
+        } catch (WebAppConfigurationException e) {
+            throw new EventHandlerException(e);
+        }
+        boolean eventGlobalTransaction;
+        try {
+            eventGlobalTransaction = 
controllerConfig.getRequestMapMap().get(requestUri).event.globalTransaction;
+        } catch (WebAppConfigurationException e) {
+            throw new EventHandlerException(e);
+        }
 
         Set<String> urlOnlyParameterNames = 
UtilHttp.getUrlOnlyParameterMap(request).keySet();
 

Modified: 
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/ViewFactory.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/ViewFactory.java?rev=1534517&r1=1534516&r2=1534517&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/ViewFactory.java 
(original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/ViewFactory.java Tue 
Oct 22 06:50:05 2013
@@ -30,6 +30,8 @@ import org.ofbiz.base.util.GeneralRuntim
 import org.ofbiz.base.util.ObjectType;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.webapp.control.RequestHandler;
+import org.ofbiz.webapp.control.RequestHandlerException;
+import org.ofbiz.webapp.control.WebAppConfigurationException;
 
 /**
  * ViewFactory - View Handler Factory
@@ -57,7 +59,12 @@ public class ViewFactory {
     }
 
     private void preLoadAll() throws ViewHandlerException {
-        Set<String> handlers = 
this.requestHandler.getControllerConfig().getViewHandlerMap().keySet();
+        Set<String> handlers = null;
+        try {
+            handlers = 
this.requestHandler.getControllerConfig().getViewHandlerMap().keySet();
+        } catch (WebAppConfigurationException e) {
+            Debug.logError(e, "Exception thrown while parsing controller.xml 
file: ", module);
+        }
         if (handlers != null) {
             for (String type: handlers) {
                 this.handlers.put(type, this.loadViewHandler(type));
@@ -111,7 +118,12 @@ public class ViewFactory {
 
     private ViewHandler loadViewHandler(String type) throws 
ViewHandlerException {
         ViewHandler handler = null;
-        String handlerClass = 
this.requestHandler.getControllerConfig().getViewHandlerMap().get(type);
+        String handlerClass = null;
+        try {
+            handlerClass = 
this.requestHandler.getControllerConfig().getViewHandlerMap().get(type);
+        } catch (WebAppConfigurationException e) {
+            Debug.logError(e, "Exception thrown while parsing controller.xml 
file: ", module);
+        }
         if (handlerClass == null) {
             throw new ViewHandlerException("Unknown handler type: " + type);
         }

Modified: 
ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java?rev=1534517&r1=1534516&r2=1534517&view=diff
==============================================================================
--- 
ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java
 (original)
+++ 
ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java
 Tue Oct 22 06:50:05 2013
@@ -53,6 +53,7 @@ import org.ofbiz.service.ModelService;
 import org.ofbiz.service.eca.ServiceEcaRule;
 import org.ofbiz.webapp.control.ConfigXMLReader;
 import org.ofbiz.webapp.control.ConfigXMLReader.ControllerConfig;
+import org.ofbiz.webapp.control.WebAppConfigurationException;
 import org.ofbiz.widget.form.FormFactory;
 import org.ofbiz.widget.form.ModelForm;
 import org.ofbiz.widget.screen.ModelScreen;
@@ -193,12 +194,23 @@ public class ArtifactInfoFactory {
     }
 
     public ConfigXMLReader.RequestMap getControllerRequestMap(URL 
controllerXmlUrl, String requestUri) {
-        return 
ConfigXMLReader.getControllerConfig(controllerXmlUrl).getRequestMapMap().get(requestUri);
+        try {
+            return 
ConfigXMLReader.getControllerConfig(controllerXmlUrl).getRequestMapMap().get(requestUri);
+        } catch (WebAppConfigurationException e) {
+            Debug.logError(e, "Exception thrown while parsing controller.xml 
file: ", module);
+        }
+        return null;
     }
 
     public ConfigXMLReader.ViewMap getControllerViewMap(URL controllerXmlUrl, 
String viewUri) {
-        ControllerConfig cc = 
ConfigXMLReader.getControllerConfig(controllerXmlUrl);
-        return cc.getViewMapMap().get(viewUri);
+        ControllerConfig cc;
+        try {
+            cc = ConfigXMLReader.getControllerConfig(controllerXmlUrl);
+            return cc.getViewMapMap().get(viewUri);
+        } catch (WebAppConfigurationException e) {
+            Debug.logError(e, "Exception thrown while parsing controller.xml 
file: ", module);
+        }
+        return null;
     }
 
     public EntityArtifactInfo getEntityArtifactInfo(String entityName) throws 
GeneralException {

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java?rev=1534517&r1=1534516&r2=1534517&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java 
(original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java Tue Oct 
22 06:50:05 2013
@@ -55,6 +55,7 @@ import org.ofbiz.service.ModelParam;
 import org.ofbiz.service.ModelService;
 import org.ofbiz.webapp.control.ConfigXMLReader;
 import org.ofbiz.webapp.control.RequestHandler;
+import org.ofbiz.webapp.control.WebAppConfigurationException;
 import org.ofbiz.webapp.taglib.ContentUrlTag;
 import org.ofbiz.widget.form.ModelForm;
 import org.ofbiz.widget.form.ModelFormField;
@@ -535,7 +536,12 @@ public class WidgetWorker {
                 String requestUri = (target.indexOf('?') > -1) ? 
target.substring(0, target.indexOf('?')) : target;
                 ServletContext servletContext = 
request.getSession().getServletContext();
                 RequestHandler rh = (RequestHandler) 
servletContext.getAttribute("_REQUEST_HANDLER_");
-                ConfigXMLReader.RequestMap requestMap = 
rh.getControllerConfig().getRequestMapMap().get(requestUri);
+                ConfigXMLReader.RequestMap requestMap = null;
+                try {
+                    requestMap = 
rh.getControllerConfig().getRequestMapMap().get(requestUri);
+                } catch (WebAppConfigurationException e) {
+                    Debug.logError(e, "Exception thrown while parsing 
controller.xml file: ", module);
+                }
                 if (requestMap != null && requestMap.event != null) {
                     return "hidden-form";
                 } else {


Reply via email to