diff --git a/dspace-api/src/main/java/org/dspace/content/ItemServiceImpl.java b/dspace-api/src/main/java/org/dspace/content/ItemServiceImpl.java index 15f9691ae7..152926249b 100644 --- a/dspace-api/src/main/java/org/dspace/content/ItemServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/content/ItemServiceImpl.java @@ -30,6 +30,7 @@ import org.dspace.harvest.service.HarvestedItemService; import org.dspace.identifier.IdentifierException; import org.dspace.identifier.service.IdentifierService; import org.dspace.versioning.service.VersioningService; +import org.dspace.workflow.WorkflowItemService; import org.springframework.beans.factory.annotation.Autowired; import java.io.IOException; @@ -78,6 +79,11 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl implements It protected VersioningService versioningService; @Autowired(required=true) protected HarvestedItemService harvestedItemService; + @Autowired(required=true) + protected WorkspaceItemService workspaceItemService; + @Autowired(required=true) + protected WorkflowItemService workflowItemService; + protected ItemServiceImpl() { @@ -881,12 +887,28 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl implements It // is this collection not yet created, and an item template is created if (item.getOwningCollection() == null) { - return true; + if (!isAnInprogressSubmission(context, item)) { + return true; + } + else { + return false; + } } return collectionService.canEditBoolean(context, item.getOwningCollection(), false); } + /** + * Check if the item is an inprogress submission + * @param context + * @param item + * @return true if the item is an inprogress submission, i.e. a WorkspaceItem or WorkflowItem + * @throws SQLException + */ + public boolean isAnInprogressSubmission(Context context, Item item) throws SQLException { + return workspaceItemService.findByItem(context, item) != null + || workflowItemService.findByItem(context, item) != null; + } /* With every finished submission a bunch of resource policy entries with have null value for the dspace_object column are generated in the database.