@Test public void testExecuteWithQueueServiceAction() throws Exception { final ServiceActionContext serviceActionContext = mockery.mock(ServiceActionContext.class); transDef.setReadOnly(false); final List<UserActionRequest> requests = new ArrayList<UserActionRequest>(); requests.add(userActionRequest); final TaskHandlerActionContext<ServiceActionContext> taskHandlerActionContextMock = mockery .mock(TaskHandlerActionContext.class); setupTaskHandlerTransactionContext(false, taskHandlerActionContextMock, false); sut.execute(serviceActionContext, queueSubmitterActionMock); mockery.assertIsSatisfied(); }
public Serializable execute(final PrincipalActionContext inServiceActionContext, final ServiceAction inServiceAction) { if (inServiceAction.getValidationStrategy() == null || inServiceAction.getAuthorizationStrategy() == null || inServiceAction.getExecutionStrategy() == null) { logger.error("Action missing strategies."); throw new InvalidActionException("Action missing strategies."); } Serializable results = null; DefaultTransactionDefinition transDef = new DefaultTransactionDefinition(); transDef.setName(inServiceAction.toString()); transDef.setReadOnly(inServiceAction.isReadOnly()); TransactionStatus transStatus = transMgr.getTransaction(transDef); try { inServiceAction.getValidationStrategy().validate(inServiceActionContext); inServiceAction.getAuthorizationStrategy().authorize(inServiceActionContext); results = inServiceAction.getExecutionStrategy().execute(inServiceActionContext); transMgr.commit(transStatus); } catch (ValidationException vex) { onException(transStatus); logger.warn("Validation failed for the current action.", vex); for (Entry<String, String> currentError : vex.getErrors().entrySet()) { logger.warn("Validation key: " + currentError.getKey() + ", value: " + currentError.getValue()); } throw vex; } catch (AuthorizationException aex) { onException(transStatus); logger.warn("Authorization failed for the current action.", aex); throw aex; } catch (ExecutionException eex) { onException(transStatus); logger.error("Error occurred during execution.", eex); throw eex; } catch (Exception ex) { onException(transStatus); logger.error("Error occurred performing transaction.", ex); throw new GeneralException(ex); } return results; }
ServiceActionController implements ActionController { public Serializable execute(final PrincipalActionContext inServiceActionContext, final ServiceAction inServiceAction) { if (inServiceAction.getValidationStrategy() == null || inServiceAction.getAuthorizationStrategy() == null || inServiceAction.getExecutionStrategy() == null) { logger.error("Action missing strategies."); throw new InvalidActionException("Action missing strategies."); } Serializable results = null; DefaultTransactionDefinition transDef = new DefaultTransactionDefinition(); transDef.setName(inServiceAction.toString()); transDef.setReadOnly(inServiceAction.isReadOnly()); TransactionStatus transStatus = transMgr.getTransaction(transDef); try { inServiceAction.getValidationStrategy().validate(inServiceActionContext); inServiceAction.getAuthorizationStrategy().authorize(inServiceActionContext); results = inServiceAction.getExecutionStrategy().execute(inServiceActionContext); transMgr.commit(transStatus); } catch (ValidationException vex) { onException(transStatus); logger.warn("Validation failed for the current action.", vex); for (Entry<String, String> currentError : vex.getErrors().entrySet()) { logger.warn("Validation key: " + currentError.getKey() + ", value: " + currentError.getValue()); } throw vex; } catch (AuthorizationException aex) { onException(transStatus); logger.warn("Authorization failed for the current action.", aex); throw aex; } catch (ExecutionException eex) { onException(transStatus); logger.error("Error occurred during execution.", eex); throw eex; } catch (Exception ex) { onException(transStatus); logger.error("Error occurred performing transaction.", ex); throw new GeneralException(ex); } return results; } }
ServiceActionController implements ActionController { public Serializable execute(final PrincipalActionContext inServiceActionContext, final ServiceAction inServiceAction) { if (inServiceAction.getValidationStrategy() == null || inServiceAction.getAuthorizationStrategy() == null || inServiceAction.getExecutionStrategy() == null) { logger.error("Action missing strategies."); throw new InvalidActionException("Action missing strategies."); } Serializable results = null; DefaultTransactionDefinition transDef = new DefaultTransactionDefinition(); transDef.setName(inServiceAction.toString()); transDef.setReadOnly(inServiceAction.isReadOnly()); TransactionStatus transStatus = transMgr.getTransaction(transDef); try { inServiceAction.getValidationStrategy().validate(inServiceActionContext); inServiceAction.getAuthorizationStrategy().authorize(inServiceActionContext); results = inServiceAction.getExecutionStrategy().execute(inServiceActionContext); transMgr.commit(transStatus); } catch (ValidationException vex) { onException(transStatus); logger.warn("Validation failed for the current action.", vex); for (Entry<String, String> currentError : vex.getErrors().entrySet()) { logger.warn("Validation key: " + currentError.getKey() + ", value: " + currentError.getValue()); } throw vex; } catch (AuthorizationException aex) { onException(transStatus); logger.warn("Authorization failed for the current action.", aex); throw aex; } catch (ExecutionException eex) { onException(transStatus); logger.error("Error occurred during execution.", eex); throw eex; } catch (Exception ex) { onException(transStatus); logger.error("Error occurred performing transaction.", ex); throw new GeneralException(ex); } return results; } ServiceActionController(final PlatformTransactionManager inTransMgr); }
ServiceActionController implements ActionController { public Serializable execute(final PrincipalActionContext inServiceActionContext, final ServiceAction inServiceAction) { if (inServiceAction.getValidationStrategy() == null || inServiceAction.getAuthorizationStrategy() == null || inServiceAction.getExecutionStrategy() == null) { logger.error("Action missing strategies."); throw new InvalidActionException("Action missing strategies."); } Serializable results = null; DefaultTransactionDefinition transDef = new DefaultTransactionDefinition(); transDef.setName(inServiceAction.toString()); transDef.setReadOnly(inServiceAction.isReadOnly()); TransactionStatus transStatus = transMgr.getTransaction(transDef); try { inServiceAction.getValidationStrategy().validate(inServiceActionContext); inServiceAction.getAuthorizationStrategy().authorize(inServiceActionContext); results = inServiceAction.getExecutionStrategy().execute(inServiceActionContext); transMgr.commit(transStatus); } catch (ValidationException vex) { onException(transStatus); logger.warn("Validation failed for the current action.", vex); for (Entry<String, String> currentError : vex.getErrors().entrySet()) { logger.warn("Validation key: " + currentError.getKey() + ", value: " + currentError.getValue()); } throw vex; } catch (AuthorizationException aex) { onException(transStatus); logger.warn("Authorization failed for the current action.", aex); throw aex; } catch (ExecutionException eex) { onException(transStatus); logger.error("Error occurred during execution.", eex); throw eex; } catch (Exception ex) { onException(transStatus); logger.error("Error occurred performing transaction.", ex); throw new GeneralException(ex); } return results; } ServiceActionController(final PlatformTransactionManager inTransMgr); Serializable execute(final PrincipalActionContext inServiceActionContext,
            final ServiceAction inServiceAction); Serializable execute(final PrincipalActionContext inServiceActionContext,
            final TaskHandlerAction inTaskHandlerAction); }
ServiceActionController implements ActionController { public Serializable execute(final PrincipalActionContext inServiceActionContext, final ServiceAction inServiceAction) { if (inServiceAction.getValidationStrategy() == null || inServiceAction.getAuthorizationStrategy() == null || inServiceAction.getExecutionStrategy() == null) { logger.error("Action missing strategies."); throw new InvalidActionException("Action missing strategies."); } Serializable results = null; DefaultTransactionDefinition transDef = new DefaultTransactionDefinition(); transDef.setName(inServiceAction.toString()); transDef.setReadOnly(inServiceAction.isReadOnly()); TransactionStatus transStatus = transMgr.getTransaction(transDef); try { inServiceAction.getValidationStrategy().validate(inServiceActionContext); inServiceAction.getAuthorizationStrategy().authorize(inServiceActionContext); results = inServiceAction.getExecutionStrategy().execute(inServiceActionContext); transMgr.commit(transStatus); } catch (ValidationException vex) { onException(transStatus); logger.warn("Validation failed for the current action.", vex); for (Entry<String, String> currentError : vex.getErrors().entrySet()) { logger.warn("Validation key: " + currentError.getKey() + ", value: " + currentError.getValue()); } throw vex; } catch (AuthorizationException aex) { onException(transStatus); logger.warn("Authorization failed for the current action.", aex); throw aex; } catch (ExecutionException eex) { onException(transStatus); logger.error("Error occurred during execution.", eex); throw eex; } catch (Exception ex) { onException(transStatus); logger.error("Error occurred performing transaction.", ex); throw new GeneralException(ex); } return results; } ServiceActionController(final PlatformTransactionManager inTransMgr); Serializable execute(final PrincipalActionContext inServiceActionContext,
            final ServiceAction inServiceAction); Serializable execute(final PrincipalActionContext inServiceActionContext,
            final TaskHandlerAction inTaskHandlerAction);  }