Author: adrianc
Date: Fri Aug 28 23:18:40 2009 New Revision: 809059 URL: http://svn.apache.org/viewvc?rev=809059&view=rev Log: Bug fixes, JavaDoc cleanups. It's almost there. Right now I'm up against a brick wall. DispatchContext.java needs to be refactored to go any further - and that will take some time. Modified: ofbiz/branches/executioncontext20090812/BranchReadMe.txt ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AccessController.java ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AdminPermission.java ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/context/ExecutionContextFactory.java ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/context/ExecutionContextImpl.java ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/AccessControllerImpl.java ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/AuthorizationManagerImpl.java ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/ExecutionContextImpl.java ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/NullAccessController.java ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/NullAuthorizationManager.java ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/PathNode.java ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/SecurityAwareListIterator.java ofbiz/branches/executioncontext20090812/framework/minilang/src/org/ofbiz/minilang/method/callops/CallService.java ofbiz/branches/executioncontext20090812/framework/security/data/SecurityData.xml ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/ServiceDispatcher.java ofbiz/branches/executioncontext20090812/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java ofbiz/branches/executioncontext20090812/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java Modified: ofbiz/branches/executioncontext20090812/BranchReadMe.txt URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/BranchReadMe.txt?rev=809059&r1=809058&r2=809059&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/BranchReadMe.txt (original) +++ ofbiz/branches/executioncontext20090812/BranchReadMe.txt Fri Aug 28 23:18:40 2009 @@ -26,6 +26,21 @@ declared in the api component, then have each component extend the interfaces and add their methods. It's not pretty, but it works. +This is where you can find the interfaces: + +org.ofbiz.api.authorization.AuthorizationManager + org.ofbiz.security.AuthorizationManager + +org.ofbiz.api.context.ExecutionContext + org.ofbiz.entity.ExecutionContext + org.ofbiz.security.ExecutionContext + org.ofbiz.service.ExecutionContext + +When the cross-dependency issues are solved, all of the extended +interfaces will be consolidated into one. + +The interface implementations can be found in the context component. + The ultimate goal of ExecutionContext is to have all client code get the contained objects from ExecutionContext only - instead of getting them from the various classes now in use. This initial @@ -58,5 +73,14 @@ 2009-08-28: Permissions checking has been implemented. The code has a few bugs, and there are places where the ExecutionContext isn't being passed along, so OFBiz won't run with the AuthorizationManager enabled. -Consequently, the AuthorizationManager is disabled by default. You can +Consequently, the AuthorizationManager is disabled by default. It still +"pretends" to check permissions, but it always grants access. You can enable it with a property in api.properties. + +When a user first logs in, all of their permissions are gathered from the +security entities and are used to assemble a tree-like Java structure. +The structure is cached. When an artifact requests the user's permissions, +an object (OFBizPermission) traverses the tree, accumulating permissions +along the way. This is how permission inheritance is acheived. The permission +object is then queried if the user has the requested permission and the +result is returned to the artifact. Modified: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AccessController.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AccessController.java?rev=809059&r1=809058&r2=809059&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AccessController.java (original) +++ ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AccessController.java Fri Aug 28 23:18:40 2009 @@ -27,7 +27,7 @@ * separate the permissions-checking logic from the artifacts * that use it. */ -public interface AccessController<E> { +public interface AccessController<E> { /** Returns silently if the user has been granted <code>permission</code> * access for the current artifact, throws <code>AccessControlException</code> Modified: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AdminPermission.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AdminPermission.java?rev=809059&r1=809058&r2=809059&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AdminPermission.java (original) +++ ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AdminPermission.java Fri Aug 28 23:18:40 2009 @@ -21,7 +21,7 @@ import java.security.Permission; /** - * Admin permission class. Extends GenericPermission. + * Admin permission class. Extends BasicPermission. */ @SuppressWarnings("serial") public class AdminPermission extends BasicPermission { @@ -52,6 +52,10 @@ return this.permissionString.hashCode(); } + /** Returns <code>true</code> - the admin permission has + * no restrictions. + * + */ @Override public boolean implies(Permission permission) { return true; Modified: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/context/ExecutionContextFactory.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/context/ExecutionContextFactory.java?rev=809059&r1=809058&r2=809059&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/context/ExecutionContextFactory.java (original) +++ ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/context/ExecutionContextFactory.java Fri Aug 28 23:18:40 2009 @@ -18,6 +18,7 @@ *******************************************************************************/ package org.ofbiz.api.context; +import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilProperties; /** ExecutionContext factory. */ Modified: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/context/ExecutionContextImpl.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/context/ExecutionContextImpl.java?rev=809059&r1=809058&r2=809059&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/context/ExecutionContextImpl.java (original) +++ ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/context/ExecutionContextImpl.java Fri Aug 28 23:18:40 2009 @@ -25,7 +25,6 @@ import javolution.util.FastList; import javolution.util.FastMap; -import org.ofbiz.api.authorization.AccessController; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilProperties; Modified: ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/AccessControllerImpl.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/AccessControllerImpl.java?rev=809059&r1=809058&r2=809059&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/AccessControllerImpl.java (original) +++ ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/AccessControllerImpl.java Fri Aug 28 23:18:40 2009 @@ -35,6 +35,7 @@ import org.ofbiz.service.LocalDispatcher; import org.ofbiz.service.ModelService; +/** An implementation of the <code>AccessController</code> interface. */ public class AccessControllerImpl<E> implements AccessController<E> { public static final String module = AccessControllerImpl.class.getName(); Modified: ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/AuthorizationManagerImpl.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/AuthorizationManagerImpl.java?rev=809059&r1=809058&r2=809059&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/AuthorizationManagerImpl.java (original) +++ ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/AuthorizationManagerImpl.java Fri Aug 28 23:18:40 2009 @@ -121,6 +121,12 @@ } + @Override + public void clearUserData(GenericValue userLogin) { + super.clearUserData(userLogin); + userPermCache.remove(userLogin.getString("userLogin")); + } + @SuppressWarnings("unchecked") public AccessController<?> getAccessController(org.ofbiz.api.context.ExecutionContext executionContext) throws AccessControlException { String userLoginId = ((ExecutionContext) executionContext).getUserLogin().getString("userLoginId"); Modified: ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/ExecutionContextImpl.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/ExecutionContextImpl.java?rev=809059&r1=809058&r2=809059&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/ExecutionContextImpl.java (original) +++ ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/ExecutionContextImpl.java Fri Aug 28 23:18:40 2009 @@ -34,7 +34,7 @@ import org.ofbiz.service.LocalDispatcher; import org.ofbiz.service.ExecutionContext; -/** ExecutionContext implementation. */ +/** An implementation of the <code>ExecutionContext</code> interface. */ public class ExecutionContextImpl extends org.ofbiz.api.context.ExecutionContextImpl implements ExecutionContext { public static final String module = ExecutionContextImpl.class.getName(); @@ -45,7 +45,7 @@ public GenericDelegator getDelegator() { if (this.delegator == null) { - this.delegator = DelegatorFactory.getGenericDelegator("default"); + this.delegator = DelegatorFactory.getGenericDelegator("default", this); } return this.delegator; } Modified: ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/NullAccessController.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/NullAccessController.java?rev=809059&r1=809058&r2=809059&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/NullAccessController.java (original) +++ ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/NullAccessController.java Fri Aug 28 23:18:40 2009 @@ -26,6 +26,9 @@ import org.ofbiz.entity.AccessController; import org.ofbiz.entity.util.EntityListIterator; +/** An implementation of the <code>AccessController</code> interface + * that allows unrestricted access. + */ public class NullAccessController<E> implements AccessController<E> { public EntityListIterator applyFilters(EntityListIterator listIterator) { Modified: ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/NullAuthorizationManager.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/NullAuthorizationManager.java?rev=809059&r1=809058&r2=809059&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/NullAuthorizationManager.java (original) +++ ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/NullAuthorizationManager.java Fri Aug 28 23:18:40 2009 @@ -46,7 +46,6 @@ * saved <code>AuthorizationManager</code> instance.</li> * </ul></p> * - * @param <E> */ public class NullAuthorizationManager<E> implements AuthorizationManager { Modified: ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/PathNode.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/PathNode.java?rev=809059&r1=809058&r2=809059&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/PathNode.java (original) +++ ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/PathNode.java Fri Aug 28 23:18:40 2009 @@ -22,6 +22,8 @@ import javolution.util.FastMap; +/** Implements a node in a permissions tree. + */ public class PathNode { protected Map<String, PathNode> childNodes = null; Modified: ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/SecurityAwareListIterator.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/SecurityAwareListIterator.java?rev=809059&r1=809058&r2=809059&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/SecurityAwareListIterator.java (original) +++ ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/SecurityAwareListIterator.java Fri Aug 28 23:18:40 2009 @@ -18,7 +18,6 @@ *******************************************************************************/ package org.ofbiz.context; -import java.util.List; import java.util.ListIterator; import java.util.Set; @@ -27,7 +26,7 @@ /** * SecurityAwareListIterator class. This class decorates a <code> * ListIterator</code> instance and filters a list of - * <code>GenericValue</code>s based on a set of permission services. + * <code>Object</code>s based on a set of permission services. * <p>The permission service must implement <code>permissionInterface</code> * and accept an optional <code>candidateObject</code> parameter (parameter * type is <code>java.lang.Object</code>). The service should Modified: ofbiz/branches/executioncontext20090812/framework/minilang/src/org/ofbiz/minilang/method/callops/CallService.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/minilang/src/org/ofbiz/minilang/method/callops/CallService.java?rev=809059&r1=809058&r2=809059&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/minilang/src/org/ofbiz/minilang/method/callops/CallService.java (original) +++ ofbiz/branches/executioncontext20090812/framework/minilang/src/org/ofbiz/minilang/method/callops/CallService.java Fri Aug 28 23:18:40 2009 @@ -25,6 +25,7 @@ import javolution.util.FastList; import javolution.util.FastMap; +import org.ofbiz.api.context.ExecutionContext; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilValidate; @@ -228,6 +229,13 @@ if (locale != null) { inMap.put("locale", locale); } + ExecutionContext executionContext = (ExecutionContext) methodContext.getParameter("executionContext"); + if (executionContext == null) { + executionContext = (ExecutionContext) methodContext.getEnv("executionContext"); + } + if (executionContext != null) { + inMap.put("executionContext", executionContext); + } try { if (UtilValidate.isEmpty(this.requireNewTransactionStr) && this.transactionTimeout < 0) { Modified: ofbiz/branches/executioncontext20090812/framework/security/data/SecurityData.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/security/data/SecurityData.xml?rev=809059&r1=809058&r2=809059&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/security/data/SecurityData.xml (original) +++ ofbiz/branches/executioncontext20090812/framework/security/data/SecurityData.xml Fri Aug 28 23:18:40 2009 @@ -72,9 +72,5 @@ <ArtifactPermission permissionValue="view=true" description="View access granted"/> <ArtifactPermission permissionValue="view=false" description="View access denied"/> <UserToArtifactPermRel userLoginId="system" artifactPath="ofbiz" permissionValue="admin=true"/> - <ArtifactPath artifactPath="ofbiz/getUserPreferenceGroup" description="The getUserPreferenceGroup service"/> - <ArtifactPath artifactPath="ofbiz/getVisualThemeResources" description="The getVisualThemeResources service"/> - <UserToArtifactPermRel userLoginId="NOT_LOGGED_IN" artifactPath="ofbiz/getUserPreferenceGroup" permissionValue="access=true"/> - <UserToArtifactPermRel userLoginId="NOT_LOGGED_IN" artifactPath="ofbiz/getVisualThemeResources" permissionValue="access=true"/> </entity-engine-xml> Modified: ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/ServiceDispatcher.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/ServiceDispatcher.java?rev=809059&r1=809058&r2=809059&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/ServiceDispatcher.java (original) +++ ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/ServiceDispatcher.java Fri Aug 28 23:18:40 2009 @@ -306,7 +306,6 @@ ExecutionContext executionContext = (ExecutionContext) context.get("executionContext"); if (executionContext == null) { try { - Debug.logInfo(new Exception(), modelService.name + ": No executionContext, creating new one", module); executionContext = (ExecutionContext) ExecutionContextFactory.getInstance(); } catch (Exception e) { throw new GenericServiceException(e); Modified: ofbiz/branches/executioncontext20090812/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java?rev=809059&r1=809058&r2=809059&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java (original) +++ ofbiz/branches/executioncontext20090812/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java Fri Aug 28 23:18:40 2009 @@ -61,6 +61,7 @@ import org.ofbiz.entity.transaction.TransactionUtil; import org.ofbiz.security.Security; import org.ofbiz.security.authz.Authorization; +import org.ofbiz.service.ExecutionContext; import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.LocalDispatcher; import org.ofbiz.service.ModelService; @@ -366,9 +367,12 @@ password = request.getParameter("newPassword"); } } + ExecutionContext executionContext = (ExecutionContext) request.getAttribute("executionContext"); try { - result = dispatcher.runSync("userLogin", UtilMisc.toMap("login.username", username, "login.password", password, "visitId", visitId, "locale", UtilHttp.getLocale(request))); + result = dispatcher.runSync("userLogin", UtilMisc.toMap("login.username", username, + "login.password", password, "visitId", visitId, "locale", UtilHttp.getLocale(request), + "executionContext", executionContext)); } catch (GenericServiceException e) { Debug.logError(e, "Error calling userLogin service", module); Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); @@ -379,6 +383,7 @@ if (ModelService.RESPOND_SUCCESS.equals(result.get(ModelService.RESPONSE_MESSAGE))) { GenericValue userLogin = (GenericValue) result.get("userLogin"); + executionContext.setUserLogin(userLogin); Map<String, Object> userLoginSession = checkMap(result.get("userLoginSession"), String.class, Object.class); if (userLogin != null && "Y".equals(userLogin.getString("requirePasswordChange"))) { return "requirePasswordChange"; @@ -388,7 +393,9 @@ javaScriptEnabled = "Y"; } try { - result = dispatcher.runSync("setUserPreference", UtilMisc.toMap("userPrefTypeId", "javaScriptEnabled", "userPrefGroupTypeId", "GLOBAL_PREFERENCES", "userPrefValue", javaScriptEnabled, "userLogin", userLogin)); + result = dispatcher.runSync("setUserPreference", UtilMisc.toMap("userPrefTypeId", "javaScriptEnabled", + "userPrefGroupTypeId", "GLOBAL_PREFERENCES", "userPrefValue", javaScriptEnabled, + "userLogin", userLogin, "executionContext", executionContext)); } catch (GenericServiceException e) { Debug.logError(e, "Error setting user preference", module); } @@ -432,7 +439,10 @@ String javaScriptEnabled = null; try { LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); - Map<String, Object> result = dispatcher.runSync("getUserPreference", UtilMisc.toMap("userPrefTypeId", "javaScriptEnabled", "userPrefGroupTypeId", "GLOBAL_PREFERENCES", "userLogin", userLogin)); + Map<String, Object> result = dispatcher.runSync("getUserPreference", + UtilMisc.toMap("userPrefTypeId", "javaScriptEnabled", + "userPrefGroupTypeId", "GLOBAL_PREFERENCES", "userLogin", userLogin, + "executionContext", request.getAttribute("executionContext"))); javaScriptEnabled = (String) result.get("userPrefValue"); } catch (GenericServiceException e) { Debug.logError(e, "Error getting user preference", module); Modified: ofbiz/branches/executioncontext20090812/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java?rev=809059&r1=809058&r2=809059&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java (original) +++ ofbiz/branches/executioncontext20090812/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java Fri Aug 28 23:18:40 2009 @@ -36,6 +36,7 @@ import javolution.util.FastMap; +import org.ofbiz.api.context.GenericExecutionArtifact; import org.ofbiz.api.context.GenericParametersArtifact; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.SSLUtil; @@ -279,6 +280,7 @@ if (visit != null) { for (ConfigXMLReader.Event event: controllerConfig.firstVisitEventList.values()) { try { + executionContext.pushExecutionArtifact(new GenericExecutionArtifact(event.path, event.invoke)); String returnString = this.runEvent(request, response, event, null, "firstvisit"); if (returnString != null && !returnString.equalsIgnoreCase("success")) { throw new EventHandlerException("First-Visit event did not return 'success'."); @@ -287,6 +289,8 @@ } } catch (EventHandlerException e) { Debug.logError(e, module); + } finally { + executionContext.popExecutionArtifact(); } } } @@ -295,6 +299,7 @@ // Invoke the pre-processor (but NOT in a chain) for (ConfigXMLReader.Event event: controllerConfig.preprocessorEventList.values()) { try { + executionContext.pushExecutionArtifact(new GenericExecutionArtifact(event.path, event.invoke)); String returnString = this.runEvent(request, response, event, null, "preprocessor"); if (returnString != null && !returnString.equalsIgnoreCase("success")) { if (!returnString.contains(":_protect_:")) { @@ -319,6 +324,8 @@ } } catch (EventHandlerException e) { Debug.logError(e, module); + } finally { + executionContext.popExecutionArtifact(); } } } @@ -344,9 +351,12 @@ String checkLoginReturnString = null; try { + executionContext.pushExecutionArtifact(new GenericExecutionArtifact(checkLoginEvent.path, checkLoginEvent.invoke)); checkLoginReturnString = this.runEvent(request, response, checkLoginEvent, null, "security-auth"); } catch (EventHandlerException e) { throw new RequestHandlerException(e.getMessage(), e); + } finally { + executionContext.popExecutionArtifact(); } if (!"success".equalsIgnoreCase(checkLoginReturnString)) { // previous URL already saved by event, so just do as the return says... @@ -377,6 +387,7 @@ long eventStartTime = System.currentTimeMillis(); // run the request event + executionContext.pushExecutionArtifact(new GenericExecutionArtifact(requestMap.event.path, requestMap.event.invoke)); eventReturn = this.runEvent(request, response, requestMap.event, requestMap, "request"); // save the server hit for the request event @@ -398,6 +409,8 @@ } else { throw new RequestHandlerException("Error calling event and no error response was specified", e); } + } finally { + executionContext.popExecutionArtifact(); } } } @@ -525,12 +538,15 @@ // first invoke the post-processor events. for (ConfigXMLReader.Event event: controllerConfig.postprocessorEventList.values()) { try { + executionContext.pushExecutionArtifact(new GenericExecutionArtifact(event.path, event.invoke)); 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); + } finally { + executionContext.popExecutionArtifact(); } } @@ -1074,27 +1090,35 @@ } public void runAfterLoginEvents(HttpServletRequest request, HttpServletResponse response) { + ExecutionContext executionContext = (ExecutionContext) request.getAttribute("executionContext"); for (ConfigXMLReader.Event event: getControllerConfig().afterLoginEventList.values()) { try { + executionContext.pushExecutionArtifact(new GenericExecutionArtifact(event.path, event.invoke)); 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); + } finally { + executionContext.popExecutionArtifact(); } } } public void runBeforeLogoutEvents(HttpServletRequest request, HttpServletResponse response) { + ExecutionContext executionContext = (ExecutionContext) request.getAttribute("executionContext"); for (ConfigXMLReader.Event event: getControllerConfig().beforeLogoutEventList.values()) { try { + executionContext.pushExecutionArtifact(new GenericExecutionArtifact(event.path, event.invoke)); 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); + } finally { + executionContext.popExecutionArtifact(); } } } |
Free forum by Nabble | Edit this page |