@Override
 public Group getWorkflowRoleGroup(
     Context context, Collection collection, String roleName, Group roleGroup)
     throws SQLException, IOException, WorkflowException, AuthorizeException {
   try {
     Role role = WorkflowUtils.getCollectionAndRepositoryRoles(collection).get(roleName);
     if (role.getScope() == Role.Scope.COLLECTION || role.getScope() == Role.Scope.REPOSITORY) {
       roleGroup = WorkflowUtils.getRoleGroup(context, collection, role);
       if (roleGroup == null) {
         authorizeService.authorizeAction(context, collection, Constants.WRITE);
         roleGroup = groupService.create(context);
         if (role.getScope() == Role.Scope.COLLECTION) {
           groupService.setName(
               roleGroup,
               "COLLECTION_" + collection.getID().toString() + "_WORKFLOW_ROLE_" + roleName);
         } else {
           groupService.setName(roleGroup, role.getName());
         }
         groupService.update(context, roleGroup);
         authorizeService.addPolicy(context, collection, Constants.ADD, roleGroup);
         if (role.getScope() == Role.Scope.COLLECTION) {
           WorkflowUtils.createCollectionWorkflowRole(context, collection, roleName, roleGroup);
         }
       }
     }
     return roleGroup;
   } catch (WorkflowConfigurationException e) {
     throw new WorkflowException(e);
   }
 }
 /*
  * Executes an action and returns the next.
  */
 @Override
 public WorkflowActionConfig doState(
     Context c,
     EPerson user,
     HttpServletRequest request,
     int workflowItemId,
     Workflow workflow,
     WorkflowActionConfig currentActionConfig)
     throws SQLException, AuthorizeException, IOException, MessagingException, WorkflowException {
   try {
     XmlWorkflowItem wi = xmlWorkflowItemService.find(c, workflowItemId);
     Step currentStep = currentActionConfig.getStep();
     if (currentActionConfig.getProcessingAction().isAuthorized(c, request, wi)) {
       ActionResult outcome =
           currentActionConfig.getProcessingAction().execute(c, wi, currentStep, request);
       return processOutcome(
           c, user, workflow, currentStep, currentActionConfig, outcome, wi, false);
     } else {
       throw new AuthorizeException("You are not allowed to to perform this task.");
     }
   } catch (WorkflowConfigurationException e) {
     log.error(
         LogManager.getHeader(
             c,
             "error while executing state",
             "workflow:  "
                 + workflow.getID()
                 + " action: "
                 + currentActionConfig.getId()
                 + " workflowItemId: "
                 + workflowItemId),
         e);
     WorkflowUtils.sendAlert(request, e);
     throw new WorkflowException(e);
   }
 }