After you know how to get pages from a specific workflow state you get here the information what you can do with them.
CmsClient client = new CmsClient(logonGuid);
Project project = client.getProject(sessionKey, projectGuid);
Page currentPg = project.getPageById(“34009”);
currentPg.reject(“note name”, “reject comment”);
The first method submitToWorkflow() can be used from an author’s perspective to confirm his changes in Tasks. It will throw a WrongStateException, if the page is not in draft state.
The last both methods are useful from a checkers perspective to return an incorrect page to the author for rework or release the changes. These methods checks for the page state too and will throw a WrongStateException too.
Before triggering one of these methods you should check the page state if you want to prevent throwing this exception.
Because I often had the need to clear the authors list of draft pages completely, because they did not want it anymore, I implemented the method resetDraftState() at Page which works as follows:
- if the page was created (isInStateSavedAsDraftNew() == true, it will be deleted with delete()
- if the page was upated (isInStateSavedAsDraftChanged() == true, the change will be skipped with undoChanges()
All you have to do is to call resetDraftState() on all pages you want get out of your Tasks list of draft pages. You can find more details on the determine page state article.