mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-16 14:33:09 +00:00
DS-2895 authorization check for item not owned by collection
This commit is contained in:
@@ -30,6 +30,7 @@ import org.dspace.harvest.service.HarvestedItemService;
|
|||||||
import org.dspace.identifier.IdentifierException;
|
import org.dspace.identifier.IdentifierException;
|
||||||
import org.dspace.identifier.service.IdentifierService;
|
import org.dspace.identifier.service.IdentifierService;
|
||||||
import org.dspace.versioning.service.VersioningService;
|
import org.dspace.versioning.service.VersioningService;
|
||||||
|
import org.dspace.workflow.WorkflowItemService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -78,6 +79,11 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
|||||||
protected VersioningService versioningService;
|
protected VersioningService versioningService;
|
||||||
@Autowired(required=true)
|
@Autowired(required=true)
|
||||||
protected HarvestedItemService harvestedItemService;
|
protected HarvestedItemService harvestedItemService;
|
||||||
|
@Autowired(required=true)
|
||||||
|
protected WorkspaceItemService workspaceItemService;
|
||||||
|
@Autowired(required=true)
|
||||||
|
protected WorkflowItemService workflowItemService;
|
||||||
|
|
||||||
|
|
||||||
protected ItemServiceImpl()
|
protected ItemServiceImpl()
|
||||||
{
|
{
|
||||||
@@ -881,12 +887,28 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
|||||||
// is this collection not yet created, and an item template is created
|
// is this collection not yet created, and an item template is created
|
||||||
if (item.getOwningCollection() == null)
|
if (item.getOwningCollection() == null)
|
||||||
{
|
{
|
||||||
return true;
|
if (!isAnInprogressSubmission(context, item)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return collectionService.canEditBoolean(context, item.getOwningCollection(), false);
|
return collectionService.canEditBoolean(context, item.getOwningCollection(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the item is an inprogress submission
|
||||||
|
* @param context
|
||||||
|
* @param item
|
||||||
|
* @return <code>true</code> 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.
|
With every finished submission a bunch of resource policy entries with have null value for the dspace_object column are generated in the database.
|
||||||
|
Reference in New Issue
Block a user