mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 10:04:21 +00:00
DS-1814: Allow submitters to create new version of their items
This commit is contained in:

committed by
Pascal-Nicolas Becker

parent
1e344bed0f
commit
701d4ba6b1
@@ -29,6 +29,7 @@ import org.dspace.harvest.HarvestedItem;
|
|||||||
import org.dspace.harvest.service.HarvestedItemService;
|
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.services.factory.DSpaceServicesFactory;
|
||||||
import org.dspace.versioning.service.VersioningService;
|
import org.dspace.versioning.service.VersioningService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
@@ -407,7 +408,7 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
|||||||
public void update(Context context, Item item) throws SQLException, AuthorizeException {
|
public void update(Context context, Item item) throws SQLException, AuthorizeException {
|
||||||
// Check authorisation
|
// Check authorisation
|
||||||
// only do write authorization if user is not an editor
|
// only do write authorization if user is not an editor
|
||||||
if (!canEdit(context, item))
|
if (!canEdit(context, item) && !canCreateNewVersion(context, item))
|
||||||
{
|
{
|
||||||
authorizeService.authorizeAction(context, item, Constants.WRITE);
|
authorizeService.authorizeAction(context, item, Constants.WRITE);
|
||||||
}
|
}
|
||||||
@@ -589,7 +590,6 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
|||||||
context.addEvent(new Event(Event.DELETE, Constants.ITEM, item.getID(),
|
context.addEvent(new Event(Event.DELETE, Constants.ITEM, item.getID(),
|
||||||
item.getHandle(), getIdentifiers(context, item)));
|
item.getHandle(), getIdentifiers(context, item)));
|
||||||
|
|
||||||
|
|
||||||
log.info(LogManager.getHeader(context, "delete_item", "item_id="
|
log.info(LogManager.getHeader(context, "delete_item", "item_id="
|
||||||
+ item.getID()));
|
+ item.getID()));
|
||||||
|
|
||||||
@@ -885,13 +885,23 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
|||||||
|
|
||||||
return collectionService.canEditBoolean(context, item.getOwningCollection(), false);
|
return collectionService.canEditBoolean(context, item.getOwningCollection(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
With every finished submission a bunch of resource policy entries with have null value for the dspace_object column are generated in the database.
|
public boolean canCreateNewVersion(Context context, Item item) throws SQLException{
|
||||||
prevent the generation of resource policy entry values with null dspace_object as value
|
if (authorizeService.isAdmin(context, item))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
*/
|
if (context.getCurrentUser() != null
|
||||||
|
&& context.getCurrentUser().equals(item.getSubmitter()))
|
||||||
|
{
|
||||||
|
return DSpaceServicesFactory.getInstance().getConfigurationService().getPropertyAsType(
|
||||||
|
"versioning.submitterCanCreateNewVersion", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the default policies, which have not been already added to the given DSpace object
|
* Add the default policies, which have not been already added to the given DSpace object
|
||||||
|
@@ -444,7 +444,15 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
|||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
*/
|
*/
|
||||||
public boolean canEdit(Context context, Item item) throws java.sql.SQLException;
|
public boolean canEdit(Context context, Item item) throws java.sql.SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return TRUE if context's user can create new version of the item, false
|
||||||
|
* otherwise.
|
||||||
|
* @return boolean true = current user can create new version of the item
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
|
public boolean canCreateNewVersion(Context context, Item item) throws SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an iterator of Items possessing the passed metadata field, or only
|
* Returns an iterator of Items possessing the passed metadata field, or only
|
||||||
* those matching the passed value, if value is not Item.ANY
|
* those matching the passed value, if value is not Item.ANY
|
||||||
|
@@ -96,18 +96,19 @@ public abstract class AbstractVersionProvider {
|
|||||||
{
|
{
|
||||||
bundleNew.setPrimaryBitstreamID(bitstreamNew);
|
bundleNew.setPrimaryBitstreamID(bitstreamNew);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bitstreamService.update(c, bitstreamNew);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected Bitstream createBitstream(Context context, Bitstream nativeBitstream) throws AuthorizeException, SQLException, IOException {
|
protected Bitstream createBitstream(Context context, Bitstream nativeBitstream) throws AuthorizeException, SQLException, IOException {
|
||||||
Bitstream newBitstream = bitstreamStorageService.clone(context, nativeBitstream);
|
Bitstream newBitstream = bitstreamStorageService.clone(context, nativeBitstream);
|
||||||
List<MetadataValue> bitstreamMeta = bitstreamService.getMetadata(nativeBitstream, Item.ANY, Item.ANY, Item.ANY, Item.ANY);
|
List<MetadataValue> bitstreamMeta = bitstreamService.getMetadata(nativeBitstream, Item.ANY, Item.ANY, Item.ANY, Item.ANY);
|
||||||
for (MetadataValue value : bitstreamMeta) {
|
for (MetadataValue value : bitstreamMeta) {
|
||||||
bitstreamService.addMetadata(context, newBitstream, value.getMetadataField(), value.getLanguage(), value.getValue(), value.getAuthority(), value.getConfidence());
|
bitstreamService.addMetadata(context, newBitstream, value.getMetadataField(), value.getLanguage(), value.getValue(), value.getAuthority(), value.getConfidence());
|
||||||
}
|
}
|
||||||
bitstreamService.update(context, newBitstream);
|
|
||||||
return newBitstream;
|
return newBitstream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1196,6 +1196,7 @@ jsp.submit.verify-prune.notproceed.button = Do Not Make th
|
|||||||
jsp.submit.verify-prune.proceed.button = Proceed With Changes
|
jsp.submit.verify-prune.proceed.button = Proceed With Changes
|
||||||
jsp.submit.verify-prune.question = Are you sure you want to proceed with the changes?
|
jsp.submit.verify-prune.question = Are you sure you want to proceed with the changes?
|
||||||
jsp.submit.verify-prune.title = Answers to Initial Questions Changed
|
jsp.submit.verify-prune.title = Answers to Initial Questions Changed
|
||||||
|
jsp.submittertools = Actions
|
||||||
jsp.suggest.button.cancel = Cancel
|
jsp.suggest.button.cancel = Cancel
|
||||||
jsp.suggest.button.send = Send Recommendation
|
jsp.suggest.button.send = Send Recommendation
|
||||||
jsp.suggest.heading = Recommended Item:
|
jsp.suggest.heading = Recommended Item:
|
||||||
|
@@ -32,6 +32,7 @@ import org.dspace.identifier.service.DOIService;
|
|||||||
import org.dspace.identifier.service.IdentifierService;
|
import org.dspace.identifier.service.IdentifierService;
|
||||||
import org.dspace.plugin.ItemHomeProcessor;
|
import org.dspace.plugin.ItemHomeProcessor;
|
||||||
import org.dspace.plugin.PluginException;
|
import org.dspace.plugin.PluginException;
|
||||||
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
import org.dspace.versioning.Version;
|
import org.dspace.versioning.Version;
|
||||||
import org.dspace.versioning.VersionHistory;
|
import org.dspace.versioning.VersionHistory;
|
||||||
import org.dspace.versioning.factory.VersionServiceFactory;
|
import org.dspace.versioning.factory.VersionServiceFactory;
|
||||||
@@ -66,6 +67,10 @@ public class VersioningItemHome implements ItemHomeProcessor {
|
|||||||
AuthorizeException {
|
AuthorizeException {
|
||||||
boolean versioningEnabled = ConfigurationManager.getBooleanProperty(
|
boolean versioningEnabled = ConfigurationManager.getBooleanProperty(
|
||||||
"versioning", "enabled");
|
"versioning", "enabled");
|
||||||
|
boolean submitterCanCreateNewVersion = DSpaceServicesFactory
|
||||||
|
.getInstance()
|
||||||
|
.getConfigurationService()
|
||||||
|
.getPropertyAsType("versioning.submitterCanCreateNewVersion", false);
|
||||||
boolean newVersionAvailable = false;
|
boolean newVersionAvailable = false;
|
||||||
boolean showVersionWorkflowAvailable = false;
|
boolean showVersionWorkflowAvailable = false;
|
||||||
boolean hasVersionButton = false;
|
boolean hasVersionButton = false;
|
||||||
@@ -81,7 +86,17 @@ public class VersioningItemHome implements ItemHomeProcessor {
|
|||||||
if (versionHistoryService.isLastVersion(context, item)
|
if (versionHistoryService.isLastVersion(context, item)
|
||||||
&& item.isArchived()) {
|
&& item.isArchived()) {
|
||||||
hasVersionButton = true;
|
hasVersionButton = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else if (submitterCanCreateNewVersion)
|
||||||
|
{
|
||||||
|
if (versionHistoryService.isLastVersion(context, item)
|
||||||
|
&& item.isArchived()
|
||||||
|
&& itemService.canCreateNewVersion(context, item))
|
||||||
|
{
|
||||||
|
hasVersionButton = true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (versionHistoryService.hasVersionHistory(context, item)) {
|
if (versionHistoryService.hasVersionHistory(context, item)) {
|
||||||
hasVersionHistory = true;
|
hasVersionHistory = true;
|
||||||
|
@@ -389,8 +389,14 @@ public class HandleServlet extends DSpaceServlet
|
|||||||
{
|
{
|
||||||
// set a variable to create an edit button
|
// set a variable to create an edit button
|
||||||
request.setAttribute("admin_button", Boolean.TRUE);
|
request.setAttribute("admin_button", Boolean.TRUE);
|
||||||
|
}
|
||||||
|
// show submitters a button to create a new item version
|
||||||
|
else if (itemService.canCreateNewVersion(context, item))
|
||||||
|
{
|
||||||
|
// set a variable to create a button to create a new item version
|
||||||
|
request.setAttribute("submitter_button", Boolean.TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the collections
|
// Get the collections
|
||||||
List<Collection> collections = item.getCollections();
|
List<Collection> collections = item.getCollections();
|
||||||
|
|
||||||
|
@@ -92,7 +92,8 @@ public class VersionUtil
|
|||||||
Item item = itemService.find(context, itemID);
|
Item item = itemService.find(context, itemID);
|
||||||
|
|
||||||
if (authorizeService.authorizeActionBoolean(context, item,
|
if (authorizeService.authorizeActionBoolean(context, item,
|
||||||
Constants.WRITE) || itemService.canEdit(context, item))
|
Constants.WRITE) || itemService.canEdit(context, item)
|
||||||
|
|| itemService.canCreateNewVersion(context, item))
|
||||||
{
|
{
|
||||||
VersioningService versioningService = new DSpace()
|
VersioningService versioningService = new DSpace()
|
||||||
.getSingletonService(VersioningService.class);
|
.getSingletonService(VersioningService.class);
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
- appear yet. If this is omitted, the item display won't
|
- appear yet. If this is omitted, the item display won't
|
||||||
- display any collections.
|
- display any collections.
|
||||||
- admin_button - Boolean, show admin 'edit' button
|
- admin_button - Boolean, show admin 'edit' button
|
||||||
|
- submitter_button - Boolean, show submitter "new version" button
|
||||||
--%>
|
--%>
|
||||||
<%@page contentType="text/html;charset=UTF-8" %>
|
<%@page contentType="text/html;charset=UTF-8" %>
|
||||||
|
|
||||||
@@ -64,7 +65,8 @@
|
|||||||
List<Collection> collections = (List<Collection>) request.getAttribute("collections");
|
List<Collection> collections = (List<Collection>) request.getAttribute("collections");
|
||||||
Boolean admin_b = (Boolean)request.getAttribute("admin_button");
|
Boolean admin_b = (Boolean)request.getAttribute("admin_button");
|
||||||
boolean admin_button = (admin_b == null ? false : admin_b.booleanValue());
|
boolean admin_button = (admin_b == null ? false : admin_b.booleanValue());
|
||||||
|
Boolean submitter_b = (Boolean) request.getAttribute("submitter_button");
|
||||||
|
boolean submitter_button = (submitter_b == null ? false : submitter_b.booleanValue());
|
||||||
// get the workspace id if one has been passed
|
// get the workspace id if one has been passed
|
||||||
Integer workspace_id = (Integer) request.getAttribute("workspace_id");
|
Integer workspace_id = (Integer) request.getAttribute("workspace_id");
|
||||||
|
|
||||||
@@ -198,6 +200,22 @@
|
|||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
<%
|
<%
|
||||||
|
// submitter create new version button
|
||||||
|
if (submitter_button && hasVersionButton) {
|
||||||
|
%>
|
||||||
|
<dspace:sidebar>
|
||||||
|
<div class="panel panel-warning">
|
||||||
|
<div class="panel-heading"><fmt:message key="jsp.submittertools"/></div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<form method="get" action="<%= request.getContextPath()%>/tools/version">
|
||||||
|
<input type="hidden" name="itemID" value="<%= item.getID()%>" />
|
||||||
|
<input class="btn btn-default col-md-12" type="submit" name="submit" value="<fmt:message key="jsp.general.version.button"/>" />
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</dspace:sidebar>
|
||||||
|
<%
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String displayStyle = (displayAll ? "full" : "");
|
String displayStyle = (displayAll ? "full" : "");
|
||||||
|
@@ -14,3 +14,7 @@ versioning.item.history.view.admin=false
|
|||||||
# the submitter of a version should be included in the version history of
|
# the submitter of a version should be included in the version history of
|
||||||
# an item.
|
# an item.
|
||||||
versioning.item.history.include.submitter=false
|
versioning.item.history.include.submitter=false
|
||||||
|
|
||||||
|
# If you want to allow submitters to create new versions of there items, set
|
||||||
|
# the property submitterCanCreateNewVersion true.
|
||||||
|
versioning.submitterCanCreateNewVersion=true
|
||||||
|
Reference in New Issue
Block a user