|
Author: doogie
Date: Thu Jan 28 20:10:51 2010 New Revision: 904250 URL: http://svn.apache.org/viewvc?rev=904250&view=rev Log: Make all variables in ControllerConfig private, and add accessor functions to them. 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/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=904250&r1=904249&r2=904250&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 Thu Jan 28 20:10:51 2010 @@ -43,7 +43,7 @@ RequestHandler rh = (RequestHandler) request.getAttribute("_REQUEST_HANDLER_"); ConfigXMLReader.ControllerConfig controllerConfig = rh.getControllerConfig(); String requestUri = (String) request.getAttribute("thisRequestUri"); - RequestMap requestMap = controllerConfig.requestMapMap.get(requestUri); + RequestMap requestMap = controllerConfig.getRequestMapMap().get(requestUri); 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=904250&r1=904249&r2=904250&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 Thu Jan 28 20:10:51 2010 @@ -81,23 +81,24 @@ public static class ControllerConfig { public URL url; - public String errorpage; - public String protectView; - public String owner; - public String securityClass; - public String defaultRequest; - - public Map<String, Event> firstVisitEventList = FastMap.newInstance(); - public Map<String, Event> preprocessorEventList = FastMap.newInstance(); - public Map<String, Event> postprocessorEventList = FastMap.newInstance(); - public Map<String, Event> afterLoginEventList = FastMap.newInstance(); - public Map<String, Event> beforeLogoutEventList = FastMap.newInstance(); + private String errorpage; + private String protectView; + private String owner; + private String securityClass; + private String defaultRequest; + + private List<URL> includes = FastList.newInstance(); + private Map<String, Event> firstVisitEventList = FastMap.newInstance(); + private Map<String, Event> preprocessorEventList = FastMap.newInstance(); + private Map<String, Event> postprocessorEventList = FastMap.newInstance(); + private Map<String, Event> afterLoginEventList = FastMap.newInstance(); + private Map<String, Event> beforeLogoutEventList = FastMap.newInstance(); - public Map<String, String> eventHandlerMap = FastMap.newInstance(); - public Map<String, String> viewHandlerMap = FastMap.newInstance(); + private Map<String, String> eventHandlerMap = FastMap.newInstance(); + private Map<String, String> viewHandlerMap = FastMap.newInstance(); - public Map<String, RequestMap> requestMapMap = FastMap.newInstance(); - public Map<String, ViewMap> viewMapMap = FastMap.newInstance(); + private Map<String, RequestMap> requestMapMap = FastMap.newInstance(); + private Map<String, ViewMap> viewMapMap = FastMap.newInstance(); public ControllerConfig(URL url) { this.url = url; @@ -120,6 +121,62 @@ } } + public String getErrorpage() { + return errorpage; + } + + public String getProtectView() { + return protectView; + } + + public String getOwner() { + return owner; + } + + public String getSecurityClass() { + return securityClass; + } + + public String getDefaultRequest() { + return defaultRequest; + } + + public Map<String, Event> getFirstVisitEventList() { + return firstVisitEventList; + } + + public Map<String, Event> getPreprocessorEventList() { + return preprocessorEventList; + } + + public Map<String, Event> getPostprocessorEventList() { + return postprocessorEventList; + } + + public Map<String, Event> getAfterLoginEventList() { + return afterLoginEventList; + } + + public Map<String, Event> getBeforeLogoutEventList() { + return beforeLogoutEventList; + } + + public Map<String, String> getEventHandlerMap() { + return eventHandlerMap; + } + + public Map<String, String> getViewHandlerMap() { + return viewHandlerMap; + } + + public Map<String, RequestMap> getRequestMapMap() { + return requestMapMap; + } + + public Map<String, ViewMap> getViewMapMap() { + return viewMapMap; + } + protected void absorbControllerConfig(ControllerConfig controllerConfig) { // copy/add all data except the url 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=904250&r1=904249&r2=904250&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 Jan 28 20:10:51 2010 @@ -110,6 +110,7 @@ // 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(); // workaround if we are in the root webapp String cname = UtilHttp.getApplicationName(request); @@ -129,12 +130,13 @@ String requestMissingErrorMessage = "Unknown request [" + defaultRequestUri + "]; this request does not exist or cannot be called directly."; ConfigXMLReader.RequestMap requestMap = null; if (defaultRequestUri != null) { - requestMap = controllerConfig.requestMapMap.get(defaultRequestUri); + requestMap = requestMapMap.get(defaultRequestUri); } // check for default request if (requestMap == null) { - if (controllerConfig.defaultRequest != null) { // required! to avoid a null pointer exception and generate a requesthandler exception if default request not found. - requestMap = controllerConfig.requestMapMap.get(controllerConfig.defaultRequest); + 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); } } // still not found so stop @@ -148,7 +150,7 @@ // Check for chained request. if (chain != null) { String chainRequestUri = RequestHandler.getRequestUri(chain); - requestMap = controllerConfig.requestMapMap.get(chainRequestUri); + requestMap = requestMapMap.get(chainRequestUri); if (requestMap == null) { throw new RequestHandlerException("Unknown chained request [" + chainRequestUri + "]; this request does not exist"); } @@ -166,12 +168,13 @@ // 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 && controllerConfig.defaultRequest != null) { - if (!controllerConfig.requestMapMap.get(controllerConfig.defaultRequest).securityDirectRequest) { + String defaultRequest = controllerConfig.getDefaultRequest(); + if (!requestMap.securityDirectRequest && defaultRequest != null) { + if (!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); } else { - requestMap = controllerConfig.requestMapMap.get(controllerConfig.defaultRequest); + requestMap = requestMapMap.get(defaultRequest); } } boolean forceHttpSession = "true".equals(context.getInitParameter("forceHttpSession")); @@ -272,7 +275,7 @@ // This isn't an event because it is required to run. We do not want to make it optional. GenericValue visit = VisitHandler.getVisit(session); if (visit != null) { - for (ConfigXMLReader.Event event: controllerConfig.firstVisitEventList.values()) { + for (ConfigXMLReader.Event event: controllerConfig.getFirstVisitEventList().values()) { try { String returnString = this.runEvent(request, response, event, null, "firstvisit"); if (returnString != null && !returnString.equalsIgnoreCase("success")) { @@ -288,7 +291,7 @@ } // Invoke the pre-processor (but NOT in a chain) - for (ConfigXMLReader.Event event: controllerConfig.preprocessorEventList.values()) { + for (ConfigXMLReader.Event event: controllerConfig.getPreprocessorEventList().values()) { try { String returnString = this.runEvent(request, response, event, null, "preprocessor"); if (returnString != null && !returnString.equalsIgnoreCase("success")) { @@ -302,8 +305,9 @@ eventReturn = "protect"; // check to see if there is an "protect" response, if so it's ok else show the default_error_response_view if (!requestMap.requestResponseMap.containsKey("protect")) { - if (controllerConfig.protectView != null) { - overrideViewUri = controllerConfig.protectView; + String protectView = controllerConfig.getProtectView(); + if (protectView != null) { + overrideViewUri = protectView; } else { overrideViewUri = UtilProperties.getPropertyValue("security.properties", "default.error.response.view"); } @@ -334,7 +338,7 @@ // Invoke the security handler // catch exceptions and throw RequestHandlerException if failed. if (Debug.verboseOn()) Debug.logVerbose("[RequestHandler]: AuthRequired. Running security check. sessionId=" + UtilHttp.getSessionId(request), module); - ConfigXMLReader.Event checkLoginEvent = controllerConfig.requestMapMap.get("checkLogin").event; + ConfigXMLReader.Event checkLoginEvent = requestMapMap.get("checkLogin").event; String checkLoginReturnString = null; try { @@ -345,7 +349,7 @@ if (!"success".equalsIgnoreCase(checkLoginReturnString)) { // previous URL already saved by event, so just do as the return says... eventReturn = checkLoginReturnString; - requestMap = controllerConfig.requestMapMap.get("checkLogin"); + requestMap = requestMapMap.get("checkLogin"); } } @@ -517,7 +521,7 @@ // ======== handle views ======== // first invoke the post-processor events. - for (ConfigXMLReader.Event event: controllerConfig.postprocessorEventList.values()) { + for (ConfigXMLReader.Event event: controllerConfig.getPostprocessorEventList().values()) { try { String returnString = this.runEvent(request, response, event, requestMap, "postprocessor"); if (returnString != null && !returnString.equalsIgnoreCase("success")) { @@ -632,7 +636,7 @@ /** Returns the default error page for this request. */ public String getDefaultErrorPage(HttpServletRequest request) { - String errorpage = getControllerConfig().errorpage; + String errorpage = getControllerConfig().getErrorpage(); if (UtilValidate.isNotEmpty(errorpage)) return errorpage; return "/error/error.jsp"; } @@ -764,7 +768,7 @@ req.getSession().removeAttribute("_SAVED_VIEW_PARAMS_"); } - ConfigXMLReader.ViewMap viewMap = (view == null ? null : getControllerConfig().viewMapMap.get(view)); + ConfigXMLReader.ViewMap viewMap = (view == null ? null : getControllerConfig().getViewMapMap().get(view)); if (viewMap == null) { throw new RequestHandlerException("No definition found for view with name [" + view + "]"); } @@ -985,7 +989,7 @@ String requestUri = RequestHandler.getRequestUri(url); ConfigXMLReader.RequestMap requestMap = null; if (requestUri != null) { - requestMap = getControllerConfig().requestMapMap.get(requestUri); + requestMap = getControllerConfig().getRequestMapMap().get(requestUri); } StringBuilder newURL = new StringBuilder(); @@ -1090,7 +1094,7 @@ } public void runAfterLoginEvents(HttpServletRequest request, HttpServletResponse response) { - for (ConfigXMLReader.Event event: getControllerConfig().afterLoginEventList.values()) { + for (ConfigXMLReader.Event event: getControllerConfig().getAfterLoginEventList().values()) { try { String returnString = this.runEvent(request, response, event, null, "after-login"); if (returnString != null && !returnString.equalsIgnoreCase("success")) { @@ -1103,7 +1107,7 @@ } public void runBeforeLogoutEvents(HttpServletRequest request, HttpServletResponse response) { - for (ConfigXMLReader.Event event: getControllerConfig().beforeLogoutEventList.values()) { + for (ConfigXMLReader.Event event: getControllerConfig().getBeforeLogoutEventList().values()) { try { String returnString = this.runEvent(request, response, event, null, "before-logout"); if (returnString != null && !returnString.equalsIgnoreCase("success")) { @@ -1121,7 +1125,7 @@ if (uriString == null) { uriString=""; } - ConfigXMLReader.RequestMap requestMap = getControllerConfig().requestMapMap.get(uriString); + ConfigXMLReader.RequestMap requestMap = getControllerConfig().getRequestMapMap().get(uriString); if (requestMap == null) return false; return requestMap.trackServerHit; } else { @@ -1135,7 +1139,7 @@ if (uriString == null) { uriString=""; } - ConfigXMLReader.RequestMap requestMap = getControllerConfig().requestMapMap.get(uriString); + ConfigXMLReader.RequestMap requestMap = getControllerConfig().getRequestMapMap().get(uriString); if (requestMap == null) return false; return requestMap.trackVisit; } else { 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=904250&r1=904249&r2=904250&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 Thu Jan 28 20:10:51 2010 @@ -59,7 +59,7 @@ } private void preLoadAll() throws EventHandlerException { - Set<String> handlers = this.requestHandler.getControllerConfig().eventHandlerMap.keySet(); + Set<String> handlers = this.requestHandler.getControllerConfig().getEventHandlerMap().keySet(); if (handlers != null) { for (String type: handlers) { this.handlers.put(type, this.loadEventHandler(type)); @@ -96,7 +96,7 @@ private EventHandler loadEventHandler(String type) throws EventHandlerException { EventHandler handler = null; - String handlerClass = this.requestHandler.getControllerConfig().eventHandlerMap.get(type); + String handlerClass = this.requestHandler.getControllerConfig().getEventHandlerMap().get(type); if (handlerClass == null) { throw new EventHandlerException("Unknown handler type: " + type); } @@ -121,7 +121,7 @@ ServletContext application = ((ServletContext) request.getAttribute("servletContext")); RequestHandler handler = (RequestHandler) application.getAttribute("_REQUEST_HANDLER_"); ConfigXMLReader.ControllerConfig controllerConfig = handler.getControllerConfig(); - ConfigXMLReader.RequestMap requestMap = controllerConfig.requestMapMap.get(requestUri); + ConfigXMLReader.RequestMap requestMap = controllerConfig.getRequestMapMap().get(requestUri); 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=904250&r1=904249&r2=904250&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 Thu Jan 28 20:10:51 2010 @@ -161,7 +161,7 @@ // event should be wrapped in a transaction String requestUri = RequestHandler.getRequestUri(request.getPathInfo()); ConfigXMLReader.ControllerConfig controllerConfig = ConfigXMLReader.getControllerConfig(ConfigXMLReader.getControllerConfigURL(servletContext)); - boolean eventGlobalTransaction = controllerConfig.requestMapMap.get(requestUri).event.globalTransaction; + boolean eventGlobalTransaction = controllerConfig.getRequestMapMap().get(requestUri).event.globalTransaction; 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=904250&r1=904249&r2=904250&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 Thu Jan 28 20:10:51 2010 @@ -57,7 +57,7 @@ } private void preLoadAll() throws ViewHandlerException { - Set<String> handlers = this.requestHandler.getControllerConfig().viewHandlerMap.keySet(); + Set<String> handlers = this.requestHandler.getControllerConfig().getViewHandlerMap().keySet(); if (handlers != null) { for (String type: handlers) { this.handlers.put(type, this.loadViewHandler(type)); @@ -111,7 +111,7 @@ private ViewHandler loadViewHandler(String type) throws ViewHandlerException { ViewHandler handler = null; - String handlerClass = this.requestHandler.getControllerConfig().viewHandlerMap.get(type); + String handlerClass = this.requestHandler.getControllerConfig().getViewHandlerMap().get(type); 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=904250&r1=904249&r2=904250&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 Thu Jan 28 20:10:51 2010 @@ -208,14 +208,14 @@ throw new GeneralException(mue.getMessage()); } ControllerConfig cc = ConfigXMLReader.getControllerConfig(controllerUrl); - for (String requestUri: cc.requestMapMap.keySet()) { + for (String requestUri: cc.getRequestMapMap().keySet()) { try { this.getControllerRequestArtifactInfo(controllerUrl, requestUri); } catch (GeneralException e) { Debug.logWarning(e.getMessage(), module); } } - for (String viewUri: cc.viewMapMap.keySet()) { + for (String viewUri: cc.getViewMapMap().keySet()) { try { this.getControllerViewArtifactInfo(controllerUrl, viewUri); } catch (GeneralException e) { @@ -255,12 +255,12 @@ } public ConfigXMLReader.RequestMap getControllerRequestMap(URL controllerXmlUrl, String requestUri) { - return ConfigXMLReader.getControllerConfig(controllerXmlUrl).requestMapMap.get(requestUri); + return ConfigXMLReader.getControllerConfig(controllerXmlUrl).getRequestMapMap().get(requestUri); } public ConfigXMLReader.ViewMap getControllerViewMap(URL controllerXmlUrl, String viewUri) { ControllerConfig cc = ConfigXMLReader.getControllerConfig(controllerXmlUrl); - return cc.viewMapMap.get(viewUri); + return cc.getViewMapMap().get(viewUri); } 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=904250&r1=904249&r2=904250&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java Thu Jan 28 20:10:51 2010 @@ -333,7 +333,7 @@ String requestUri = (target.indexOf('?') > -1) ? target.substring(0, target.indexOf('?')) : target; ServletContext servletContext = (ServletContext) request.getSession().getServletContext(); RequestHandler rh = (RequestHandler) servletContext.getAttribute("_REQUEST_HANDLER_"); - ConfigXMLReader.RequestMap requestMap = rh.getControllerConfig().requestMapMap.get(requestUri); + ConfigXMLReader.RequestMap requestMap = rh.getControllerConfig().getRequestMapMap().get(requestUri); if (requestMap != null && requestMap.event != null) { return "hidden-form"; } else { |
| Free forum by Nabble | Edit this page |
