mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-14 13:33:08 +00:00
DS-3851 Configurable Workflow endpoints
This commit is contained in:

committed by
Andrea Bollini

parent
c0066d2a2f
commit
25e3a69b8f
@@ -0,0 +1,44 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.browse;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.dspace.core.Constants;
|
||||||
|
|
||||||
|
public interface BrowsableDSpaceObject<PK extends Serializable> {
|
||||||
|
Map<String, Object> extraInfo = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
default public Map<String, Object> getExtraInfo() {
|
||||||
|
return extraInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
default public boolean isArchived() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
default public boolean isDiscoverable() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getType();
|
||||||
|
|
||||||
|
public PK getID();
|
||||||
|
|
||||||
|
default String getUniqueIndexID() {
|
||||||
|
return getType() + "-" + getID().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
default public String getTypeText() {
|
||||||
|
return Constants.typeText[getType()];
|
||||||
|
};
|
||||||
|
|
||||||
|
public String getHandle();
|
||||||
|
}
|
@@ -11,6 +11,7 @@ import java.io.InputStream;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.FetchType;
|
import javax.persistence.FetchType;
|
||||||
@@ -21,6 +22,8 @@ import javax.persistence.OneToOne;
|
|||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.persistence.Transient;
|
import javax.persistence.Transient;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
import org.dspace.content.factory.ContentServiceFactory;
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
import org.dspace.content.service.BitstreamService;
|
import org.dspace.content.service.BitstreamService;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
@@ -40,6 +43,12 @@ import org.hibernate.proxy.HibernateProxyHelper;
|
|||||||
@Entity
|
@Entity
|
||||||
@Table(name = "bitstream")
|
@Table(name = "bitstream")
|
||||||
public class Bitstream extends DSpaceObject implements DSpaceObjectLegacySupport {
|
public class Bitstream extends DSpaceObject implements DSpaceObjectLegacySupport {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* log4j logger
|
||||||
|
*/
|
||||||
|
private static Logger log = Logger.getLogger(Bitstream.class);
|
||||||
|
|
||||||
@Column(name = "bitstream_id", insertable = false, updatable = false)
|
@Column(name = "bitstream_id", insertable = false, updatable = false)
|
||||||
private Integer legacyId;
|
private Integer legacyId;
|
||||||
|
|
||||||
@@ -426,4 +435,17 @@ public class Bitstream extends DSpaceObject implements DSpaceObjectLegacySupport
|
|||||||
.setMetadataSingleValue(context, this, "dcterms", "accessRights", null, null, acceptanceDate.toString());
|
.setMetadataSingleValue(context, this, "dcterms", "accessRights", null, null, acceptanceDate.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BrowsableDSpaceObject getParentObject() {
|
||||||
|
Context context = new Context();
|
||||||
|
try {
|
||||||
|
return (BrowsableDSpaceObject) (getBitstreamService().getParentObject(context, this));
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMetadata(String field) {
|
||||||
|
return getBitstreamService().getMetadata(this, field);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -460,6 +460,13 @@ public class BitstreamServiceImpl extends DSpaceObjectServiceImpl<Bitstream> imp
|
|||||||
return bitstreamDAO.getNotReferencedBitstreams(context);
|
return bitstreamDAO.getNotReferencedBitstreams(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addMetadata(Context context, Bitstream dso, MetadataField metadataField, String lang,
|
||||||
|
List<String> values, List<String> authorities, List<Integer> confidences)
|
||||||
|
throws SQLException {
|
||||||
|
addMetadata(context, dso, metadataField, lang, values, authorities, confidences, null);
|
||||||
|
}
|
||||||
|
|
||||||
public Long getLastModified(Bitstream bitstream) {
|
public Long getLastModified(Bitstream bitstream) {
|
||||||
return bitstreamStorageService.getLastModified(bitstream);
|
return bitstreamStorageService.getLastModified(bitstream);
|
||||||
}
|
}
|
||||||
|
@@ -12,6 +12,8 @@ import java.util.Arrays;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.persistence.Cacheable;
|
import javax.persistence.Cacheable;
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
@@ -25,6 +27,7 @@ import javax.persistence.Table;
|
|||||||
import javax.persistence.Transient;
|
import javax.persistence.Transient;
|
||||||
|
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
import org.dspace.content.comparator.NameAscendingComparator;
|
import org.dspace.content.comparator.NameAscendingComparator;
|
||||||
import org.dspace.content.factory.ContentServiceFactory;
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
import org.dspace.content.service.CollectionService;
|
import org.dspace.content.service.CollectionService;
|
||||||
@@ -52,7 +55,7 @@ import org.hibernate.proxy.HibernateProxyHelper;
|
|||||||
@Table(name = "collection")
|
@Table(name = "collection")
|
||||||
@Cacheable
|
@Cacheable
|
||||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, include = "non-lazy")
|
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, include = "non-lazy")
|
||||||
public class Collection extends DSpaceObject implements DSpaceObjectLegacySupport {
|
public class Collection extends DSpaceObject implements DSpaceObjectLegacySupport, BrowsableDSpaceObject<UUID> {
|
||||||
|
|
||||||
@Column(name = "collection_id", insertable = false, updatable = false)
|
@Column(name = "collection_id", insertable = false, updatable = false)
|
||||||
private Integer legacyId;
|
private Integer legacyId;
|
||||||
@@ -347,10 +350,26 @@ public class Collection extends DSpaceObject implements DSpaceObjectLegacySuppor
|
|||||||
return legacyId;
|
return legacyId;
|
||||||
}
|
}
|
||||||
|
|
||||||
private CollectionService getCollectionService() {
|
public CollectionService getCollectionService() {
|
||||||
if (collectionService == null) {
|
if (collectionService == null) {
|
||||||
collectionService = ContentServiceFactory.getInstance().getCollectionService();
|
collectionService = ContentServiceFactory.getInstance().getCollectionService();
|
||||||
}
|
}
|
||||||
return collectionService;
|
return collectionService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTypeText() {
|
||||||
|
return Constants.typeText[Constants.COLLECTION];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isArchived() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDiscoverable() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -11,6 +11,8 @@ import java.util.Arrays;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.persistence.Cacheable;
|
import javax.persistence.Cacheable;
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
@@ -25,6 +27,7 @@ import javax.persistence.Transient;
|
|||||||
|
|
||||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
import org.dspace.content.comparator.NameAscendingComparator;
|
import org.dspace.content.comparator.NameAscendingComparator;
|
||||||
import org.dspace.content.factory.ContentServiceFactory;
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
import org.dspace.content.service.CommunityService;
|
import org.dspace.content.service.CommunityService;
|
||||||
@@ -48,7 +51,7 @@ import org.hibernate.proxy.HibernateProxyHelper;
|
|||||||
@Table(name = "community")
|
@Table(name = "community")
|
||||||
@Cacheable
|
@Cacheable
|
||||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, include = "non-lazy")
|
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, include = "non-lazy")
|
||||||
public class Community extends DSpaceObject implements DSpaceObjectLegacySupport {
|
public class Community extends DSpaceObject implements DSpaceObjectLegacySupport, BrowsableDSpaceObject<UUID> {
|
||||||
/**
|
/**
|
||||||
* log4j category
|
* log4j category
|
||||||
*/
|
*/
|
||||||
@@ -251,6 +254,11 @@ public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
|
|||||||
return Constants.COMMUNITY;
|
return Constants.COMMUNITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTypeText() {
|
||||||
|
return Constants.typeText[Constants.COMMUNITY];
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
String value = getCommunityService()
|
String value = getCommunityService()
|
||||||
@@ -269,4 +277,15 @@ public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
|
|||||||
}
|
}
|
||||||
return communityService;
|
return communityService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isArchived() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDiscoverable() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -26,6 +26,7 @@ import javax.persistence.Transient;
|
|||||||
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.dspace.authorize.ResourcePolicy;
|
import org.dspace.authorize.ResourcePolicy;
|
||||||
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
import org.dspace.core.ReloadableEntity;
|
import org.dspace.core.ReloadableEntity;
|
||||||
import org.dspace.handle.Handle;
|
import org.dspace.handle.Handle;
|
||||||
import org.hibernate.annotations.GenericGenerator;
|
import org.hibernate.annotations.GenericGenerator;
|
||||||
@@ -36,7 +37,8 @@ import org.hibernate.annotations.GenericGenerator;
|
|||||||
@Entity
|
@Entity
|
||||||
@Inheritance(strategy = InheritanceType.JOINED)
|
@Inheritance(strategy = InheritanceType.JOINED)
|
||||||
@Table(name = "dspaceobject")
|
@Table(name = "dspaceobject")
|
||||||
public abstract class DSpaceObject implements Serializable, ReloadableEntity<java.util.UUID> {
|
public abstract class DSpaceObject implements Serializable, ReloadableEntity<java.util.UUID>,
|
||||||
|
BrowsableDSpaceObject<UUID> {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(generator = "system-uuid")
|
@GeneratedValue(generator = "system-uuid")
|
||||||
@GenericGenerator(name = "system-uuid", strategy = "uuid2")
|
@GenericGenerator(name = "system-uuid", strategy = "uuid2")
|
||||||
@@ -199,4 +201,7 @@ public abstract class DSpaceObject implements Serializable, ReloadableEntity<jav
|
|||||||
this.modified = true;
|
this.modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getUniqueIndexID() {
|
||||||
|
return getType() + "-" + getID().toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -141,7 +141,7 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
|||||||
public List<MetadataValue> getMetadataByMetadataString(T dso, String mdString) {
|
public List<MetadataValue> getMetadataByMetadataString(T dso, String mdString) {
|
||||||
StringTokenizer dcf = new StringTokenizer(mdString, ".");
|
StringTokenizer dcf = new StringTokenizer(mdString, ".");
|
||||||
|
|
||||||
String[] tokens = {"", "", ""};
|
String[] tokens = { "", "", "" };
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (dcf.hasMoreTokens()) {
|
while (dcf.hasMoreTokens()) {
|
||||||
tokens[i] = dcf.nextToken().trim();
|
tokens[i] = dcf.nextToken().trim();
|
||||||
@@ -231,7 +231,8 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addMetadata(Context context, T dso, MetadataField metadataField, String lang, List<String> values,
|
public void addMetadata(Context context, T dso, MetadataField metadataField, String lang, List<String> values,
|
||||||
List<String> authorities, List<Integer> confidences) throws SQLException {
|
List<String> authorities, List<Integer> confidences, List<Integer> places)
|
||||||
|
throws SQLException {
|
||||||
boolean authorityControlled = metadataAuthorityService.isAuthorityControlled(metadataField);
|
boolean authorityControlled = metadataAuthorityService.isAuthorityControlled(metadataField);
|
||||||
boolean authorityRequired = metadataAuthorityService.isAuthorityRequired(metadataField);
|
boolean authorityRequired = metadataAuthorityService.isAuthorityRequired(metadataField);
|
||||||
|
|
||||||
@@ -520,7 +521,7 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
|||||||
protected String[] getMDValueByField(String field) {
|
protected String[] getMDValueByField(String field) {
|
||||||
StringTokenizer dcf = new StringTokenizer(field, ".");
|
StringTokenizer dcf = new StringTokenizer(field, ".");
|
||||||
|
|
||||||
String[] tokens = {"", "", ""};
|
String[] tokens = { "", "", "" };
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (dcf.hasMoreTokens()) {
|
while (dcf.hasMoreTokens()) {
|
||||||
tokens[i] = dcf.nextToken().trim();
|
tokens[i] = dcf.nextToken().trim();
|
||||||
@@ -701,4 +702,16 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
|||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addMetadata(Context context, T dso, MetadataField metadataField, String lang, List<String> values,
|
||||||
|
List<String> authorities, List<Integer> confidences) throws SQLException {
|
||||||
|
addMetadata(context, dso, metadataField, lang, values, authorities, confidences, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addMetadata(Context context, T dso, MetadataField metadataField, String language, String value,
|
||||||
|
String authority, int confidence, int place) throws SQLException {
|
||||||
|
addMetadata(context, dso, metadataField, language, value, authority, confidence);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -7,8 +7,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.content;
|
package org.dspace.content;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
import org.dspace.authorize.AuthorizeException;
|
||||||
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -18,13 +21,18 @@ import org.dspace.eperson.EPerson;
|
|||||||
* @author Robert Tansley
|
* @author Robert Tansley
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
public interface InProgressSubmission {
|
public interface InProgressSubmission<ID extends Serializable> extends BrowsableDSpaceObject<ID> {
|
||||||
/**
|
/**
|
||||||
* Get the internal ID of this submission
|
* Get the internal ID of this submission
|
||||||
*
|
*
|
||||||
* @return the internal identifier
|
* @return the internal identifier
|
||||||
*/
|
*/
|
||||||
Integer getID();
|
ID getID();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the submission, including the unarchived item.
|
||||||
|
*/
|
||||||
|
void update() throws SQLException, AuthorizeException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the incomplete item object
|
* Get the incomplete item object
|
||||||
|
@@ -13,6 +13,8 @@ import java.util.Date;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
@@ -27,6 +29,8 @@ import javax.persistence.Temporal;
|
|||||||
import javax.persistence.TemporalType;
|
import javax.persistence.TemporalType;
|
||||||
import javax.persistence.Transient;
|
import javax.persistence.Transient;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
import org.dspace.content.comparator.NameAscendingComparator;
|
import org.dspace.content.comparator.NameAscendingComparator;
|
||||||
import org.dspace.content.factory.ContentServiceFactory;
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
@@ -51,7 +55,13 @@ import org.hibernate.proxy.HibernateProxyHelper;
|
|||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "item")
|
@Table(name = "item")
|
||||||
public class Item extends DSpaceObject implements DSpaceObjectLegacySupport {
|
public class Item extends DSpaceObject implements DSpaceObjectLegacySupport, BrowsableDSpaceObject<UUID> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* log4j logger
|
||||||
|
*/
|
||||||
|
private static Logger log = Logger.getLogger(Item.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wild card for Dublin Core metadata qualifiers/languages
|
* Wild card for Dublin Core metadata qualifiers/languages
|
||||||
*/
|
*/
|
||||||
@@ -366,4 +376,9 @@ public class Item extends DSpaceObject implements DSpaceObjectLegacySupport {
|
|||||||
}
|
}
|
||||||
return itemService;
|
return itemService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getTypeText() {
|
||||||
|
return getItemService().getTypeText(this);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -27,6 +27,7 @@ import org.dspace.authorize.service.AuthorizeService;
|
|||||||
import org.dspace.authorize.service.ResourcePolicyService;
|
import org.dspace.authorize.service.ResourcePolicyService;
|
||||||
import org.dspace.content.authority.Choices;
|
import org.dspace.content.authority.Choices;
|
||||||
import org.dspace.content.dao.ItemDAO;
|
import org.dspace.content.dao.ItemDAO;
|
||||||
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
import org.dspace.content.service.BitstreamFormatService;
|
import org.dspace.content.service.BitstreamFormatService;
|
||||||
import org.dspace.content.service.BitstreamService;
|
import org.dspace.content.service.BitstreamService;
|
||||||
import org.dspace.content.service.BundleService;
|
import org.dspace.content.service.BundleService;
|
||||||
@@ -49,6 +50,7 @@ import org.dspace.identifier.service.IdentifierService;
|
|||||||
import org.dspace.services.ConfigurationService;
|
import org.dspace.services.ConfigurationService;
|
||||||
import org.dspace.versioning.service.VersioningService;
|
import org.dspace.versioning.service.VersioningService;
|
||||||
import org.dspace.workflow.WorkflowItemService;
|
import org.dspace.workflow.WorkflowItemService;
|
||||||
|
import org.dspace.workflow.factory.WorkflowServiceFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -214,6 +216,12 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
|||||||
return itemDAO.findBySubmitter(context, eperson);
|
return itemDAO.findBySubmitter(context, eperson);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Item> findBySubmitter(Context context, EPerson eperson, Integer limit, Integer offset)
|
||||||
|
throws SQLException {
|
||||||
|
return itemDAO.findBySubmitter(context, eperson, limit, offset);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterator<Item> findBySubmitterDateSorted(Context context, EPerson eperson, Integer limit)
|
public Iterator<Item> findBySubmitterDateSorted(Context context, EPerson eperson, Integer limit)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
@@ -300,6 +308,11 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
|||||||
return matchingBundles;
|
return matchingBundles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Bundle> getBundles(Context context, Item item, String name) throws SQLException {
|
||||||
|
return itemDAO.findBundlesByName(context, item, name);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addBundle(Context context, Item item, Bundle bundle) throws SQLException, AuthorizeException {
|
public void addBundle(Context context, Item item, Bundle bundle) throws SQLException, AuthorizeException {
|
||||||
// Check authorisation
|
// Check authorisation
|
||||||
@@ -1109,6 +1122,16 @@ prevent the generation of resource policy entry values with null dspace_object a
|
|||||||
if (ownCollection != null) {
|
if (ownCollection != null) {
|
||||||
return ownCollection;
|
return ownCollection;
|
||||||
} else {
|
} else {
|
||||||
|
InProgressSubmission inprogress = ContentServiceFactory.getInstance().getWorkspaceItemService()
|
||||||
|
.findByItem(context,
|
||||||
|
item);
|
||||||
|
if (inprogress == null) {
|
||||||
|
inprogress = WorkflowServiceFactory.getInstance().getWorkflowItemService().findByItem(context, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inprogress != null) {
|
||||||
|
return inprogress.getCollection();
|
||||||
|
}
|
||||||
// is a template item?
|
// is a template item?
|
||||||
return item.getTemplateItemOf();
|
return item.getTemplateItemOf();
|
||||||
}
|
}
|
||||||
@@ -1237,6 +1260,12 @@ prevent the generation of resource policy entry values with null dspace_object a
|
|||||||
return itemDAO.countItems(context, false, false);
|
return itemDAO.countItems(context, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int countArchivedItems(Context context) throws SQLException {
|
||||||
|
// return count of items in archive and also not withdrawn
|
||||||
|
return itemDAO.countItems(context, true, false);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int countWithdrawnItems(Context context) throws SQLException {
|
public int countWithdrawnItems(Context context) throws SQLException {
|
||||||
// return count of items that are not in archive and withdrawn
|
// return count of items that are not in archive and withdrawn
|
||||||
@@ -1257,4 +1286,10 @@ prevent the generation of resource policy entry values with null dspace_object a
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int countBySubmitter(Context context, EPerson ep) throws SQLException {
|
||||||
|
return itemDAO.countItems(context, ep, true, false);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -11,6 +11,7 @@ import java.io.Serializable;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.FetchType;
|
import javax.persistence.FetchType;
|
||||||
@@ -26,6 +27,10 @@ import javax.persistence.SequenceGenerator;
|
|||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||||
|
import org.dspace.authorize.AuthorizeException;
|
||||||
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.core.ReloadableEntity;
|
import org.dspace.core.ReloadableEntity;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
@@ -41,7 +46,8 @@ import org.hibernate.proxy.HibernateProxyHelper;
|
|||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "workspaceitem")
|
@Table(name = "workspaceitem")
|
||||||
public class WorkspaceItem implements InProgressSubmission, Serializable, ReloadableEntity<Integer> {
|
public class WorkspaceItem
|
||||||
|
implements InProgressSubmission<Integer>, Serializable, ReloadableEntity<Integer>, BrowsableDSpaceObject<Integer> {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "workspace_item_id", unique = true, nullable = false)
|
@Column(name = "workspace_item_id", unique = true, nullable = false)
|
||||||
@@ -238,4 +244,44 @@ public class WorkspaceItem implements InProgressSubmission, Serializable, Reload
|
|||||||
void addSupervisorGroup(Group group) {
|
void addSupervisorGroup(Group group) {
|
||||||
supervisorGroups.add(group);
|
supervisorGroups.add(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update() throws SQLException, AuthorizeException {
|
||||||
|
|
||||||
|
Context context = null;
|
||||||
|
try {
|
||||||
|
context = new Context();
|
||||||
|
ContentServiceFactory.getInstance().getWorkspaceItemService().update(context, this);
|
||||||
|
} finally {
|
||||||
|
if (context != null && context.isValid()) {
|
||||||
|
context.abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHandle() {
|
||||||
|
return getType() + "-" + getID();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTypeText() {
|
||||||
|
return "workspaceitem";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getType() {
|
||||||
|
return Constants.WORKSPACEITEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isArchived() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDiscoverable() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -60,7 +60,12 @@ public class WorkspaceItemServiceImpl implements WorkspaceItemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WorkspaceItem find(Context context, int id) throws SQLException {
|
public int getSupportsTypeConstant() {
|
||||||
|
return Constants.WORKSPACEITEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WorkspaceItem find(Context context, Integer id) throws SQLException {
|
||||||
WorkspaceItem workspaceItem = workspaceItemDAO.findByID(context, WorkspaceItem.class, id);
|
WorkspaceItem workspaceItem = workspaceItemDAO.findByID(context, WorkspaceItem.class, id);
|
||||||
|
|
||||||
if (workspaceItem == null) {
|
if (workspaceItem == null) {
|
||||||
|
@@ -13,7 +13,9 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.dspace.content.Bundle;
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
|
import org.dspace.content.Community;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataField;
|
import org.dspace.content.MetadataField;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
@@ -131,4 +133,12 @@ public interface ItemDAO extends DSpaceObjectLegacySupportDAO<Item> {
|
|||||||
*/
|
*/
|
||||||
int countItems(Context context, boolean includeArchived, boolean includeWithdrawn) throws SQLException;
|
int countItems(Context context, boolean includeArchived, boolean includeWithdrawn) throws SQLException;
|
||||||
|
|
||||||
|
public List<Bundle> findBundlesByName(Context context, Item item, String name) throws SQLException;
|
||||||
|
|
||||||
|
public List<Item> findBySubmitter(Context context, EPerson eperson, Integer limit, Integer offset)
|
||||||
|
throws SQLException;
|
||||||
|
|
||||||
|
public int countItems(Context context, EPerson submitter, boolean includeArchived, boolean includeWithdrawn)
|
||||||
|
throws SQLException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -14,7 +14,9 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
import org.dspace.content.Bundle;
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataField;
|
import org.dspace.content.MetadataField;
|
||||||
@@ -26,6 +28,7 @@ import org.dspace.eperson.EPerson;
|
|||||||
import org.hibernate.Criteria;
|
import org.hibernate.Criteria;
|
||||||
import org.hibernate.Query;
|
import org.hibernate.Query;
|
||||||
import org.hibernate.criterion.DetachedCriteria;
|
import org.hibernate.criterion.DetachedCriteria;
|
||||||
|
import org.hibernate.criterion.Order;
|
||||||
import org.hibernate.criterion.Projections;
|
import org.hibernate.criterion.Projections;
|
||||||
import org.hibernate.criterion.Property;
|
import org.hibernate.criterion.Property;
|
||||||
import org.hibernate.criterion.Restrictions;
|
import org.hibernate.criterion.Restrictions;
|
||||||
@@ -314,4 +317,46 @@ public class ItemDAOImpl extends AbstractHibernateDSODAO<Item> implements ItemDA
|
|||||||
query.setParameter("withdrawn", includeWithdrawn);
|
query.setParameter("withdrawn", includeWithdrawn);
|
||||||
return count(query);
|
return count(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Bundle> findBundlesByName(Context context, Item item, String name) throws SQLException {
|
||||||
|
String hqlQueryString = "SELECT bundles FROM Item as item join item.bundles bundles join bundles.metadata " +
|
||||||
|
"metadatavalue WHERE item = :item";
|
||||||
|
if (StringUtils.isNotBlank(name)) {
|
||||||
|
hqlQueryString += " AND STR(metadatavalue.value) = :text_value ";
|
||||||
|
}
|
||||||
|
Query query = createQuery(context, hqlQueryString);
|
||||||
|
|
||||||
|
query.setParameter("item", item);
|
||||||
|
if (StringUtils.isNotBlank(name)) {
|
||||||
|
query.setParameter("text_value", name);
|
||||||
|
}
|
||||||
|
return query.list();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Item> findBySubmitter(Context context, EPerson eperson, Integer limit, Integer offset)
|
||||||
|
throws SQLException {
|
||||||
|
Criteria criteria = createCriteria(context, Item.class);
|
||||||
|
criteria.addOrder(Order.asc("lastModified"));
|
||||||
|
criteria.add(Restrictions.eq("inArchive", true));
|
||||||
|
criteria.add(Restrictions.eq("withdrawn", false));
|
||||||
|
criteria.add(Restrictions.eq("submitter.id", eperson.getID()));
|
||||||
|
criteria.setFirstResult(offset);
|
||||||
|
criteria.setMaxResults(limit);
|
||||||
|
return list(criteria);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int countItems(Context context, EPerson submitter, boolean includeArchived, boolean includeWithdrawn)
|
||||||
|
throws SQLException {
|
||||||
|
Query query = createQuery(context,
|
||||||
|
"SELECT count(*) FROM Item i join i.submitter submitter WHERE i" +
|
||||||
|
".inArchive=:in_archive AND i.withdrawn=:withdrawn AND submitter = :submitter");
|
||||||
|
query.setParameter("submitter", submitter);
|
||||||
|
query.setParameter("in_archive", includeArchived);
|
||||||
|
query.setParameter("withdrawn", includeWithdrawn);
|
||||||
|
return count(query);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -7,13 +7,16 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.content.factory;
|
package org.dspace.content.factory;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.content.InProgressSubmission;
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.content.WorkspaceItem;
|
import org.dspace.content.WorkspaceItem;
|
||||||
import org.dspace.content.service.BitstreamFormatService;
|
import org.dspace.content.service.BitstreamFormatService;
|
||||||
import org.dspace.content.service.BitstreamService;
|
import org.dspace.content.service.BitstreamService;
|
||||||
|
import org.dspace.content.service.BrowsableObjectService;
|
||||||
import org.dspace.content.service.BundleService;
|
import org.dspace.content.service.BundleService;
|
||||||
import org.dspace.content.service.CollectionService;
|
import org.dspace.content.service.CollectionService;
|
||||||
import org.dspace.content.service.CommunityService;
|
import org.dspace.content.service.CommunityService;
|
||||||
@@ -39,6 +42,8 @@ import org.dspace.workflow.factory.WorkflowServiceFactory;
|
|||||||
*/
|
*/
|
||||||
public abstract class ContentServiceFactory {
|
public abstract class ContentServiceFactory {
|
||||||
|
|
||||||
|
public abstract List<BrowsableObjectService> getBrowsableDSpaceObjectServices();
|
||||||
|
|
||||||
public abstract List<DSpaceObjectService<? extends DSpaceObject>> getDSpaceObjectServices();
|
public abstract List<DSpaceObjectService<? extends DSpaceObject>> getDSpaceObjectServices();
|
||||||
|
|
||||||
public abstract List<DSpaceObjectLegacySupportService<? extends DSpaceObject>>
|
public abstract List<DSpaceObjectLegacySupportService<? extends DSpaceObject>>
|
||||||
@@ -86,16 +91,29 @@ public abstract class ContentServiceFactory {
|
|||||||
return manager;
|
return manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DSpaceObjectService getDSpaceObjectService(int type) {
|
@SuppressWarnings("unchecked")
|
||||||
|
public <T extends DSpaceObject> DSpaceObjectService<T> getDSpaceObjectService(int type) {
|
||||||
for (int i = 0; i < getDSpaceObjectServices().size(); i++) {
|
for (int i = 0; i < getDSpaceObjectServices().size(); i++) {
|
||||||
DSpaceObjectService objectService = getDSpaceObjectServices().get(i);
|
DSpaceObjectService<? extends DSpaceObject> objectService = getDSpaceObjectServices().get(i);
|
||||||
if (objectService.getSupportsTypeConstant() == type) {
|
if (objectService.getSupportsTypeConstant() == type) {
|
||||||
return objectService;
|
return (DSpaceObjectService<T>) objectService;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new UnsupportedOperationException("Unknown DSpace type: " + type);
|
throw new UnsupportedOperationException("Unknown DSpace type: " + type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public <T extends BrowsableDSpaceObject<PK>, PK extends Serializable> BrowsableObjectService<T, PK>
|
||||||
|
getBrowsableDSpaceObjectService(int type) {
|
||||||
|
for (int i = 0; i < getBrowsableDSpaceObjectServices().size(); i++) {
|
||||||
|
BrowsableObjectService objectService = getBrowsableDSpaceObjectServices().get(i);
|
||||||
|
if (objectService.getSupportsTypeConstant() == type) {
|
||||||
|
return (BrowsableObjectService<T, PK>) objectService;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new UnsupportedOperationException("Unknown Browsable DSpace type: " + type);
|
||||||
|
}
|
||||||
|
|
||||||
public DSpaceObjectLegacySupportService<? extends DSpaceObject> getDSpaceLegacyObjectService(int type) {
|
public DSpaceObjectLegacySupportService<? extends DSpaceObject> getDSpaceLegacyObjectService(int type) {
|
||||||
for (int i = 0; i < getDSpaceObjectLegacySupportServices().size(); i++) {
|
for (int i = 0; i < getDSpaceObjectLegacySupportServices().size(); i++) {
|
||||||
DSpaceObjectLegacySupportService<? extends DSpaceObject> objectLegacySupportService =
|
DSpaceObjectLegacySupportService<? extends DSpaceObject> objectLegacySupportService =
|
||||||
|
@@ -12,6 +12,7 @@ import java.util.List;
|
|||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.content.service.BitstreamFormatService;
|
import org.dspace.content.service.BitstreamFormatService;
|
||||||
import org.dspace.content.service.BitstreamService;
|
import org.dspace.content.service.BitstreamService;
|
||||||
|
import org.dspace.content.service.BrowsableObjectService;
|
||||||
import org.dspace.content.service.BundleService;
|
import org.dspace.content.service.BundleService;
|
||||||
import org.dspace.content.service.CollectionService;
|
import org.dspace.content.service.CollectionService;
|
||||||
import org.dspace.content.service.CommunityService;
|
import org.dspace.content.service.CommunityService;
|
||||||
@@ -25,6 +26,7 @@ import org.dspace.content.service.MetadataValueService;
|
|||||||
import org.dspace.content.service.SiteService;
|
import org.dspace.content.service.SiteService;
|
||||||
import org.dspace.content.service.SupervisedItemService;
|
import org.dspace.content.service.SupervisedItemService;
|
||||||
import org.dspace.content.service.WorkspaceItemService;
|
import org.dspace.content.service.WorkspaceItemService;
|
||||||
|
import org.dspace.utils.DSpace;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -35,7 +37,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
*/
|
*/
|
||||||
public class ContentServiceFactoryImpl extends ContentServiceFactory {
|
public class ContentServiceFactoryImpl extends ContentServiceFactory {
|
||||||
|
|
||||||
|
// @Autowired(required = true)
|
||||||
|
// private List<BrowsableObjectService<? extends BrowsableDSpaceObject<? extends Serializable>, Serializable>>
|
||||||
|
// browsableDSpaceObjectServices;
|
||||||
@Autowired(required = true)
|
@Autowired(required = true)
|
||||||
private List<DSpaceObjectService<? extends DSpaceObject>> dSpaceObjectServices;
|
private List<DSpaceObjectService<? extends DSpaceObject>> dSpaceObjectServices;
|
||||||
@Autowired(required = true)
|
@Autowired(required = true)
|
||||||
@@ -68,6 +72,10 @@ public class ContentServiceFactoryImpl extends ContentServiceFactory {
|
|||||||
@Autowired(required = true)
|
@Autowired(required = true)
|
||||||
private SiteService siteService;
|
private SiteService siteService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BrowsableObjectService> getBrowsableDSpaceObjectServices() {
|
||||||
|
return new DSpace().getServiceManager().getServicesByType(BrowsableObjectService.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DSpaceObjectService<? extends DSpaceObject>> getDSpaceObjectServices() {
|
public List<DSpaceObjectService<? extends DSpaceObject>> getDSpaceObjectServices() {
|
||||||
@@ -143,4 +151,5 @@ public class ContentServiceFactoryImpl extends ContentServiceFactory {
|
|||||||
public SiteService getSiteService() {
|
public SiteService getSiteService() {
|
||||||
return siteService;
|
return siteService;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -12,6 +12,7 @@ import java.io.InputStream;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
@@ -31,6 +32,8 @@ import org.dspace.core.Context;
|
|||||||
*/
|
*/
|
||||||
public interface BitstreamService extends DSpaceObjectService<Bitstream>, DSpaceObjectLegacySupportService<Bitstream> {
|
public interface BitstreamService extends DSpaceObjectService<Bitstream>, DSpaceObjectLegacySupportService<Bitstream> {
|
||||||
|
|
||||||
|
public Bitstream find(Context context, UUID id) throws SQLException;
|
||||||
|
|
||||||
public List<Bitstream> findAll(Context context) throws SQLException;
|
public List<Bitstream> findAll(Context context) throws SQLException;
|
||||||
|
|
||||||
public Iterator<Bitstream> findAll(Context context, int limit, int offset) throws SQLException;
|
public Iterator<Bitstream> findAll(Context context, int limit, int offset) throws SQLException;
|
||||||
|
@@ -0,0 +1,44 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.content.service;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Service interface class for any BrowsableDSpaceObject.
|
||||||
|
* All BrowsableObject service classes should implement this class since it offers some basic methods which all
|
||||||
|
* BrowsableObjects are required to have.
|
||||||
|
*
|
||||||
|
* @param <T> class type
|
||||||
|
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||||
|
*/
|
||||||
|
public interface BrowsableObjectService<T extends BrowsableDSpaceObject<PK>, PK extends Serializable> {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic find for when the precise type of a BDSO is not known, just the
|
||||||
|
* a pair of type number and database ID.
|
||||||
|
*
|
||||||
|
* @param context - the context
|
||||||
|
* @param id - id within table of type'd objects
|
||||||
|
* @return the object found, or null if it does not exist.
|
||||||
|
* @throws SQLException only upon failure accessing the database.
|
||||||
|
*/
|
||||||
|
public T find(Context context, PK id) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Constants which this service supports
|
||||||
|
*
|
||||||
|
* @return a org.dspace.core.Constants that represents a BrowsableDSpaceObject type
|
||||||
|
*/
|
||||||
|
public int getSupportsTypeConstant();
|
||||||
|
}
|
@@ -28,19 +28,7 @@ import org.dspace.core.Context;
|
|||||||
* @param <T> class type
|
* @param <T> class type
|
||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
public interface DSpaceObjectService<T extends DSpaceObject> {
|
public interface DSpaceObjectService<T extends DSpaceObject> extends BrowsableObjectService<T, UUID> {
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generic find for when the precise type of a DSO is not known, just the
|
|
||||||
* a pair of type number and database ID.
|
|
||||||
*
|
|
||||||
* @param context - the context
|
|
||||||
* @param id - id within table of type'd objects
|
|
||||||
* @return the object found, or null if it does not exist.
|
|
||||||
* @throws SQLException only upon failure accessing the database.
|
|
||||||
*/
|
|
||||||
public T find(Context context, UUID id) throws SQLException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a proper name for the object. This may return <code>null</code>.
|
* Get a proper name for the object. This may return <code>null</code>.
|
||||||
@@ -251,9 +239,15 @@ public interface DSpaceObjectService<T extends DSpaceObject> {
|
|||||||
public void addMetadata(Context context, T dso, MetadataField metadataField, String lang, List<String> values,
|
public void addMetadata(Context context, T dso, MetadataField metadataField, String lang, List<String> values,
|
||||||
List<String> authorities, List<Integer> confidences) throws SQLException;
|
List<String> authorities, List<Integer> confidences) throws SQLException;
|
||||||
|
|
||||||
|
public void addMetadata(Context context, T dso, MetadataField metadataField, String lang, List<String> values,
|
||||||
|
List<String> authorities, List<Integer> confidences, List<Integer> places) throws SQLException;
|
||||||
|
|
||||||
public void addMetadata(Context context, T dso, MetadataField metadataField, String language, String value,
|
public void addMetadata(Context context, T dso, MetadataField metadataField, String language, String value,
|
||||||
String authority, int confidence) throws SQLException;
|
String authority, int confidence) throws SQLException;
|
||||||
|
|
||||||
|
public void addMetadata(Context context, T dso, MetadataField metadataField, String language, String value,
|
||||||
|
String authority, int confidence, int place) throws SQLException;
|
||||||
|
|
||||||
public void addMetadata(Context context, T dso, MetadataField metadataField, String language, String value)
|
public void addMetadata(Context context, T dso, MetadataField metadataField, String language, String value)
|
||||||
throws SQLException;
|
throws SQLException;
|
||||||
|
|
||||||
@@ -361,13 +355,6 @@ public interface DSpaceObjectService<T extends DSpaceObject> {
|
|||||||
public void delete(Context context, T dso) throws SQLException, AuthorizeException, IOException;
|
public void delete(Context context, T dso) throws SQLException, AuthorizeException, IOException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the Constants which this service supports
|
|
||||||
*
|
|
||||||
* @return a org.dspace.core.Constants that represents a DSpaceObjct type
|
|
||||||
*/
|
|
||||||
public int getSupportsTypeConstant();
|
|
||||||
|
|
||||||
void addAndShiftRightMetadata(Context context, T dso, String schema, String element, String qualifier, String lang,
|
void addAndShiftRightMetadata(Context context, T dso, String schema, String element, String qualifier, String lang,
|
||||||
String value, String authority, int confidence, int index) throws SQLException;
|
String value, String authority, int confidence, int index) throws SQLException;
|
||||||
|
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.content.service;
|
package org.dspace.content.service;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
import org.dspace.app.util.DCInputsReaderException;
|
import org.dspace.app.util.DCInputsReaderException;
|
||||||
@@ -24,7 +25,8 @@ import org.dspace.core.Context;
|
|||||||
* @param <T> class type
|
* @param <T> class type
|
||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
public interface InProgressSubmissionService<T extends InProgressSubmission> {
|
public interface InProgressSubmissionService<T extends InProgressSubmission<ID>, ID extends Serializable>
|
||||||
|
extends BrowsableObjectService<T, ID> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes submission wrapper, doesn't delete item contents
|
* Deletes submission wrapper, doesn't delete item contents
|
||||||
@@ -48,4 +50,5 @@ public interface InProgressSubmissionService<T extends InProgressSubmission> {
|
|||||||
|
|
||||||
public void move(Context context, T inProgressSubmission, Collection fromCollection, Collection toCollection)
|
public void move(Context context, T inProgressSubmission, Collection fromCollection, Collection toCollection)
|
||||||
throws DCInputsReaderException;
|
throws DCInputsReaderException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -37,6 +37,9 @@ import org.dspace.eperson.Group;
|
|||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLegacySupportService<Item> {
|
public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLegacySupportService<Item> {
|
||||||
|
|
||||||
|
public Item find(Context context, UUID id) throws SQLException;
|
||||||
|
|
||||||
public Thumbnail getThumbnail(Context context, Item item, boolean requireOriginal) throws SQLException;
|
public Thumbnail getThumbnail(Context context, Item item, boolean requireOriginal) throws SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -621,6 +624,8 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
|||||||
*/
|
*/
|
||||||
int countNotArchivedItems(Context context) throws SQLException;
|
int countNotArchivedItems(Context context) throws SQLException;
|
||||||
|
|
||||||
|
int countArchivedItems(Context context) throws SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* counts all withdrawn items
|
* counts all withdrawn items
|
||||||
*
|
*
|
||||||
@@ -639,4 +644,12 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
|||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
*/
|
*/
|
||||||
boolean isInProgressSubmission(Context context, Item item) throws SQLException;
|
boolean isInProgressSubmission(Context context, Item item) throws SQLException;
|
||||||
|
|
||||||
|
List<Bundle> getBundles(Context context, Item item, String name) throws SQLException;
|
||||||
|
|
||||||
|
public List<Item> findBySubmitter(Context context, EPerson ep, Integer pageSize, Integer offset)
|
||||||
|
throws SQLException;
|
||||||
|
|
||||||
|
public int countBySubmitter(Context context, EPerson ep) throws SQLException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -27,19 +27,7 @@ import org.dspace.workflow.WorkflowItem;
|
|||||||
*
|
*
|
||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
public interface WorkspaceItemService extends InProgressSubmissionService<WorkspaceItem> {
|
public interface WorkspaceItemService extends InProgressSubmissionService<WorkspaceItem, Integer> {
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a workspace item from the database. The item, collection and
|
|
||||||
* submitter are loaded into memory.
|
|
||||||
*
|
|
||||||
* @param context DSpace context object
|
|
||||||
* @param id ID of the workspace item
|
|
||||||
* @return the workspace item, or null if the ID is invalid.
|
|
||||||
* @throws SQLException if database error
|
|
||||||
*/
|
|
||||||
public WorkspaceItem find(Context context, int id) throws SQLException;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new workspace item, with a new ID. An Item is also created. The
|
* Create a new workspace item, with a new ID. An Item is also created. The
|
||||||
|
@@ -55,11 +55,31 @@ public class Constants {
|
|||||||
*/
|
*/
|
||||||
public static final int EPERSON = 7;
|
public static final int EPERSON = 7;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type of workspace item objects
|
||||||
|
*/
|
||||||
|
public static final int WORKSPACEITEM = 8;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type of workflow item objects
|
||||||
|
*/
|
||||||
|
public static final int WORKFLOWITEM = 9;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type of pool task workflow objects
|
||||||
|
*/
|
||||||
|
public static final int WORKFLOW_POOL = 10;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type of pool task workflow objects
|
||||||
|
*/
|
||||||
|
public static final int WORKFLOW_CLAIMED = 11;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* lets you look up type names from the type IDs
|
* lets you look up type names from the type IDs
|
||||||
*/
|
*/
|
||||||
public static final String[] typeText = {"BITSTREAM", "BUNDLE", "ITEM",
|
public static final String[] typeText = { "BITSTREAM", "BUNDLE", "ITEM", "COLLECTION", "COMMUNITY", "SITE", "GROUP",
|
||||||
"COLLECTION", "COMMUNITY", "SITE", "GROUP", "EPERSON"};
|
"EPERSON", "WORKSPACEITEM", "WORKFLOWITEM", "WORKFLOW POOL", "WORKFLOW CLAIMED" };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Special Bundle and Bitstream Names:
|
* Special Bundle and Bitstream Names:
|
||||||
@@ -179,10 +199,10 @@ public class Constants {
|
|||||||
/**
|
/**
|
||||||
* lets you look up action names from the action IDs
|
* lets you look up action names from the action IDs
|
||||||
*/
|
*/
|
||||||
public static final String[] actionText = {"READ", "WRITE",
|
public static final String[] actionText = { "READ", "WRITE",
|
||||||
"OBSOLETE (DELETE)", "ADD", "REMOVE", "WORKFLOW_STEP_1",
|
"OBSOLETE (DELETE)", "ADD", "REMOVE", "WORKFLOW_STEP_1",
|
||||||
"WORKFLOW_STEP_2", "WORKFLOW_STEP_3", "WORKFLOW_ABORT",
|
"WORKFLOW_STEP_2", "WORKFLOW_STEP_3", "WORKFLOW_ABORT",
|
||||||
"DEFAULT_BITSTREAM_READ", "DEFAULT_ITEM_READ", "ADMIN", "WITHDRAWN_READ"};
|
"DEFAULT_BITSTREAM_READ", "DEFAULT_ITEM_READ", "ADMIN", "WITHDRAWN_READ" };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* generating constants for the relevance array dynamically is simple: just
|
* generating constants for the relevance array dynamically is simple: just
|
||||||
|
@@ -0,0 +1,61 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.storage.rdbms.migration;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
|
||||||
|
import org.dspace.core.Constants;
|
||||||
|
import org.dspace.storage.rdbms.DatabaseUtils;
|
||||||
|
import org.dspace.workflow.factory.WorkflowServiceFactory;
|
||||||
|
import org.dspace.xmlworkflow.service.XmlWorkflowService;
|
||||||
|
import org.flywaydb.core.api.migration.MigrationChecksumProvider;
|
||||||
|
import org.flywaydb.core.api.migration.jdbc.JdbcMigration;
|
||||||
|
import org.flywaydb.core.internal.util.scanner.classpath.ClassPathResource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class automatically adding rptype to the resource policy created with a migration into XML-based Configurable
|
||||||
|
* Workflow system
|
||||||
|
*
|
||||||
|
* @author Luigi Andrea Pascarelli (luigiandrea.pascarelli at 4science.it)
|
||||||
|
*/
|
||||||
|
public class V7_0_2018_04_03__Upgrade_Workflow_Policy implements JdbcMigration, MigrationChecksumProvider {
|
||||||
|
// Size of migration script run
|
||||||
|
protected Integer migration_file_size = -1;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void migrate(Connection connection) throws Exception {
|
||||||
|
// Make sure XML Workflow is enabled, shouldn't even be needed since this class is only loaded if the service
|
||||||
|
// is enabled.
|
||||||
|
if (WorkflowServiceFactory.getInstance().getWorkflowService() instanceof XmlWorkflowService) {
|
||||||
|
// Now, check if the XMLWorkflow table (cwf_workflowitem) already exists in this database
|
||||||
|
if (DatabaseUtils.tableExists(connection, "cwf_workflowitem")) {
|
||||||
|
String dbtype = DatabaseUtils.getDbType(connection);
|
||||||
|
|
||||||
|
String sqlMigrationPath = "org/dspace/storage/rdbms/sqlmigration/workflow/" + dbtype + "/";
|
||||||
|
String dataMigrateSQL = new ClassPathResource(sqlMigrationPath +
|
||||||
|
"xmlworkflow" +
|
||||||
|
"/V7.0_2018.04.03__upgrade_workflow_policy.sql",
|
||||||
|
getClass().getClassLoader())
|
||||||
|
.loadAsString(Constants.DEFAULT_ENCODING);
|
||||||
|
|
||||||
|
// Actually execute the Data migration SQL
|
||||||
|
// This will migrate all existing traditional workflows to the new XMLWorkflow system & tables
|
||||||
|
DatabaseUtils.executeSql(connection, dataMigrateSQL);
|
||||||
|
|
||||||
|
// Assuming both succeeded, save the size of the scripts for getChecksum() below
|
||||||
|
migration_file_size = dataMigrateSQL.length();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getChecksum() {
|
||||||
|
return migration_file_size;
|
||||||
|
}
|
||||||
|
}
|
@@ -15,6 +15,6 @@ import org.dspace.core.ReloadableEntity;
|
|||||||
*
|
*
|
||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
public interface WorkflowItem extends InProgressSubmission, ReloadableEntity<Integer> {
|
public interface WorkflowItem extends InProgressSubmission<Integer>, ReloadableEntity<Integer> {
|
||||||
|
public int getState();
|
||||||
}
|
}
|
||||||
|
@@ -26,20 +26,10 @@ import org.dspace.eperson.EPerson;
|
|||||||
*
|
*
|
||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
public interface WorkflowItemService<T extends WorkflowItem> extends InProgressSubmissionService<T> {
|
public interface WorkflowItemService<T extends WorkflowItem> extends InProgressSubmissionService<T, Integer> {
|
||||||
|
|
||||||
public T create(Context context, Item item, Collection collection) throws SQLException, AuthorizeException;
|
public T create(Context context, Item item, Collection collection) throws SQLException, AuthorizeException;
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a workflow item from the database.
|
|
||||||
*
|
|
||||||
* @param context The relevant DSpace Context.
|
|
||||||
* @param id ID of the workflow item
|
|
||||||
* @return the workflow item, or null if the ID is invalid.
|
|
||||||
* @throws SQLException An exception that provides information on a database access error or other errors.
|
|
||||||
*/
|
|
||||||
public T find(Context context, int id) throws SQLException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return all workflowitems
|
* return all workflowitems
|
||||||
*
|
*
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
package org.dspace.workflowbasic;
|
package org.dspace.workflowbasic;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.FetchType;
|
import javax.persistence.FetchType;
|
||||||
@@ -20,11 +21,14 @@ import javax.persistence.OneToOne;
|
|||||||
import javax.persistence.SequenceGenerator;
|
import javax.persistence.SequenceGenerator;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.workflow.WorkflowItem;
|
import org.dspace.workflow.WorkflowItem;
|
||||||
|
import org.dspace.workflow.factory.WorkflowServiceFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class representing an item going through the workflow process in DSpace
|
* Class representing an item going through the workflow process in DSpace
|
||||||
@@ -145,7 +149,7 @@ public class BasicWorkflowItem implements WorkflowItem {
|
|||||||
return collection;
|
return collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCollection(Collection collection) {
|
public void setCollection(Collection collection) {
|
||||||
this.collection = collection;
|
this.collection = collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,4 +187,33 @@ public class BasicWorkflowItem implements WorkflowItem {
|
|||||||
public void setPublishedBefore(boolean b) {
|
public void setPublishedBefore(boolean b) {
|
||||||
this.publishedBefore = b;
|
this.publishedBefore = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update() throws SQLException, AuthorizeException {
|
||||||
|
|
||||||
|
Context context = null;
|
||||||
|
try {
|
||||||
|
context = new Context();
|
||||||
|
WorkflowServiceFactory.getInstance().getWorkflowItemService().update(context, this);
|
||||||
|
} finally {
|
||||||
|
if (context != null && context.isValid()) {
|
||||||
|
context.abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTypeText() {
|
||||||
|
return "workflowitem";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getType() {
|
||||||
|
return Constants.WORKFLOWITEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHandle() {
|
||||||
|
return getType() + "-" + getID();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@ import org.dspace.authorize.AuthorizeException;
|
|||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.core.LogManager;
|
import org.dspace.core.LogManager;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
@@ -52,6 +53,11 @@ public class BasicWorkflowItemServiceImpl implements BasicWorkflowItemService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSupportsTypeConstant() {
|
||||||
|
return Constants.WORKFLOWITEM;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BasicWorkflowItem create(Context context, Item item, Collection collection)
|
public BasicWorkflowItem create(Context context, Item item, Collection collection)
|
||||||
throws SQLException, AuthorizeException {
|
throws SQLException, AuthorizeException {
|
||||||
@@ -67,7 +73,7 @@ public class BasicWorkflowItemServiceImpl implements BasicWorkflowItemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BasicWorkflowItem find(Context context, int id) throws SQLException {
|
public BasicWorkflowItem find(Context context, Integer id) throws SQLException {
|
||||||
BasicWorkflowItem workflowItem = workflowItemDAO.findByID(context, BasicWorkflowItem.class, id);
|
BasicWorkflowItem workflowItem = workflowItemDAO.findByID(context, BasicWorkflowItem.class, id);
|
||||||
|
|
||||||
if (workflowItem == null) {
|
if (workflowItem == null) {
|
||||||
|
@@ -13,6 +13,7 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
|
import org.dspace.authorize.ResourcePolicy;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
@@ -76,7 +77,7 @@ public class WorkflowRequirementsServiceImpl implements WorkflowRequirementsServ
|
|||||||
inProgressUserService.update(context, ipu);
|
inProgressUserService.update(context, ipu);
|
||||||
|
|
||||||
//Make sure the user has the necessary rights to update the item after the tasks is removed from the pool
|
//Make sure the user has the necessary rights to update the item after the tasks is removed from the pool
|
||||||
xmlWorkflowService.grantUserAllItemPolicies(context, wfi.getItem(), user);
|
xmlWorkflowService.grantUserAllItemPolicies(context, wfi.getItem(), user, ResourcePolicy.TYPE_WORKFLOW);
|
||||||
|
|
||||||
int totalUsers = inProgressUserService.getNumberOfInProgressUsers(context, wfi) + inProgressUserService
|
int totalUsers = inProgressUserService.getNumberOfInProgressUsers(context, wfi) + inProgressUserService
|
||||||
.getNumberOfFinishedUsers(context, wfi);
|
.getNumberOfFinishedUsers(context, wfi);
|
||||||
|
@@ -7,10 +7,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.xmlworkflow;
|
package org.dspace.xmlworkflow;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -18,6 +22,7 @@ import java.util.Locale;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.MissingResourceException;
|
import java.util.MissingResourceException;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.mail.MessagingException;
|
import javax.mail.MessagingException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
@@ -27,6 +32,7 @@ import org.dspace.authorize.AuthorizeException;
|
|||||||
import org.dspace.authorize.ResourcePolicy;
|
import org.dspace.authorize.ResourcePolicy;
|
||||||
import org.dspace.authorize.service.AuthorizeService;
|
import org.dspace.authorize.service.AuthorizeService;
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
|
import org.dspace.content.BitstreamFormat;
|
||||||
import org.dspace.content.Bundle;
|
import org.dspace.content.Bundle;
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.content.DCDate;
|
import org.dspace.content.DCDate;
|
||||||
@@ -34,6 +40,9 @@ import org.dspace.content.Item;
|
|||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchema;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
import org.dspace.content.WorkspaceItem;
|
import org.dspace.content.WorkspaceItem;
|
||||||
|
import org.dspace.content.service.BitstreamFormatService;
|
||||||
|
import org.dspace.content.service.BitstreamService;
|
||||||
|
import org.dspace.content.service.BundleService;
|
||||||
import org.dspace.content.service.InstallItemService;
|
import org.dspace.content.service.InstallItemService;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.content.service.WorkspaceItemService;
|
import org.dspace.content.service.WorkspaceItemService;
|
||||||
@@ -112,6 +121,12 @@ public class XmlWorkflowServiceImpl implements XmlWorkflowService {
|
|||||||
protected XmlWorkflowItemService xmlWorkflowItemService;
|
protected XmlWorkflowItemService xmlWorkflowItemService;
|
||||||
@Autowired(required = true)
|
@Autowired(required = true)
|
||||||
protected GroupService groupService;
|
protected GroupService groupService;
|
||||||
|
@Autowired(required = true)
|
||||||
|
protected BundleService bundleService;
|
||||||
|
@Autowired(required = true)
|
||||||
|
protected BitstreamFormatService bitstreamFormatService;
|
||||||
|
@Autowired(required = true)
|
||||||
|
protected BitstreamService bitstreamService;
|
||||||
|
|
||||||
protected XmlWorkflowServiceImpl() {
|
protected XmlWorkflowServiceImpl() {
|
||||||
|
|
||||||
@@ -672,7 +687,7 @@ public class XmlWorkflowServiceImpl implements XmlWorkflowService {
|
|||||||
task.setWorkflowItem(wi);
|
task.setWorkflowItem(wi);
|
||||||
poolTaskService.update(context, task);
|
poolTaskService.update(context, task);
|
||||||
//Make sure this user has a task
|
//Make sure this user has a task
|
||||||
grantUserAllItemPolicies(context, wi.getItem(), anEpa);
|
grantUserAllItemPolicies(context, wi.getItem(), anEpa, ResourcePolicy.TYPE_WORKFLOW);
|
||||||
}
|
}
|
||||||
for (Group group : assignees.getGroups()) {
|
for (Group group : assignees.getGroups()) {
|
||||||
PoolTask task = poolTaskService.create(context);
|
PoolTask task = poolTaskService.create(context);
|
||||||
@@ -683,7 +698,7 @@ public class XmlWorkflowServiceImpl implements XmlWorkflowService {
|
|||||||
task.setWorkflowItem(wi);
|
task.setWorkflowItem(wi);
|
||||||
poolTaskService.update(context, task);
|
poolTaskService.update(context, task);
|
||||||
//Make sure this user has a task
|
//Make sure this user has a task
|
||||||
grantGroupAllItemPolicies(context, wi.getItem(), group);
|
grantGroupAllItemPolicies(context, wi.getItem(), group, ResourcePolicy.TYPE_WORKFLOW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -701,10 +716,10 @@ public class XmlWorkflowServiceImpl implements XmlWorkflowService {
|
|||||||
task.setWorkflowID(step.getWorkflow().getID());
|
task.setWorkflowID(step.getWorkflow().getID());
|
||||||
claimedTaskService.update(context, task);
|
claimedTaskService.update(context, task);
|
||||||
//Make sure this user has a task
|
//Make sure this user has a task
|
||||||
grantUserAllItemPolicies(context, wi.getItem(), e);
|
grantUserAllItemPolicies(context, wi.getItem(), e, ResourcePolicy.TYPE_WORKFLOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void grantUserAllItemPolicies(Context context, Item item, EPerson epa)
|
public void grantUserAllItemPolicies(Context context, Item item, EPerson epa, String policyType)
|
||||||
throws AuthorizeException, SQLException {
|
throws AuthorizeException, SQLException {
|
||||||
if (epa != null) {
|
if (epa != null) {
|
||||||
//A list of policies the user has for this item
|
//A list of policies the user has for this item
|
||||||
@@ -719,24 +734,24 @@ public class XmlWorkflowServiceImpl implements XmlWorkflowService {
|
|||||||
|
|
||||||
//Make sure we don't add duplicate policies
|
//Make sure we don't add duplicate policies
|
||||||
if (!userHasPolicies.contains(Constants.READ)) {
|
if (!userHasPolicies.contains(Constants.READ)) {
|
||||||
addPolicyToItem(context, item, Constants.READ, epa);
|
addPolicyToItem(context, item, Constants.READ, epa, policyType);
|
||||||
}
|
}
|
||||||
if (!userHasPolicies.contains(Constants.WRITE)) {
|
if (!userHasPolicies.contains(Constants.WRITE)) {
|
||||||
addPolicyToItem(context, item, Constants.WRITE, epa);
|
addPolicyToItem(context, item, Constants.WRITE, epa, policyType);
|
||||||
}
|
}
|
||||||
if (!userHasPolicies.contains(Constants.DELETE)) {
|
if (!userHasPolicies.contains(Constants.DELETE)) {
|
||||||
addPolicyToItem(context, item, Constants.DELETE, epa);
|
addPolicyToItem(context, item, Constants.DELETE, epa, policyType);
|
||||||
}
|
}
|
||||||
if (!userHasPolicies.contains(Constants.ADD)) {
|
if (!userHasPolicies.contains(Constants.ADD)) {
|
||||||
addPolicyToItem(context, item, Constants.ADD, epa);
|
addPolicyToItem(context, item, Constants.ADD, epa, policyType);
|
||||||
}
|
}
|
||||||
if (!userHasPolicies.contains(Constants.REMOVE)) {
|
if (!userHasPolicies.contains(Constants.REMOVE)) {
|
||||||
addPolicyToItem(context, item, Constants.REMOVE, epa);
|
addPolicyToItem(context, item, Constants.REMOVE, epa, policyType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void grantGroupAllItemPolicies(Context context, Item item, Group group)
|
protected void grantGroupAllItemPolicies(Context context, Item item, Group group, String policyType)
|
||||||
throws AuthorizeException, SQLException {
|
throws AuthorizeException, SQLException {
|
||||||
if (group != null) {
|
if (group != null) {
|
||||||
//A list of policies the user has for this item
|
//A list of policies the user has for this item
|
||||||
@@ -750,53 +765,48 @@ public class XmlWorkflowServiceImpl implements XmlWorkflowService {
|
|||||||
}
|
}
|
||||||
//Make sure we don't add duplicate policies
|
//Make sure we don't add duplicate policies
|
||||||
if (!groupHasPolicies.contains(Constants.READ)) {
|
if (!groupHasPolicies.contains(Constants.READ)) {
|
||||||
addGroupPolicyToItem(context, item, Constants.READ, group);
|
addGroupPolicyToItem(context, item, Constants.READ, group, policyType);
|
||||||
}
|
}
|
||||||
if (!groupHasPolicies.contains(Constants.WRITE)) {
|
if (!groupHasPolicies.contains(Constants.WRITE)) {
|
||||||
addGroupPolicyToItem(context, item, Constants.WRITE, group);
|
addGroupPolicyToItem(context, item, Constants.WRITE, group, policyType);
|
||||||
}
|
}
|
||||||
if (!groupHasPolicies.contains(Constants.DELETE)) {
|
if (!groupHasPolicies.contains(Constants.DELETE)) {
|
||||||
addGroupPolicyToItem(context, item, Constants.DELETE, group);
|
addGroupPolicyToItem(context, item, Constants.DELETE, group, policyType);
|
||||||
}
|
}
|
||||||
if (!groupHasPolicies.contains(Constants.ADD)) {
|
if (!groupHasPolicies.contains(Constants.ADD)) {
|
||||||
addGroupPolicyToItem(context, item, Constants.ADD, group);
|
addGroupPolicyToItem(context, item, Constants.ADD, group, policyType);
|
||||||
}
|
}
|
||||||
if (!groupHasPolicies.contains(Constants.REMOVE)) {
|
if (!groupHasPolicies.contains(Constants.REMOVE)) {
|
||||||
addGroupPolicyToItem(context, item, Constants.REMOVE, group);
|
addGroupPolicyToItem(context, item, Constants.REMOVE, group, policyType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addPolicyToItem(Context context, Item item, int type, EPerson epa)
|
protected void addPolicyToItem(Context context, Item item, int action, EPerson epa, String policyType)
|
||||||
throws AuthorizeException, SQLException {
|
|
||||||
addPolicyToItem(context, item, type, epa, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void addPolicyToItem(Context context, Item item, int type, EPerson epa, String policyType)
|
|
||||||
throws AuthorizeException, SQLException {
|
throws AuthorizeException, SQLException {
|
||||||
if (epa != null) {
|
if (epa != null) {
|
||||||
authorizeService.addPolicy(context, item, type, epa, policyType);
|
authorizeService.addPolicy(context, item, action, epa, policyType);
|
||||||
List<Bundle> bundles = item.getBundles();
|
List<Bundle> bundles = item.getBundles();
|
||||||
for (Bundle bundle : bundles) {
|
for (Bundle bundle : bundles) {
|
||||||
authorizeService.addPolicy(context, bundle, type, epa, policyType);
|
authorizeService.addPolicy(context, bundle, action, epa, policyType);
|
||||||
List<Bitstream> bits = bundle.getBitstreams();
|
List<Bitstream> bits = bundle.getBitstreams();
|
||||||
for (Bitstream bit : bits) {
|
for (Bitstream bit : bits) {
|
||||||
authorizeService.addPolicy(context, bit, type, epa, policyType);
|
authorizeService.addPolicy(context, bit, action, epa, policyType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addGroupPolicyToItem(Context context, Item item, int type, Group group)
|
protected void addGroupPolicyToItem(Context context, Item item, int action, Group group, String policyType)
|
||||||
throws AuthorizeException, SQLException {
|
throws AuthorizeException, SQLException {
|
||||||
if (group != null) {
|
if (group != null) {
|
||||||
authorizeService.addPolicy(context, item, type, group);
|
authorizeService.addPolicy(context, item, action, group, policyType);
|
||||||
List<Bundle> bundles = item.getBundles();
|
List<Bundle> bundles = item.getBundles();
|
||||||
for (Bundle bundle : bundles) {
|
for (Bundle bundle : bundles) {
|
||||||
authorizeService.addPolicy(context, bundle, type, group);
|
authorizeService.addPolicy(context, bundle, action, group, policyType);
|
||||||
List<Bitstream> bits = bundle.getBitstreams();
|
List<Bitstream> bits = bundle.getBitstreams();
|
||||||
for (Bitstream bit : bits) {
|
for (Bitstream bit : bits) {
|
||||||
authorizeService.addPolicy(context, bit, type, group);
|
authorizeService.addPolicy(context, bit, action, group, policyType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -882,9 +892,16 @@ public class XmlWorkflowServiceImpl implements XmlWorkflowService {
|
|||||||
|
|
||||||
itemService.update(context, myitem);
|
itemService.update(context, myitem);
|
||||||
|
|
||||||
|
//send an internal message to the submitter
|
||||||
|
createMessage(context, myitem, rejection_message,
|
||||||
|
I18nUtil.getMessage("message.subject.xmlworkflow.rejected.item", context));
|
||||||
|
|
||||||
// convert into personal workspace
|
// convert into personal workspace
|
||||||
WorkspaceItem wsi = returnToWorkspace(context, wi);
|
WorkspaceItem wsi = returnToWorkspace(context, wi);
|
||||||
|
|
||||||
|
// remove policy for controller
|
||||||
|
removeUserItemPolicies(context, myitem, e);
|
||||||
|
revokeReviewerPolicies(context, myitem);
|
||||||
// notify that it's been rejected
|
// notify that it's been rejected
|
||||||
notifyOfReject(context, wi, e, rejection_message);
|
notifyOfReject(context, wi, e, rejection_message);
|
||||||
log.info(LogManager.getHeader(context, "reject_workflow", "workflow_item_id="
|
log.info(LogManager.getHeader(context, "reject_workflow", "workflow_item_id="
|
||||||
@@ -947,7 +964,7 @@ public class XmlWorkflowServiceImpl implements XmlWorkflowService {
|
|||||||
|
|
||||||
Item myitem = wfi.getItem();
|
Item myitem = wfi.getItem();
|
||||||
//Restore permissions for the submitter
|
//Restore permissions for the submitter
|
||||||
grantUserAllItemPolicies(c, myitem, myitem.getSubmitter());
|
grantUserAllItemPolicies(c, myitem, myitem.getSubmitter(), ResourcePolicy.TYPE_SUBMISSION);
|
||||||
|
|
||||||
// FIXME: How should this interact with the workflow system?
|
// FIXME: How should this interact with the workflow system?
|
||||||
// FIXME: Remove license
|
// FIXME: Remove license
|
||||||
@@ -1041,4 +1058,62 @@ public class XmlWorkflowServiceImpl implements XmlWorkflowService {
|
|||||||
public String getMyDSpaceLink() {
|
public String getMyDSpaceLink() {
|
||||||
return ConfigurationManager.getProperty("dspace.url") + "/mydspace";
|
return ConfigurationManager.getProperty("dspace.url") + "/mydspace";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void createMessage(Context context, Item item, String description, String subject)
|
||||||
|
throws SQLException, IOException, AuthorizeException {
|
||||||
|
Bundle message = null;
|
||||||
|
for (Bundle bnd : item.getBundles()) {
|
||||||
|
if ("MESSAGE".equals(bnd.getName())) {
|
||||||
|
message = bnd;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (message == null) {
|
||||||
|
message = bundleService.create(context, item, "MESSAGE");
|
||||||
|
}
|
||||||
|
|
||||||
|
BitstreamFormat bitstreamFormat = bitstreamFormatService.findByMIMEType(context, "text/plain");
|
||||||
|
|
||||||
|
InputStream is = new ByteArrayInputStream(description.getBytes(StandardCharsets.UTF_8));
|
||||||
|
Bitstream bitMessage = bitstreamService.create(context, message, is);
|
||||||
|
bitMessage.setFormat(context, bitstreamFormat);
|
||||||
|
bitstreamService.addMetadata(context, bitMessage, "dc", "title", null, null, subject);
|
||||||
|
bitstreamService.addMetadata(context, bitMessage, "dc", "creator", null, null,
|
||||||
|
context.getCurrentUser().getFullName() + " <" + context.getCurrentUser()
|
||||||
|
.getEmail() + ">");
|
||||||
|
bitstreamService.addMetadata(context, bitMessage, "dc", "date", "issued", null,
|
||||||
|
new DCDate(new Date()).toString());
|
||||||
|
bitstreamService.addMetadata(context, bitMessage, "dc", "type", null, null, "outbound");
|
||||||
|
bitstreamService.update(context, bitMessage);
|
||||||
|
authorizeService.addPolicy(context, bitMessage, Constants.READ, context.getCurrentUser());
|
||||||
|
|
||||||
|
Group controllers = groupService.findByName(context, "Controllers");
|
||||||
|
if (controllers != null) {
|
||||||
|
authorizeService.addPolicy(context, bitMessage, Constants.READ, controllers);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void revokeReviewerPolicies(Context context, Item item) throws SQLException, AuthorizeException {
|
||||||
|
// get bundle "ORIGINAL"
|
||||||
|
Bundle originalBundle;
|
||||||
|
try {
|
||||||
|
originalBundle = itemService.getBundles(item, "ORIGINAL").get(0);
|
||||||
|
} catch (IndexOutOfBoundsException ex) {
|
||||||
|
originalBundle = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove bitstream and bundle level policies
|
||||||
|
if (originalBundle != null) {
|
||||||
|
// We added policies for Bitstreams of the bundle "original" only
|
||||||
|
for (Bitstream bitstream : originalBundle.getBitstreams()) {
|
||||||
|
authorizeService.removeAllPoliciesByDSOAndType(context, bitstream, ResourcePolicy.TYPE_WORKFLOW);
|
||||||
|
}
|
||||||
|
|
||||||
|
authorizeService.removeAllPoliciesByDSOAndType(context, originalBundle, ResourcePolicy.TYPE_WORKFLOW);
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove item level policies
|
||||||
|
authorizeService.removeAllPoliciesByDSOAndType(context, item, ResourcePolicy.TYPE_WORKFLOW);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -70,7 +70,7 @@ public interface XmlWorkflowService extends WorkflowService<XmlWorkflowItem> {
|
|||||||
public void createOwnedTask(Context context, XmlWorkflowItem wi, Step step, WorkflowActionConfig action, EPerson e)
|
public void createOwnedTask(Context context, XmlWorkflowItem wi, Step step, WorkflowActionConfig action, EPerson e)
|
||||||
throws SQLException, AuthorizeException;
|
throws SQLException, AuthorizeException;
|
||||||
|
|
||||||
public void grantUserAllItemPolicies(Context context, Item item, EPerson epa)
|
public void grantUserAllItemPolicies(Context context, Item item, EPerson epa, String actionType)
|
||||||
throws AuthorizeException, SQLException;
|
throws AuthorizeException, SQLException;
|
||||||
|
|
||||||
public void removeUserItemPolicies(Context context, Item item, EPerson e) throws SQLException, AuthorizeException;
|
public void removeUserItemPolicies(Context context, Item item, EPerson e) throws SQLException, AuthorizeException;
|
||||||
|
@@ -24,10 +24,6 @@ public class WorkflowActionConfig {
|
|||||||
private Step step;
|
private Step step;
|
||||||
private boolean requiresUI;
|
private boolean requiresUI;
|
||||||
|
|
||||||
|
|
||||||
private ActionInterface actionUI;
|
|
||||||
|
|
||||||
|
|
||||||
public WorkflowActionConfig(String id) {
|
public WorkflowActionConfig(String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
@@ -63,11 +59,4 @@ public class WorkflowActionConfig {
|
|||||||
return step;
|
return step;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionInterface getActionUI() {
|
|
||||||
return actionUI;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setActionUI(ActionInterface actionUI) {
|
|
||||||
this.actionUI = actionUI;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -11,7 +11,6 @@ import java.io.IOException;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import org.dspace.app.util.Util;
|
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.DCDate;
|
import org.dspace.content.DCDate;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchema;
|
||||||
@@ -45,59 +44,39 @@ public class AcceptEditRejectAction extends ProcessingAction {
|
|||||||
@Override
|
@Override
|
||||||
public ActionResult execute(Context c, XmlWorkflowItem wfi, Step step, HttpServletRequest request)
|
public ActionResult execute(Context c, XmlWorkflowItem wfi, Step step, HttpServletRequest request)
|
||||||
throws SQLException, AuthorizeException, IOException {
|
throws SQLException, AuthorizeException, IOException {
|
||||||
int page = Util.getIntParameter(request, "page");
|
|
||||||
|
|
||||||
switch (page) {
|
if (request.getParameter("submit_approve") != null) {
|
||||||
case MAIN_PAGE:
|
|
||||||
return processMainPage(c, wfi, step, request);
|
return processMainPage(c, wfi, step, request);
|
||||||
case REJECT_PAGE:
|
} else {
|
||||||
|
if (request.getParameter("submit_reject") != null) {
|
||||||
return processRejectPage(c, wfi, step, request);
|
return processRejectPage(c, wfi, step, request);
|
||||||
default:
|
|
||||||
return new ActionResult(ActionResult.TYPE.TYPE_CANCEL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return new ActionResult(ActionResult.TYPE.TYPE_CANCEL);
|
||||||
|
}
|
||||||
|
|
||||||
public ActionResult processMainPage(Context c, XmlWorkflowItem wfi, Step step, HttpServletRequest request)
|
public ActionResult processMainPage(Context c, XmlWorkflowItem wfi, Step step, HttpServletRequest request)
|
||||||
throws SQLException, AuthorizeException {
|
throws SQLException, AuthorizeException {
|
||||||
if (request.getParameter("submit_approve") != null) {
|
|
||||||
//Delete the tasks
|
//Delete the tasks
|
||||||
addApprovedProvenance(c, wfi);
|
addApprovedProvenance(c, wfi);
|
||||||
|
|
||||||
return new ActionResult(ActionResult.TYPE.TYPE_OUTCOME, ActionResult.OUTCOME_COMPLETE);
|
return new ActionResult(ActionResult.TYPE.TYPE_OUTCOME, ActionResult.OUTCOME_COMPLETE);
|
||||||
} else if (request.getParameter("submit_reject") != null) {
|
|
||||||
// Make sure we indicate which page we want to process
|
|
||||||
request.setAttribute("page", REJECT_PAGE);
|
|
||||||
// We have pressed reject item, so take the user to a page where he can reject
|
|
||||||
return new ActionResult(ActionResult.TYPE.TYPE_PAGE);
|
|
||||||
} else {
|
|
||||||
//We pressed the leave button so return to our submissions page
|
|
||||||
return new ActionResult(ActionResult.TYPE.TYPE_SUBMISSION_PAGE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult processRejectPage(Context c, XmlWorkflowItem wfi, Step step, HttpServletRequest request)
|
public ActionResult processRejectPage(Context c, XmlWorkflowItem wfi, Step step, HttpServletRequest request)
|
||||||
throws SQLException, AuthorizeException, IOException {
|
throws SQLException, AuthorizeException, IOException {
|
||||||
if (request.getParameter("submit_reject") != null) {
|
|
||||||
String reason = request.getParameter("reason");
|
String reason = request.getParameter("reason");
|
||||||
if (reason == null || 0 == reason.trim().length()) {
|
if (reason == null || 0 == reason.trim().length()) {
|
||||||
addErrorField(request, "reason");
|
addErrorField(request, "reason");
|
||||||
request.setAttribute("page", REJECT_PAGE);
|
|
||||||
return new ActionResult(ActionResult.TYPE.TYPE_ERROR);
|
return new ActionResult(ActionResult.TYPE.TYPE_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
//We have pressed reject, so remove the task the user has & put it back to a workspace item
|
// We have pressed reject, so remove the task the user has & put it back
|
||||||
XmlWorkflowServiceFactory.getInstance().getXmlWorkflowService()
|
// to a workspace item
|
||||||
.sendWorkflowItemBackSubmission(c, wfi, c.getCurrentUser(),
|
XmlWorkflowServiceFactory.getInstance().getXmlWorkflowService().sendWorkflowItemBackSubmission(c, wfi,
|
||||||
this.getProvenanceStartId(), reason);
|
c.getCurrentUser(), this.getProvenanceStartId(), reason);
|
||||||
|
|
||||||
|
|
||||||
return new ActionResult(ActionResult.TYPE.TYPE_SUBMISSION_PAGE);
|
return new ActionResult(ActionResult.TYPE.TYPE_SUBMISSION_PAGE);
|
||||||
} else {
|
|
||||||
//Cancel, go back to the main task page
|
|
||||||
request.setAttribute("page", MAIN_PAGE);
|
|
||||||
|
|
||||||
return new ActionResult(ActionResult.TYPE.TYPE_PAGE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addApprovedProvenance(Context c, XmlWorkflowItem wfi) throws SQLException, AuthorizeException {
|
private void addApprovedProvenance(Context c, XmlWorkflowItem wfi) throws SQLException, AuthorizeException {
|
||||||
|
@@ -61,16 +61,10 @@ public class ClaimAction extends UserSelectionAction {
|
|||||||
@Override
|
@Override
|
||||||
public ActionResult execute(Context c, XmlWorkflowItem wfi, Step step, HttpServletRequest request)
|
public ActionResult execute(Context c, XmlWorkflowItem wfi, Step step, HttpServletRequest request)
|
||||||
throws SQLException, AuthorizeException, IOException {
|
throws SQLException, AuthorizeException, IOException {
|
||||||
//Check if we are accept this task, or accepting multiple tasks
|
// accept task, or accepting multiple tasks
|
||||||
if (request.getParameter("submit_take_task") != null || request.getParameter("submit_take_tasks") != null) {
|
XmlWorkflowServiceFactory.getInstance().getWorkflowRequirementsService().addClaimedUser(c, wfi, step,
|
||||||
//Add a claimed user to our task
|
c.getCurrentUser());
|
||||||
XmlWorkflowServiceFactory.getInstance().getWorkflowRequirementsService()
|
|
||||||
.addClaimedUser(c, wfi, step, c.getCurrentUser());
|
|
||||||
|
|
||||||
return new ActionResult(ActionResult.TYPE.TYPE_OUTCOME, ActionResult.OUTCOME_COMPLETE);
|
return new ActionResult(ActionResult.TYPE.TYPE_OUTCOME, ActionResult.OUTCOME_COMPLETE);
|
||||||
} else {
|
|
||||||
return new ActionResult(ActionResult.TYPE.TYPE_CANCEL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -7,6 +7,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.xmlworkflow.storedcomponents;
|
package org.dspace.xmlworkflow.storedcomponents;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.FetchType;
|
import javax.persistence.FetchType;
|
||||||
@@ -17,7 +20,10 @@ import javax.persistence.JoinColumn;
|
|||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.SequenceGenerator;
|
import javax.persistence.SequenceGenerator;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
import javax.persistence.Transient;
|
||||||
|
|
||||||
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.core.ReloadableEntity;
|
import org.dspace.core.ReloadableEntity;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
@@ -32,8 +38,10 @@ import org.dspace.eperson.EPerson;
|
|||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "cwf_claimtask")
|
@Table(name = "cwf_claimtask")
|
||||||
public class ClaimedTask implements ReloadableEntity<Integer> {
|
public class ClaimedTask implements ReloadableEntity<Integer>, BrowsableDSpaceObject<Integer> {
|
||||||
|
|
||||||
|
@Transient
|
||||||
|
public transient Map<String, Object> extraInfo = new HashMap<String, Object>();
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "claimtask_id")
|
@Column(name = "claimtask_id")
|
||||||
@@ -115,4 +123,29 @@ public class ClaimedTask implements ReloadableEntity<Integer> {
|
|||||||
public String getWorkflowID() {
|
public String getWorkflowID() {
|
||||||
return workflowId;
|
return workflowId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTypeText() {
|
||||||
|
return "claimedtask";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getType() {
|
||||||
|
return Constants.WORKFLOW_CLAIMED;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isArchived() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDiscoverable() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHandle() {
|
||||||
|
return getType() + "-" + getID();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -14,6 +14,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.xmlworkflow.storedcomponents.dao.ClaimedTaskDAO;
|
import org.dspace.xmlworkflow.storedcomponents.dao.ClaimedTaskDAO;
|
||||||
@@ -36,6 +37,11 @@ public class ClaimedTaskServiceImpl implements ClaimedTaskService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSupportsTypeConstant() {
|
||||||
|
return Constants.WORKFLOW_CLAIMED;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClaimedTask create(Context context) throws SQLException, AuthorizeException {
|
public ClaimedTask create(Context context) throws SQLException, AuthorizeException {
|
||||||
return claimedTaskDAO.create(context, new ClaimedTask());
|
return claimedTaskDAO.create(context, new ClaimedTask());
|
||||||
@@ -46,6 +52,14 @@ public class ClaimedTaskServiceImpl implements ClaimedTaskService {
|
|||||||
return claimedTaskDAO.findByID(context, ClaimedTask.class, id);
|
return claimedTaskDAO.findByID(context, ClaimedTask.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClaimedTask find(Context context, Integer id) throws SQLException {
|
||||||
|
if (id == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return find(context, id.intValue());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Context context, ClaimedTask claimedTask) throws SQLException, AuthorizeException {
|
public void update(Context context, ClaimedTask claimedTask) throws SQLException, AuthorizeException {
|
||||||
update(context, Collections.singletonList(claimedTask));
|
update(context, Collections.singletonList(claimedTask));
|
||||||
|
@@ -7,7 +7,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.xmlworkflow.storedcomponents;
|
package org.dspace.xmlworkflow.storedcomponents;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.FetchType;
|
import javax.persistence.FetchType;
|
||||||
@@ -19,7 +21,10 @@ import javax.persistence.ManyToOne;
|
|||||||
import javax.persistence.OneToOne;
|
import javax.persistence.OneToOne;
|
||||||
import javax.persistence.SequenceGenerator;
|
import javax.persistence.SequenceGenerator;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
import javax.persistence.Transient;
|
||||||
|
|
||||||
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.core.ReloadableEntity;
|
import org.dspace.core.ReloadableEntity;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
@@ -35,7 +40,10 @@ import org.dspace.eperson.Group;
|
|||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "cwf_pooltask")
|
@Table(name = "cwf_pooltask")
|
||||||
public class PoolTask implements ReloadableEntity<Integer> {
|
public class PoolTask implements ReloadableEntity<Integer>, BrowsableDSpaceObject<Integer> {
|
||||||
|
|
||||||
|
@Transient
|
||||||
|
public transient Map<String, Object> extraInfo = new HashMap<String, Object>();
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "pooltask_id")
|
@Column(name = "pooltask_id")
|
||||||
@@ -119,7 +127,7 @@ public class PoolTask implements ReloadableEntity<Integer> {
|
|||||||
this.stepId = stepID;
|
this.stepId = stepID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getStepID() throws SQLException {
|
public String getStepID() {
|
||||||
return stepId;
|
return stepId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,4 +138,29 @@ public class PoolTask implements ReloadableEntity<Integer> {
|
|||||||
public String getActionID() {
|
public String getActionID() {
|
||||||
return this.actionId;
|
return this.actionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTypeText() {
|
||||||
|
return "pooltask";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getType() {
|
||||||
|
return Constants.WORKFLOW_POOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isArchived() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDiscoverable() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHandle() {
|
||||||
|
return getType() + "-" + getID();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.eperson.Group;
|
import org.dspace.eperson.Group;
|
||||||
@@ -47,6 +48,11 @@ public class PoolTaskServiceImpl implements PoolTaskService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSupportsTypeConstant() {
|
||||||
|
return Constants.WORKFLOW_POOL;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PoolTask> findByEperson(Context context, EPerson ePerson)
|
public List<PoolTask> findByEperson(Context context, EPerson ePerson)
|
||||||
throws SQLException, AuthorizeException, IOException {
|
throws SQLException, AuthorizeException, IOException {
|
||||||
@@ -135,6 +141,14 @@ public class PoolTaskServiceImpl implements PoolTaskService {
|
|||||||
return poolTaskDAO.findByID(context, PoolTask.class, id);
|
return poolTaskDAO.findByID(context, PoolTask.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PoolTask find(Context context, Integer id) throws SQLException {
|
||||||
|
if (id == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return find(context, id.intValue());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Context context, PoolTask poolTask) throws SQLException, AuthorizeException {
|
public void update(Context context, PoolTask poolTask) throws SQLException, AuthorizeException {
|
||||||
update(context, Collections.singletonList(poolTask));
|
update(context, Collections.singletonList(poolTask));
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
package org.dspace.xmlworkflow.storedcomponents;
|
package org.dspace.xmlworkflow.storedcomponents;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.FetchType;
|
import javax.persistence.FetchType;
|
||||||
@@ -20,12 +21,16 @@ import javax.persistence.OneToOne;
|
|||||||
import javax.persistence.SequenceGenerator;
|
import javax.persistence.SequenceGenerator;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
import org.dspace.authorize.AuthorizeException;
|
||||||
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.core.ReloadableEntity;
|
import org.dspace.core.ReloadableEntity;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.workflow.WorkflowItem;
|
import org.dspace.workflow.WorkflowItem;
|
||||||
|
import org.dspace.workflow.factory.WorkflowServiceFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class representing an item going through the workflow process in DSpace
|
* Class representing an item going through the workflow process in DSpace
|
||||||
@@ -37,7 +42,7 @@ import org.dspace.workflow.WorkflowItem;
|
|||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "cwf_workflowitem")
|
@Table(name = "cwf_workflowitem")
|
||||||
public class XmlWorkflowItem implements WorkflowItem, ReloadableEntity<Integer> {
|
public class XmlWorkflowItem implements WorkflowItem, ReloadableEntity<Integer>, BrowsableDSpaceObject<Integer> {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "workflowitem_id")
|
@Column(name = "workflowitem_id")
|
||||||
@@ -134,4 +139,49 @@ public class XmlWorkflowItem implements WorkflowItem, ReloadableEntity<Integer>
|
|||||||
this.publishedBefore = b;
|
this.publishedBefore = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update() throws SQLException, AuthorizeException {
|
||||||
|
|
||||||
|
Context context = null;
|
||||||
|
try {
|
||||||
|
context = new Context();
|
||||||
|
WorkflowServiceFactory.getInstance().getWorkflowItemService().update(context, this);
|
||||||
|
} finally {
|
||||||
|
if (context != null && context.isValid()) {
|
||||||
|
context.abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getState() {
|
||||||
|
// FIXME
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTypeText() {
|
||||||
|
return "workflowitem";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getType() {
|
||||||
|
return Constants.WORKFLOWITEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isArchived() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDiscoverable() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHandle() {
|
||||||
|
return getType() + "-" + getID();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@ import org.dspace.authorize.AuthorizeException;
|
|||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.core.LogManager;
|
import org.dspace.core.LogManager;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
@@ -59,6 +60,11 @@ public class XmlWorkflowItemServiceImpl implements XmlWorkflowItemService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSupportsTypeConstant() {
|
||||||
|
return Constants.WORKFLOWITEM;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XmlWorkflowItem create(Context context, Item item, Collection collection)
|
public XmlWorkflowItem create(Context context, Item item, Collection collection)
|
||||||
throws SQLException, AuthorizeException {
|
throws SQLException, AuthorizeException {
|
||||||
@@ -69,7 +75,7 @@ public class XmlWorkflowItemServiceImpl implements XmlWorkflowItemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XmlWorkflowItem find(Context context, int id) throws SQLException {
|
public XmlWorkflowItem find(Context context, Integer id) throws SQLException {
|
||||||
XmlWorkflowItem workflowItem = xmlWorkflowItemDAO.findByID(context, XmlWorkflowItem.class, id);
|
XmlWorkflowItem workflowItem = xmlWorkflowItemDAO.findByID(context, XmlWorkflowItem.class, id);
|
||||||
|
|
||||||
|
|
||||||
|
@@ -11,6 +11,7 @@ import java.sql.SQLException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
|
import org.dspace.content.service.BrowsableObjectService;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.service.DSpaceCRUDService;
|
import org.dspace.service.DSpaceCRUDService;
|
||||||
@@ -24,7 +25,8 @@ import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
|||||||
*
|
*
|
||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
public interface ClaimedTaskService extends DSpaceCRUDService<ClaimedTask> {
|
public interface ClaimedTaskService extends DSpaceCRUDService<ClaimedTask>,
|
||||||
|
BrowsableObjectService<ClaimedTask, Integer> {
|
||||||
|
|
||||||
public List<ClaimedTask> findByWorkflowItem(Context context, XmlWorkflowItem workflowItem) throws SQLException;
|
public List<ClaimedTask> findByWorkflowItem(Context context, XmlWorkflowItem workflowItem) throws SQLException;
|
||||||
|
|
||||||
|
@@ -12,6 +12,7 @@ import java.sql.SQLException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
|
import org.dspace.content.service.BrowsableObjectService;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.service.DSpaceCRUDService;
|
import org.dspace.service.DSpaceCRUDService;
|
||||||
@@ -25,7 +26,7 @@ import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
|||||||
*
|
*
|
||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
public interface PoolTaskService extends DSpaceCRUDService<PoolTask> {
|
public interface PoolTaskService extends DSpaceCRUDService<PoolTask>, BrowsableObjectService<PoolTask, Integer> {
|
||||||
public List<PoolTask> findByEperson(Context context, EPerson ePerson)
|
public List<PoolTask> findByEperson(Context context, EPerson ePerson)
|
||||||
throws SQLException, AuthorizeException, IOException;
|
throws SQLException, AuthorizeException, IOException;
|
||||||
|
|
||||||
|
@@ -0,0 +1,24 @@
|
|||||||
|
--
|
||||||
|
-- The contents of this file are subject to the license and copyright
|
||||||
|
-- detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
-- tree and available online at
|
||||||
|
--
|
||||||
|
-- http://www.dspace.org/license/
|
||||||
|
--
|
||||||
|
|
||||||
|
-- ===============================================================
|
||||||
|
-- WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||||
|
--
|
||||||
|
-- DO NOT MANUALLY RUN THIS DATABASE MIGRATION. IT WILL BE EXECUTED
|
||||||
|
-- AUTOMATICALLY (IF NEEDED) BY "FLYWAY" WHEN YOU STARTUP DSPACE.
|
||||||
|
-- http://flywaydb.org/
|
||||||
|
-- ===============================================================
|
||||||
|
|
||||||
|
----------------------------------------------------------------------------------------------------------------
|
||||||
|
-- This adds TYPE_INHERITED to all old archived items permission due to the change on resource policy management
|
||||||
|
----------------------------------------------------------------------------------------------------------------
|
||||||
|
UPDATE resourcepolicy set rptype = 'TYPE_INHERITED'
|
||||||
|
where resource_type_id = 2 and rptype is null
|
||||||
|
and dspace_object in (
|
||||||
|
select uuid from item where in_archive = 1
|
||||||
|
);
|
@@ -0,0 +1,24 @@
|
|||||||
|
--
|
||||||
|
-- The contents of this file are subject to the license and copyright
|
||||||
|
-- detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
-- tree and available online at
|
||||||
|
--
|
||||||
|
-- http://www.dspace.org/license/
|
||||||
|
--
|
||||||
|
|
||||||
|
-- ===============================================================
|
||||||
|
-- WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||||
|
--
|
||||||
|
-- DO NOT MANUALLY RUN THIS DATABASE MIGRATION. IT WILL BE EXECUTED
|
||||||
|
-- AUTOMATICALLY (IF NEEDED) BY "FLYWAY" WHEN YOU STARTUP DSPACE.
|
||||||
|
-- http://flywaydb.org/
|
||||||
|
-- ===============================================================
|
||||||
|
|
||||||
|
----------------------------------------------------------------------------------------------------------------
|
||||||
|
-- This adds TYPE_INHERITED to all old archived items permission due to the change on resource policy management
|
||||||
|
----------------------------------------------------------------------------------------------------------------
|
||||||
|
UPDATE resourcepolicy set rptype = 'TYPE_INHERITED'
|
||||||
|
where resource_type_id = 2 and rptype is null
|
||||||
|
and dspace_object in (
|
||||||
|
select uuid from item where in_archive = true
|
||||||
|
);
|
@@ -0,0 +1,27 @@
|
|||||||
|
--
|
||||||
|
-- The contents of this file are subject to the license and copyright
|
||||||
|
-- detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
-- tree and available online at
|
||||||
|
--
|
||||||
|
-- http://www.dspace.org/license/
|
||||||
|
--
|
||||||
|
|
||||||
|
-- UPDATE policies for claimtasks
|
||||||
|
-- Item
|
||||||
|
UPDATE RESOURCEPOLICY SET rptype = 'TYPE_WORKFLOW' WHERE dspace_object in (SELECT cwf_workflowitem.item_id FROM cwf_workflowitem INNER JOIN cwf_claimtask ON cwf_workflowitem.workflowitem_id = cwf_claimtask.workflowitem_id JOIN item ON cwf_workflowitem.item_id = item.uuid) AND eperson_id not in (SELECT item.submitter_id FROM cwf_workflowitem JOIN item ON cwf_workflowitem.item_id = item.uuid);
|
||||||
|
|
||||||
|
-- Bundles
|
||||||
|
UPDATE RESOURCEPOLICY SET rptype = 'TYPE_WORKFLOW' WHERE dspace_object in (SELECT item2bundle.bundle_id FROM cwf_workflowitem INNER JOIN cwf_claimtask ON cwf_workflowitem.workflowitem_id = cwf_claimtask.workflowitem_id INNER JOIN item2bundle ON cwf_workflowitem.item_id = item2bundle.item_id) AND eperson_id not in (SELECT item.submitter_id FROM cwf_workflowitem JOIN item ON cwf_workflowitem.item_id = item.uuid);
|
||||||
|
|
||||||
|
-- Bitstreams
|
||||||
|
UPDATE RESOURCEPOLICY SET rptype = 'TYPE_WORKFLOW' WHERE dspace_object in (SELECT bundle2bitstream.bitstream_id FROM cwf_workflowitem INNER JOIN cwf_claimtask ON cwf_workflowitem.workflowitem_id = cwf_claimtask.workflowitem_id INNER JOIN item2bundle ON cwf_workflowitem.item_id = item2bundle.item_id INNER JOIN bundle2bitstream ON item2bundle.bundle_id = bundle2bitstream.bundle_id) AND eperson_id not in (SELECT item.submitter_id FROM cwf_workflowitem JOIN item ON cwf_workflowitem.item_id = item.uuid);
|
||||||
|
|
||||||
|
-- Create policies for pooled tasks
|
||||||
|
-- Item
|
||||||
|
UPDATE RESOURCEPOLICY SET rptype = 'TYPE_WORKFLOW' WHERE dspace_object in (SELECT cwf_workflowitem.item_id FROM cwf_workflowitem INNER JOIN cwf_pooltask ON cwf_workflowitem.workflowitem_id = cwf_pooltask.workflowitem_id) AND eperson_id not in (SELECT item.submitter_id FROM cwf_workflowitem JOIN item ON cwf_workflowitem.item_id = item.uuid);
|
||||||
|
|
||||||
|
-- Bundles
|
||||||
|
UPDATE RESOURCEPOLICY SET rptype = 'TYPE_WORKFLOW' WHERE dspace_object in (SELECT cwf_workflowitem.item_id FROM cwf_workflowitem INNER JOIN cwf_pooltask ON cwf_workflowitem.workflowitem_id = cwf_pooltask.workflowitem_id INNER JOIN item2bundle ON cwf_workflowitem.item_id = item2bundle.item_id) AND eperson_id not in (SELECT item.submitter_id FROM cwf_workflowitem JOIN item ON cwf_workflowitem.item_id = item.uuid);
|
||||||
|
|
||||||
|
-- Bitstreams
|
||||||
|
UPDATE RESOURCEPOLICY SET rptype = 'TYPE_WORKFLOW' WHERE dspace_object in (SELECT cwf_workflowitem.item_id FROM cwf_workflowitem INNER JOIN cwf_pooltask ON cwf_workflowitem.workflowitem_id = cwf_pooltask.workflowitem_id INNER JOIN item2bundle ON cwf_workflowitem.item_id = item2bundle.item_id INNER JOIN bundle2bitstream ON item2bundle.bundle_id = bundle2bitstream.bundle_id) AND eperson_id not in (SELECT item.submitter_id FROM cwf_workflowitem JOIN item ON cwf_workflowitem.item_id = item.uuid);
|
@@ -0,0 +1,27 @@
|
|||||||
|
--
|
||||||
|
-- The contents of this file are subject to the license and copyright
|
||||||
|
-- detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
-- tree and available online at
|
||||||
|
--
|
||||||
|
-- http://www.dspace.org/license/
|
||||||
|
--
|
||||||
|
|
||||||
|
-- UPDATE policies for claimtasks
|
||||||
|
-- Item
|
||||||
|
UPDATE RESOURCEPOLICY SET rptype = 'TYPE_WORKFLOW' WHERE dspace_object in (SELECT cwf_workflowitem.item_id FROM cwf_workflowitem INNER JOIN cwf_claimtask ON cwf_workflowitem.workflowitem_id = cwf_claimtask.workflowitem_id JOIN item ON cwf_workflowitem.item_id = item.uuid) AND eperson_id not in (SELECT item.submitter_id FROM cwf_workflowitem JOIN item ON cwf_workflowitem.item_id = item.uuid);
|
||||||
|
|
||||||
|
-- Bundles
|
||||||
|
UPDATE RESOURCEPOLICY SET rptype = 'TYPE_WORKFLOW' WHERE dspace_object in (SELECT item2bundle.bundle_id FROM cwf_workflowitem INNER JOIN cwf_claimtask ON cwf_workflowitem.workflowitem_id = cwf_claimtask.workflowitem_id INNER JOIN item2bundle ON cwf_workflowitem.item_id = item2bundle.item_id) AND eperson_id not in (SELECT item.submitter_id FROM cwf_workflowitem JOIN item ON cwf_workflowitem.item_id = item.uuid);
|
||||||
|
|
||||||
|
-- Bitstreams
|
||||||
|
UPDATE RESOURCEPOLICY SET rptype = 'TYPE_WORKFLOW' WHERE dspace_object in (SELECT bundle2bitstream.bitstream_id FROM cwf_workflowitem INNER JOIN cwf_claimtask ON cwf_workflowitem.workflowitem_id = cwf_claimtask.workflowitem_id INNER JOIN item2bundle ON cwf_workflowitem.item_id = item2bundle.item_id INNER JOIN bundle2bitstream ON item2bundle.bundle_id = bundle2bitstream.bundle_id) AND eperson_id not in (SELECT item.submitter_id FROM cwf_workflowitem JOIN item ON cwf_workflowitem.item_id = item.uuid);
|
||||||
|
|
||||||
|
-- Create policies for pooled tasks
|
||||||
|
-- Item
|
||||||
|
UPDATE RESOURCEPOLICY SET rptype = 'TYPE_WORKFLOW' WHERE dspace_object in (SELECT cwf_workflowitem.item_id FROM cwf_workflowitem INNER JOIN cwf_pooltask ON cwf_workflowitem.workflowitem_id = cwf_pooltask.workflowitem_id) AND eperson_id not in (SELECT item.submitter_id FROM cwf_workflowitem JOIN item ON cwf_workflowitem.item_id = item.uuid);
|
||||||
|
|
||||||
|
-- Bundles
|
||||||
|
UPDATE RESOURCEPOLICY SET rptype = 'TYPE_WORKFLOW' WHERE dspace_object in (SELECT cwf_workflowitem.item_id FROM cwf_workflowitem INNER JOIN cwf_pooltask ON cwf_workflowitem.workflowitem_id = cwf_pooltask.workflowitem_id INNER JOIN item2bundle ON cwf_workflowitem.item_id = item2bundle.item_id) AND eperson_id not in (SELECT item.submitter_id FROM cwf_workflowitem JOIN item ON cwf_workflowitem.item_id = item.uuid);
|
||||||
|
|
||||||
|
-- Bitstreams
|
||||||
|
UPDATE RESOURCEPOLICY SET rptype = 'TYPE_WORKFLOW' WHERE dspace_object in (SELECT cwf_workflowitem.item_id FROM cwf_workflowitem INNER JOIN cwf_pooltask ON cwf_workflowitem.workflowitem_id = cwf_pooltask.workflowitem_id INNER JOIN item2bundle ON cwf_workflowitem.item_id = item2bundle.item_id INNER JOIN bundle2bitstream ON item2bundle.bundle_id = bundle2bitstream.bundle_id) AND eperson_id not in (SELECT item.submitter_id FROM cwf_workflowitem JOIN item ON cwf_workflowitem.item_id = item.uuid);
|
@@ -88,7 +88,8 @@ public class UUIDLookupRestController implements InitializingBean {
|
|||||||
Context context = null;
|
Context context = null;
|
||||||
try {
|
try {
|
||||||
context = ContextUtil.obtainContext(request);
|
context = ContextUtil.obtainContext(request);
|
||||||
for (DSpaceObjectService dSpaceObjectService : contentServiceFactory.getDSpaceObjectServices()) {
|
for (DSpaceObjectService<? extends DSpaceObject> dSpaceObjectService : contentServiceFactory
|
||||||
|
.getDSpaceObjectServices()) {
|
||||||
DSpaceObject dso = dSpaceObjectService.find(context, uuid);
|
DSpaceObject dso = dSpaceObjectService.find(context, uuid);
|
||||||
if (dso != null) {
|
if (dso != null) {
|
||||||
DSpaceObjectRest dsor = converter.convert(dso);
|
DSpaceObjectRest dsor = converter.convert(dso);
|
||||||
|
@@ -0,0 +1,25 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.app.rest.converter;
|
||||||
|
|
||||||
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the base converter from/to objects in the DSpace API data model and
|
||||||
|
* the REST data model that can be indexed
|
||||||
|
*
|
||||||
|
* @param <M> the Class in the DSpace API data model
|
||||||
|
* @param <R> the Class in the DSpace REST data model
|
||||||
|
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||||
|
*/
|
||||||
|
public abstract class BrowsableDSpaceObjectConverter<M extends BrowsableDSpaceObject,
|
||||||
|
R extends org.dspace.app.rest.model.RestAddressableModel> extends DSpaceConverter<M, R> {
|
||||||
|
|
||||||
|
public abstract boolean supportsModel(BrowsableDSpaceObject bdso);
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,55 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.app.rest.converter;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.dspace.app.rest.model.ClaimedTaskRest;
|
||||||
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.ClaimedTask;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the converter from/to the laimTask in the DSpace API data model
|
||||||
|
* and the REST data model
|
||||||
|
*
|
||||||
|
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class ClaimedTaskConverter
|
||||||
|
extends BrowsableDSpaceObjectConverter<ClaimedTask, org.dspace.app.rest.model.ClaimedTaskRest> {
|
||||||
|
|
||||||
|
private static final Logger log = Logger.getLogger(ClaimedTaskConverter.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private WorkflowItemConverter workflowItemConverter;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClaimedTaskRest fromModel(ClaimedTask obj) {
|
||||||
|
ClaimedTaskRest taskRest = new ClaimedTaskRest();
|
||||||
|
|
||||||
|
XmlWorkflowItem witem = obj.getWorkflowItem();
|
||||||
|
taskRest.setId(obj.getID());
|
||||||
|
taskRest.setWorkflowitem(workflowItemConverter.convert(witem));
|
||||||
|
taskRest.setAction(obj.getActionID());
|
||||||
|
taskRest.setStep(obj.getStepID());
|
||||||
|
return taskRest;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClaimedTask toModel(ClaimedTaskRest obj) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsModel(BrowsableDSpaceObject object) {
|
||||||
|
return object instanceof ClaimedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -11,6 +11,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.dspace.app.rest.model.MetadataEntryRest;
|
import org.dspace.app.rest.model.MetadataEntryRest;
|
||||||
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
|
|
||||||
@@ -24,7 +25,7 @@ import org.dspace.content.MetadataValue;
|
|||||||
*/
|
*/
|
||||||
public abstract class DSpaceObjectConverter<M extends DSpaceObject, R extends org.dspace.app.rest.model
|
public abstract class DSpaceObjectConverter<M extends DSpaceObject, R extends org.dspace.app.rest.model
|
||||||
.DSpaceObjectRest>
|
.DSpaceObjectRest>
|
||||||
extends DSpaceConverter<M, R> {
|
extends BrowsableDSpaceObjectConverter<M, R> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public R fromModel(M obj) {
|
public R fromModel(M obj) {
|
||||||
@@ -51,7 +52,7 @@ public abstract class DSpaceObjectConverter<M extends DSpaceObject, R extends or
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean supportsModel(DSpaceObject object) {
|
public boolean supportsModel(BrowsableDSpaceObject object) {
|
||||||
return object != null && object.getClass().equals(getModelClass());
|
return object != null && object.getClass().equals(getModelClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -0,0 +1,55 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.app.rest.converter;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.dspace.app.rest.model.PoolTaskRest;
|
||||||
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.PoolTask;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the converter from/to the PoolTask in the DSpace API data model
|
||||||
|
* and the REST data model
|
||||||
|
*
|
||||||
|
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class PoolTaskConverter
|
||||||
|
extends BrowsableDSpaceObjectConverter<PoolTask, org.dspace.app.rest.model.PoolTaskRest> {
|
||||||
|
|
||||||
|
private static final Logger log = Logger.getLogger(PoolTaskConverter.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private WorkflowItemConverter workflowItemConverter;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PoolTaskRest fromModel(PoolTask obj) {
|
||||||
|
PoolTaskRest taskRest = new PoolTaskRest();
|
||||||
|
|
||||||
|
XmlWorkflowItem witem = obj.getWorkflowItem();
|
||||||
|
taskRest.setId(obj.getID());
|
||||||
|
taskRest.setWorkflowitem(workflowItemConverter.convert(witem));
|
||||||
|
taskRest.setAction(obj.getActionID());
|
||||||
|
taskRest.setStep(obj.getStepID());
|
||||||
|
return taskRest;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PoolTask toModel(PoolTaskRest obj) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsModel(BrowsableDSpaceObject object) {
|
||||||
|
return object instanceof PoolTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,161 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.app.rest.converter;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.dspace.app.rest.model.ErrorRest;
|
||||||
|
import org.dspace.app.rest.model.SubmissionDefinitionRest;
|
||||||
|
import org.dspace.app.rest.model.SubmissionSectionRest;
|
||||||
|
import org.dspace.app.rest.model.WorkflowItemRest;
|
||||||
|
import org.dspace.app.rest.submit.AbstractRestProcessingStep;
|
||||||
|
import org.dspace.app.rest.submit.SubmissionService;
|
||||||
|
import org.dspace.app.util.SubmissionConfigReader;
|
||||||
|
import org.dspace.app.util.SubmissionConfigReaderException;
|
||||||
|
import org.dspace.app.util.SubmissionStepConfig;
|
||||||
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
|
import org.dspace.content.Collection;
|
||||||
|
import org.dspace.content.Item;
|
||||||
|
import org.dspace.eperson.EPerson;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the converter from/to the WorkflowItem in the DSpace API data model
|
||||||
|
* and the REST data model
|
||||||
|
*
|
||||||
|
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||||
|
* @author Luigi Andrea Pascarelli (luigiandrea.pascarelli at 4science.it)
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class WorkflowItemConverter
|
||||||
|
extends BrowsableDSpaceObjectConverter<XmlWorkflowItem, org.dspace.app.rest.model.WorkflowItemRest> {
|
||||||
|
|
||||||
|
private static final Logger log = Logger.getLogger(WorkflowItemConverter.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EPersonConverter epersonConverter;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ItemConverter itemConverter;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CollectionConverter collectionConverter;
|
||||||
|
|
||||||
|
private SubmissionConfigReader submissionConfigReader;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SubmissionDefinitionConverter submissionDefinitionConverter;
|
||||||
|
@Autowired
|
||||||
|
private SubmissionSectionConverter submissionSectionConverter;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SubmissionService submissionService;
|
||||||
|
|
||||||
|
public WorkflowItemConverter() throws SubmissionConfigReaderException {
|
||||||
|
submissionConfigReader = new SubmissionConfigReader();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WorkflowItemRest fromModel(XmlWorkflowItem obj) {
|
||||||
|
WorkflowItemRest witem = new WorkflowItemRest();
|
||||||
|
|
||||||
|
Collection collection = obj.getCollection();
|
||||||
|
Item item = obj.getItem();
|
||||||
|
EPerson submitter = null;
|
||||||
|
try {
|
||||||
|
submitter = obj.getSubmitter();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
witem.setId(obj.getID());
|
||||||
|
witem.setCollection(collection != null ? collectionConverter.convert(collection) : null);
|
||||||
|
witem.setItem(itemConverter.convert(item));
|
||||||
|
witem.setSubmitter(epersonConverter.convert(submitter));
|
||||||
|
|
||||||
|
// 1. retrieve the submission definition
|
||||||
|
// 2. iterate over the submission section to allow to plugin additional
|
||||||
|
// info
|
||||||
|
|
||||||
|
if (collection != null) {
|
||||||
|
SubmissionDefinitionRest def = submissionDefinitionConverter
|
||||||
|
.convert(submissionConfigReader.getSubmissionConfigByCollection(collection.getHandle()));
|
||||||
|
witem.setSubmissionDefinition(def);
|
||||||
|
for (SubmissionSectionRest sections : def.getPanels()) {
|
||||||
|
SubmissionStepConfig stepConfig = submissionSectionConverter.toModel(sections);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* First, load the step processing class (using the current
|
||||||
|
* class loader)
|
||||||
|
*/
|
||||||
|
ClassLoader loader = this.getClass().getClassLoader();
|
||||||
|
Class stepClass;
|
||||||
|
try {
|
||||||
|
stepClass = loader.loadClass(stepConfig.getProcessingClassName());
|
||||||
|
|
||||||
|
Object stepInstance = stepClass.newInstance();
|
||||||
|
|
||||||
|
if (stepInstance instanceof AbstractRestProcessingStep) {
|
||||||
|
// load the interface for this step
|
||||||
|
AbstractRestProcessingStep stepProcessing =
|
||||||
|
(AbstractRestProcessingStep) stepClass.newInstance();
|
||||||
|
for (ErrorRest error : stepProcessing.validate(submissionService, obj, stepConfig)) {
|
||||||
|
addError(witem.getErrors(), error);
|
||||||
|
}
|
||||||
|
witem.getSections()
|
||||||
|
.put(sections.getId(), stepProcessing.getData(submissionService, obj, stepConfig));
|
||||||
|
} else {
|
||||||
|
log.warn("The submission step class specified by '" + stepConfig.getProcessingClassName() +
|
||||||
|
"' does not extend the class org.dspace.app.rest.submit.AbstractRestProcessingStep!" +
|
||||||
|
" Therefore it cannot be used by the Configurable Submission as the " +
|
||||||
|
"<processing-class>!");
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return witem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public XmlWorkflowItem toModel(WorkflowItemRest obj) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void addError(List<ErrorRest> errors, ErrorRest toAdd) {
|
||||||
|
|
||||||
|
boolean found = false;
|
||||||
|
String i18nKey = toAdd.getMessage();
|
||||||
|
if (StringUtils.isNotBlank(i18nKey)) {
|
||||||
|
for (ErrorRest error : errors) {
|
||||||
|
if (i18nKey.equals(error.getMessage())) {
|
||||||
|
error.getPaths().addAll(toAdd.getPaths());
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
errors.add(toAdd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsModel(BrowsableDSpaceObject object) {
|
||||||
|
return object instanceof XmlWorkflowItem;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,67 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.app.rest.model;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import org.dspace.app.rest.RestResourceController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The WorkflowItem REST Resource
|
||||||
|
*
|
||||||
|
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||||
|
*/
|
||||||
|
public class ClaimedTaskRest extends BaseObjectRest<Integer> {
|
||||||
|
public static final String NAME = "claimedtask";
|
||||||
|
public static final String CATEGORY = RestAddressableModel.WORKFLOW;
|
||||||
|
|
||||||
|
private String step;
|
||||||
|
|
||||||
|
private String action;
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
private WorkflowItemRest workflowitem;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCategory() {
|
||||||
|
return CATEGORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class getController() {
|
||||||
|
return RestResourceController.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStep() {
|
||||||
|
return step;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStep(String step) {
|
||||||
|
this.step = step;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAction() {
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAction(String action) {
|
||||||
|
this.action = action;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorkflowItemRest getWorkflowitem() {
|
||||||
|
return workflowitem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWorkflowitem(WorkflowItemRest workflowitem) {
|
||||||
|
this.workflowitem = workflowitem;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,67 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.app.rest.model;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import org.dspace.app.rest.RestResourceController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The PoolTask REST Resource
|
||||||
|
*
|
||||||
|
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||||
|
*/
|
||||||
|
public class PoolTaskRest extends BaseObjectRest<Integer> {
|
||||||
|
public static final String NAME = "pooltask";
|
||||||
|
public static final String CATEGORY = RestAddressableModel.WORKFLOW;
|
||||||
|
|
||||||
|
private String step;
|
||||||
|
|
||||||
|
private String action;
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
private WorkflowItemRest workflowitem;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCategory() {
|
||||||
|
return CATEGORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class getController() {
|
||||||
|
return RestResourceController.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStep() {
|
||||||
|
return step;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStep(String step) {
|
||||||
|
this.step = step;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAction() {
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAction(String action) {
|
||||||
|
this.action = action;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorkflowItemRest getWorkflowitem() {
|
||||||
|
return workflowitem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWorkflowitem(WorkflowItemRest workflowitem) {
|
||||||
|
this.workflowitem = workflowitem;
|
||||||
|
}
|
||||||
|
}
|
@@ -27,6 +27,7 @@ public interface RestModel extends Serializable {
|
|||||||
public static final String CONFIGURATION = "config";
|
public static final String CONFIGURATION = "config";
|
||||||
public static final String INTEGRATION = "integration";
|
public static final String INTEGRATION = "integration";
|
||||||
public static final String SUBMISSION = "submission";
|
public static final String SUBMISSION = "submission";
|
||||||
|
public static final String WORKFLOW = "workflow";
|
||||||
public static final String AUTHORIZATION = "authz";
|
public static final String AUTHORIZATION = "authz";
|
||||||
|
|
||||||
public String getType();
|
public String getType();
|
||||||
|
@@ -0,0 +1,108 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.app.rest.model;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import org.dspace.app.rest.RestResourceController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The WorkflowItem REST Resource
|
||||||
|
*
|
||||||
|
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||||
|
*/
|
||||||
|
public class WorkflowItemRest extends BaseObjectRest<Integer> {
|
||||||
|
public static final String NAME = "workflowitem";
|
||||||
|
public static final String CATEGORY = RestAddressableModel.WORKFLOW;
|
||||||
|
|
||||||
|
private Date lastModified = new Date();
|
||||||
|
|
||||||
|
private Map<String, Serializable> sections;
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
private CollectionRest collection;
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
private ItemRest item;
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
private SubmissionDefinitionRest submissionDefinition;
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
private EPersonRest submitter;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCategory() {
|
||||||
|
return CATEGORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getLastModified() {
|
||||||
|
return lastModified;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastModified(Date lastModified) {
|
||||||
|
this.lastModified = lastModified;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemRest getItem() {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItem(ItemRest item) {
|
||||||
|
this.item = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SubmissionDefinitionRest getSubmissionDefinition() {
|
||||||
|
return submissionDefinition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubmissionDefinition(SubmissionDefinitionRest submissionDefinition) {
|
||||||
|
this.submissionDefinition = submissionDefinition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EPersonRest getSubmitter() {
|
||||||
|
return submitter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubmitter(EPersonRest submitter) {
|
||||||
|
this.submitter = submitter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class getController() {
|
||||||
|
return RestResourceController.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Serializable> getSections() {
|
||||||
|
if (sections == null) {
|
||||||
|
sections = new HashMap<String, Serializable>();
|
||||||
|
}
|
||||||
|
return sections;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSections(Map<String, Serializable> sections) {
|
||||||
|
this.sections = sections;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CollectionRest getCollection() {
|
||||||
|
return collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCollection(CollectionRest collection) {
|
||||||
|
this.collection = collection;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,25 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.app.rest.model.hateoas;
|
||||||
|
|
||||||
|
import org.dspace.app.rest.model.ClaimedTaskRest;
|
||||||
|
import org.dspace.app.rest.model.hateoas.annotations.RelNameDSpaceResource;
|
||||||
|
import org.dspace.app.rest.utils.Utils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PooledTask Rest HAL Resource. The HAL Resource wraps the REST Resource
|
||||||
|
* adding support for the links and embedded resources
|
||||||
|
*
|
||||||
|
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||||
|
*/
|
||||||
|
@RelNameDSpaceResource(ClaimedTaskRest.NAME)
|
||||||
|
public class ClaimedTaskResource extends DSpaceResource<ClaimedTaskRest> {
|
||||||
|
public ClaimedTaskResource(ClaimedTaskRest witem, Utils utils, String... rels) {
|
||||||
|
super(witem, utils, rels);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,25 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.app.rest.model.hateoas;
|
||||||
|
|
||||||
|
import org.dspace.app.rest.model.PoolTaskRest;
|
||||||
|
import org.dspace.app.rest.model.hateoas.annotations.RelNameDSpaceResource;
|
||||||
|
import org.dspace.app.rest.utils.Utils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PooledTask Rest HAL Resource. The HAL Resource wraps the REST Resource
|
||||||
|
* adding support for the links and embedded resources
|
||||||
|
*
|
||||||
|
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||||
|
*/
|
||||||
|
@RelNameDSpaceResource(PoolTaskRest.NAME)
|
||||||
|
public class PoolTaskResource extends DSpaceResource<PoolTaskRest> {
|
||||||
|
public PoolTaskResource(PoolTaskRest witem, Utils utils, String... rels) {
|
||||||
|
super(witem, utils, rels);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,25 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.app.rest.model.hateoas;
|
||||||
|
|
||||||
|
import org.dspace.app.rest.model.WorkflowItemRest;
|
||||||
|
import org.dspace.app.rest.model.hateoas.annotations.RelNameDSpaceResource;
|
||||||
|
import org.dspace.app.rest.utils.Utils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WorkflowItem Rest HAL Resource. The HAL Resource wraps the REST Resource
|
||||||
|
* adding support for the links and embedded resources
|
||||||
|
*
|
||||||
|
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||||
|
*/
|
||||||
|
@RelNameDSpaceResource(WorkflowItemRest.NAME)
|
||||||
|
public class WorkflowItemResource extends DSpaceResource<WorkflowItemRest> {
|
||||||
|
public WorkflowItemResource(WorkflowItemRest witem, Utils utils, String... rels) {
|
||||||
|
super(witem, utils, rels);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.app.rest.model.patch;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* Strategy interface for resolving values from an operation definition.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* Based on {@link org.springframework.data.rest.webmvc.json.patch.LateObjectEvaluator}
|
||||||
|
*
|
||||||
|
* @author Luigi Andrea Pascarelli (luigiandrea.pascarelli at 4science.it)
|
||||||
|
*/
|
||||||
|
public interface LateObjectEvaluator {
|
||||||
|
|
||||||
|
<T> Object evaluate(Class<T> type);
|
||||||
|
}
|
@@ -0,0 +1,163 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.app.rest.repository;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import javax.mail.MessagingException;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.dspace.app.rest.SearchRestMethod;
|
||||||
|
import org.dspace.app.rest.converter.ClaimedTaskConverter;
|
||||||
|
import org.dspace.app.rest.exception.UnprocessableEntityException;
|
||||||
|
import org.dspace.app.rest.model.ClaimedTaskRest;
|
||||||
|
import org.dspace.app.rest.model.PoolTaskRest;
|
||||||
|
import org.dspace.app.rest.model.hateoas.ClaimedTaskResource;
|
||||||
|
import org.dspace.authorize.AuthorizeException;
|
||||||
|
import org.dspace.content.service.ItemService;
|
||||||
|
import org.dspace.core.Constants;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.eperson.EPerson;
|
||||||
|
import org.dspace.eperson.service.EPersonService;
|
||||||
|
import org.dspace.event.Event;
|
||||||
|
import org.dspace.workflow.WorkflowException;
|
||||||
|
import org.dspace.xmlworkflow.WorkflowConfigurationException;
|
||||||
|
import org.dspace.xmlworkflow.factory.XmlWorkflowServiceFactory;
|
||||||
|
import org.dspace.xmlworkflow.service.WorkflowRequirementsService;
|
||||||
|
import org.dspace.xmlworkflow.service.XmlWorkflowService;
|
||||||
|
import org.dspace.xmlworkflow.state.Step;
|
||||||
|
import org.dspace.xmlworkflow.state.Workflow;
|
||||||
|
import org.dspace.xmlworkflow.state.actions.Action;
|
||||||
|
import org.dspace.xmlworkflow.state.actions.WorkflowActionConfig;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.ClaimedTask;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.service.ClaimedTaskService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the repository responsible to manage PooledTask Rest object
|
||||||
|
*
|
||||||
|
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Component(PoolTaskRest.CATEGORY + "." + ClaimedTaskRest.NAME)
|
||||||
|
public class ClaimedTaskRestRepository extends DSpaceRestRepository<ClaimedTaskRest, Integer> {
|
||||||
|
|
||||||
|
private static final Logger log = Logger.getLogger(ClaimedTaskRestRepository.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ItemService itemService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
EPersonService epersonService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ClaimedTaskService claimedTaskService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ClaimedTaskConverter converter;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
XmlWorkflowService workflowService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
WorkflowRequirementsService workflowRequirementsService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClaimedTaskRest findOne(Context context, Integer id) {
|
||||||
|
ClaimedTask task = null;
|
||||||
|
try {
|
||||||
|
task = claimedTaskService.find(context, id);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
if (task == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return converter.fromModel(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SearchRestMethod(name = "findByUser")
|
||||||
|
public Page<ClaimedTaskRest> findByUser(@Param(value = "uuid") UUID userID, Pageable pageable) {
|
||||||
|
List<ClaimedTask> tasks = null;
|
||||||
|
try {
|
||||||
|
Context context = obtainContext();
|
||||||
|
EPerson ep = epersonService.find(context, userID);
|
||||||
|
tasks = claimedTaskService.findByEperson(context, ep);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
Page<ClaimedTaskRest> page = utils.getPage(tasks, pageable).map(converter);
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<ClaimedTaskRest> getDomainClass() {
|
||||||
|
return ClaimedTaskRest.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClaimedTaskResource wrapResource(ClaimedTaskRest task, String... rels) {
|
||||||
|
return new ClaimedTaskResource(task, utils, rels);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ClaimedTaskRest action(Context context, HttpServletRequest request, Integer id)
|
||||||
|
throws SQLException, IOException, AuthorizeException {
|
||||||
|
ClaimedTask task = null;
|
||||||
|
task = claimedTaskService.find(context, id);
|
||||||
|
XmlWorkflowServiceFactory factory = (XmlWorkflowServiceFactory) XmlWorkflowServiceFactory.getInstance();
|
||||||
|
Workflow workflow;
|
||||||
|
try {
|
||||||
|
workflow = factory.getWorkflowFactory().getWorkflow(task.getWorkflowItem().getCollection());
|
||||||
|
|
||||||
|
Step step = workflow.getStep(task.getStepID());
|
||||||
|
WorkflowActionConfig currentActionConfig = step.getActionConfig(task.getActionID());
|
||||||
|
workflowService
|
||||||
|
.doState(context, context.getCurrentUser(), request, task.getWorkflowItem().getID(), workflow,
|
||||||
|
currentActionConfig);
|
||||||
|
if (!Action.getErrorFields(request).isEmpty()) {
|
||||||
|
throw new UnprocessableEntityException("Missing required fields");
|
||||||
|
}
|
||||||
|
// workflowRequirementsService.removeClaimedUser(context, task.getWorkflowItem(), task.getOwner(), task
|
||||||
|
// .getStepID());
|
||||||
|
context.addEvent(new Event(Event.MODIFY, Constants.ITEM, task.getWorkflowItem().getItem().getID(), null,
|
||||||
|
itemService.getIdentifiers(context, task.getWorkflowItem().getItem())));
|
||||||
|
} catch (WorkflowConfigurationException | MessagingException | WorkflowException e) {
|
||||||
|
throw new RuntimeException(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void delete(Context context, Integer id) {
|
||||||
|
ClaimedTask task = null;
|
||||||
|
try {
|
||||||
|
task = claimedTaskService.find(context, id);
|
||||||
|
XmlWorkflowItem workflowItem = task.getWorkflowItem();
|
||||||
|
workflowService.deleteClaimedTask(context, workflowItem, task);
|
||||||
|
workflowRequirementsService.removeClaimedUser(context, workflowItem, task.getOwner(), task.getStepID());
|
||||||
|
context.addEvent(new Event(Event.MODIFY, Constants.ITEM, workflowItem.getItem().getID(), null,
|
||||||
|
itemService.getIdentifiers(context, workflowItem.getItem())));
|
||||||
|
} catch (SQLException | IOException | WorkflowConfigurationException | AuthorizeException e) {
|
||||||
|
throw new RuntimeException(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<ClaimedTaskRest> findAll(Context context, Pageable pageable) {
|
||||||
|
throw new RuntimeException("Method not allowed!");
|
||||||
|
}
|
||||||
|
}
|
@@ -204,6 +204,18 @@ public abstract class DSpaceRestRepository<T extends RestAddressableModel, ID ex
|
|||||||
throw new RepositoryMethodNotImplementedException(apiCategory, model);
|
throw new RepositoryMethodNotImplementedException(apiCategory, model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public T action(HttpServletRequest request, ID id) throws SQLException, IOException, AuthorizeException {
|
||||||
|
Context context = obtainContext();
|
||||||
|
T entity = action(context, request, id);
|
||||||
|
context.commit();
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected T action(Context context, HttpServletRequest request, ID id)
|
||||||
|
throws SQLException, IOException, AuthorizeException {
|
||||||
|
throw new RuntimeException("No implementation found; Method not allowed!");
|
||||||
|
}
|
||||||
|
|
||||||
public Iterable<T> upload(HttpServletRequest request, MultipartFile uploadfile)
|
public Iterable<T> upload(HttpServletRequest request, MultipartFile uploadfile)
|
||||||
throws SQLException, FileNotFoundException, IOException, AuthorizeException {
|
throws SQLException, FileNotFoundException, IOException, AuthorizeException {
|
||||||
Context context = obtainContext();
|
Context context = obtainContext();
|
||||||
|
@@ -0,0 +1,137 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.app.rest.repository;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import javax.mail.MessagingException;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.dspace.app.rest.SearchRestMethod;
|
||||||
|
import org.dspace.app.rest.converter.PoolTaskConverter;
|
||||||
|
import org.dspace.app.rest.model.PoolTaskRest;
|
||||||
|
import org.dspace.app.rest.model.hateoas.PoolTaskResource;
|
||||||
|
import org.dspace.authorize.AuthorizeException;
|
||||||
|
import org.dspace.content.service.ItemService;
|
||||||
|
import org.dspace.core.Constants;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.eperson.EPerson;
|
||||||
|
import org.dspace.eperson.service.EPersonService;
|
||||||
|
import org.dspace.event.Event;
|
||||||
|
import org.dspace.workflow.WorkflowException;
|
||||||
|
import org.dspace.xmlworkflow.WorkflowConfigurationException;
|
||||||
|
import org.dspace.xmlworkflow.factory.XmlWorkflowServiceFactory;
|
||||||
|
import org.dspace.xmlworkflow.service.WorkflowRequirementsService;
|
||||||
|
import org.dspace.xmlworkflow.service.XmlWorkflowService;
|
||||||
|
import org.dspace.xmlworkflow.state.Step;
|
||||||
|
import org.dspace.xmlworkflow.state.Workflow;
|
||||||
|
import org.dspace.xmlworkflow.state.actions.WorkflowActionConfig;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.PoolTask;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.service.PoolTaskService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the repository responsible to manage PooledTask Rest object
|
||||||
|
*
|
||||||
|
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Component(PoolTaskRest.CATEGORY + "." + PoolTaskRest.NAME)
|
||||||
|
public class PoolTaskRestRepository extends DSpaceRestRepository<PoolTaskRest, Integer> {
|
||||||
|
|
||||||
|
private static final Logger log = Logger.getLogger(PoolTaskRestRepository.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ItemService itemService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
EPersonService epersonService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
PoolTaskService poolTaskService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
PoolTaskConverter converter;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
XmlWorkflowService workflowService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
WorkflowRequirementsService workflowRequirementsService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PoolTaskRest findOne(Context context, Integer id) {
|
||||||
|
PoolTask task = null;
|
||||||
|
try {
|
||||||
|
task = poolTaskService.find(context, id);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
if (task == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return converter.fromModel(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SearchRestMethod(name = "findByUser")
|
||||||
|
public Page<PoolTaskRest> findByUser(@Param(value = "uuid") UUID userID, Pageable pageable) {
|
||||||
|
List<PoolTask> tasks = null;
|
||||||
|
try {
|
||||||
|
Context context = obtainContext();
|
||||||
|
EPerson ep = epersonService.find(context, userID);
|
||||||
|
tasks = poolTaskService.findByEperson(context, ep);
|
||||||
|
} catch (SQLException | AuthorizeException | IOException e) {
|
||||||
|
throw new RuntimeException(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
Page<PoolTaskRest> page = utils.getPage(tasks, pageable).map(converter);
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<PoolTaskRest> getDomainClass() {
|
||||||
|
return PoolTaskRest.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PoolTaskResource wrapResource(PoolTaskRest task, String... rels) {
|
||||||
|
return new PoolTaskResource(task, utils, rels);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PoolTaskRest action(Context context, HttpServletRequest request, Integer id)
|
||||||
|
throws SQLException, IOException, AuthorizeException {
|
||||||
|
PoolTask task = null;
|
||||||
|
try {
|
||||||
|
task = poolTaskService.find(context, id);
|
||||||
|
XmlWorkflowServiceFactory factory = (XmlWorkflowServiceFactory) XmlWorkflowServiceFactory.getInstance();
|
||||||
|
Workflow workflow = factory.getWorkflowFactory().getWorkflow(task.getWorkflowItem().getCollection());
|
||||||
|
Step step = workflow.getStep(task.getStepID());
|
||||||
|
WorkflowActionConfig currentActionConfig = step.getActionConfig(task.getActionID());
|
||||||
|
workflowService
|
||||||
|
.doState(context, context.getCurrentUser(), request, task.getWorkflowItem().getID(), workflow,
|
||||||
|
currentActionConfig);
|
||||||
|
context.addEvent(new Event(Event.MODIFY, Constants.ITEM, task.getWorkflowItem().getItem().getID(), null,
|
||||||
|
itemService.getIdentifiers(context, task.getWorkflowItem().getItem())));
|
||||||
|
} catch (WorkflowConfigurationException | MessagingException | WorkflowException e) {
|
||||||
|
throw new RuntimeException(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<PoolTaskRest> findAll(Context context, Pageable pageable) {
|
||||||
|
throw new RuntimeException("Method not allowed!");
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,335 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.app.rest.repository;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.dspace.app.rest.SearchRestMethod;
|
||||||
|
import org.dspace.app.rest.converter.WorkflowItemConverter;
|
||||||
|
import org.dspace.app.rest.exception.PatchBadRequestException;
|
||||||
|
import org.dspace.app.rest.model.ErrorRest;
|
||||||
|
import org.dspace.app.rest.model.WorkflowItemRest;
|
||||||
|
import org.dspace.app.rest.model.hateoas.WorkflowItemResource;
|
||||||
|
import org.dspace.app.rest.model.patch.Operation;
|
||||||
|
import org.dspace.app.rest.model.patch.Patch;
|
||||||
|
import org.dspace.app.rest.submit.AbstractRestProcessingStep;
|
||||||
|
import org.dspace.app.rest.submit.SubmissionService;
|
||||||
|
import org.dspace.app.rest.submit.UploadableStep;
|
||||||
|
import org.dspace.app.util.SubmissionConfig;
|
||||||
|
import org.dspace.app.util.SubmissionConfigReader;
|
||||||
|
import org.dspace.app.util.SubmissionConfigReaderException;
|
||||||
|
import org.dspace.app.util.SubmissionStepConfig;
|
||||||
|
import org.dspace.authorize.AuthorizeException;
|
||||||
|
import org.dspace.content.service.BitstreamFormatService;
|
||||||
|
import org.dspace.content.service.BitstreamService;
|
||||||
|
import org.dspace.content.service.ItemService;
|
||||||
|
import org.dspace.core.Constants;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.eperson.EPerson;
|
||||||
|
import org.dspace.eperson.EPersonServiceImpl;
|
||||||
|
import org.dspace.event.Event;
|
||||||
|
import org.dspace.services.ConfigurationService;
|
||||||
|
import org.dspace.submit.AbstractProcessingStep;
|
||||||
|
import org.dspace.workflow.WorkflowException;
|
||||||
|
import org.dspace.workflow.WorkflowService;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.service.XmlWorkflowItemService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.PageImpl;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the repository responsible to manage WorkflowItem Rest object
|
||||||
|
*
|
||||||
|
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Component(WorkflowItemRest.CATEGORY + "." + WorkflowItemRest.NAME)
|
||||||
|
public class WorkflowItemRestRepository extends DSpaceRestRepository<WorkflowItemRest, Integer> {
|
||||||
|
|
||||||
|
public static final String OPERATION_PATH_SECTIONS = "sections";
|
||||||
|
|
||||||
|
private static final Logger log = Logger.getLogger(WorkflowItemRestRepository.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
XmlWorkflowItemService wis;
|
||||||
|
@Autowired
|
||||||
|
ItemService itemService;
|
||||||
|
@Autowired
|
||||||
|
BitstreamService bitstreamService;
|
||||||
|
@Autowired
|
||||||
|
BitstreamFormatService bitstreamFormatService;
|
||||||
|
@Autowired
|
||||||
|
ConfigurationService configurationService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
WorkflowItemConverter converter;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SubmissionService submissionService;
|
||||||
|
@Autowired
|
||||||
|
EPersonServiceImpl epersonService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
WorkflowService<XmlWorkflowItem> wfs;
|
||||||
|
|
||||||
|
private SubmissionConfigReader submissionConfigReader;
|
||||||
|
|
||||||
|
public WorkflowItemRestRepository() throws SubmissionConfigReaderException {
|
||||||
|
submissionConfigReader = new SubmissionConfigReader();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WorkflowItemRest findOne(Context context, Integer id) {
|
||||||
|
XmlWorkflowItem witem = null;
|
||||||
|
try {
|
||||||
|
witem = wis.find(context, id);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
if (witem == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return converter.fromModel(witem);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<WorkflowItemRest> findAll(Context context, Pageable pageable) {
|
||||||
|
List<XmlWorkflowItem> witems = null;
|
||||||
|
int total = 0;
|
||||||
|
try {
|
||||||
|
total = wis.countAll(context);
|
||||||
|
witems = wis.findAll(context, pageable.getPageNumber(), pageable.getPageSize());
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
Page<WorkflowItemRest> page = new PageImpl<XmlWorkflowItem>(witems, pageable, total).map(converter);
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SearchRestMethod(name = "findBySubmitter")
|
||||||
|
public Page<WorkflowItemRest> findBySubmitter(@Param(value = "uuid") UUID submitterID, Pageable pageable) {
|
||||||
|
List<XmlWorkflowItem> witems = null;
|
||||||
|
try {
|
||||||
|
Context context = obtainContext();
|
||||||
|
EPerson ep = epersonService.find(context, submitterID);
|
||||||
|
witems = wis.findBySubmitter(context, ep);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
Page<WorkflowItemRest> page = utils.getPage(witems, pageable).map(converter);
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected WorkflowItemRest createAndReturn(Context context) {
|
||||||
|
XmlWorkflowItem source;
|
||||||
|
try {
|
||||||
|
source = submissionService.createWorkflowItem(context, getRequestService().getCurrentRequest());
|
||||||
|
} catch (SQLException | AuthorizeException | WorkflowException e) {
|
||||||
|
throw new RuntimeException(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
//if the item go directly in published status we have to manage a status code 204 with no content
|
||||||
|
if (source.getItem().isArchived()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return converter.convert(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected WorkflowItemRest save(Context context, WorkflowItemRest wfi) {
|
||||||
|
SubmissionConfig submissionConfig =
|
||||||
|
submissionConfigReader.getSubmissionConfigByName(submissionConfigReader.getDefaultSubmissionConfigName());
|
||||||
|
XmlWorkflowItem source = converter.toModel(wfi);
|
||||||
|
for (int stepNum = 0; stepNum < submissionConfig.getNumberOfSteps(); stepNum++) {
|
||||||
|
|
||||||
|
SubmissionStepConfig stepConfig = submissionConfig.getStep(stepNum);
|
||||||
|
/*
|
||||||
|
* First, load the step processing class (using the current
|
||||||
|
* class loader)
|
||||||
|
*/
|
||||||
|
ClassLoader loader = this.getClass().getClassLoader();
|
||||||
|
Class stepClass;
|
||||||
|
try {
|
||||||
|
stepClass = loader.loadClass(stepConfig.getProcessingClassName());
|
||||||
|
|
||||||
|
Object stepInstance = stepClass.newInstance();
|
||||||
|
|
||||||
|
if (stepInstance instanceof AbstractProcessingStep) {
|
||||||
|
// load the JSPStep interface for this step
|
||||||
|
AbstractProcessingStep stepProcessing = (AbstractProcessingStep) stepClass.newInstance();
|
||||||
|
stepProcessing.doPreProcessing(context, source);
|
||||||
|
} else {
|
||||||
|
throw new Exception(
|
||||||
|
"The submission step class specified by '" + stepConfig.getProcessingClassName() +
|
||||||
|
"' does not extend the class org.dspace.submit.AbstractProcessingStep!" +
|
||||||
|
" Therefore it cannot be used by the Configurable Submission as the <processing-class>!");
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
submissionService.saveWorkflowItem(context, source);
|
||||||
|
} catch (SQLException | AuthorizeException e) {
|
||||||
|
throw new RuntimeException(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
return wfi;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<WorkflowItemRest> getDomainClass() {
|
||||||
|
return WorkflowItemRest.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WorkflowItemResource wrapResource(WorkflowItemRest witem, String... rels) {
|
||||||
|
return new WorkflowItemResource(witem, utils, rels);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WorkflowItemRest upload(HttpServletRequest request, String apiCategory, String model, Integer id,
|
||||||
|
String extraField, MultipartFile file) throws Exception {
|
||||||
|
|
||||||
|
Context context = obtainContext();
|
||||||
|
WorkflowItemRest wsi = findOne(id);
|
||||||
|
XmlWorkflowItem source = wis.find(context, id);
|
||||||
|
List<ErrorRest> errors = new ArrayList<ErrorRest>();
|
||||||
|
SubmissionConfig submissionConfig =
|
||||||
|
submissionConfigReader.getSubmissionConfigByName(wsi.getSubmissionDefinition().getName());
|
||||||
|
for (int i = 0; i < submissionConfig.getNumberOfSteps(); i++) {
|
||||||
|
SubmissionStepConfig stepConfig = submissionConfig.getStep(i);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* First, load the step processing class (using the current
|
||||||
|
* class loader)
|
||||||
|
*/
|
||||||
|
ClassLoader loader = this.getClass().getClassLoader();
|
||||||
|
Class stepClass;
|
||||||
|
try {
|
||||||
|
stepClass = loader.loadClass(stepConfig.getProcessingClassName());
|
||||||
|
|
||||||
|
Object stepInstance = stepClass.newInstance();
|
||||||
|
if (UploadableStep.class.isAssignableFrom(stepClass)) {
|
||||||
|
UploadableStep uploadableStep = (UploadableStep) stepInstance;
|
||||||
|
uploadableStep.doPreProcessing(context, source);
|
||||||
|
ErrorRest err =
|
||||||
|
uploadableStep.upload(context, submissionService, stepConfig, source, file, extraField);
|
||||||
|
uploadableStep.doPostProcessing(context, source);
|
||||||
|
if (err != null) {
|
||||||
|
errors.add(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
wsi = converter.convert(source);
|
||||||
|
|
||||||
|
if (errors.isEmpty()) {
|
||||||
|
wsi.setStatus(true);
|
||||||
|
} else {
|
||||||
|
wsi.setStatus(false);
|
||||||
|
wsi.getErrors().addAll(errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
context.commit();
|
||||||
|
return wsi;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void patch(Context context, HttpServletRequest request, String apiCategory, String model, Integer id,
|
||||||
|
Patch patch) throws SQLException, AuthorizeException {
|
||||||
|
List<Operation> operations = patch.getOperations();
|
||||||
|
WorkflowItemRest wsi = findOne(id);
|
||||||
|
XmlWorkflowItem source = wis.find(context, id);
|
||||||
|
for (Operation op : operations) {
|
||||||
|
//the value in the position 0 is a null value
|
||||||
|
String[] path = op.getPath().substring(1).split("/", 3);
|
||||||
|
if (OPERATION_PATH_SECTIONS.equals(path[0])) {
|
||||||
|
String section = path[1];
|
||||||
|
evaluatePatch(context, request, source, wsi, section, op);
|
||||||
|
} else {
|
||||||
|
throw new PatchBadRequestException(
|
||||||
|
"Patch path operation need to starts with '" + OPERATION_PATH_SECTIONS + "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wis.update(context, source);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void evaluatePatch(Context context, HttpServletRequest request, XmlWorkflowItem source,
|
||||||
|
WorkflowItemRest wsi, String section, Operation op) {
|
||||||
|
SubmissionConfig submissionConfig =
|
||||||
|
submissionConfigReader.getSubmissionConfigByName(wsi.getSubmissionDefinition().getName());
|
||||||
|
for (int stepNum = 0; stepNum < submissionConfig.getNumberOfSteps(); stepNum++) {
|
||||||
|
|
||||||
|
SubmissionStepConfig stepConfig = submissionConfig.getStep(stepNum);
|
||||||
|
|
||||||
|
if (section.equals(stepConfig.getId())) {
|
||||||
|
/*
|
||||||
|
* First, load the step processing class (using the current
|
||||||
|
* class loader)
|
||||||
|
*/
|
||||||
|
ClassLoader loader = this.getClass().getClassLoader();
|
||||||
|
Class stepClass;
|
||||||
|
try {
|
||||||
|
stepClass = loader.loadClass(stepConfig.getProcessingClassName());
|
||||||
|
|
||||||
|
Object stepInstance = stepClass.newInstance();
|
||||||
|
|
||||||
|
if (stepInstance instanceof AbstractRestProcessingStep) {
|
||||||
|
// load the JSPStep interface for this step
|
||||||
|
AbstractRestProcessingStep stepProcessing =
|
||||||
|
(AbstractRestProcessingStep) stepClass.newInstance();
|
||||||
|
stepProcessing.doPreProcessing(context, source);
|
||||||
|
stepProcessing.doPatchProcessing(context, getRequestService().getCurrentRequest(), source, op);
|
||||||
|
stepProcessing.doPostProcessing(context, source);
|
||||||
|
} else {
|
||||||
|
throw new PatchBadRequestException(
|
||||||
|
"The submission step class specified by '" + stepConfig.getProcessingClassName() +
|
||||||
|
"' does not extend the class org.dspace.submit.AbstractProcessingStep!" +
|
||||||
|
" Therefore it cannot be used by the Configurable Submission as the <processing-class>!");
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void delete(Context context, Integer id) {
|
||||||
|
XmlWorkflowItem witem = null;
|
||||||
|
try {
|
||||||
|
witem = wis.find(context, id);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
wfs.abort(context, witem, context.getCurrentUser());
|
||||||
|
context.addEvent(new Event(Event.MODIFY, Constants.ITEM, witem.getItem().getID(), null,
|
||||||
|
itemService.getIdentifiers(context, witem.getItem())));
|
||||||
|
} catch (SQLException | AuthorizeException | IOException e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -67,7 +67,7 @@ public class AuthorizeServicePermissionEvaluatorPlugin extends DSpaceObjectPermi
|
|||||||
ePerson = ePersonService.findByEmail(context, (String) authentication.getPrincipal());
|
ePerson = ePersonService.findByEmail(context, (String) authentication.getPrincipal());
|
||||||
|
|
||||||
UUID dsoId = UUIDUtils.fromString(targetId.toString());
|
UUID dsoId = UUIDUtils.fromString(targetId.toString());
|
||||||
DSpaceObjectService dSpaceObjectService =
|
DSpaceObjectService<DSpaceObject> dSpaceObjectService =
|
||||||
contentServiceFactory.getDSpaceObjectService(Constants.getTypeID(targetType));
|
contentServiceFactory.getDSpaceObjectService(Constants.getTypeID(targetType));
|
||||||
|
|
||||||
if (dSpaceObjectService != null && dsoId != null) {
|
if (dSpaceObjectService != null && dsoId != null) {
|
||||||
|
@@ -15,7 +15,7 @@ import org.dspace.app.rest.model.ErrorRest;
|
|||||||
import org.dspace.app.rest.model.patch.Operation;
|
import org.dspace.app.rest.model.patch.Operation;
|
||||||
import org.dspace.app.rest.submit.step.validation.Validation;
|
import org.dspace.app.rest.submit.step.validation.Validation;
|
||||||
import org.dspace.app.util.SubmissionStepConfig;
|
import org.dspace.app.util.SubmissionStepConfig;
|
||||||
import org.dspace.content.WorkspaceItem;
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
import org.dspace.services.model.Request;
|
import org.dspace.services.model.Request;
|
||||||
@@ -37,12 +37,13 @@ public interface AbstractRestProcessingStep extends ListenerProcessingStep {
|
|||||||
|
|
||||||
public static final String UPLOAD_STEP_METADATA_PATH = "metadata";
|
public static final String UPLOAD_STEP_METADATA_PATH = "metadata";
|
||||||
|
|
||||||
public <T extends Serializable> T getData(SubmissionService submissionService, WorkspaceItem obj,
|
public <T extends Serializable> T getData(SubmissionService submissionService, InProgressSubmission obj,
|
||||||
SubmissionStepConfig config) throws Exception;
|
SubmissionStepConfig config) throws Exception;
|
||||||
|
|
||||||
default public List<ErrorRest> validate(SubmissionService submissionService, WorkspaceItem obj,
|
default public List<ErrorRest> validate(SubmissionService submissionService, InProgressSubmission obj,
|
||||||
SubmissionStepConfig config) throws Exception {
|
SubmissionStepConfig config) throws Exception {
|
||||||
List<ErrorRest> errors = new ArrayList<ErrorRest>();
|
List<ErrorRest> errors = new ArrayList<ErrorRest>();
|
||||||
|
|
||||||
List<Validation> validations = DSpaceServicesFactory.getInstance().getServiceManager()
|
List<Validation> validations = DSpaceServicesFactory.getInstance().getServiceManager()
|
||||||
.getServicesByType(Validation.class);
|
.getServicesByType(Validation.class);
|
||||||
if (validations != null) {
|
if (validations != null) {
|
||||||
@@ -55,7 +56,7 @@ public interface AbstractRestProcessingStep extends ListenerProcessingStep {
|
|||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doPatchProcessing(Context context, Request currentRequest, WorkspaceItem source, Operation op)
|
public void doPatchProcessing(Context context, Request currentRequest, InProgressSubmission source, Operation op)
|
||||||
throws Exception;
|
throws Exception;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -7,10 +7,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.app.rest.submit;
|
package org.dspace.app.rest.submit;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.Reader;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
@@ -18,24 +21,35 @@ import org.apache.log4j.Logger;
|
|||||||
import org.atteo.evo.inflector.English;
|
import org.atteo.evo.inflector.English;
|
||||||
import org.dspace.app.rest.converter.BitstreamFormatConverter;
|
import org.dspace.app.rest.converter.BitstreamFormatConverter;
|
||||||
import org.dspace.app.rest.converter.ResourcePolicyConverter;
|
import org.dspace.app.rest.converter.ResourcePolicyConverter;
|
||||||
|
import org.dspace.app.rest.converter.WorkspaceItemConverter;
|
||||||
|
import org.dspace.app.rest.exception.UnprocessableEntityException;
|
||||||
import org.dspace.app.rest.model.BitstreamRest;
|
import org.dspace.app.rest.model.BitstreamRest;
|
||||||
import org.dspace.app.rest.model.CheckSumRest;
|
import org.dspace.app.rest.model.CheckSumRest;
|
||||||
import org.dspace.app.rest.model.MetadataValueRest;
|
import org.dspace.app.rest.model.MetadataValueRest;
|
||||||
import org.dspace.app.rest.model.ResourcePolicyRest;
|
import org.dspace.app.rest.model.ResourcePolicyRest;
|
||||||
|
import org.dspace.app.rest.model.WorkspaceItemRest;
|
||||||
import org.dspace.app.rest.model.step.UploadBitstreamRest;
|
import org.dspace.app.rest.model.step.UploadBitstreamRest;
|
||||||
import org.dspace.app.rest.utils.ContextUtil;
|
import org.dspace.app.rest.utils.ContextUtil;
|
||||||
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.authorize.ResourcePolicy;
|
import org.dspace.authorize.ResourcePolicy;
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
import org.dspace.content.WorkspaceItem;
|
import org.dspace.content.WorkspaceItem;
|
||||||
import org.dspace.content.service.CollectionService;
|
import org.dspace.content.service.CollectionService;
|
||||||
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.content.service.WorkspaceItemService;
|
import org.dspace.content.service.WorkspaceItemService;
|
||||||
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.core.Utils;
|
import org.dspace.core.Utils;
|
||||||
|
import org.dspace.event.Event;
|
||||||
import org.dspace.services.ConfigurationService;
|
import org.dspace.services.ConfigurationService;
|
||||||
import org.dspace.services.RequestService;
|
import org.dspace.services.RequestService;
|
||||||
import org.dspace.services.model.Request;
|
import org.dspace.services.model.Request;
|
||||||
|
import org.dspace.workflow.WorkflowException;
|
||||||
|
import org.dspace.workflow.WorkflowItemService;
|
||||||
|
import org.dspace.workflow.WorkflowService;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@@ -54,34 +68,39 @@ public class SubmissionService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
protected CollectionService collectionService;
|
protected CollectionService collectionService;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
protected ItemService itemService;
|
||||||
|
@Autowired
|
||||||
protected WorkspaceItemService workspaceItemService;
|
protected WorkspaceItemService workspaceItemService;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
protected WorkflowItemService workflowItemService;
|
||||||
|
@Autowired
|
||||||
|
protected WorkflowService<XmlWorkflowItem> workflowService;
|
||||||
|
@Autowired
|
||||||
private RequestService requestService;
|
private RequestService requestService;
|
||||||
@Autowired(required = true)
|
@Autowired(required = true)
|
||||||
BitstreamFormatConverter bfConverter;
|
BitstreamFormatConverter bfConverter;
|
||||||
|
@Autowired
|
||||||
|
WorkspaceItemConverter workspaceItemConverter;
|
||||||
@Autowired(required = true)
|
@Autowired(required = true)
|
||||||
ResourcePolicyConverter aCConverter;
|
ResourcePolicyConverter aCConverter;
|
||||||
|
|
||||||
public WorkspaceItem createWorkspaceItem(Context context, Request request) {
|
public WorkspaceItem createWorkspaceItem(Context context, Request request) throws SQLException, AuthorizeException {
|
||||||
WorkspaceItem wsi = null;
|
WorkspaceItem wsi = null;
|
||||||
String collectionUUID = request.getHttpServletRequest().getParameter("collection");
|
String uuid = request.getHttpServletRequest().getParameter("collection");
|
||||||
if (StringUtils.isBlank(collectionUUID)) {
|
if (StringUtils.isBlank(uuid)) {
|
||||||
String uuid = configurationService.getProperty("submission.default.collection");
|
uuid = configurationService.getProperty("submission.default.collection");
|
||||||
|
}
|
||||||
|
|
||||||
Collection collection = null;
|
Collection collection = null;
|
||||||
try {
|
|
||||||
if (StringUtils.isNotBlank(uuid)) {
|
if (StringUtils.isNotBlank(uuid)) {
|
||||||
collection = collectionService.find(context, UUID.fromString(uuid));
|
collection = collectionService.find(context, UUID.fromString(uuid));
|
||||||
} else {
|
} else {
|
||||||
collection = collectionService.findAll(context, 1, 0).get(0);
|
collection = collectionService.findAll(context, 1, 0).get(0);
|
||||||
}
|
}
|
||||||
wsi = workspaceItemService.create(context, collection, true);
|
wsi = workspaceItemService.create(context, collection, true);
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e.getMessage(), e);
|
context.addEvent(new Event(Event.MODIFY, Constants.ITEM, wsi.getItem().getID(), null,
|
||||||
}
|
itemService.getIdentifiers(context, wsi.getItem())));
|
||||||
} else {
|
|
||||||
//TODO manage setup of default collection in the case WSI it is not null
|
|
||||||
//TODO manage setup of collection discovered into request
|
|
||||||
}
|
|
||||||
return wsi;
|
return wsi;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,4 +163,51 @@ public class SubmissionService {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public XmlWorkflowItem createWorkflowItem(Context context, Request currentRequest)
|
||||||
|
throws SQLException, AuthorizeException, WorkflowException {
|
||||||
|
Reader reader = null;
|
||||||
|
XmlWorkflowItem wi = null;
|
||||||
|
try {
|
||||||
|
reader = currentRequest.getHttpServletRequest().getReader();
|
||||||
|
char[] arr = new char[1024];
|
||||||
|
StringBuilder buffer = new StringBuilder();
|
||||||
|
int numCharsRead = reader.read(arr, 0, arr.length);
|
||||||
|
buffer.append(arr, 0, numCharsRead);
|
||||||
|
if (numCharsRead == arr.length) {
|
||||||
|
throw new RuntimeException("Malformed body... too long");
|
||||||
|
}
|
||||||
|
String regex = "\\/api\\/" + WorkspaceItemRest.CATEGORY + "\\/" + English.plural(WorkspaceItemRest.NAME)
|
||||||
|
+ "\\/";
|
||||||
|
String[] split = buffer.toString().split(regex, 2);
|
||||||
|
if (split.length != 2) {
|
||||||
|
throw new RuntimeException("Malformed body..." + buffer);
|
||||||
|
}
|
||||||
|
WorkspaceItem wsi = workspaceItemService.find(context, Integer.parseInt(split[1]));
|
||||||
|
|
||||||
|
if (!workspaceItemConverter.convert(wsi).getErrors().isEmpty()) {
|
||||||
|
throw new UnprocessableEntityException(
|
||||||
|
"Start workflow failed due to validation error on workspaceitem");
|
||||||
|
}
|
||||||
|
|
||||||
|
wi = workflowService.start(context, wsi);
|
||||||
|
|
||||||
|
context.addEvent(new Event(Event.MODIFY, Constants.ITEM, wi.getItem().getID(), null,
|
||||||
|
itemService.getIdentifiers(context, wi.getItem())));
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e.getMessage(), e);
|
||||||
|
} finally {
|
||||||
|
if (reader != null) {
|
||||||
|
try {
|
||||||
|
reader.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return wi;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveWorkflowItem(Context context, XmlWorkflowItem source) throws SQLException, AuthorizeException {
|
||||||
|
workflowItemService.update(context, source);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
package org.dspace.app.rest.submit.factory.impl;
|
package org.dspace.app.rest.submit.factory.impl;
|
||||||
|
|
||||||
import org.dspace.app.rest.model.patch.Operation;
|
import org.dspace.app.rest.model.patch.Operation;
|
||||||
import org.dspace.content.WorkspaceItem;
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.services.model.Request;
|
import org.dspace.services.model.Request;
|
||||||
|
|
||||||
@@ -21,12 +21,12 @@ import org.dspace.services.model.Request;
|
|||||||
public abstract class AddPatchOperation<T extends Object> extends PatchOperation<T> {
|
public abstract class AddPatchOperation<T extends Object> extends PatchOperation<T> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(Context context, Request currentRequest, WorkspaceItem source, Operation operation)
|
public void perform(Context context, Request currentRequest, InProgressSubmission source, Operation operation)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
add(context, currentRequest, source, operation.getPath(), operation.getValue());
|
add(context, currentRequest, source, operation.getPath(), operation.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract void add(Context context, Request currentRequest, WorkspaceItem source, String string, Object value)
|
abstract void add(Context context, Request currentRequest, InProgressSubmission source, String string, Object value)
|
||||||
throws Exception;
|
throws Exception;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -10,18 +10,18 @@ package org.dspace.app.rest.submit.factory.impl;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.dspace.app.rest.model.MetadataValueRest;
|
import org.dspace.app.rest.model.MetadataValueRest;
|
||||||
|
import org.dspace.app.rest.model.patch.LateObjectEvaluator;
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
import org.dspace.content.Bundle;
|
import org.dspace.content.Bundle;
|
||||||
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
import org.dspace.content.WorkspaceItem;
|
|
||||||
import org.dspace.content.service.BitstreamService;
|
import org.dspace.content.service.BitstreamService;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.services.model.Request;
|
import org.dspace.services.model.Request;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.rest.webmvc.json.patch.LateObjectEvaluator;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,7 +40,7 @@ public class BitstreamMetadataValueAddPatchOperation extends MetadataValueAddPat
|
|||||||
ItemService itemService;
|
ItemService itemService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void add(Context context, Request currentRequest, WorkspaceItem source, String path, Object value)
|
void add(Context context, Request currentRequest, InProgressSubmission source, String path, Object value)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
//"path": "/sections/upload/files/0/metadata/dc.title/2"
|
//"path": "/sections/upload/files/0/metadata/dc.title/2"
|
||||||
//"abspath": "/files/0/metadata/dc.title/2"
|
//"abspath": "/files/0/metadata/dc.title/2"
|
||||||
|
@@ -11,8 +11,8 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
import org.dspace.content.Bundle;
|
import org.dspace.content.Bundle;
|
||||||
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.WorkspaceItem;
|
|
||||||
import org.dspace.content.service.BitstreamService;
|
import org.dspace.content.service.BitstreamService;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
@@ -36,7 +36,7 @@ public class BitstreamMetadataValueMovePatchOperation extends MetadataValueMoveP
|
|||||||
ItemService itemService;
|
ItemService itemService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void move(Context context, Request currentRequest, WorkspaceItem source, String path, String from)
|
void move(Context context, Request currentRequest, InProgressSubmission source, String path, String from)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
//"path": "/sections/upload/files/0/metadata/dc.title/2"
|
//"path": "/sections/upload/files/0/metadata/dc.title/2"
|
||||||
//"abspath": "/files/0/metadata/dc.title/2"
|
//"abspath": "/files/0/metadata/dc.title/2"
|
||||||
|
@@ -11,8 +11,8 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
import org.dspace.content.Bundle;
|
import org.dspace.content.Bundle;
|
||||||
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.WorkspaceItem;
|
|
||||||
import org.dspace.content.service.BitstreamService;
|
import org.dspace.content.service.BitstreamService;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
@@ -36,7 +36,7 @@ public class BitstreamMetadataValueRemovePatchOperation extends MetadataValueRem
|
|||||||
ItemService itemService;
|
ItemService itemService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void remove(Context context, Request currentRequest, WorkspaceItem source, String path, Object value)
|
void remove(Context context, Request currentRequest, InProgressSubmission source, String path, Object value)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
//"path": "/sections/upload/files/0/metadata/dc.title/2"
|
//"path": "/sections/upload/files/0/metadata/dc.title/2"
|
||||||
//"abspath": "/files/0/metadata/dc.title/2"
|
//"abspath": "/files/0/metadata/dc.title/2"
|
||||||
|
@@ -11,18 +11,18 @@ import java.sql.SQLException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.dspace.app.rest.model.MetadataValueRest;
|
import org.dspace.app.rest.model.MetadataValueRest;
|
||||||
|
import org.dspace.app.rest.model.patch.LateObjectEvaluator;
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
import org.dspace.content.Bundle;
|
import org.dspace.content.Bundle;
|
||||||
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
import org.dspace.content.WorkspaceItem;
|
|
||||||
import org.dspace.content.service.BitstreamService;
|
import org.dspace.content.service.BitstreamService;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.services.model.Request;
|
import org.dspace.services.model.Request;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.rest.webmvc.json.patch.LateObjectEvaluator;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,7 +39,7 @@ public class BitstreamMetadataValueReplacePatchOperation extends MetadataValueRe
|
|||||||
ItemService itemService;
|
ItemService itemService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void replace(Context context, Request currentRequest, WorkspaceItem source, String path, Object value)
|
void replace(Context context, Request currentRequest, InProgressSubmission source, String path, Object value)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
//"path": "/sections/upload/files/0/metadata/dc.title/2"
|
//"path": "/sections/upload/files/0/metadata/dc.title/2"
|
||||||
//"abspath": "/files/0/metadata/dc.title/2"
|
//"abspath": "/files/0/metadata/dc.title/2"
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.app.rest.submit.factory.impl;
|
package org.dspace.app.rest.submit.factory.impl;
|
||||||
|
|
||||||
import org.dspace.content.WorkspaceItem;
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.content.service.BundleService;
|
import org.dspace.content.service.BundleService;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
@@ -39,7 +39,7 @@ public class BitstreamMovePatchOperation extends MovePatchOperation<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void move(Context context, Request currentRequest, WorkspaceItem source, String path, String from)
|
void move(Context context, Request currentRequest, InProgressSubmission source, String path, String from)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
@@ -11,8 +11,8 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
import org.dspace.content.Bundle;
|
import org.dspace.content.Bundle;
|
||||||
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.WorkspaceItem;
|
|
||||||
import org.dspace.content.service.BundleService;
|
import org.dspace.content.service.BundleService;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
@@ -34,7 +34,7 @@ public class BitstreamRemovePatchOperation extends RemovePatchOperation<String>
|
|||||||
BundleService bundleService;
|
BundleService bundleService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void remove(Context context, Request currentRequest, WorkspaceItem source, String path, Object value)
|
void remove(Context context, Request currentRequest, InProgressSubmission source, String path, Object value)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
||||||
String absPath = getAbsolutePath(path);
|
String absPath = getAbsolutePath(path);
|
||||||
|
@@ -11,6 +11,7 @@ import java.sql.SQLException;
|
|||||||
|
|
||||||
import org.dspace.app.util.DCInputsReaderException;
|
import org.dspace.app.util.DCInputsReaderException;
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.content.WorkspaceItem;
|
import org.dspace.content.WorkspaceItem;
|
||||||
import org.dspace.content.service.CollectionService;
|
import org.dspace.content.service.CollectionService;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
@@ -35,13 +36,17 @@ public class CollectionReplacePatchOperation extends ReplacePatchOperation<Strin
|
|||||||
WorkspaceItemService workspaceItemService;
|
WorkspaceItemService workspaceItemService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void replace(Context context, Request currentRequest, WorkspaceItem source, String path, Object value)
|
void replace(Context context, Request currentRequest, InProgressSubmission source, String path, Object value)
|
||||||
throws SQLException, DCInputsReaderException {
|
throws SQLException, DCInputsReaderException {
|
||||||
String uuid = (String) value;
|
|
||||||
|
|
||||||
|
if (!(source instanceof WorkspaceItem)) {
|
||||||
|
throw new IllegalArgumentException("the replace operation is only supported on workspaceitem");
|
||||||
|
}
|
||||||
|
WorkspaceItem wsi = (WorkspaceItem) source;
|
||||||
|
String uuid = (String) value;
|
||||||
Collection fromCollection = source.getCollection();
|
Collection fromCollection = source.getCollection();
|
||||||
Collection toCollection = collectionService.find(context, UUIDUtils.fromString(uuid));
|
Collection toCollection = collectionService.find(context, UUIDUtils.fromString(uuid));
|
||||||
workspaceItemService.move(context, source, fromCollection, toCollection);
|
workspaceItemService.move(context, wsi, fromCollection, toCollection);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -11,14 +11,14 @@ import java.sql.SQLException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.dspace.app.rest.model.MetadataValueRest;
|
import org.dspace.app.rest.model.MetadataValueRest;
|
||||||
|
import org.dspace.app.rest.model.patch.LateObjectEvaluator;
|
||||||
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
import org.dspace.content.WorkspaceItem;
|
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.services.model.Request;
|
import org.dspace.services.model.Request;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.rest.webmvc.json.patch.LateObjectEvaluator;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -70,7 +70,7 @@ public class ItemMetadataValueAddPatchOperation extends MetadataValueAddPatchOpe
|
|||||||
ItemService itemService;
|
ItemService itemService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void add(Context context, Request currentRequest, WorkspaceItem source, String path, Object value)
|
void add(Context context, Request currentRequest, InProgressSubmission source, String path, Object value)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
String[] split = getAbsolutePath(path).split("/");
|
String[] split = getAbsolutePath(path).split("/");
|
||||||
// if split size is one so we have a call to initialize or replace
|
// if split size is one so we have a call to initialize or replace
|
||||||
|
@@ -7,8 +7,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.app.rest.submit.factory.impl;
|
package org.dspace.app.rest.submit.factory.impl;
|
||||||
|
|
||||||
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.WorkspaceItem;
|
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.services.model.Request;
|
import org.dspace.services.model.Request;
|
||||||
@@ -35,7 +35,7 @@ public class ItemMetadataValueMovePatchOperation extends MetadataValueMovePatchO
|
|||||||
ItemService itemService;
|
ItemService itemService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void move(Context context, Request currentRequest, WorkspaceItem source, String path, String from)
|
void move(Context context, Request currentRequest, InProgressSubmission source, String path, String from)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
String[] splitTo = getAbsolutePath(path).split("/");
|
String[] splitTo = getAbsolutePath(path).split("/");
|
||||||
|
|
||||||
|
@@ -7,8 +7,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.app.rest.submit.factory.impl;
|
package org.dspace.app.rest.submit.factory.impl;
|
||||||
|
|
||||||
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.WorkspaceItem;
|
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.services.model.Request;
|
import org.dspace.services.model.Request;
|
||||||
@@ -43,7 +43,7 @@ public class ItemMetadataValueRemovePatchOperation extends MetadataValueRemovePa
|
|||||||
ItemService itemService;
|
ItemService itemService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void remove(Context context, Request currentRequest, WorkspaceItem source, String path, Object value)
|
void remove(Context context, Request currentRequest, InProgressSubmission source, String path, Object value)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
String[] split = getAbsolutePath(path).split("/");
|
String[] split = getAbsolutePath(path).split("/");
|
||||||
if (split.length == 1) {
|
if (split.length == 1) {
|
||||||
|
@@ -10,14 +10,14 @@ package org.dspace.app.rest.submit.factory.impl;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.dspace.app.rest.model.MetadataValueRest;
|
import org.dspace.app.rest.model.MetadataValueRest;
|
||||||
|
import org.dspace.app.rest.model.patch.LateObjectEvaluator;
|
||||||
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
import org.dspace.content.WorkspaceItem;
|
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.services.model.Request;
|
import org.dspace.services.model.Request;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.rest.webmvc.json.patch.LateObjectEvaluator;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -50,7 +50,7 @@ public class ItemMetadataValueReplacePatchOperation extends MetadataValueReplace
|
|||||||
ItemService itemService;
|
ItemService itemService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void replace(Context context, Request currentRequest, WorkspaceItem source, String path, Object value)
|
void replace(Context context, Request currentRequest, InProgressSubmission source, String path, Object value)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
String[] split = getAbsolutePath(path).split("/");
|
String[] split = getAbsolutePath(path).split("/");
|
||||||
|
|
||||||
|
@@ -8,9 +8,9 @@
|
|||||||
package org.dspace.app.rest.submit.factory.impl;
|
package org.dspace.app.rest.submit.factory.impl;
|
||||||
|
|
||||||
import org.apache.commons.lang.BooleanUtils;
|
import org.apache.commons.lang.BooleanUtils;
|
||||||
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.LicenseUtils;
|
import org.dspace.content.LicenseUtils;
|
||||||
import org.dspace.content.WorkspaceItem;
|
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
@@ -49,7 +49,7 @@ public class LicenseAddPatchOperation extends AddPatchOperation<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void add(Context context, Request currentRequest, WorkspaceItem source, String path, Object value)
|
void add(Context context, Request currentRequest, InProgressSubmission source, String path, Object value)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
||||||
Boolean grant = BooleanUtils.toBooleanObject((String) value);
|
Boolean grant = BooleanUtils.toBooleanObject((String) value);
|
||||||
|
@@ -7,8 +7,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.app.rest.submit.factory.impl;
|
package org.dspace.app.rest.submit.factory.impl;
|
||||||
|
|
||||||
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.WorkspaceItem;
|
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.services.model.Request;
|
import org.dspace.services.model.Request;
|
||||||
@@ -32,7 +32,7 @@ public class LicenseRemovePatchOperation extends RemovePatchOperation<String> {
|
|||||||
ItemService itemService;
|
ItemService itemService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void remove(Context context, Request currentRequest, WorkspaceItem source, String path, Object value)
|
void remove(Context context, Request currentRequest, InProgressSubmission source, String path, Object value)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
Item item = source.getItem();
|
Item item = source.getItem();
|
||||||
itemService.removeDSpaceLicense(context, item);
|
itemService.removeDSpaceLicense(context, item);
|
||||||
|
@@ -8,9 +8,9 @@
|
|||||||
package org.dspace.app.rest.submit.factory.impl;
|
package org.dspace.app.rest.submit.factory.impl;
|
||||||
|
|
||||||
import org.apache.commons.lang.BooleanUtils;
|
import org.apache.commons.lang.BooleanUtils;
|
||||||
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.LicenseUtils;
|
import org.dspace.content.LicenseUtils;
|
||||||
import org.dspace.content.WorkspaceItem;
|
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
@@ -30,7 +30,7 @@ public class LicenseReplacePatchOperation extends ReplacePatchOperation<String>
|
|||||||
ItemService itemService;
|
ItemService itemService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void replace(Context context, Request currentRequest, WorkspaceItem source, String path, Object value)
|
void replace(Context context, Request currentRequest, InProgressSubmission source, String path, Object value)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
||||||
Boolean grant = BooleanUtils.toBooleanObject((String) value);
|
Boolean grant = BooleanUtils.toBooleanObject((String) value);
|
||||||
|
@@ -9,7 +9,7 @@ package org.dspace.app.rest.submit.factory.impl;
|
|||||||
|
|
||||||
import org.dspace.app.rest.model.patch.MoveOperation;
|
import org.dspace.app.rest.model.patch.MoveOperation;
|
||||||
import org.dspace.app.rest.model.patch.Operation;
|
import org.dspace.app.rest.model.patch.Operation;
|
||||||
import org.dspace.content.WorkspaceItem;
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.services.model.Request;
|
import org.dspace.services.model.Request;
|
||||||
|
|
||||||
@@ -22,12 +22,12 @@ import org.dspace.services.model.Request;
|
|||||||
public abstract class MovePatchOperation<T extends Object> extends PatchOperation<T> {
|
public abstract class MovePatchOperation<T extends Object> extends PatchOperation<T> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(Context context, Request currentRequest, WorkspaceItem source, Operation operation)
|
public void perform(Context context, Request currentRequest, InProgressSubmission source, Operation operation)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
move(context, currentRequest, source, operation.getPath(), ((MoveOperation) operation).getFrom());
|
move(context, currentRequest, source, operation.getPath(), ((MoveOperation) operation).getFrom());
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract void move(Context context, Request currentRequest, WorkspaceItem source, String path, String from)
|
abstract void move(Context context, Request currentRequest, InProgressSubmission source, String path, String from)
|
||||||
throws Exception;
|
throws Exception;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -10,11 +10,11 @@ package org.dspace.app.rest.submit.factory.impl;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.dspace.app.rest.model.patch.LateObjectEvaluator;
|
||||||
import org.dspace.app.rest.model.patch.Operation;
|
import org.dspace.app.rest.model.patch.Operation;
|
||||||
import org.dspace.content.WorkspaceItem;
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.services.model.Request;
|
import org.dspace.services.model.Request;
|
||||||
import org.springframework.data.rest.webmvc.json.patch.LateObjectEvaluator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to abstract the HTTP PATCH method operation
|
* Class to abstract the HTTP PATCH method operation
|
||||||
@@ -24,7 +24,8 @@ import org.springframework.data.rest.webmvc.json.patch.LateObjectEvaluator;
|
|||||||
*/
|
*/
|
||||||
public abstract class PatchOperation<T extends Object> {
|
public abstract class PatchOperation<T extends Object> {
|
||||||
|
|
||||||
public abstract void perform(Context context, Request currentRequest, WorkspaceItem source, Operation operation)
|
public abstract void perform(Context context, Request currentRequest, InProgressSubmission source,
|
||||||
|
Operation operation)
|
||||||
throws Exception;
|
throws Exception;
|
||||||
|
|
||||||
public List<T> evaluateArrayObject(LateObjectEvaluator value) {
|
public List<T> evaluateArrayObject(LateObjectEvaluator value) {
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
package org.dspace.app.rest.submit.factory.impl;
|
package org.dspace.app.rest.submit.factory.impl;
|
||||||
|
|
||||||
import org.dspace.app.rest.model.patch.Operation;
|
import org.dspace.app.rest.model.patch.Operation;
|
||||||
import org.dspace.content.WorkspaceItem;
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.services.model.Request;
|
import org.dspace.services.model.Request;
|
||||||
|
|
||||||
@@ -21,12 +21,13 @@ import org.dspace.services.model.Request;
|
|||||||
public abstract class RemovePatchOperation<T extends Object> extends PatchOperation<T> {
|
public abstract class RemovePatchOperation<T extends Object> extends PatchOperation<T> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(Context context, Request currentRequest, WorkspaceItem source, Operation operation)
|
public void perform(Context context, Request currentRequest, InProgressSubmission source, Operation operation)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
remove(context, currentRequest, source, operation.getPath(), operation.getValue());
|
remove(context, currentRequest, source, operation.getPath(), operation.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract void remove(Context context, Request currentRequest, WorkspaceItem source, String string, Object value)
|
abstract void remove(Context context, Request currentRequest, InProgressSubmission source, String string,
|
||||||
|
Object value)
|
||||||
throws Exception;
|
throws Exception;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
package org.dspace.app.rest.submit.factory.impl;
|
package org.dspace.app.rest.submit.factory.impl;
|
||||||
|
|
||||||
import org.dspace.app.rest.model.patch.Operation;
|
import org.dspace.app.rest.model.patch.Operation;
|
||||||
import org.dspace.content.WorkspaceItem;
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.services.model.Request;
|
import org.dspace.services.model.Request;
|
||||||
|
|
||||||
@@ -21,12 +21,13 @@ import org.dspace.services.model.Request;
|
|||||||
public abstract class ReplacePatchOperation<T extends Object> extends PatchOperation<T> {
|
public abstract class ReplacePatchOperation<T extends Object> extends PatchOperation<T> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(Context context, Request currentRequest, WorkspaceItem source, Operation operation)
|
public void perform(Context context, Request currentRequest, InProgressSubmission source, Operation operation)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
replace(context, currentRequest, source, operation.getPath(), operation.getValue());
|
replace(context, currentRequest, source, operation.getPath(), operation.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract void replace(Context context, Request currentRequest, WorkspaceItem source, String string, Object value)
|
abstract void replace(Context context, Request currentRequest, InProgressSubmission source, String string,
|
||||||
|
Object value)
|
||||||
throws Exception;
|
throws Exception;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -12,12 +12,13 @@ import java.util.Date;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.dspace.app.rest.model.ResourcePolicyRest;
|
import org.dspace.app.rest.model.ResourcePolicyRest;
|
||||||
|
import org.dspace.app.rest.model.patch.LateObjectEvaluator;
|
||||||
import org.dspace.authorize.ResourcePolicy;
|
import org.dspace.authorize.ResourcePolicy;
|
||||||
import org.dspace.authorize.service.AuthorizeService;
|
import org.dspace.authorize.service.AuthorizeService;
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
import org.dspace.content.Bundle;
|
import org.dspace.content.Bundle;
|
||||||
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.WorkspaceItem;
|
|
||||||
import org.dspace.content.service.BitstreamService;
|
import org.dspace.content.service.BitstreamService;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
@@ -28,7 +29,6 @@ import org.dspace.eperson.service.EPersonService;
|
|||||||
import org.dspace.eperson.service.GroupService;
|
import org.dspace.eperson.service.GroupService;
|
||||||
import org.dspace.services.model.Request;
|
import org.dspace.services.model.Request;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.rest.webmvc.json.patch.LateObjectEvaluator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Submission "add" operation to add resource policies in the Bitstream
|
* Submission "add" operation to add resource policies in the Bitstream
|
||||||
@@ -52,7 +52,7 @@ public class ResourcePolicyAddPatchOperation extends AddPatchOperation<ResourceP
|
|||||||
EPersonService epersonService;
|
EPersonService epersonService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void add(Context context, Request currentRequest, WorkspaceItem source, String path, Object value)
|
void add(Context context, Request currentRequest, InProgressSubmission source, String path, Object value)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
//"path": "/sections/upload/files/0/accessConditions"
|
//"path": "/sections/upload/files/0/accessConditions"
|
||||||
String[] split = getAbsolutePath(path).split("/");
|
String[] split = getAbsolutePath(path).split("/");
|
||||||
|
@@ -14,8 +14,8 @@ import org.dspace.authorize.ResourcePolicy;
|
|||||||
import org.dspace.authorize.service.ResourcePolicyService;
|
import org.dspace.authorize.service.ResourcePolicyService;
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
import org.dspace.content.Bundle;
|
import org.dspace.content.Bundle;
|
||||||
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.WorkspaceItem;
|
|
||||||
import org.dspace.content.service.BitstreamService;
|
import org.dspace.content.service.BitstreamService;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
@@ -40,7 +40,7 @@ public class ResourcePolicyRemovePatchOperation extends RemovePatchOperation<Res
|
|||||||
BitstreamService bitstreamService;
|
BitstreamService bitstreamService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void remove(Context context, Request currentRequest, WorkspaceItem source, String path, Object value)
|
void remove(Context context, Request currentRequest, InProgressSubmission source, String path, Object value)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
// "path" : "/sections/upload/files/0/accessConditions/0"
|
// "path" : "/sections/upload/files/0/accessConditions/0"
|
||||||
// "abspath" : "/files/0/accessConditions/0"
|
// "abspath" : "/files/0/accessConditions/0"
|
||||||
|
@@ -11,13 +11,14 @@ import java.util.Date;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.dspace.app.rest.model.ResourcePolicyRest;
|
import org.dspace.app.rest.model.ResourcePolicyRest;
|
||||||
|
import org.dspace.app.rest.model.patch.LateObjectEvaluator;
|
||||||
import org.dspace.authorize.ResourcePolicy;
|
import org.dspace.authorize.ResourcePolicy;
|
||||||
import org.dspace.authorize.service.AuthorizeService;
|
import org.dspace.authorize.service.AuthorizeService;
|
||||||
import org.dspace.authorize.service.ResourcePolicyService;
|
import org.dspace.authorize.service.ResourcePolicyService;
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
import org.dspace.content.Bundle;
|
import org.dspace.content.Bundle;
|
||||||
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.WorkspaceItem;
|
|
||||||
import org.dspace.content.service.BitstreamService;
|
import org.dspace.content.service.BitstreamService;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
@@ -28,7 +29,6 @@ import org.dspace.eperson.service.EPersonService;
|
|||||||
import org.dspace.eperson.service.GroupService;
|
import org.dspace.eperson.service.GroupService;
|
||||||
import org.dspace.services.model.Request;
|
import org.dspace.services.model.Request;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.rest.webmvc.json.patch.LateObjectEvaluator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Submission "replace" operation to replace resource policies in the Bitstream
|
* Submission "replace" operation to replace resource policies in the Bitstream
|
||||||
@@ -54,7 +54,7 @@ public class ResourcePolicyReplacePatchOperation extends ReplacePatchOperation<R
|
|||||||
EPersonService epersonService;
|
EPersonService epersonService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void replace(Context context, Request currentRequest, WorkspaceItem source, String path, Object value)
|
void replace(Context context, Request currentRequest, InProgressSubmission source, String path, Object value)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
// "path": "/sections/upload/files/0/accessConditions/0"
|
// "path": "/sections/upload/files/0/accessConditions/0"
|
||||||
// "abspath": "/files/0/accessConditions/0"
|
// "abspath": "/files/0/accessConditions/0"
|
||||||
|
@@ -15,7 +15,7 @@ import org.dspace.app.rest.submit.SubmissionService;
|
|||||||
import org.dspace.app.rest.submit.factory.PatchOperationFactory;
|
import org.dspace.app.rest.submit.factory.PatchOperationFactory;
|
||||||
import org.dspace.app.rest.submit.factory.impl.PatchOperation;
|
import org.dspace.app.rest.submit.factory.impl.PatchOperation;
|
||||||
import org.dspace.app.util.SubmissionStepConfig;
|
import org.dspace.app.util.SubmissionStepConfig;
|
||||||
import org.dspace.content.WorkspaceItem;
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.services.model.Request;
|
import org.dspace.services.model.Request;
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ import org.dspace.services.model.Request;
|
|||||||
public class CollectionStep extends org.dspace.submit.step.SelectCollectionStep implements AbstractRestProcessingStep {
|
public class CollectionStep extends org.dspace.submit.step.SelectCollectionStep implements AbstractRestProcessingStep {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UUID getData(SubmissionService submissionService, WorkspaceItem obj, SubmissionStepConfig config) {
|
public UUID getData(SubmissionService submissionService, InProgressSubmission obj, SubmissionStepConfig config) {
|
||||||
if (obj.getCollection() != null) {
|
if (obj.getCollection() != null) {
|
||||||
return obj.getCollection().getID();
|
return obj.getCollection().getID();
|
||||||
}
|
}
|
||||||
@@ -36,7 +36,7 @@ public class CollectionStep extends org.dspace.submit.step.SelectCollectionStep
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doPatchProcessing(Context context, Request currentRequest, WorkspaceItem source, Operation op)
|
public void doPatchProcessing(Context context, Request currentRequest, InProgressSubmission source, Operation op)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
||||||
PatchOperation<String> patchOperation = new PatchOperationFactory()
|
PatchOperation<String> patchOperation = new PatchOperationFactory()
|
||||||
|
@@ -23,8 +23,8 @@ import org.dspace.app.util.DCInputSet;
|
|||||||
import org.dspace.app.util.DCInputsReader;
|
import org.dspace.app.util.DCInputsReader;
|
||||||
import org.dspace.app.util.DCInputsReaderException;
|
import org.dspace.app.util.DCInputsReaderException;
|
||||||
import org.dspace.app.util.SubmissionStepConfig;
|
import org.dspace.app.util.SubmissionStepConfig;
|
||||||
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
import org.dspace.content.WorkspaceItem;
|
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.core.Utils;
|
import org.dspace.core.Utils;
|
||||||
import org.dspace.services.model.Request;
|
import org.dspace.services.model.Request;
|
||||||
@@ -45,7 +45,8 @@ public class DescribeStep extends org.dspace.submit.step.DescribeStep implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataDescribe getData(SubmissionService submissionService, WorkspaceItem obj, SubmissionStepConfig config) {
|
public DataDescribe getData(SubmissionService submissionService, InProgressSubmission obj,
|
||||||
|
SubmissionStepConfig config) {
|
||||||
DataDescribe data = new DataDescribe();
|
DataDescribe data = new DataDescribe();
|
||||||
try {
|
try {
|
||||||
DCInputSet inputConfig = inputReader.getInputsByFormName(config.getId());
|
DCInputSet inputConfig = inputReader.getInputsByFormName(config.getId());
|
||||||
@@ -100,7 +101,7 @@ public class DescribeStep extends org.dspace.submit.step.DescribeStep implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doPatchProcessing(Context context, Request currentRequest, WorkspaceItem source, Operation op)
|
public void doPatchProcessing(Context context, Request currentRequest, InProgressSubmission source, Operation op)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
||||||
PatchOperation<MetadataValueRest> patchOperation = new PatchOperationFactory()
|
PatchOperation<MetadataValueRest> patchOperation = new PatchOperationFactory()
|
||||||
|
@@ -16,7 +16,6 @@ import gr.ekt.bte.core.Record;
|
|||||||
import gr.ekt.bte.core.RecordSet;
|
import gr.ekt.bte.core.RecordSet;
|
||||||
import gr.ekt.bte.core.Value;
|
import gr.ekt.bte.core.Value;
|
||||||
import gr.ekt.bte.dataloader.FileDataLoader;
|
import gr.ekt.bte.dataloader.FileDataLoader;
|
||||||
|
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
@@ -17,7 +17,7 @@ import org.dspace.app.rest.submit.factory.PatchOperationFactory;
|
|||||||
import org.dspace.app.rest.submit.factory.impl.PatchOperation;
|
import org.dspace.app.rest.submit.factory.impl.PatchOperation;
|
||||||
import org.dspace.app.util.SubmissionStepConfig;
|
import org.dspace.app.util.SubmissionStepConfig;
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
import org.dspace.content.WorkspaceItem;
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.services.model.Request;
|
import org.dspace.services.model.Request;
|
||||||
@@ -32,7 +32,8 @@ public class LicenseStep extends org.dspace.submit.step.LicenseStep implements A
|
|||||||
private static final String DCTERMS_RIGHTSDATE = "dcterms.accessRights";
|
private static final String DCTERMS_RIGHTSDATE = "dcterms.accessRights";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataLicense getData(SubmissionService submissionService, WorkspaceItem obj, SubmissionStepConfig config)
|
public DataLicense getData(SubmissionService submissionService, InProgressSubmission obj,
|
||||||
|
SubmissionStepConfig config)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
DataLicense result = new DataLicense();
|
DataLicense result = new DataLicense();
|
||||||
Bitstream bitstream = bitstreamService
|
Bitstream bitstream = bitstreamService
|
||||||
@@ -49,7 +50,7 @@ public class LicenseStep extends org.dspace.submit.step.LicenseStep implements A
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doPatchProcessing(Context context, Request currentRequest, WorkspaceItem source, Operation op)
|
public void doPatchProcessing(Context context, Request currentRequest, InProgressSubmission source, Operation op)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
||||||
if (op.getPath().endsWith(LICENSE_STEP_OPERATION_ENTRY)) {
|
if (op.getPath().endsWith(LICENSE_STEP_OPERATION_ENTRY)) {
|
||||||
|
@@ -7,22 +7,31 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.app.rest.submit.step;
|
package org.dspace.app.rest.submit.step;
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.dspace.app.rest.model.ErrorRest;
|
||||||
import org.dspace.app.rest.model.patch.Operation;
|
import org.dspace.app.rest.model.patch.Operation;
|
||||||
import org.dspace.app.rest.model.step.DataUpload;
|
import org.dspace.app.rest.model.step.DataUpload;
|
||||||
import org.dspace.app.rest.model.step.UploadBitstreamRest;
|
import org.dspace.app.rest.model.step.UploadBitstreamRest;
|
||||||
|
import org.dspace.app.rest.repository.WorkspaceItemRestRepository;
|
||||||
import org.dspace.app.rest.submit.AbstractRestProcessingStep;
|
import org.dspace.app.rest.submit.AbstractRestProcessingStep;
|
||||||
import org.dspace.app.rest.submit.SubmissionService;
|
import org.dspace.app.rest.submit.SubmissionService;
|
||||||
|
import org.dspace.app.rest.submit.UploadableStep;
|
||||||
import org.dspace.app.rest.submit.factory.PatchOperationFactory;
|
import org.dspace.app.rest.submit.factory.PatchOperationFactory;
|
||||||
import org.dspace.app.rest.submit.factory.impl.PatchOperation;
|
import org.dspace.app.rest.submit.factory.impl.PatchOperation;
|
||||||
import org.dspace.app.util.SubmissionStepConfig;
|
import org.dspace.app.util.SubmissionStepConfig;
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
|
import org.dspace.content.BitstreamFormat;
|
||||||
import org.dspace.content.Bundle;
|
import org.dspace.content.Bundle;
|
||||||
import org.dspace.content.WorkspaceItem;
|
import org.dspace.content.InProgressSubmission;
|
||||||
|
import org.dspace.content.Item;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.services.model.Request;
|
import org.dspace.services.model.Request;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Upload step for DSpace Spring Rest. Expose information about the bitstream
|
* Upload step for DSpace Spring Rest. Expose information about the bitstream
|
||||||
@@ -30,12 +39,14 @@ import org.dspace.services.model.Request;
|
|||||||
*
|
*
|
||||||
* @author Luigi Andrea Pascarelli (luigiandrea.pascarelli at 4science.it)
|
* @author Luigi Andrea Pascarelli (luigiandrea.pascarelli at 4science.it)
|
||||||
*/
|
*/
|
||||||
public class UploadStep extends org.dspace.submit.step.UploadStep implements AbstractRestProcessingStep {
|
public class UploadStep extends org.dspace.submit.step.UploadStep
|
||||||
|
implements AbstractRestProcessingStep, UploadableStep {
|
||||||
|
|
||||||
|
private static final Logger log = Logger.getLogger(UploadStep.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataUpload getData(SubmissionService submissionService, WorkspaceItem obj, SubmissionStepConfig config)
|
public DataUpload getData(SubmissionService submissionService, InProgressSubmission obj,
|
||||||
throws Exception {
|
SubmissionStepConfig config) throws Exception {
|
||||||
|
|
||||||
DataUpload result = new DataUpload();
|
DataUpload result = new DataUpload();
|
||||||
List<Bundle> bundles = itemService.getBundles(obj.getItem(), Constants.CONTENT_BUNDLE_NAME);
|
List<Bundle> bundles = itemService.getBundles(obj.getItem(), Constants.CONTENT_BUNDLE_NAME);
|
||||||
@@ -49,7 +60,7 @@ public class UploadStep extends org.dspace.submit.step.UploadStep implements Abs
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doPatchProcessing(Context context, Request currentRequest, WorkspaceItem source, Operation op)
|
public void doPatchProcessing(Context context, Request currentRequest, InProgressSubmission source, Operation op)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
||||||
String instance = "";
|
String instance = "";
|
||||||
@@ -79,4 +90,56 @@ public class UploadStep extends org.dspace.submit.step.UploadStep implements Abs
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ErrorRest upload(Context context, SubmissionService submissionService, SubmissionStepConfig stepConfig,
|
||||||
|
InProgressSubmission wsi, MultipartFile file, String extraField) {
|
||||||
|
|
||||||
|
Bitstream source = null;
|
||||||
|
BitstreamFormat bf = null;
|
||||||
|
|
||||||
|
Item item = wsi.getItem();
|
||||||
|
List<Bundle> bundles = null;
|
||||||
|
try {
|
||||||
|
// do we already have a bundle?
|
||||||
|
bundles = itemService.getBundles(item, Constants.CONTENT_BUNDLE_NAME);
|
||||||
|
|
||||||
|
InputStream inputStream = new BufferedInputStream(file.getInputStream());
|
||||||
|
if (bundles.size() < 1) {
|
||||||
|
// set bundle's name to ORIGINAL
|
||||||
|
source = itemService.createSingleBitstream(context, inputStream, item, Constants.CONTENT_BUNDLE_NAME);
|
||||||
|
} else {
|
||||||
|
// we have a bundle already, just add bitstream
|
||||||
|
source = bitstreamService.create(context, bundles.get(0), inputStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
source.setName(context, file.getOriginalFilename());
|
||||||
|
// TODO how retrieve this information?
|
||||||
|
source.setSource(context, extraField);
|
||||||
|
|
||||||
|
// Identify the format
|
||||||
|
bf = bitstreamFormatService.guessFormat(context, source);
|
||||||
|
source.setFormat(context, bf);
|
||||||
|
|
||||||
|
// Update to DB
|
||||||
|
bitstreamService.update(context, source);
|
||||||
|
itemService.update(context, item);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
ErrorRest result = new ErrorRest();
|
||||||
|
result.setMessage(e.getMessage());
|
||||||
|
if (bundles != null && bundles.size() > 0) {
|
||||||
|
result.getPaths().add(
|
||||||
|
"/" + WorkspaceItemRestRepository.OPERATION_PATH_SECTIONS + "/" + stepConfig.getId() + "/files/" +
|
||||||
|
bundles.get(0).getBitstreams().size());
|
||||||
|
} else {
|
||||||
|
result.getPaths()
|
||||||
|
.add("/" + WorkspaceItemRestRepository.OPERATION_PATH_SECTIONS + "/" + stepConfig.getId());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,7 @@ import org.dspace.app.rest.submit.SubmissionService;
|
|||||||
import org.dspace.app.util.DCInputsReaderException;
|
import org.dspace.app.util.DCInputsReaderException;
|
||||||
import org.dspace.app.util.SubmissionStepConfig;
|
import org.dspace.app.util.SubmissionStepConfig;
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
import org.dspace.content.WorkspaceItem;
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.content.service.BitstreamService;
|
import org.dspace.content.service.BitstreamService;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -37,7 +37,7 @@ public class LicenseValidation extends AbstractValidation {
|
|||||||
private BitstreamService bitstreamService;
|
private BitstreamService bitstreamService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ErrorRest> validate(SubmissionService submissionService, WorkspaceItem obj,
|
public List<ErrorRest> validate(SubmissionService submissionService, InProgressSubmission obj,
|
||||||
SubmissionStepConfig config) throws DCInputsReaderException, SQLException {
|
SubmissionStepConfig config) throws DCInputsReaderException, SQLException {
|
||||||
|
|
||||||
Bitstream bitstream = bitstreamService
|
Bitstream bitstream = bitstreamService
|
||||||
|
@@ -21,8 +21,8 @@ import org.dspace.app.util.DCInputSet;
|
|||||||
import org.dspace.app.util.DCInputsReader;
|
import org.dspace.app.util.DCInputsReader;
|
||||||
import org.dspace.app.util.DCInputsReaderException;
|
import org.dspace.app.util.DCInputsReaderException;
|
||||||
import org.dspace.app.util.SubmissionStepConfig;
|
import org.dspace.app.util.SubmissionStepConfig;
|
||||||
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
import org.dspace.content.WorkspaceItem;
|
|
||||||
import org.dspace.content.authority.service.MetadataAuthorityService;
|
import org.dspace.content.authority.service.MetadataAuthorityService;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ public class MetadataValidation extends AbstractValidation {
|
|||||||
private MetadataAuthorityService metadataAuthorityService;
|
private MetadataAuthorityService metadataAuthorityService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ErrorRest> validate(SubmissionService submissionService, WorkspaceItem obj,
|
public List<ErrorRest> validate(SubmissionService submissionService, InProgressSubmission obj,
|
||||||
SubmissionStepConfig config) throws DCInputsReaderException, SQLException {
|
SubmissionStepConfig config) throws DCInputsReaderException, SQLException {
|
||||||
|
|
||||||
DCInputSet inputConfig = getInputReader().getInputsByFormName(config.getId());
|
DCInputSet inputConfig = getInputReader().getInputsByFormName(config.getId());
|
||||||
|
@@ -16,7 +16,7 @@ import org.dspace.app.rest.repository.WorkspaceItemRestRepository;
|
|||||||
import org.dspace.app.rest.submit.SubmissionService;
|
import org.dspace.app.rest.submit.SubmissionService;
|
||||||
import org.dspace.app.util.DCInputsReaderException;
|
import org.dspace.app.util.DCInputsReaderException;
|
||||||
import org.dspace.app.util.SubmissionStepConfig;
|
import org.dspace.app.util.SubmissionStepConfig;
|
||||||
import org.dspace.content.WorkspaceItem;
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.submit.model.UploadConfiguration;
|
import org.dspace.submit.model.UploadConfiguration;
|
||||||
import org.dspace.submit.model.UploadConfigurationService;
|
import org.dspace.submit.model.UploadConfigurationService;
|
||||||
@@ -37,7 +37,7 @@ public class UploadValidation extends AbstractValidation {
|
|||||||
private UploadConfigurationService uploadConfigurationService;
|
private UploadConfigurationService uploadConfigurationService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ErrorRest> validate(SubmissionService submissionService, WorkspaceItem obj,
|
public List<ErrorRest> validate(SubmissionService submissionService, InProgressSubmission obj,
|
||||||
SubmissionStepConfig config) throws DCInputsReaderException, SQLException {
|
SubmissionStepConfig config) throws DCInputsReaderException, SQLException {
|
||||||
//TODO MANAGE METADATA
|
//TODO MANAGE METADATA
|
||||||
|
|
||||||
|
@@ -14,7 +14,7 @@ import org.dspace.app.rest.model.ErrorRest;
|
|||||||
import org.dspace.app.rest.submit.SubmissionService;
|
import org.dspace.app.rest.submit.SubmissionService;
|
||||||
import org.dspace.app.util.DCInputsReaderException;
|
import org.dspace.app.util.DCInputsReaderException;
|
||||||
import org.dspace.app.util.SubmissionStepConfig;
|
import org.dspace.app.util.SubmissionStepConfig;
|
||||||
import org.dspace.content.WorkspaceItem;
|
import org.dspace.content.InProgressSubmission;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface to support validation on submission process
|
* Interface to support validation on submission process
|
||||||
@@ -27,7 +27,7 @@ public interface Validation {
|
|||||||
|
|
||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
List<? extends ErrorRest> validate(SubmissionService submissionService, WorkspaceItem obj,
|
List<? extends ErrorRest> validate(SubmissionService submissionService, InProgressSubmission obj,
|
||||||
SubmissionStepConfig config) throws DCInputsReaderException, SQLException;
|
SubmissionStepConfig config) throws DCInputsReaderException, SQLException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user