mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-13 13:03:11 +00:00
DS-4166 community feedback: implement the IndexableObject interface only where really needed
This commit is contained in:
@@ -20,6 +20,7 @@ import com.sun.syndication.feed.module.opensearch.OpenSearchModule;
|
||||
import com.sun.syndication.feed.module.opensearch.entity.OSQuery;
|
||||
import com.sun.syndication.feed.module.opensearch.impl.OpenSearchModuleImpl;
|
||||
import com.sun.syndication.io.FeedException;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.util.service.OpenSearchService;
|
||||
import org.dspace.browse.IndexableObject;
|
||||
@@ -119,7 +120,7 @@ public class OpenSearchServiceImpl implements OpenSearchService {
|
||||
@Override
|
||||
public String getResultsString(Context context, String format, String query, int totalResults, int start,
|
||||
int pageSize,
|
||||
DSpaceObject scope, List<IndexableObject> results,
|
||||
IndexableObject scope, List<IndexableObject> results,
|
||||
Map<String, String> labels) throws IOException {
|
||||
try {
|
||||
return getResults(context, format, query, totalResults, start, pageSize, scope, results, labels)
|
||||
@@ -133,7 +134,7 @@ public class OpenSearchServiceImpl implements OpenSearchService {
|
||||
@Override
|
||||
public Document getResultsDoc(Context context, String format, String query, int totalResults, int start,
|
||||
int pageSize,
|
||||
DSpaceObject scope, List<IndexableObject> results, Map<String, String> labels)
|
||||
IndexableObject scope, List<IndexableObject> results, Map<String, String> labels)
|
||||
throws IOException {
|
||||
try {
|
||||
return getResults(context, format, query, totalResults, start, pageSize, scope, results, labels)
|
||||
@@ -145,7 +146,7 @@ public class OpenSearchServiceImpl implements OpenSearchService {
|
||||
}
|
||||
|
||||
protected SyndicationFeed getResults(Context context, String format, String query, int totalResults, int start,
|
||||
int pageSize, DSpaceObject scope,
|
||||
int pageSize, IndexableObject scope,
|
||||
List<IndexableObject> results, Map<String, String> labels) {
|
||||
// Encode results in requested format
|
||||
if ("rss".equals(format)) {
|
||||
|
@@ -180,11 +180,11 @@ public class SyndicationFeed {
|
||||
*
|
||||
* @param request request
|
||||
* @param context context
|
||||
* @param dso DSpaceObject
|
||||
* @param dso the scope
|
||||
* @param items array of objects
|
||||
* @param labels label map
|
||||
*/
|
||||
public void populate(HttpServletRequest request, Context context, DSpaceObject dso,
|
||||
public void populate(HttpServletRequest request, Context context, IndexableObject dso,
|
||||
List<IndexableObject> items, Map<String, String> labels) {
|
||||
String logoURL = null;
|
||||
String objectURL = null;
|
||||
@@ -209,6 +209,7 @@ public class SyndicationFeed {
|
||||
if (cols != null && cols.length() > 1 && cols.contains(col.getHandle())) {
|
||||
podcastFeed = true;
|
||||
}
|
||||
objectURL = resolveURL(request, col);
|
||||
} else if (dso.getType() == Constants.COMMUNITY) {
|
||||
Community comm = (Community) dso;
|
||||
defaultTitle = comm.getName();
|
||||
@@ -218,8 +219,9 @@ public class SyndicationFeed {
|
||||
if (comms != null && comms.length() > 1 && comms.contains(comm.getHandle())) {
|
||||
podcastFeed = true;
|
||||
}
|
||||
objectURL = resolveURL(request, comm);
|
||||
}
|
||||
objectURL = resolveURL(request, dso);
|
||||
|
||||
if (logo != null) {
|
||||
logoURL = urlOfBitstream(request, logo);
|
||||
}
|
||||
|
@@ -84,7 +84,7 @@ public interface OpenSearchService {
|
||||
* @param totalResults - the hit count
|
||||
* @param start - start result index
|
||||
* @param pageSize - page size
|
||||
* @param scope - search scope, null or community/collection handle
|
||||
* @param scope - search scope, null or the community/collection
|
||||
* @param results the retreived DSpace objects satisfying search
|
||||
* @param labels labels to apply - format specific
|
||||
* @return formatted search results
|
||||
@@ -92,7 +92,7 @@ public interface OpenSearchService {
|
||||
*/
|
||||
public String getResultsString(Context context, String format, String query, int totalResults, int start,
|
||||
int pageSize,
|
||||
DSpaceObject scope, List<IndexableObject> results,
|
||||
IndexableObject scope, List<IndexableObject> results,
|
||||
Map<String, String> labels) throws IOException;
|
||||
|
||||
/**
|
||||
@@ -104,7 +104,7 @@ public interface OpenSearchService {
|
||||
* @param totalResults - the hit count
|
||||
* @param start - start result index
|
||||
* @param pageSize - page size
|
||||
* @param scope - search scope, null or community/collection handle
|
||||
* @param scope - search scope, null or the community/collection
|
||||
* @param results the retreived DSpace objects satisfying search
|
||||
* @param labels labels to apply - format specific
|
||||
* @return formatted search results
|
||||
@@ -112,7 +112,7 @@ public interface OpenSearchService {
|
||||
*/
|
||||
public Document getResultsDoc(Context context, String format, String query, int totalResults, int start,
|
||||
int pageSize,
|
||||
DSpaceObject scope, List<IndexableObject> results, Map<String, String> labels)
|
||||
IndexableObject scope, List<IndexableObject> results, Map<String, String> labels)
|
||||
throws IOException;
|
||||
|
||||
public DSpaceObject resolveScope(Context context, String scope) throws SQLException;
|
||||
|
@@ -12,6 +12,7 @@ import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.CascadeType;
|
||||
@@ -26,6 +27,7 @@ import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.browse.IndexableObject;
|
||||
import org.dspace.content.comparator.NameAscendingComparator;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.CollectionService;
|
||||
@@ -53,7 +55,7 @@ import org.hibernate.proxy.HibernateProxyHelper;
|
||||
@Table(name = "collection")
|
||||
@Cacheable
|
||||
@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, IndexableObject<UUID> {
|
||||
|
||||
@Column(name = "collection_id", insertable = false, updatable = false)
|
||||
private Integer legacyId;
|
||||
|
@@ -11,6 +11,7 @@ import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.CascadeType;
|
||||
@@ -26,6 +27,7 @@ import javax.persistence.Transient;
|
||||
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.browse.IndexableObject;
|
||||
import org.dspace.content.comparator.NameAscendingComparator;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.CommunityService;
|
||||
@@ -49,7 +51,7 @@ import org.hibernate.proxy.HibernateProxyHelper;
|
||||
@Table(name = "community")
|
||||
@Cacheable
|
||||
@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, IndexableObject<UUID> {
|
||||
/**
|
||||
* log4j category
|
||||
*/
|
||||
|
@@ -11,6 +11,7 @@ import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
@@ -26,7 +27,6 @@ import javax.persistence.Transient;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.dspace.authorize.ResourcePolicy;
|
||||
import org.dspace.browse.IndexableObject;
|
||||
import org.dspace.core.ReloadableEntity;
|
||||
import org.dspace.handle.Handle;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
@@ -37,8 +37,7 @@ import org.hibernate.annotations.GenericGenerator;
|
||||
@Entity
|
||||
@Inheritance(strategy = InheritanceType.JOINED)
|
||||
@Table(name = "dspaceobject")
|
||||
public abstract class DSpaceObject implements Serializable, ReloadableEntity<java.util.UUID>,
|
||||
IndexableObject<UUID> {
|
||||
public abstract class DSpaceObject implements Serializable, ReloadableEntity<java.util.UUID> {
|
||||
@Id
|
||||
@GeneratedValue(generator = "system-uuid")
|
||||
@GenericGenerator(name = "system-uuid", strategy = "uuid2")
|
||||
|
@@ -13,6 +13,7 @@ import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
@@ -29,6 +30,7 @@ import javax.persistence.TemporalType;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.browse.IndexableObject;
|
||||
import org.dspace.content.comparator.NameAscendingComparator;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.ItemService;
|
||||
@@ -53,7 +55,7 @@ import org.hibernate.proxy.HibernateProxyHelper;
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "item")
|
||||
public class Item extends DSpaceObject implements DSpaceObjectLegacySupport {
|
||||
public class Item extends DSpaceObject implements DSpaceObjectLegacySupport, IndexableObject<UUID> {
|
||||
|
||||
/**
|
||||
* log4j logger
|
||||
|
@@ -21,8 +21,8 @@ import org.dspace.content.service.CollectionService;
|
||||
import org.dspace.content.service.CommunityService;
|
||||
import org.dspace.content.service.DSpaceObjectLegacySupportService;
|
||||
import org.dspace.content.service.DSpaceObjectService;
|
||||
import org.dspace.content.service.FindableObjectService;
|
||||
import org.dspace.content.service.InProgressSubmissionService;
|
||||
import org.dspace.content.service.IndexableObjectService;
|
||||
import org.dspace.content.service.InstallItemService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.content.service.MetadataFieldService;
|
||||
@@ -43,11 +43,11 @@ import org.dspace.workflow.factory.WorkflowServiceFactory;
|
||||
public abstract class ContentServiceFactory {
|
||||
|
||||
/**
|
||||
* Return the list of all the available implementation of the IndexableObjectService interface
|
||||
* Return the list of all the available implementation of the FindableObjectService interface
|
||||
*
|
||||
* @return the list of IndexableObjectService
|
||||
* @return the list of FindableObjectService
|
||||
*/
|
||||
public abstract List<IndexableObjectService> getIndexableObjectServices();
|
||||
public abstract List<FindableObjectService> getFindableObjectServices();
|
||||
|
||||
public abstract List<DSpaceObjectService<? extends DSpaceObject>> getDSpaceObjectServices();
|
||||
|
||||
@@ -108,15 +108,15 @@ public abstract class ContentServiceFactory {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends IndexableObject<PK>, PK extends Serializable> IndexableObjectService<T, PK>
|
||||
getIndexableObjectService(int type) {
|
||||
for (int i = 0; i < getIndexableObjectServices().size(); i++) {
|
||||
IndexableObjectService objectService = getIndexableObjectServices().get(i);
|
||||
public <T extends IndexableObject<PK>, PK extends Serializable> FindableObjectService<T, PK>
|
||||
getFindableObjectService(int type) {
|
||||
for (int i = 0; i < getFindableObjectServices().size(); i++) {
|
||||
FindableObjectService objectService = getFindableObjectServices().get(i);
|
||||
if (objectService.getSupportsTypeConstant() == type) {
|
||||
return (IndexableObjectService<T, PK>) objectService;
|
||||
return (FindableObjectService<T, PK>) objectService;
|
||||
}
|
||||
}
|
||||
throw new UnsupportedOperationException("Unknown Browsable DSpace type: " + type);
|
||||
throw new UnsupportedOperationException("Unknown Findable Object type: " + type);
|
||||
}
|
||||
|
||||
public DSpaceObjectLegacySupportService<? extends DSpaceObject> getDSpaceLegacyObjectService(int type) {
|
||||
|
@@ -17,7 +17,7 @@ import org.dspace.content.service.CollectionService;
|
||||
import org.dspace.content.service.CommunityService;
|
||||
import org.dspace.content.service.DSpaceObjectLegacySupportService;
|
||||
import org.dspace.content.service.DSpaceObjectService;
|
||||
import org.dspace.content.service.IndexableObjectService;
|
||||
import org.dspace.content.service.FindableObjectService;
|
||||
import org.dspace.content.service.InstallItemService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.content.service.MetadataFieldService;
|
||||
@@ -70,8 +70,8 @@ public class ContentServiceFactoryImpl extends ContentServiceFactory {
|
||||
private SiteService siteService;
|
||||
|
||||
@Override
|
||||
public List<IndexableObjectService> getIndexableObjectServices() {
|
||||
return new DSpace().getServiceManager().getServicesByType(IndexableObjectService.class);
|
||||
public List<FindableObjectService> getFindableObjectServices() {
|
||||
return new DSpace().getServiceManager().getServicesByType(FindableObjectService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -28,7 +28,7 @@ import org.dspace.core.Context;
|
||||
* @param <T> class type
|
||||
* @author kevinvandevelde at atmire.com
|
||||
*/
|
||||
public interface DSpaceObjectService<T extends DSpaceObject> extends IndexableObjectService<T, UUID> {
|
||||
public interface DSpaceObjectService<T extends DSpaceObject> extends FindableObjectService<T, UUID> {
|
||||
|
||||
/**
|
||||
* Get a proper name for the object. This may return <code>null</code>.
|
||||
@@ -398,7 +398,6 @@ public interface DSpaceObjectService<T extends DSpaceObject> extends IndexableOb
|
||||
|
||||
public void delete(Context context, T dso) throws SQLException, AuthorizeException, IOException;
|
||||
|
||||
|
||||
void addAndShiftRightMetadata(Context context, T dso, String schema, String element, String qualifier, String lang,
|
||||
String value, String authority, int confidence, int index) throws SQLException;
|
||||
|
||||
|
@@ -10,22 +10,20 @@ package org.dspace.content.service;
|
||||
import java.io.Serializable;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.dspace.browse.IndexableObject;
|
||||
import org.dspace.core.Context;
|
||||
|
||||
/**
|
||||
* Service interface class for any IndexableObject.
|
||||
* All IndexableObject service classes should implement this class since it offers some basic methods which all
|
||||
* IndexableObjects are required to have.
|
||||
* Base Service interface class for any Persistent Entity findable by a primary key.
|
||||
*
|
||||
* @param <T> class type
|
||||
* @param <T> class type of the persistent entity
|
||||
* @param <PK> class type of the primary key
|
||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||
*/
|
||||
public interface IndexableObjectService<T extends IndexableObject<PK>, PK extends Serializable> {
|
||||
public interface FindableObjectService<T, PK extends Serializable> {
|
||||
|
||||
|
||||
/**
|
||||
* Generic find for when the precise type of an IndexableObject is not known
|
||||
* Generic find for when the precise type of an Entity is not known
|
||||
*
|
||||
* @param context - the context
|
||||
* @param id - id within table of type'd objects
|
@@ -26,7 +26,7 @@ import org.dspace.core.Context;
|
||||
* @author kevinvandevelde at atmire.com
|
||||
*/
|
||||
public interface InProgressSubmissionService<T extends InProgressSubmission<ID>, ID extends Serializable>
|
||||
extends IndexableObjectService<T, ID> {
|
||||
extends FindableObjectService<T, ID> {
|
||||
|
||||
/**
|
||||
* Deletes submission wrapper, doesn't delete item contents
|
||||
|
@@ -2230,7 +2230,7 @@ public class SolrServiceImpl implements SearchService, IndexingService {
|
||||
}
|
||||
|
||||
if (uid != null) {
|
||||
o = (IndexableObject) contentServiceFactory.getIndexableObjectService(type).find(context, uid);
|
||||
o = (IndexableObject) contentServiceFactory.getFindableObjectService(type).find(context, uid);
|
||||
}
|
||||
|
||||
if (o == null) {
|
||||
@@ -2275,7 +2275,7 @@ public class SolrServiceImpl implements SearchService, IndexingService {
|
||||
SolrDocument doc = (SolrDocument) iter.next();
|
||||
|
||||
IndexableObject o = (IndexableObject)contentServiceFactory
|
||||
.getIndexableObjectService((Integer) doc.getFirstValue(RESOURCE_TYPE_FIELD))
|
||||
.getFindableObjectService((Integer) doc.getFirstValue(RESOURCE_TYPE_FIELD))
|
||||
.find(context, UUID.fromString((String) doc.getFirstValue(RESOURCE_ID_FIELD)));
|
||||
|
||||
if (o != null) {
|
||||
|
@@ -11,7 +11,7 @@ import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.service.IndexableObjectService;
|
||||
import org.dspace.content.service.FindableObjectService;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.service.DSpaceCRUDService;
|
||||
@@ -26,7 +26,7 @@ import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
||||
* @author kevinvandevelde at atmire.com
|
||||
*/
|
||||
public interface ClaimedTaskService extends DSpaceCRUDService<ClaimedTask>,
|
||||
IndexableObjectService<ClaimedTask, Integer> {
|
||||
FindableObjectService<ClaimedTask, Integer> {
|
||||
|
||||
public List<ClaimedTask> findByWorkflowItem(Context context, XmlWorkflowItem workflowItem) throws SQLException;
|
||||
|
||||
|
@@ -12,7 +12,7 @@ import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.service.IndexableObjectService;
|
||||
import org.dspace.content.service.FindableObjectService;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.service.DSpaceCRUDService;
|
||||
@@ -26,7 +26,7 @@ import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
||||
*
|
||||
* @author kevinvandevelde at atmire.com
|
||||
*/
|
||||
public interface PoolTaskService extends DSpaceCRUDService<PoolTask>, IndexableObjectService<PoolTask, Integer> {
|
||||
public interface PoolTaskService extends DSpaceCRUDService<PoolTask>, FindableObjectService<PoolTask, Integer> {
|
||||
public List<PoolTask> findByEperson(Context context, EPerson ePerson)
|
||||
throws SQLException, AuthorizeException, IOException;
|
||||
|
||||
|
@@ -12,6 +12,8 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -22,7 +24,6 @@ import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.app.rest.utils.ScopeResolver;
|
||||
import org.dspace.app.util.SyndicationFeed;
|
||||
@@ -31,7 +32,6 @@ import org.dspace.app.util.service.OpenSearchService;
|
||||
import org.dspace.authorize.factory.AuthorizeServiceFactory;
|
||||
import org.dspace.authorize.service.AuthorizeService;
|
||||
import org.dspace.browse.IndexableObject;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.CollectionService;
|
||||
import org.dspace.content.service.CommunityService;
|
||||
@@ -43,13 +43,11 @@ import org.dspace.discovery.SearchServiceException;
|
||||
import org.dspace.discovery.SearchUtils;
|
||||
import org.dspace.discovery.configuration.DiscoveryConfiguration;
|
||||
import org.dspace.discovery.configuration.DiscoverySearchFilter;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
/**
|
||||
@@ -114,7 +112,7 @@ public class OpenSearchController {
|
||||
}
|
||||
|
||||
// then the rest - we are processing the query
|
||||
DSpaceObject container = null;
|
||||
IndexableObject<UUID> container = null;
|
||||
|
||||
// support pagination parameters
|
||||
DiscoverQuery queryArgs = new DiscoverQuery();
|
||||
|
@@ -22,7 +22,7 @@ import org.springframework.stereotype.Component;
|
||||
* @author Luigi Andrea Pascarelli (luigiandrea.pascarelli at 4science.it)
|
||||
*/
|
||||
@Component
|
||||
public class AuthorityEntryRestConverter extends DSpaceConverter<Choice, AuthorityEntryRest> {
|
||||
public class AuthorityEntryRestConverter implements DSpaceConverter<Choice, AuthorityEntryRest> {
|
||||
|
||||
@Override
|
||||
public AuthorityEntryRest fromModel(Choice choice) {
|
||||
|
@@ -23,7 +23,7 @@ import org.springframework.stereotype.Component;
|
||||
* @author Luigi Andrea Pascarelli (luigiandrea.pascarelli at 4science.it)
|
||||
*/
|
||||
@Component
|
||||
public class AuthorityRestConverter extends DSpaceConverter<ChoiceAuthority, AuthorityRest> {
|
||||
public class AuthorityRestConverter implements DSpaceConverter<ChoiceAuthority, AuthorityRest> {
|
||||
|
||||
@Override
|
||||
public AuthorityRest fromModel(ChoiceAuthority step) {
|
||||
|
@@ -8,6 +8,7 @@
|
||||
package org.dspace.app.rest.converter;
|
||||
|
||||
import org.dspace.app.rest.model.BitstreamFormatRest;
|
||||
import org.dspace.content.BitstreamFormat;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
@@ -17,9 +18,9 @@ import org.springframework.stereotype.Component;
|
||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||
*/
|
||||
@Component
|
||||
public class BitstreamFormatConverter extends DSpaceConverter<org.dspace.content.BitstreamFormat, BitstreamFormatRest> {
|
||||
public class BitstreamFormatConverter implements DSpaceConverter<BitstreamFormat, BitstreamFormatRest> {
|
||||
@Override
|
||||
public BitstreamFormatRest fromModel(org.dspace.content.BitstreamFormat obj) {
|
||||
public BitstreamFormatRest fromModel(BitstreamFormat obj) {
|
||||
BitstreamFormatRest bf = new BitstreamFormatRest();
|
||||
bf.setDescription(obj.getDescription());
|
||||
bf.setExtensions(bf.getExtensions());
|
||||
@@ -31,7 +32,7 @@ public class BitstreamFormatConverter extends DSpaceConverter<org.dspace.content
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.dspace.content.BitstreamFormat toModel(BitstreamFormatRest obj) {
|
||||
public BitstreamFormat toModel(BitstreamFormatRest obj) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@ import org.springframework.stereotype.Component;
|
||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||
*/
|
||||
@Component
|
||||
public class BrowseIndexConverter extends DSpaceConverter<BrowseIndex, BrowseIndexRest> {
|
||||
public class BrowseIndexConverter implements DSpaceConverter<BrowseIndex, BrowseIndexRest> {
|
||||
@Override
|
||||
public BrowseIndexRest fromModel(BrowseIndex obj) {
|
||||
BrowseIndexRest bir = new BrowseIndexRest();
|
||||
|
@@ -23,7 +23,7 @@ import org.springframework.stereotype.Component;
|
||||
*/
|
||||
@Component
|
||||
public class ClaimedTaskConverter
|
||||
extends IndexableDSpaceObjectConverter<ClaimedTask, org.dspace.app.rest.model.ClaimedTaskRest> {
|
||||
implements IndexableDSpaceObjectConverter<ClaimedTask, org.dspace.app.rest.model.ClaimedTaskRest> {
|
||||
|
||||
private static final Logger log = Logger.getLogger(ClaimedTaskConverter.class);
|
||||
|
||||
|
@@ -19,6 +19,7 @@ import org.dspace.app.rest.model.ResourcePolicyRest;
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.authorize.ResourcePolicy;
|
||||
import org.dspace.authorize.service.AuthorizeService;
|
||||
import org.dspace.browse.IndexableObject;
|
||||
import org.dspace.content.Bitstream;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.service.CollectionService;
|
||||
@@ -37,7 +38,8 @@ import org.springframework.stereotype.Component;
|
||||
*/
|
||||
@Component
|
||||
public class CollectionConverter
|
||||
extends DSpaceObjectConverter<org.dspace.content.Collection, org.dspace.app.rest.model.CollectionRest> {
|
||||
extends DSpaceObjectConverter<org.dspace.content.Collection, org.dspace.app.rest.model.CollectionRest>
|
||||
implements IndexableDSpaceObjectConverter<Collection, CollectionRest> {
|
||||
|
||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(CollectionConverter.class);
|
||||
|
||||
@@ -110,4 +112,9 @@ public class CollectionConverter
|
||||
protected Class<org.dspace.content.Collection> getModelClass() {
|
||||
return org.dspace.content.Collection.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsModel(IndexableObject idxo) {
|
||||
return idxo instanceof Collection;
|
||||
}
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@ import java.util.List;
|
||||
|
||||
import org.dspace.app.rest.model.CollectionRest;
|
||||
import org.dspace.app.rest.model.CommunityRest;
|
||||
import org.dspace.browse.IndexableObject;
|
||||
import org.dspace.content.Bitstream;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.Community;
|
||||
@@ -26,7 +27,9 @@ import org.springframework.stereotype.Component;
|
||||
*/
|
||||
@Component
|
||||
public class CommunityConverter
|
||||
extends DSpaceObjectConverter<org.dspace.content.Community, org.dspace.app.rest.model.CommunityRest> {
|
||||
extends DSpaceObjectConverter<org.dspace.content.Community, org.dspace.app.rest.model.CommunityRest>
|
||||
implements IndexableDSpaceObjectConverter<Community, CommunityRest> {
|
||||
|
||||
@Autowired
|
||||
private BitstreamConverter bitstreamConverter;
|
||||
|
||||
@@ -77,4 +80,9 @@ public class CommunityConverter
|
||||
protected Class<org.dspace.content.Community> getModelClass() {
|
||||
return org.dspace.content.Community.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsModel(IndexableObject idxo) {
|
||||
return idxo instanceof Community;
|
||||
}
|
||||
}
|
||||
|
@@ -9,9 +9,9 @@ package org.dspace.app.rest.converter;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
|
||||
public abstract class DSpaceConverter<M, R> implements Converter<M, R> {
|
||||
public interface DSpaceConverter<M, R> extends Converter<M, R> {
|
||||
@Override
|
||||
public R convert(M source) {
|
||||
public default R convert(M source) {
|
||||
return fromModel(source);
|
||||
}
|
||||
|
||||
|
@@ -7,7 +7,6 @@
|
||||
*/
|
||||
package org.dspace.app.rest.converter;
|
||||
|
||||
import org.dspace.browse.IndexableObject;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -20,8 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||
*/
|
||||
public abstract class DSpaceObjectConverter<M extends DSpaceObject, R extends org.dspace.app.rest.model
|
||||
.DSpaceObjectRest>
|
||||
extends IndexableDSpaceObjectConverter<M, R> {
|
||||
.DSpaceObjectRest> implements DSpaceConverter<M, R> {
|
||||
|
||||
@Autowired(required = true)
|
||||
private MetadataConverter metadataConverter;
|
||||
@@ -43,7 +41,7 @@ public abstract class DSpaceObjectConverter<M extends DSpaceObject, R extends or
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean supportsModel(IndexableObject object) {
|
||||
public boolean supportsModel(DSpaceObject object) {
|
||||
return object != null && object.getClass().equals(getModelClass());
|
||||
}
|
||||
|
||||
|
@@ -17,7 +17,7 @@ import org.dspace.browse.IndexableObject;
|
||||
* @param <R> the Class in the DSpace REST data model
|
||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||
*/
|
||||
public abstract class IndexableDSpaceObjectConverter<M extends IndexableObject,
|
||||
public interface IndexableDSpaceObjectConverter<M extends IndexableObject,
|
||||
R extends org.dspace.app.rest.model.RestAddressableModel> extends DSpaceConverter<M, R> {
|
||||
|
||||
/**
|
||||
@@ -26,6 +26,6 @@ public abstract class IndexableDSpaceObjectConverter<M extends IndexableObject,
|
||||
* the IndexableObject to check
|
||||
* @return true if the actual converter implementation is able to manage the supplied IndexableObject
|
||||
*/
|
||||
public abstract boolean supportsModel(IndexableObject idxo);
|
||||
public boolean supportsModel(IndexableObject idxo);
|
||||
|
||||
}
|
@@ -13,6 +13,7 @@ import java.util.List;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.model.BitstreamRest;
|
||||
import org.dspace.app.rest.model.ItemRest;
|
||||
import org.dspace.browse.IndexableObject;
|
||||
import org.dspace.content.Bitstream;
|
||||
import org.dspace.content.Bundle;
|
||||
import org.dspace.content.Collection;
|
||||
@@ -27,7 +28,10 @@ import org.springframework.stereotype.Component;
|
||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||
*/
|
||||
@Component
|
||||
public class ItemConverter extends DSpaceObjectConverter<org.dspace.content.Item, org.dspace.app.rest.model.ItemRest> {
|
||||
public class ItemConverter
|
||||
extends DSpaceObjectConverter<org.dspace.content.Item, org.dspace.app.rest.model.ItemRest>
|
||||
implements IndexableDSpaceObjectConverter<Item, ItemRest> {
|
||||
|
||||
@Autowired(required = true)
|
||||
private CollectionConverter collectionConverter;
|
||||
@Autowired(required = true)
|
||||
@@ -85,4 +89,8 @@ public class ItemConverter extends DSpaceObjectConverter<org.dspace.content.Item
|
||||
return Item.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsModel(IndexableObject idxo) {
|
||||
return idxo instanceof Item;
|
||||
}
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@ import org.springframework.stereotype.Component;
|
||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||
*/
|
||||
@Component
|
||||
public class MetadataFieldConverter extends DSpaceConverter<org.dspace.content.MetadataField, MetadataFieldRest> {
|
||||
public class MetadataFieldConverter implements DSpaceConverter<org.dspace.content.MetadataField, MetadataFieldRest> {
|
||||
@Autowired(required = true)
|
||||
private MetadataSchemaConverter metadataSchemaConverter;
|
||||
|
||||
|
@@ -17,7 +17,7 @@ import org.springframework.stereotype.Component;
|
||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||
*/
|
||||
@Component
|
||||
public class MetadataSchemaConverter extends DSpaceConverter<org.dspace.content.MetadataSchema, MetadataSchemaRest> {
|
||||
public class MetadataSchemaConverter implements DSpaceConverter<org.dspace.content.MetadataSchema, MetadataSchemaRest> {
|
||||
@Override
|
||||
public MetadataSchemaRest fromModel(org.dspace.content.MetadataSchema obj) {
|
||||
MetadataSchemaRest schema = new MetadataSchemaRest();
|
||||
|
@@ -23,7 +23,7 @@ import org.springframework.stereotype.Component;
|
||||
*/
|
||||
@Component
|
||||
public class PoolTaskConverter
|
||||
extends IndexableDSpaceObjectConverter<PoolTask, org.dspace.app.rest.model.PoolTaskRest> {
|
||||
implements IndexableDSpaceObjectConverter<PoolTask, org.dspace.app.rest.model.PoolTaskRest> {
|
||||
|
||||
private static final Logger log = Logger.getLogger(PoolTaskConverter.class);
|
||||
|
||||
|
@@ -20,7 +20,7 @@ import org.springframework.stereotype.Component;
|
||||
* @author Luigi Andrea Pascarelli (luigiandrea.pascarelli at 4science.it)
|
||||
*/
|
||||
@Component
|
||||
public class ResourcePolicyConverter extends DSpaceConverter<ResourcePolicy, ResourcePolicyRest> {
|
||||
public class ResourcePolicyConverter implements DSpaceConverter<ResourcePolicy, ResourcePolicyRest> {
|
||||
|
||||
@Autowired
|
||||
ResourcePolicyService resourcePolicyService;
|
||||
|
@@ -35,7 +35,7 @@ import org.springframework.stereotype.Component;
|
||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||
*/
|
||||
@Component
|
||||
public class SubmissionDefinitionConverter extends DSpaceConverter<SubmissionConfig, SubmissionDefinitionRest> {
|
||||
public class SubmissionDefinitionConverter implements DSpaceConverter<SubmissionConfig, SubmissionDefinitionRest> {
|
||||
|
||||
private static final Logger log = org.apache.logging.log4j.LogManager
|
||||
.getLogger(SubmissionDefinitionConverter.class);
|
||||
|
@@ -36,7 +36,7 @@ import org.springframework.stereotype.Component;
|
||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||
*/
|
||||
@Component
|
||||
public class SubmissionFormConverter extends DSpaceConverter<DCInputSet, SubmissionFormRest> {
|
||||
public class SubmissionFormConverter implements DSpaceConverter<DCInputSet, SubmissionFormRest> {
|
||||
|
||||
private static final String INPUT_TYPE_ONEBOX = "onebox";
|
||||
private static final String INPUT_TYPE_NAME = "name";
|
||||
|
@@ -23,7 +23,7 @@ import org.springframework.stereotype.Component;
|
||||
* @author Luigi Andrea Pascarelli (luigiandrea.pascarelli at 4science.it)
|
||||
*/
|
||||
@Component
|
||||
public class SubmissionSectionConverter extends DSpaceConverter<SubmissionStepConfig, SubmissionSectionRest> {
|
||||
public class SubmissionSectionConverter implements DSpaceConverter<SubmissionStepConfig, SubmissionSectionRest> {
|
||||
|
||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(SubmissionSectionConverter.class);
|
||||
|
||||
|
@@ -38,7 +38,7 @@ import org.springframework.stereotype.Component;
|
||||
*/
|
||||
@Component
|
||||
public class WorkflowItemConverter
|
||||
extends IndexableDSpaceObjectConverter<XmlWorkflowItem, org.dspace.app.rest.model.WorkflowItemRest> {
|
||||
implements IndexableDSpaceObjectConverter<XmlWorkflowItem, org.dspace.app.rest.model.WorkflowItemRest> {
|
||||
|
||||
private static final Logger log = Logger.getLogger(WorkflowItemConverter.class);
|
||||
|
||||
|
@@ -37,7 +37,7 @@ import org.springframework.stereotype.Component;
|
||||
*/
|
||||
@Component
|
||||
public class WorkspaceItemConverter
|
||||
extends
|
||||
implements
|
||||
IndexableDSpaceObjectConverter<org.dspace.content.WorkspaceItem, org.dspace.app.rest.model.WorkspaceItemRest> {
|
||||
|
||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(WorkspaceItemConverter.class);
|
||||
|
@@ -12,7 +12,7 @@ import java.util.UUID;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.browse.IndexableObject;
|
||||
import org.dspace.content.service.CollectionService;
|
||||
import org.dspace.content.service.CommunityService;
|
||||
import org.dspace.core.Context;
|
||||
@@ -33,8 +33,8 @@ public class ScopeResolver {
|
||||
@Autowired
|
||||
CommunityService communityService;
|
||||
|
||||
public DSpaceObject resolveScope(Context context, String scope) {
|
||||
DSpaceObject scopeObj = null;
|
||||
public IndexableObject<UUID> resolveScope(Context context, String scope) {
|
||||
IndexableObject<UUID> scopeObj = null;
|
||||
if (StringUtils.isNotBlank(scope)) {
|
||||
try {
|
||||
UUID uuid = UUID.fromString(scope);
|
||||
|
Reference in New Issue
Block a user