private static Group getOriginalWorkflowRole( String roleName, Collection collection, Group roleGroup) throws SQLException, AuthorizeException { if (ROLE_WF_STEP1.equals(roleName)) { roleGroup = collection.getWorkflowGroup(1); if (roleGroup == null) roleGroup = collection.createWorkflowGroup(1); } else if (ROLE_WF_STEP2.equals(roleName)) { roleGroup = collection.getWorkflowGroup(2); if (roleGroup == null) roleGroup = collection.createWorkflowGroup(2); } else if (ROLE_WF_STEP3.equals(roleName)) { roleGroup = collection.getWorkflowGroup(3); if (roleGroup == null) roleGroup = collection.createWorkflowGroup(3); } return roleGroup; }
// returns true if archived private static boolean doState(Context c, WorkflowItem wi, int newstate, EPerson newowner) throws SQLException, IOException, AuthorizeException { Collection mycollection = wi.getCollection(); Group mygroup = null; boolean archived = false; wi.setState(newstate); switch (newstate) { case WFSTATE_STEP1POOL: // any reviewers? // if so, add them to the tasklist wi.setOwner(null); // get reviewers (group 1 ) mygroup = mycollection.getWorkflowGroup(1); if ((mygroup != null) && !(mygroup.isEmpty())) { // get a list of all epeople in group (or any subgroups) EPerson[] epa = Group.allMembers(c, mygroup); // there were reviewers, change the state // and add them to the list createTasks(c, wi, epa); wi.update(); // email notification notifyGroupOfTask(c, wi, mygroup, epa); } else { // no reviewers, skip ahead archived = doState(c, wi, WFSTATE_STEP2POOL, null); } break; case WFSTATE_STEP1: // remove reviewers from tasklist // assign owner deleteTasks(c, wi); wi.setOwner(newowner); break; case WFSTATE_STEP2POOL: // clear owner // any approvers? // if so, add them to tasklist // if not, skip to next state wi.setOwner(null); // get approvers (group 2) mygroup = mycollection.getWorkflowGroup(2); if ((mygroup != null) && !(mygroup.isEmpty())) { // get a list of all epeople in group (or any subgroups) EPerson[] epa = Group.allMembers(c, mygroup); // there were approvers, change the state // timestamp, and add them to the list createTasks(c, wi, epa); // email notification notifyGroupOfTask(c, wi, mygroup, epa); } else { // no reviewers, skip ahead archived = doState(c, wi, WFSTATE_STEP3POOL, null); } break; case WFSTATE_STEP2: // remove admins from tasklist // assign owner deleteTasks(c, wi); wi.setOwner(newowner); break; case WFSTATE_STEP3POOL: // any editors? // if so, add them to tasklist wi.setOwner(null); mygroup = mycollection.getWorkflowGroup(3); if ((mygroup != null) && !(mygroup.isEmpty())) { // get a list of all epeople in group (or any subgroups) EPerson[] epa = Group.allMembers(c, mygroup); // there were editors, change the state // timestamp, and add them to the list createTasks(c, wi, epa); // email notification notifyGroupOfTask(c, wi, mygroup, epa); } else { // no editors, skip ahead archived = doState(c, wi, WFSTATE_ARCHIVE, newowner); } break; case WFSTATE_STEP3: // remove editors from tasklist // assign owner deleteTasks(c, wi); wi.setOwner(newowner); break; case WFSTATE_ARCHIVE: // put in archive in one transaction try { // remove workflow tasks deleteTasks(c, wi); mycollection = wi.getCollection(); Item myitem = archive(c, wi); // now email notification notifyOfArchive(c, myitem, mycollection); archived = true; } catch (IOException e) { // indexer causes this throw e; } catch (SQLException e) { // problem starting workflow throw e; } break; } if ((wi != null) && !archived) { wi.update(); } return archived; }