DSIndexer.indexItem(c, myitem);
    private static void doState(Context c,WorkflowItem wi, int newstate, EPerson newowner)        throws SQLException, IOException, AuthorizeException    {        Collection mycollection = wi.getCollection();        Group mygroup = null;                wi.setState(newstate);        //		wi.update();        switch (newstate)        {        case WFSTATE_REVIEWPOOL:            // any reviewers?            // if so, add them to the tasklist            wi.setOwner( null );            //wi.update();            // get reviewers (group 1 )            mygroup = mycollection.getWorkflowGroup( 1 );            if (mygroup != null )            {                // there were reviewers, change the state                //  and add them to the list                createTasks(c, wi, mygroup);                wi.update();                // email notification                notifyGroupOfTask(c, mygroup, wi);            }            else            {                // no reviewers, skip ahead                doState(c, wi, WFSTATE_ADMINPOOL, null);            }            break;        case WFSTATE_REVIEW:            // remove reviewers from tasklist            // assign owner            deleteTasks(c, wi);            wi.setOwner(newowner);            //wi.update();            break;        case WFSTATE_ADMINPOOL:            // clear owner            // any approvers?            // if so, add them to tasklist            // if not, skip to next state            wi.setOwner( null );            //wi.update();            // get approvers (group 2)            mygroup = mycollection.getWorkflowGroup( 2 );            if( mygroup != null )            {                // there were approvers, change the state                //  timestamp, and add them to the list                createTasks(c, wi, mygroup );                //wi.update();                // email notification                notifyGroupOfTask(c, mygroup, wi);            }            else            {                // no reviewers, skip ahead                doState(c, wi, WFSTATE_EDITPOOL, null);            }            break;        case WFSTATE_ADMIN:            // remove admins from tasklist            // assign owner            deleteTasks(c, wi);            wi.setOwner(newowner);            //wi.update();            break;        case WFSTATE_EDITPOOL:            // any editors?            // if so, add them to tasklist            wi.setOwner( null );            //wi.update();            mygroup = mycollection.getWorkflowGroup( 3 );                        if( mygroup != null )            {                // there were editors, change the state                //  timestamp, and add them to the list                createTasks(c, wi, mygroup);                //wi.update();                // email notification                notifyGroupOfTask(c, mygroup, wi);            }            else            {                // no editors, skip ahead                doState(c, wi, WFSTATE_ARCHIVE, newowner);            }            break;        case WFSTATE_EDIT:            // remove editors from tasklist            // assign owner            deleteTasks(c, wi);            wi.setOwner(newowner);            //wi.update();            break;        case WFSTATE_ARCHIVE:            // put in archive in one transaction//            int itemid = wi.getItemId();//            Collection col =//                wi.getCollectionFromCollectionId();            try            {                // notify that it's been archived                //notifyOfArchive( wi );                // remove workflow tasks                deleteTasks(c, wi);                                mycollection = wi.getCollection();                Item myitem = archive(c, wi);                // now email notification                notifyOfArchive(c, myitem, mycollection);                // index the item                DSIndexer.indexItem(c, myitem);//                SubmitServlet.installItem(connection, wi);                // delete workflow - done in installItem                //					wi.delete( connection );//                wi = null;            }            catch(IOException e)            {                // indexer causes this                throw e;            }            catch (SQLException e)            {                // problem starting workflow - roll back//                connection.rollback();                throw e;            }            break;        }        if (wi != null) wi.update();    }