@Override
  public void addInitialWorkspaceItemPolicies(Context context, WorkspaceItem workspaceItem)
      throws SQLException, AuthorizeException {
    // Now create the policies for the submitter and workflow
    // users to modify item and contents
    // contents = bitstreams, bundles
    // FIXME: icky hardcoded workflow steps
    Collection collection = workspaceItem.getCollection();
    Group step1group = collectionService.getWorkflowGroup(collection, 1);
    Group step2group = collectionService.getWorkflowGroup(collection, 2);
    Group step3group = collectionService.getWorkflowGroup(collection, 3);

    Item item = workspaceItem.getItem();

    if (step1group != null) {
      authorizeService.addPolicy(
          context, item, Constants.READ, step1group, ResourcePolicy.TYPE_WORKFLOW);
    }

    if (step2group != null) {
      authorizeService.addPolicy(
          context, item, Constants.READ, step2group, ResourcePolicy.TYPE_WORKFLOW);
    }

    if (step3group != null) {
      authorizeService.addPolicy(
          context, item, Constants.READ, step3group, ResourcePolicy.TYPE_WORKFLOW);
    }

    if (step1group != null) {
      authorizeService.addPolicy(
          context, item, Constants.WRITE, step1group, ResourcePolicy.TYPE_WORKFLOW);
    }

    if (step2group != null) {
      authorizeService.addPolicy(
          context, item, Constants.WRITE, step2group, ResourcePolicy.TYPE_WORKFLOW);
    }

    if (step3group != null) {
      authorizeService.addPolicy(
          context, item, Constants.WRITE, step3group, ResourcePolicy.TYPE_WORKFLOW);
    }

    if (step1group != null) {
      authorizeService.addPolicy(
          context, item, Constants.ADD, step1group, ResourcePolicy.TYPE_WORKFLOW);
    }

    if (step2group != null) {
      authorizeService.addPolicy(
          context, item, Constants.ADD, step2group, ResourcePolicy.TYPE_WORKFLOW);
    }

    if (step3group != null) {
      authorizeService.addPolicy(
          context, item, Constants.ADD, step3group, ResourcePolicy.TYPE_WORKFLOW);
    }

    if (step1group != null) {
      authorizeService.addPolicy(
          context, item, Constants.REMOVE, step1group, ResourcePolicy.TYPE_WORKFLOW);
    }

    if (step2group != null) {
      authorizeService.addPolicy(
          context, item, Constants.REMOVE, step2group, ResourcePolicy.TYPE_WORKFLOW);
    }

    if (step3group != null) {
      authorizeService.addPolicy(
          context, item, Constants.REMOVE, step3group, ResourcePolicy.TYPE_WORKFLOW);
    }
  }
  // returns true if archived
  protected boolean doState(
      Context context, BasicWorkflowItem workflowItem, int newstate, EPerson newowner)
      throws SQLException, IOException, AuthorizeException {
    Collection mycollection = workflowItem.getCollection();
    Group mygroup = null;
    boolean archived = false;

    // Gather our old data for launching the workflow event
    int oldState = workflowItem.getState();

    workflowItem.setState(newstate);

    switch (newstate) {
      case WFSTATE_STEP1POOL:

        // any reviewers?
        // if so, add them to the tasklist
        workflowItem.setOwner(null);

        // get reviewers (group 1 )
        mygroup = collectionService.getWorkflowGroup(mycollection, 1);

        if ((mygroup != null) && !(groupService.isEmpty(mygroup))) {
          // get a list of all epeople in group (or any subgroups)
          List<EPerson> epa = groupService.allMembers(context, mygroup);

          // there were reviewers, change the state
          //  and add them to the list
          createTasks(context, workflowItem, epa);
          workflowItemService.update(context, workflowItem);

          // email notification
          notifyGroupOfTask(context, workflowItem, mygroup, epa);
        } else {
          // no reviewers, skip ahead
          workflowItem.setState(WFSTATE_STEP1);
          archived = advance(context, workflowItem, null, true, false);
        }

        break;

      case WFSTATE_STEP1:

        // remove reviewers from tasklist
        // assign owner
        taskListItemService.deleteByWorkflowItem(context, workflowItem);
        workflowItem.setOwner(newowner);

        break;

      case WFSTATE_STEP2POOL:

        // clear owner
        // any approvers?
        // if so, add them to tasklist
        // if not, skip to next state
        workflowItem.setOwner(null);

        // get approvers (group 2)
        mygroup = collectionService.getWorkflowGroup(mycollection, 2);

        if ((mygroup != null) && !(groupService.isEmpty(mygroup))) {
          // get a list of all epeople in group (or any subgroups)
          List<EPerson> epa = groupService.allMembers(context, mygroup);

          // there were approvers, change the state
          //  timestamp, and add them to the list
          createTasks(context, workflowItem, epa);

          // email notification
          notifyGroupOfTask(context, workflowItem, mygroup, epa);
        } else {
          // no reviewers, skip ahead
          workflowItem.setState(WFSTATE_STEP2);
          archived = advance(context, workflowItem, null, true, false);
        }

        break;

      case WFSTATE_STEP2:

        // remove admins from tasklist
        // assign owner
        taskListItemService.deleteByWorkflowItem(context, workflowItem);
        workflowItem.setOwner(newowner);

        break;

      case WFSTATE_STEP3POOL:

        // any editors?
        // if so, add them to tasklist
        workflowItem.setOwner(null);
        mygroup = collectionService.getWorkflowGroup(mycollection, 3);

        if ((mygroup != null) && !(groupService.isEmpty(mygroup))) {
          // get a list of all epeople in group (or any subgroups)
          List<EPerson> epa = groupService.allMembers(context, mygroup);

          // there were editors, change the state
          //  timestamp, and add them to the list
          createTasks(context, workflowItem, epa);

          // email notification
          notifyGroupOfTask(context, workflowItem, mygroup, epa);
        } else {
          // no editors, skip ahead
          workflowItem.setState(WFSTATE_STEP3);
          archived = advance(context, workflowItem, null, true, false);
        }

        break;

      case WFSTATE_STEP3:

        // remove editors from tasklist
        // assign owner
        taskListItemService.deleteByWorkflowItem(context, workflowItem);
        workflowItem.setOwner(newowner);

        break;

      case WFSTATE_ARCHIVE:

        // put in archive in one transaction
        // remove workflow tasks
        taskListItemService.deleteByWorkflowItem(context, workflowItem);

        mycollection = workflowItem.getCollection();

        Item myitem = archive(context, workflowItem);

        // now email notification
        notifyOfArchive(context, myitem, mycollection);
        archived = true;

        break;
    }

    logWorkflowEvent(
        context,
        workflowItem.getItem(),
        workflowItem,
        context.getCurrentUser(),
        newstate,
        newowner,
        mycollection,
        oldState,
        mygroup);

    if (!archived) {
      workflowItemService.update(context, workflowItem);
    }

    return archived;
  }