Package org.dspace.workflowbasic
Class BasicWorkflowServiceImpl
- java.lang.Object
-
- org.dspace.workflowbasic.BasicWorkflowServiceImpl
-
- All Implemented Interfaces:
WorkflowService<BasicWorkflowItem>,BasicWorkflowService
public class BasicWorkflowServiceImpl extends Object implements BasicWorkflowService
-
-
Field Summary
Fields Modifier and Type Field Description protected AuthorizeServiceauthorizeServiceprotected CollectionServicecollectionServiceprotected ConfigurationServiceconfigurationServiceprotected GroupServicegroupServiceprotected HandleServicehandleServiceprotected InstallItemServiceinstallItemServiceprotected ItemServiceitemServiceprotected Map<UUID,Boolean>noEMailprotected TaskListItemServicetaskListItemServiceprotected WorkflowCuratorServiceworkflowCuratorServiceprotected BasicWorkflowItemServiceworkflowItemServiceprotected String[]workflowTextSymbolic names of workflow steps.protected WorkspaceItemServiceworkspaceItemService-
Fields inherited from interface org.dspace.workflowbasic.service.BasicWorkflowService
WFSTATE_ARCHIVE, WFSTATE_STEP1, WFSTATE_STEP1POOL, WFSTATE_STEP2, WFSTATE_STEP2POOL, WFSTATE_STEP3, WFSTATE_STEP3POOL, WFSTATE_SUBMIT
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedBasicWorkflowServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WorkspaceItemabort(Context context, BasicWorkflowItem workflowItem, EPerson e)abort() aborts a workflow, completely deleting it (administrator do this) (it will basically do a reject from any state - the item ends up back in the user's PersonalWorkspacevoidadvance(Context context, BasicWorkflowItem workflowItem, EPerson e)advance() sends an item forward in the workflow (reviewers, approvers, and editors all do an 'approve' to move the item forward) if the item arrives at the submit state, then remove the WorkflowItem and call the archive() method to put it in the archive, and email notify the submitter of a successful submissionbooleanadvance(Context context, BasicWorkflowItem workflowItem, EPerson e, boolean curate, boolean record)advance() sends an item forward in the workflow (reviewers, approvers, and editors all do an 'approve' to move the item forward) if the item arrives at the submit state, then remove the WorkflowItem and call the archive() method to put it in the archive, and email notify the submitter of a successful submissionprotected Itemarchive(Context context, BasicWorkflowItem workflowItem)Commit the contained item to the main archive.protected voidassignToReviewer(Context context, BasicWorkflowItem workflowItem, int step, EPerson newowner)Helper method to take an item out of the pool, to assign it to a reviewer and to deal with reviewer policies.voidclaim(Context context, BasicWorkflowItem workflowItem, EPerson e)claim() claims a workflow task for an EPersonprotected voidcreateTasks(Context c, BasicWorkflowItem wi, List<EPerson> epa)GroupcreateWorkflowRoleGroup(Context context, Collection collection, String roleName)This method will create the workflowRoleGroup for a collection and the given rolenamevoiddeleteCollection(Context context, Collection collection)protected booleandoState(Context context, BasicWorkflowItem workflowItem, int newstate, EPerson newowner)List<String>getEPersonDeleteConstraints(Context context, EPerson ePerson)protected StringgetEPersonName(EPerson e)List<String>getFlywayMigrationLocations()StringgetItemTitle(BasicWorkflowItem wi)get the title of the item in this workflowStringgetMyDSpaceLink()List<BasicWorkflowItem>getOwnedTasks(Context context, EPerson e)getOwnedTasks() returns a List of WorkflowItems containing the tasks claimed and owned by an EPerson.List<BasicWorkflowItem>getPooledTasks(Context context, EPerson e)getPooledTasks() returns a List of WorkflowItems an EPerson could claim (as a reviewer, etc.) for display on a user's MyDSpace page.StringgetSubmitterName(BasicWorkflowItem wi)get the name of the eperson who started this workflowintgetWorkflowID(String state)Translate symbolic name of workflow state into number.GroupgetWorkflowRoleGroup(Context context, Collection collection, String roleName, Group roleGroup)StringgetWorkflowText(int state)Get the text representing the given workflow stateprotected voidgrantReviewerPolicies(Context context, BasicWorkflowItem wfi, EPerson reviewer)This methods grants the appropriate permissions to reviewers so that they can read and edit metadata and read files and edit files if allowed by configuration.protected voidlogWorkflowEvent(Context context, Item item, BasicWorkflowItem workflowItem, EPerson actor, int newstate, EPerson newOwner, Collection mycollection, int oldState, Group newOwnerGroup)protected voidnotifyGroupOfTask(Context c, BasicWorkflowItem wi, Group mygroup, List<EPerson> epa)protected voidnotifyOfArchive(Context context, Item item, Collection coll)notify the submitter that the item is archivedvoidnotifyOfCuration(Context c, BasicWorkflowItem wi, List<EPerson> ePeople, String taskName, String action, String message)protected voidnotifyOfReject(Context context, BasicWorkflowItem workflowItem, EPerson e, String reason)protected booleanpool(Context context, BasicWorkflowItem workflowItem, int step)Helper method that manages state, policies, owner, notifies, tasklistitems and so on whenever an WorkflowItem should be added to a workflow step pool.protected voidrecordApproval(Context context, BasicWorkflowItem workflowItem, EPerson e)protected voidrecordStart(Context context, Item myitem)protected WorkspaceItemreturnToWorkspace(Context c, BasicWorkflowItem wfi)Return the workflow item to the workspace of the submitter.protected voidrevokeReviewerPolicies(Context context, Item item)This methods revokes any permission granted by the basic workflow systems on the item specified as attribute.WorkspaceItemsendWorkflowItemBackSubmission(Context context, BasicWorkflowItem workflowItem, EPerson ePerson, String provenancePrefix, String rejection_message)BasicWorkflowItemstart(Context context, WorkspaceItem wsi)startWorkflow() begins a workflow - in a single transaction do away with the PersonalWorkspace entry and turn it into a WorkflowItem.BasicWorkflowItemstartWithoutNotify(Context c, WorkspaceItem wsi)startWithoutNotify() starts the workflow normally, but disables notifications (useful for large imports,) for the first workflow step - subsequent notifications happen normallyvoidunclaim(Context context, BasicWorkflowItem workflowItem, EPerson e)unclaim() returns an owned task/item to the pool
-
-
-
Field Detail
-
authorizeService
@Autowired(required=true) protected AuthorizeService authorizeService
-
collectionService
@Autowired(required=true) protected CollectionService collectionService
-
groupService
@Autowired(required=true) protected GroupService groupService
-
handleService
@Autowired(required=true) protected HandleService handleService
-
installItemService
@Autowired(required=true) protected InstallItemService installItemService
-
itemService
@Autowired(required=true) protected ItemService itemService
-
taskListItemService
@Autowired(required=true) protected TaskListItemService taskListItemService
-
workflowCuratorService
@Autowired(required=true) protected WorkflowCuratorService workflowCuratorService
-
workflowItemService
@Autowired(required=true) protected BasicWorkflowItemService workflowItemService
-
workspaceItemService
@Autowired(required=true) protected WorkspaceItemService workspaceItemService
-
configurationService
@Autowired(required=true) protected ConfigurationService configurationService
-
workflowText
protected final String[] workflowText
Symbolic names of workflow steps.
-
-
Method Detail
-
getWorkflowID
public int getWorkflowID(String state)
Description copied from interface:BasicWorkflowServiceTranslate symbolic name of workflow state into number. The name is case-insensitive. Returns -1 when name cannot be matched.- Specified by:
getWorkflowIDin interfaceBasicWorkflowService- Parameters:
state- symbolic name of workflow state, must be one of the elements of workflowText array.- Returns:
- numeric workflow state or -1 for error.
-
grantReviewerPolicies
protected void grantReviewerPolicies(Context context, BasicWorkflowItem wfi, EPerson reviewer) throws SQLException, AuthorizeException
This methods grants the appropriate permissions to reviewers so that they can read and edit metadata and read files and edit files if allowed by configuration. In most cases this method must be called within a try-finally-block that temporary disables the authentication system. This is not done by this method as it should be done carefully and only in contexts in which granting the permissions is authorized by some previous checks.- Parameters:
context-wfi- While all policies are granted on item, bundle or bitstream level, this method takes an workflowitem for convenience and uses wfi.getItem() to get the actual item.reviewer- EPerson to grant the rights to.- Throws:
SQLExceptionAuthorizeException
-
revokeReviewerPolicies
protected void revokeReviewerPolicies(Context context, Item item) throws SQLException, AuthorizeException
This methods revokes any permission granted by the basic workflow systems on the item specified as attribute. At time of writing this method these permissions will all be granted bygrantReviewerPolicies(org.dspace.core.Context, org.dspace.workflowbasic.BasicWorkflowItem, org.dspace.eperson.EPerson). In most cases this method must be called within a try-finally-block that temporary disables the authentication system. This is not done by this method as it should be done carefully and only in contexts in which revoking the permissions is authorized by some previous checks.- Parameters:
context-item-- Throws:
SQLExceptionAuthorizeException
-
start
public BasicWorkflowItem start(Context context, WorkspaceItem wsi) throws SQLException, AuthorizeException, IOException
Description copied from interface:WorkflowServicestartWorkflow() begins a workflow - in a single transaction do away with the PersonalWorkspace entry and turn it into a WorkflowItem.- Specified by:
startin interfaceWorkflowService<BasicWorkflowItem>- Parameters:
context- The relevant DSpace Context.wsi- The WorkspaceItem to convert to a workflow item- Returns:
- The resulting workflow item
- Throws:
SQLException- An exception that provides information on a database access error or other errors.AuthorizeException- Exception indicating the current user of the context does not have permission to perform a particular action.IOException- A general class of exceptions produced by failed or interrupted I/O operations.
-
startWithoutNotify
public BasicWorkflowItem startWithoutNotify(Context c, WorkspaceItem wsi) throws SQLException, AuthorizeException, IOException
Description copied from interface:WorkflowServicestartWithoutNotify() starts the workflow normally, but disables notifications (useful for large imports,) for the first workflow step - subsequent notifications happen normally- Specified by:
startWithoutNotifyin interfaceWorkflowService<BasicWorkflowItem>- Parameters:
c- The relevant DSpace Context.wsi- workspace item- Returns:
- the resulting workflow item.
- Throws:
SQLException- An exception that provides information on a database access error or other errors.AuthorizeException- Exception indicating the current user of the context does not have permission to perform a particular action.IOException- A general class of exceptions produced by failed or interrupted I/O operations.
-
getOwnedTasks
public List<BasicWorkflowItem> getOwnedTasks(Context context, EPerson e) throws SQLException
Description copied from interface:BasicWorkflowServicegetOwnedTasks() returns a List of WorkflowItems containing the tasks claimed and owned by an EPerson. The GUI displays this info on the MyDSpace page.- Specified by:
getOwnedTasksin interfaceBasicWorkflowService- Parameters:
context- The relevant DSpace Context.e- The EPerson we want to fetch owned tasks for.- Returns:
- list of basic workflow items
- Throws:
SQLException- An exception that provides information on a database access error or other errors.
-
getPooledTasks
public List<BasicWorkflowItem> getPooledTasks(Context context, EPerson e) throws SQLException
Description copied from interface:BasicWorkflowServicegetPooledTasks() returns a List of WorkflowItems an EPerson could claim (as a reviewer, etc.) for display on a user's MyDSpace page.- Specified by:
getPooledTasksin interfaceBasicWorkflowService- Parameters:
context- The relevant DSpace Context.e- The Eperson we want to fetch the pooled tasks for.- Returns:
- list of basic workflow items
- Throws:
SQLException- An exception that provides information on a database access error or other errors.
-
claim
public void claim(Context context, BasicWorkflowItem workflowItem, EPerson e) throws SQLException, IOException, AuthorizeException
Description copied from interface:BasicWorkflowServiceclaim() claims a workflow task for an EPerson- Specified by:
claimin interfaceBasicWorkflowService- Parameters:
context- The relevant DSpace Context.workflowItem- WorkflowItem to do the claim one- The EPerson doing the claim- Throws:
SQLException- An exception that provides information on a database access error or other errors.IOException- A general class of exceptions produced by failed or interrupted I/O operations.AuthorizeException- Exception indicating the current user of the context does not have permission to perform a particular action.
-
advance
public void advance(Context context, BasicWorkflowItem workflowItem, EPerson e) throws SQLException, IOException, AuthorizeException
Description copied from interface:BasicWorkflowServiceadvance() sends an item forward in the workflow (reviewers, approvers, and editors all do an 'approve' to move the item forward) if the item arrives at the submit state, then remove the WorkflowItem and call the archive() method to put it in the archive, and email notify the submitter of a successful submission- Specified by:
advancein interfaceBasicWorkflowService- Parameters:
context- The relevant DSpace Context.workflowItem- WorkflowItem do do the approval one- EPerson doing the approval- Throws:
SQLException- An exception that provides information on a database access error or other errors.IOException- A general class of exceptions produced by failed or interrupted I/O operations.AuthorizeException- Exception indicating the current user of the context does not have permission to perform a particular action.
-
advance
public boolean advance(Context context, BasicWorkflowItem workflowItem, EPerson e, boolean curate, boolean record) throws SQLException, IOException, AuthorizeException
Description copied from interface:BasicWorkflowServiceadvance() sends an item forward in the workflow (reviewers, approvers, and editors all do an 'approve' to move the item forward) if the item arrives at the submit state, then remove the WorkflowItem and call the archive() method to put it in the archive, and email notify the submitter of a successful submission- Specified by:
advancein interfaceBasicWorkflowService- Parameters:
context- The relevant DSpace Context.workflowItem- WorkflowItem do do the approval one- EPerson doing the approvalcurate- boolean indicating whether curation tasks should be donerecord- boolean indicating whether to record action- Returns:
- true if the item was successfully archived
- Throws:
SQLException- An exception that provides information on a database access error or other errors.IOException- A general class of exceptions produced by failed or interrupted I/O operations.AuthorizeException- Exception indicating the current user of the context does not have permission to perform a particular action.
-
unclaim
public void unclaim(Context context, BasicWorkflowItem workflowItem, EPerson e) throws SQLException, IOException, AuthorizeException
Description copied from interface:BasicWorkflowServiceunclaim() returns an owned task/item to the pool- Specified by:
unclaimin interfaceBasicWorkflowService- Parameters:
context- ContextworkflowItem- WorkflowItem to operate one- EPerson doing the operation- Throws:
SQLException- An exception that provides information on a database access error or other errors.IOException- A general class of exceptions produced by failed or interrupted I/O operations.AuthorizeException- Exception indicating the current user of the context does not have permission to perform a particular action.
-
abort
public WorkspaceItem abort(Context context, BasicWorkflowItem workflowItem, EPerson e) throws SQLException, AuthorizeException, IOException
Description copied from interface:WorkflowServiceabort() aborts a workflow, completely deleting it (administrator do this) (it will basically do a reject from any state - the item ends up back in the user's PersonalWorkspace- Specified by:
abortin interfaceWorkflowService<BasicWorkflowItem>- Parameters:
context- The relevant DSpace Context.workflowItem- WorkflowItem to operate one- EPerson doing the operation- Returns:
- workspace item returned to workspace
- Throws:
SQLException- An exception that provides information on a database access error or other errors.AuthorizeException- Exception indicating the current user of the context does not have permission to perform a particular action.IOException- A general class of exceptions produced by failed or interrupted I/O operations.
-
doState
protected boolean doState(Context context, BasicWorkflowItem workflowItem, int newstate, EPerson newowner) throws SQLException, IOException, AuthorizeException
-
assignToReviewer
protected void assignToReviewer(Context context, BasicWorkflowItem workflowItem, int step, EPerson newowner) throws AuthorizeException, SQLException
Helper method to take an item out of the pool, to assign it to a reviewer and to deal with reviewer policies. Don't use this method directly. Instead: usestart(Context, WorkspaceItem)to start a workflow andclaim(Context, BasicWorkflowItem, EPerson)as those methods handles the internal states and checks for the appropriate permissions.- Parameters:
context- DSpace context objectworkflowItem- The item that shall be pooled.step- The step (1-3) of the pool the item should be put to.newowner- The EPerson that should do the review.- Throws:
SQLExceptionAuthorizeExceptionIOExceptionIllegalArgumentException- Ifparamhas another value than either 1, 2, or 3.
-
pool
protected boolean pool(Context context, BasicWorkflowItem workflowItem, int step) throws SQLException, AuthorizeException, IOException
Helper method that manages state, policies, owner, notifies, tasklistitems and so on whenever an WorkflowItem should be added to a workflow step pool. Don't use this method directly. Either useunclaim(Context, BasicWorkflowItem, EPerson)if the item is claimed,start(Context, WorkspaceItem)to start the workflow oradvance(Context, BasicWorkflowItem, EPerson)to move an item to the next state.- Parameters:
context- DSpace context objectworkflowItem- The item that shall be pooled.step- The step (1-3) of the pool the item should be put to.- Returns:
- True if the item was archived because no reviewers were assigned to any of the following workflow steps, false otherwise.
- Throws:
SQLExceptionAuthorizeExceptionIOExceptionIllegalArgumentException- Ifparamhas another value than either 1, 2, or 3.
-
logWorkflowEvent
protected void logWorkflowEvent(Context context, Item item, BasicWorkflowItem workflowItem, EPerson actor, int newstate, EPerson newOwner, Collection mycollection, int oldState, Group newOwnerGroup)
-
getWorkflowText
public String getWorkflowText(int state)
Description copied from interface:BasicWorkflowServiceGet the text representing the given workflow state- Specified by:
getWorkflowTextin interfaceBasicWorkflowService- Parameters:
state- the workflow state- Returns:
- the text representation
-
archive
protected Item archive(Context context, BasicWorkflowItem workflowItem) throws SQLException, IOException, AuthorizeException
Commit the contained item to the main archive. The item is associated with the relevant collection, added to the search index, and any other tasks such as assigning dates are performed.- Parameters:
context- The relevant DSpace Context.workflowItem- which workflow item to archive- Returns:
- the fully archived item.
- Throws:
IOException- A general class of exceptions produced by failed or interrupted I/O operations.SQLException- An exception that provides information on a database access error or other errors.AuthorizeException- Exception indicating the current user of the context does not have permission to perform a particular action.
-
notifyOfArchive
protected void notifyOfArchive(Context context, Item item, Collection coll) throws SQLException, IOException
notify the submitter that the item is archived- Parameters:
context- The relevant DSpace Context.item- which item was archivedcoll- collection name to display in template- Throws:
SQLException- An exception that provides information on a database access error or other errors.IOException- A general class of exceptions produced by failed or interrupted I/O operations.
-
returnToWorkspace
protected WorkspaceItem returnToWorkspace(Context c, BasicWorkflowItem wfi) throws SQLException, IOException, AuthorizeException
Return the workflow item to the workspace of the submitter. The workflow item is removed, and a workspace item created.- Parameters:
c- Contextwfi- WorkflowItem to be 'dismantled'- Returns:
- the workspace item
- Throws:
SQLException- An exception that provides information on a database access error or other errors.IOException- A general class of exceptions produced by failed or interrupted I/O operations.AuthorizeException- Exception indicating the current user of the context does not have permission to perform a particular action.
-
sendWorkflowItemBackSubmission
public WorkspaceItem sendWorkflowItemBackSubmission(Context context, BasicWorkflowItem workflowItem, EPerson ePerson, String provenancePrefix, String rejection_message) throws SQLException, AuthorizeException, IOException
- Specified by:
sendWorkflowItemBackSubmissionin interfaceWorkflowService<BasicWorkflowItem>- Throws:
SQLExceptionAuthorizeExceptionIOException
-
createTasks
protected void createTasks(Context c, BasicWorkflowItem wi, List<EPerson> epa) throws SQLException
- Throws:
SQLException
-
notifyOfCuration
public void notifyOfCuration(Context c, BasicWorkflowItem wi, List<EPerson> ePeople, String taskName, String action, String message) throws SQLException, IOException
- Specified by:
notifyOfCurationin interfaceBasicWorkflowService- Throws:
SQLExceptionIOException
-
notifyGroupOfTask
protected void notifyGroupOfTask(Context c, BasicWorkflowItem wi, Group mygroup, List<EPerson> epa) throws SQLException, IOException
- Throws:
SQLExceptionIOException
-
getMyDSpaceLink
public String getMyDSpaceLink()
- Specified by:
getMyDSpaceLinkin interfaceWorkflowService<BasicWorkflowItem>
-
notifyOfReject
protected void notifyOfReject(Context context, BasicWorkflowItem workflowItem, EPerson e, String reason)
-
getItemTitle
public String getItemTitle(BasicWorkflowItem wi) throws SQLException
Description copied from interface:BasicWorkflowServiceget the title of the item in this workflow- Specified by:
getItemTitlein interfaceBasicWorkflowService- Parameters:
wi- the workflow item object- Returns:
- item title
- Throws:
SQLException- An exception that provides information on a database access error or other errors.
-
getSubmitterName
public String getSubmitterName(BasicWorkflowItem wi) throws SQLException
Description copied from interface:BasicWorkflowServiceget the name of the eperson who started this workflow- Specified by:
getSubmitterNamein interfaceBasicWorkflowService- Parameters:
wi- the workflow item- Returns:
- submitter's name
- Throws:
SQLException- An exception that provides information on a database access error or other errors.
-
getEPersonName
protected String getEPersonName(EPerson e) throws SQLException
- Throws:
SQLException
-
recordApproval
protected void recordApproval(Context context, BasicWorkflowItem workflowItem, EPerson e) throws SQLException, IOException, AuthorizeException
-
recordStart
protected void recordStart(Context context, Item myitem) throws SQLException, IOException, AuthorizeException
-
deleteCollection
public void deleteCollection(Context context, Collection collection) throws SQLException, IOException, AuthorizeException
- Specified by:
deleteCollectionin interfaceWorkflowService<BasicWorkflowItem>- Throws:
SQLExceptionIOExceptionAuthorizeException
-
getEPersonDeleteConstraints
public List<String> getEPersonDeleteConstraints(Context context, EPerson ePerson) throws SQLException
- Specified by:
getEPersonDeleteConstraintsin interfaceWorkflowService<BasicWorkflowItem>- Throws:
SQLException
-
getWorkflowRoleGroup
public Group getWorkflowRoleGroup(Context context, Collection collection, String roleName, Group roleGroup) throws SQLException, AuthorizeException
- Specified by:
getWorkflowRoleGroupin interfaceWorkflowService<BasicWorkflowItem>- Throws:
SQLExceptionAuthorizeException
-
createWorkflowRoleGroup
public Group createWorkflowRoleGroup(Context context, Collection collection, String roleName) throws AuthorizeException, SQLException
Description copied from interface:WorkflowServiceThis method will create the workflowRoleGroup for a collection and the given rolename- Specified by:
createWorkflowRoleGroupin interfaceWorkflowService<BasicWorkflowItem>- Parameters:
context- The relevant DSpace contextcollection- The collectionroleName- The rolename- Returns:
- The created Group
- Throws:
AuthorizeException- If something goes wrongSQLException- If something goes wrong
-
getFlywayMigrationLocations
public List<String> getFlywayMigrationLocations()
- Specified by:
getFlywayMigrationLocationsin interfaceWorkflowService<BasicWorkflowItem>
-
-