mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-16 06:23:10 +00:00
DS-3533 Simplify and normalize code
This commit is contained in:
@@ -153,9 +153,9 @@ public class RestResourceController implements InitializingBean {
|
||||
*
|
||||
* Note that the regular expression in the request mapping accept a number as identifier;
|
||||
*
|
||||
* Please see {@link RestResourceController#findOne(String, String, String, String)} for findOne with string as
|
||||
* Please see {@link RestResourceController#findOne(String, String, String)} for findOne with string as
|
||||
* identifier
|
||||
* and see {@link RestResourceController#findOne(String, String, UUID, String)} for uuid as identifier
|
||||
* and see {@link RestResourceController#findOne(String, String, UUID)} for uuid as identifier
|
||||
*
|
||||
* @param apiCategory
|
||||
* @param model
|
||||
@@ -185,9 +185,9 @@ public class RestResourceController implements InitializingBean {
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* Please see {@link RestResourceController#findOne(String, String, Integer, String)} for findOne with number as
|
||||
* Please see {@link RestResourceController#findOne(String, String, Integer)} for findOne with number as
|
||||
* identifier
|
||||
* and see {@link RestResourceController#findOne(String, String, UUID, String)} for uuid as identifier
|
||||
* and see {@link RestResourceController#findOne(String, String, UUID)} for uuid as identifier
|
||||
*
|
||||
* @param apiCategory
|
||||
* @param model
|
||||
@@ -206,9 +206,9 @@ public class RestResourceController implements InitializingBean {
|
||||
*
|
||||
* Note that the regular expression in the request mapping accept a UUID as identifier;
|
||||
*
|
||||
* Please see {@link RestResourceController#findOne(String, String, Integer, String)} for findOne with number as
|
||||
* Please see {@link RestResourceController#findOne(String, String, Integer)} for findOne with number as
|
||||
* identifier
|
||||
* and see {@link RestResourceController#findOne(String, String, String, String)} for string as identifier
|
||||
* and see {@link RestResourceController#findOne(String, String, String)} for string as identifier
|
||||
*
|
||||
* @param apiCategory
|
||||
* @param model
|
||||
|
@@ -29,6 +29,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
|
||||
import org.springframework.core.type.filter.AssignableTypeFilter;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.hateoas.Resource;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -89,6 +92,25 @@ public class ConverterService {
|
||||
return restObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a list of model objects to a page of rest objects using the given {@link Projection}.
|
||||
*
|
||||
* @param modelObjects
|
||||
* @param pageable
|
||||
* @param total
|
||||
* @param projection
|
||||
* @param <T>
|
||||
* @param <D>
|
||||
* @return
|
||||
*/
|
||||
public <T, D> Page<T> toRestPage(List<D> modelObjects, Pageable pageable, long total, Projection projection) {
|
||||
return new PageImpl<>(modelObjects, pageable, total).map((object) -> toRest(object, projection));
|
||||
}
|
||||
|
||||
public <T, D> Page<T> toRestPage(Page<D> modelObjects, Projection projection) {
|
||||
return modelObjects.map((object) -> toRest(object, projection));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the converter supporting the given class as input.
|
||||
*
|
||||
|
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
package org.dspace.app.rest.repository;
|
||||
|
||||
import org.dspace.app.rest.converter.ConverterService;
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.app.rest.utils.Utils;
|
||||
import org.dspace.core.Context;
|
||||
@@ -26,6 +27,9 @@ public abstract class AbstractDSpaceRestRepository {
|
||||
@Autowired
|
||||
protected Utils utils;
|
||||
|
||||
@Autowired
|
||||
protected ConverterService converter;
|
||||
|
||||
protected RequestService requestService = new DSpace().getRequestService();
|
||||
|
||||
protected Context obtainContext() {
|
||||
|
@@ -42,22 +42,21 @@ public class AuthorityRestRepository extends DSpaceRestRepository<AuthorityRest,
|
||||
@Override
|
||||
public AuthorityRest findOne(Context context, String name) {
|
||||
ChoiceAuthority source = cas.getChoiceAuthorityByAuthorityName(name);
|
||||
AuthorityRest result = authorityUtils.convertAuthority(source, name, utils.obtainProjection());
|
||||
return result;
|
||||
return authorityUtils.convertAuthority(source, name, utils.obtainProjection());
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('AUTHENTICATED')")
|
||||
@Override
|
||||
public Page<AuthorityRest> findAll(Context context, Pageable pageable) {
|
||||
Set<String> authoritiesName = cas.getChoiceAuthoritiesNames();
|
||||
List<AuthorityRest> results = new ArrayList<AuthorityRest>();
|
||||
List<AuthorityRest> results = new ArrayList<>();
|
||||
Projection projection = utils.obtainProjection(true);
|
||||
for (String authorityName : authoritiesName) {
|
||||
ChoiceAuthority source = cas.getChoiceAuthorityByAuthorityName(authorityName);
|
||||
AuthorityRest result = authorityUtils.convertAuthority(source, authorityName, projection);
|
||||
results.add(result);
|
||||
}
|
||||
return new PageImpl<AuthorityRest>(results, pageable, results.size());
|
||||
return new PageImpl<>(results, pageable, results.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -15,7 +15,6 @@ import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.dspace.app.rest.converter.ConverterService;
|
||||
import org.dspace.app.rest.exception.DSpaceBadRequestException;
|
||||
import org.dspace.app.rest.exception.UnprocessableEntityException;
|
||||
import org.dspace.app.rest.model.BitstreamFormatRest;
|
||||
@@ -43,14 +42,6 @@ public class BitstreamFormatRestRepository extends DSpaceRestRepository<Bitstrea
|
||||
@Autowired
|
||||
BitstreamFormatService bitstreamFormatService;
|
||||
|
||||
@Autowired
|
||||
ConverterService converter;
|
||||
|
||||
|
||||
public BitstreamFormatRestRepository() {
|
||||
System.out.println("Repository initialized by Spring");
|
||||
}
|
||||
|
||||
@Override
|
||||
public BitstreamFormatRest findOne(Context context, Integer id) {
|
||||
BitstreamFormat bit = null;
|
||||
@@ -67,16 +58,12 @@ public class BitstreamFormatRestRepository extends DSpaceRestRepository<Bitstrea
|
||||
|
||||
@Override
|
||||
public Page<BitstreamFormatRest> findAll(Context context, Pageable pageable) {
|
||||
List<BitstreamFormat> bit = null;
|
||||
try {
|
||||
bit = bitstreamFormatService.findAll(context);
|
||||
List<BitstreamFormat> bit = bitstreamFormatService.findAll(context);
|
||||
return converter.toRestPage(utils.getPage(bit, pageable), utils.obtainProjection(true));
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
Projection projection = utils.obtainProjection(true);
|
||||
Page<BitstreamFormatRest> page = utils.getPage(bit, pageable)
|
||||
.map((object) -> converter.toRest(object, projection));
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -14,7 +14,6 @@ import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dspace.app.rest.converter.BrowseEntryConverter;
|
||||
import org.dspace.app.rest.converter.ConverterService;
|
||||
import org.dspace.app.rest.model.BrowseEntryRest;
|
||||
import org.dspace.app.rest.model.BrowseIndexRest;
|
||||
import org.dspace.app.rest.projection.Projection;
|
||||
@@ -45,9 +44,6 @@ import org.springframework.stereotype.Component;
|
||||
public class BrowseEntryLinkRepository extends AbstractDSpaceRestRepository
|
||||
implements LinkRestRepository {
|
||||
|
||||
@Autowired
|
||||
ConverterService converter;
|
||||
|
||||
@Autowired
|
||||
BrowseEntryConverter browseEntryConverter;
|
||||
|
||||
|
@@ -7,18 +7,14 @@
|
||||
*/
|
||||
package org.dspace.app.rest.repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.dspace.app.rest.converter.ConverterService;
|
||||
import org.dspace.app.rest.model.BrowseIndexRest;
|
||||
import org.dspace.app.rest.projection.Projection;
|
||||
import org.dspace.browse.BrowseException;
|
||||
import org.dspace.browse.BrowseIndex;
|
||||
import org.dspace.core.Context;
|
||||
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.stereotype.Component;
|
||||
|
||||
@@ -30,9 +26,6 @@ import org.springframework.stereotype.Component;
|
||||
@Component(BrowseIndexRest.CATEGORY + "." + BrowseIndexRest.NAME)
|
||||
public class BrowseIndexRestRepository extends DSpaceRestRepository<BrowseIndexRest, String> {
|
||||
|
||||
@Autowired
|
||||
ConverterService converter;
|
||||
|
||||
@Override
|
||||
public BrowseIndexRest findOne(Context context, String name) {
|
||||
BrowseIndexRest bi = null;
|
||||
@@ -50,22 +43,12 @@ public class BrowseIndexRestRepository extends DSpaceRestRepository<BrowseIndexR
|
||||
|
||||
@Override
|
||||
public Page<BrowseIndexRest> findAll(Context context, Pageable pageable) {
|
||||
List<BrowseIndexRest> it = null;
|
||||
List<BrowseIndex> indexesList = new ArrayList<BrowseIndex>();
|
||||
int total = 0;
|
||||
try {
|
||||
BrowseIndex[] indexes = BrowseIndex.getBrowseIndices();
|
||||
total = indexes.length;
|
||||
for (BrowseIndex bix : indexes) {
|
||||
indexesList.add(bix);
|
||||
}
|
||||
List<BrowseIndex> indexes = Arrays.asList(BrowseIndex.getBrowseIndices());
|
||||
return converter.toRestPage(indexes, pageable, indexes.size(), utils.obtainProjection(true));
|
||||
} catch (BrowseException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
Projection projection = utils.obtainProjection(true);
|
||||
Page<BrowseIndexRest> page = new PageImpl<>(indexesList, pageable, total)
|
||||
.map((object) -> converter.toRest(object, projection));
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -14,7 +14,6 @@ import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dspace.app.rest.converter.ConverterService;
|
||||
import org.dspace.app.rest.model.BrowseIndexRest;
|
||||
import org.dspace.app.rest.model.ItemRest;
|
||||
import org.dspace.app.rest.projection.Projection;
|
||||
@@ -31,7 +30,6 @@ import org.dspace.sort.SortException;
|
||||
import org.dspace.sort.SortOption;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
@@ -47,8 +45,6 @@ import org.springframework.stereotype.Component;
|
||||
@Component(BrowseIndexRest.CATEGORY + "." + BrowseIndexRest.NAME + "." + BrowseIndexRest.ITEMS)
|
||||
public class BrowseItemLinkRepository extends AbstractDSpaceRestRepository
|
||||
implements LinkRestRepository {
|
||||
@Autowired
|
||||
ConverterService converter;
|
||||
|
||||
@Autowired
|
||||
ScopeResolver scopeResolver;
|
||||
@@ -153,9 +149,7 @@ public class BrowseItemLinkRepository extends AbstractDSpaceRestRepository
|
||||
tmpResult.add((Item) bb);
|
||||
}
|
||||
|
||||
Page<ItemRest> page = new PageImpl<Item>(tmpResult, pageResultInfo, binfo.getTotal())
|
||||
.map((object) -> converter.toRest(object, projection));
|
||||
return page;
|
||||
return converter.toRestPage(tmpResult, pageResultInfo, binfo.getTotal(), projection);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -18,7 +18,6 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.app.rest.Parameter;
|
||||
import org.dspace.app.rest.SearchRestMethod;
|
||||
import org.dspace.app.rest.converter.ConverterService;
|
||||
import org.dspace.app.rest.exception.RESTAuthorizationException;
|
||||
import org.dspace.app.rest.exception.RepositoryMethodNotImplementedException;
|
||||
import org.dspace.app.rest.exception.UnprocessableEntityException;
|
||||
@@ -69,9 +68,6 @@ public class ClaimedTaskRestRepository extends DSpaceRestRepository<ClaimedTaskR
|
||||
@Autowired
|
||||
ClaimedTaskService claimedTaskService;
|
||||
|
||||
@Autowired
|
||||
ConverterService converter;
|
||||
|
||||
@Autowired
|
||||
XmlWorkflowService workflowService;
|
||||
|
||||
@@ -100,7 +96,6 @@ public class ClaimedTaskRestRepository extends DSpaceRestRepository<ClaimedTaskR
|
||||
public Page<ClaimedTaskRest> findByUser(@Parameter(value = "uuid", required = true) UUID userID,
|
||||
Pageable pageable) {
|
||||
//FIXME this should be secured with annotation but they are currently ignored by search methods
|
||||
List<ClaimedTask> tasks = null;
|
||||
try {
|
||||
Context context = obtainContext();
|
||||
EPerson currentUser = context.getCurrentUser();
|
||||
@@ -111,16 +106,14 @@ public class ClaimedTaskRestRepository extends DSpaceRestRepository<ClaimedTaskR
|
||||
}
|
||||
if (authorizeService.isAdmin(context) || userID.equals(currentUser.getID())) {
|
||||
EPerson ep = epersonService.find(context, userID);
|
||||
tasks = claimedTaskService.findByEperson(context, ep);
|
||||
List<ClaimedTask> tasks = claimedTaskService.findByEperson(context, ep);
|
||||
return converter.toRestPage(utils.getPage(tasks, pageable), utils.obtainProjection(true));
|
||||
} else {
|
||||
throw new RESTAuthorizationException("Only administrators can search for claimed tasks of other users");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
Page<ClaimedTaskRest> page = utils.getPage(tasks, pageable)
|
||||
.map((object) -> converter.toRest(object, utils.obtainProjection()));
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -9,7 +9,6 @@ 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.ServletInputStream;
|
||||
@@ -19,7 +18,6 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.dspace.app.rest.Parameter;
|
||||
import org.dspace.app.rest.SearchRestMethod;
|
||||
import org.dspace.app.rest.converter.ConverterService;
|
||||
import org.dspace.app.rest.exception.DSpaceBadRequestException;
|
||||
import org.dspace.app.rest.exception.RepositoryMethodNotImplementedException;
|
||||
import org.dspace.app.rest.exception.UnprocessableEntityException;
|
||||
@@ -38,7 +36,6 @@ import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
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.rest.webmvc.ResourceNotFoundException;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -58,9 +55,6 @@ public class CollectionRestRepository extends DSpaceObjectRestRepository<Collect
|
||||
@Autowired
|
||||
CommunityService communityService;
|
||||
|
||||
@Autowired
|
||||
ConverterService converter;
|
||||
|
||||
@Autowired
|
||||
CollectionRestEqualityUtils collectionRestEqualityUtils;
|
||||
|
||||
@@ -86,65 +80,42 @@ public class CollectionRestRepository extends DSpaceObjectRestRepository<Collect
|
||||
|
||||
@Override
|
||||
public Page<CollectionRest> findAll(Context context, Pageable pageable) {
|
||||
List<Collection> it = null;
|
||||
List<Collection> collections = new ArrayList<Collection>();
|
||||
int total = 0;
|
||||
try {
|
||||
total = cs.countTotal(context);
|
||||
it = cs.findAll(context, pageable.getPageSize(), pageable.getOffset());
|
||||
for (Collection c : it) {
|
||||
collections.add(c);
|
||||
}
|
||||
long total = cs.countTotal(context);
|
||||
List<Collection> collections = cs.findAll(context, pageable.getPageSize(), pageable.getOffset());
|
||||
return converter.toRestPage(collections, pageable, total, utils.obtainProjection(true));
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
Projection projection = utils.obtainProjection(true);
|
||||
Page<CollectionRest> page = new PageImpl<>(collections, pageable, total)
|
||||
.map((object) -> converter.toRest(object, projection));
|
||||
return page;
|
||||
}
|
||||
|
||||
@SearchRestMethod(name = "findAuthorizedByCommunity")
|
||||
public Page<CollectionRest> findAuthorizedByCommunity(
|
||||
@Parameter(value = "uuid", required = true) UUID communityUuid, Pageable pageable) {
|
||||
Context context = obtainContext();
|
||||
List<Collection> it = null;
|
||||
List<Collection> collections = new ArrayList<Collection>();
|
||||
try {
|
||||
Context context = obtainContext();
|
||||
Community com = communityService.find(context, communityUuid);
|
||||
if (com == null) {
|
||||
throw new ResourceNotFoundException(
|
||||
CommunityRest.CATEGORY + "." + CommunityRest.NAME + " with id: " + communityUuid
|
||||
+ " not found");
|
||||
}
|
||||
it = cs.findAuthorized(context, com, Constants.ADD);
|
||||
for (Collection c : it) {
|
||||
collections.add(c);
|
||||
}
|
||||
List<Collection> collections = cs.findAuthorized(context, com, Constants.ADD);
|
||||
return converter.toRestPage(utils.getPage(collections, pageable), utils.obtainProjection(true));
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
Page<CollectionRest> page = utils.getPage(collections, pageable)
|
||||
.map((object) -> converter.toRest(object, utils.obtainProjection()));
|
||||
return page;
|
||||
}
|
||||
|
||||
@SearchRestMethod(name = "findAuthorized")
|
||||
public Page<CollectionRest> findAuthorized(Pageable pageable) {
|
||||
Context context = obtainContext();
|
||||
List<Collection> it = null;
|
||||
List<Collection> collections = new ArrayList<Collection>();
|
||||
try {
|
||||
it = cs.findAuthorizedOptimized(context, Constants.ADD);
|
||||
for (Collection c : it) {
|
||||
collections.add(c);
|
||||
}
|
||||
Context context = obtainContext();
|
||||
List<Collection> collections = cs.findAuthorizedOptimized(context, Constants.ADD);
|
||||
return converter.toRestPage(utils.getPage(collections, pageable), utils.obtainProjection(true));
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
Page<CollectionRest> page = utils.getPage(collections, pageable)
|
||||
.map((object) -> converter.toRest(object, utils.obtainProjection()));
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -9,7 +9,6 @@ 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.ServletInputStream;
|
||||
@@ -33,7 +32,6 @@ import org.dspace.content.service.CommunityService;
|
||||
import org.dspace.core.Context;
|
||||
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.rest.webmvc.ResourceNotFoundException;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -138,37 +136,25 @@ public class CommunityRestRepository extends DSpaceObjectRestRepository<Communit
|
||||
|
||||
@Override
|
||||
public Page<CommunityRest> findAll(Context context, Pageable pageable) {
|
||||
List<Community> it = null;
|
||||
List<Community> communities = new ArrayList<Community>();
|
||||
int total = 0;
|
||||
try {
|
||||
total = cs.countTotal(context);
|
||||
it = cs.findAll(context, pageable.getPageSize(), pageable.getOffset());
|
||||
for (Community c : it) {
|
||||
communities.add(c);
|
||||
}
|
||||
long total = cs.countTotal(context);
|
||||
List<Community> communities = cs.findAll(context, pageable.getPageSize(), pageable.getOffset());
|
||||
return converter.toRestPage(communities, pageable, total, utils.obtainProjection(true));
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
Projection projection = utils.obtainProjection(true);
|
||||
Page<CommunityRest> page = new PageImpl<>(communities, pageable, total)
|
||||
.map((object) -> converter.toRest(object, projection));
|
||||
return page;
|
||||
}
|
||||
|
||||
// TODO: Add methods in dspace api to support pagination of top level
|
||||
// communities
|
||||
@SearchRestMethod(name = "top")
|
||||
public Page<CommunityRest> findAllTop(Pageable pageable) {
|
||||
List<Community> topCommunities = null;
|
||||
try {
|
||||
topCommunities = cs.findAllTop(obtainContext());
|
||||
List<Community> communities = cs.findAllTop(obtainContext());
|
||||
return converter.toRestPage(utils.getPage(communities, pageable), utils.obtainProjection(true));
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
Page<CommunityRest> page = utils.getPage(topCommunities, pageable)
|
||||
.map((object) -> converter.toRest(object, utils.obtainProjection()));
|
||||
return page;
|
||||
}
|
||||
|
||||
// TODO: add method in dspace api to support direct query for subcommunities
|
||||
@@ -177,20 +163,17 @@ public class CommunityRestRepository extends DSpaceObjectRestRepository<Communit
|
||||
public Page<CommunityRest> findSubCommunities(@Parameter(value = "parent", required = true) UUID parentCommunity,
|
||||
Pageable pageable) {
|
||||
Context context = obtainContext();
|
||||
List<Community> subCommunities = new ArrayList<Community>();
|
||||
try {
|
||||
Community community = cs.find(context, parentCommunity);
|
||||
if (community == null) {
|
||||
throw new ResourceNotFoundException(
|
||||
CommunityRest.CATEGORY + "." + CommunityRest.NAME + " with id: " + parentCommunity + " not found");
|
||||
}
|
||||
subCommunities = community.getSubcommunities();
|
||||
List<Community> subCommunities = community.getSubcommunities();
|
||||
return converter.toRestPage(utils.getPage(subCommunities, pageable), utils.obtainProjection(true));
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
Page<CommunityRest> page = utils.getPage(subCommunities, pageable)
|
||||
.map((object) -> converter.toRest(object, utils.obtainProjection()));
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -10,7 +10,6 @@ package org.dspace.app.rest.repository;
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.dspace.app.rest.converter.ConverterService;
|
||||
import org.dspace.app.rest.converter.MetadataConverter;
|
||||
import org.dspace.app.rest.exception.UnprocessableEntityException;
|
||||
import org.dspace.app.rest.model.DSpaceObjectRest;
|
||||
@@ -38,9 +37,6 @@ public abstract class DSpaceObjectRestRepository<M extends DSpaceObject, R exten
|
||||
@Autowired
|
||||
MetadataConverter metadataConverter;
|
||||
|
||||
@Autowired
|
||||
ConverterService converter;
|
||||
|
||||
DSpaceObjectRestRepository(DSpaceObjectService<M> dsoService,
|
||||
DSpaceObjectPatch<R> dsoPatch) {
|
||||
this.dsoService = dsoService;
|
||||
|
@@ -18,7 +18,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dspace.app.rest.Parameter;
|
||||
import org.dspace.app.rest.SearchRestMethod;
|
||||
import org.dspace.app.rest.exception.RESTAuthorizationException;
|
||||
import org.dspace.app.rest.exception.UnprocessableEntityException;
|
||||
import org.dspace.app.rest.model.EPersonRest;
|
||||
import org.dspace.app.rest.model.patch.Patch;
|
||||
@@ -31,7 +30,6 @@ import org.dspace.eperson.EPerson;
|
||||
import org.dspace.eperson.service.EPersonService;
|
||||
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.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -112,22 +110,13 @@ public class EPersonRestRepository extends DSpaceObjectRestRepository<EPerson, E
|
||||
@Override
|
||||
@PreAuthorize("hasAuthority('ADMIN')")
|
||||
public Page<EPersonRest> findAll(Context context, Pageable pageable) {
|
||||
List<EPerson> epersons = null;
|
||||
int total = 0;
|
||||
try {
|
||||
if (!authorizeService.isAdmin(context)) {
|
||||
throw new RESTAuthorizationException(
|
||||
"The EPerson collection endpoint is reserved to system administrators");
|
||||
}
|
||||
total = es.countTotal(context);
|
||||
epersons = es.findAll(context, EPerson.EMAIL, pageable.getPageSize(), pageable.getOffset());
|
||||
long total = es.countTotal(context);
|
||||
List<EPerson> epersons = es.findAll(context, EPerson.EMAIL, pageable.getPageSize(), pageable.getOffset());
|
||||
return converter.toRestPage(epersons, pageable, total, utils.obtainProjection(true));
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
Projection projection = utils.obtainProjection(true);
|
||||
Page<EPersonRest> page = new PageImpl<>(epersons, pageable, total)
|
||||
.map((object) -> converter.toRest(object, projection));
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,18 +132,15 @@ public class EPersonRestRepository extends DSpaceObjectRestRepository<EPerson, E
|
||||
@SearchRestMethod(name = "byName")
|
||||
public Page<EPersonRest> findByName(@Parameter(value = "q", required = true) String q,
|
||||
Pageable pageable) {
|
||||
List<EPerson> epersons = null;
|
||||
int total = 0;
|
||||
try {
|
||||
Context context = obtainContext();
|
||||
epersons = es.search(context, q, pageable.getOffset(), pageable.getOffset() + pageable.getPageSize());
|
||||
total = es.searchResultCount(context, q);
|
||||
long total = es.searchResultCount(context, q);
|
||||
List<EPerson> epersons = es.search(context, q, pageable.getOffset(),
|
||||
pageable.getOffset() + pageable.getPageSize());
|
||||
return converter.toRestPage(epersons, pageable, total, utils.obtainProjection(true));
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
Page<EPersonRest> page = new PageImpl<>(epersons, pageable, total)
|
||||
.map((object) -> converter.toRest(object, utils.obtainProjection()));
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -10,9 +10,7 @@ package org.dspace.app.rest.repository;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import org.dspace.app.rest.converter.ConverterService;
|
||||
import org.dspace.app.rest.model.EntityTypeRest;
|
||||
import org.dspace.app.rest.projection.Projection;
|
||||
import org.dspace.content.EntityType;
|
||||
import org.dspace.content.service.EntityTypeService;
|
||||
import org.dspace.core.Context;
|
||||
@@ -31,9 +29,6 @@ public class EntityTypeRestRepository extends DSpaceRestRepository<EntityTypeRes
|
||||
@Autowired
|
||||
private EntityTypeService entityTypeService;
|
||||
|
||||
@Autowired
|
||||
private ConverterService converter;
|
||||
|
||||
public EntityTypeRest findOne(Context context, Integer integer) {
|
||||
try {
|
||||
EntityType entityType = entityTypeService.find(context, integer);
|
||||
@@ -47,16 +42,12 @@ public class EntityTypeRestRepository extends DSpaceRestRepository<EntityTypeRes
|
||||
}
|
||||
|
||||
public Page<EntityTypeRest> findAll(Context context, Pageable pageable) {
|
||||
List<EntityType> entityTypeList = null;
|
||||
try {
|
||||
entityTypeList = entityTypeService.findAll(context);
|
||||
List<EntityType> entityTypes = entityTypeService.findAll(context);
|
||||
return converter.toRestPage(utils.getPage(entityTypes, pageable), utils.obtainProjection(true));
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
Projection projection = utils.obtainProjection(true);
|
||||
Page<EntityTypeRest> page = utils.getPage(entityTypeList, pageable)
|
||||
.map((object) -> converter.toRest(object, projection));
|
||||
return page;
|
||||
}
|
||||
|
||||
public Class<EntityTypeRest> getDomainClass() {
|
||||
|
@@ -27,7 +27,6 @@ import org.dspace.eperson.Group;
|
||||
import org.dspace.eperson.service.GroupService;
|
||||
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.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -97,18 +96,13 @@ public class GroupRestRepository extends DSpaceObjectRestRepository<Group, Group
|
||||
@PreAuthorize("hasAuthority('ADMIN')")
|
||||
@Override
|
||||
public Page<GroupRest> findAll(Context context, Pageable pageable) {
|
||||
List<Group> groups = null;
|
||||
int total = 0;
|
||||
try {
|
||||
total = gs.countTotal(context);
|
||||
groups = gs.findAll(context, null, pageable.getPageSize(), pageable.getOffset());
|
||||
long total = gs.countTotal(context);
|
||||
List<Group> groups = gs.findAll(context, null, pageable.getPageSize(), pageable.getOffset());
|
||||
return converter.toRestPage(groups, pageable, total, utils.obtainProjection(true));
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
Projection projection = utils.obtainProjection(true);
|
||||
Page<GroupRest> page = new PageImpl<Group>(groups, pageable, total)
|
||||
.map((object) -> converter.toRest(object, projection));
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -17,7 +17,6 @@ import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.dspace.app.rest.converter.ConverterService;
|
||||
import org.dspace.app.rest.converter.HarvestedCollectionConverter;
|
||||
import org.dspace.app.rest.exception.UnprocessableEntityException;
|
||||
import org.dspace.app.rest.model.HarvestTypeEnum;
|
||||
@@ -46,9 +45,6 @@ public class HarvestedCollectionRestRepository extends AbstractDSpaceRestReposit
|
||||
@Autowired
|
||||
HarvestedCollectionConverter harvestedCollectionConverter;
|
||||
|
||||
@Autowired
|
||||
ConverterService converter;
|
||||
|
||||
public HarvestedCollectionRest findOne(Collection collection) throws SQLException {
|
||||
Context context = obtainContext();
|
||||
|
||||
|
@@ -13,7 +13,6 @@ import java.util.UUID;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.dspace.app.rest.converter.ConverterService;
|
||||
import org.dspace.app.rest.model.ItemRest;
|
||||
import org.dspace.app.rest.model.RelationshipRest;
|
||||
import org.dspace.app.rest.projection.Projection;
|
||||
@@ -24,7 +23,6 @@ import org.dspace.content.service.RelationshipService;
|
||||
import org.dspace.core.Context;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -42,9 +40,6 @@ public class ItemRelationshipLinkRepository extends AbstractDSpaceRestRepository
|
||||
@Autowired
|
||||
ItemService itemService;
|
||||
|
||||
@Autowired
|
||||
ConverterService converter;
|
||||
|
||||
//@PreAuthorize("hasPermission(#itemId, 'ITEM', 'READ')")
|
||||
public Page<RelationshipRest> getItemRelationships(@Nullable HttpServletRequest request,
|
||||
UUID itemId,
|
||||
@@ -61,8 +56,7 @@ public class ItemRelationshipLinkRepository extends AbstractDSpaceRestRepository
|
||||
Integer offset = pageable == null ? null : pageable.getOffset();
|
||||
int total = relationshipService.countByItem(context, item);
|
||||
List<Relationship> relationships = relationshipService.findByItem(context, item, limit, offset);
|
||||
return new PageImpl<>(relationships, pageable, total)
|
||||
.map((object) -> converter.toRest(object, projection));
|
||||
return converter.toRestPage(relationships, pageable, total, projection);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@@ -40,7 +40,6 @@ import org.dspace.core.Context;
|
||||
import org.dspace.util.UUIDUtils;
|
||||
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.rest.webmvc.ResourceNotFoundException;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -100,21 +99,17 @@ public class ItemRestRepository extends DSpaceObjectRestRepository<Item, ItemRes
|
||||
@Override
|
||||
@PreAuthorize("hasAuthority('ADMIN')")
|
||||
public Page<ItemRest> findAll(Context context, Pageable pageable) {
|
||||
Iterator<Item> it = null;
|
||||
List<Item> items = new ArrayList<Item>();
|
||||
int total = 0;
|
||||
try {
|
||||
total = is.countTotal(context);
|
||||
it = is.findAll(context, pageable.getPageSize(), pageable.getOffset());
|
||||
long total = is.countTotal(context);
|
||||
Iterator<Item> it = is.findAll(context, pageable.getPageSize(), pageable.getOffset());
|
||||
List<Item> items = new ArrayList<>();
|
||||
while (it.hasNext()) {
|
||||
Item i = it.next();
|
||||
items.add(i);
|
||||
items.add(it.next());
|
||||
}
|
||||
return converter.toRestPage(items, pageable, total, utils.obtainProjection(true));
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
Projection projection = utils.obtainProjection(true);
|
||||
return new PageImpl<>(items, pageable, total).map((object) -> converter.toRest(object, projection));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -21,7 +21,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.gson.Gson;
|
||||
import org.dspace.app.rest.Parameter;
|
||||
import org.dspace.app.rest.SearchRestMethod;
|
||||
import org.dspace.app.rest.converter.ConverterService;
|
||||
import org.dspace.app.rest.exception.DSpaceBadRequestException;
|
||||
import org.dspace.app.rest.exception.UnprocessableEntityException;
|
||||
import org.dspace.app.rest.model.MetadataFieldRest;
|
||||
@@ -54,12 +53,6 @@ public class MetadataFieldRestRepository extends DSpaceRestRepository<MetadataFi
|
||||
@Autowired
|
||||
MetadataSchemaService metadataSchemaService;
|
||||
|
||||
@Autowired
|
||||
ConverterService converter;
|
||||
|
||||
public MetadataFieldRestRepository() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetadataFieldRest findOne(Context context, Integer id) {
|
||||
MetadataField metadataField = null;
|
||||
@@ -76,36 +69,28 @@ public class MetadataFieldRestRepository extends DSpaceRestRepository<MetadataFi
|
||||
|
||||
@Override
|
||||
public Page<MetadataFieldRest> findAll(Context context, Pageable pageable) {
|
||||
List<MetadataField> metadataField = null;
|
||||
try {
|
||||
metadataField = metadataFieldService.findAll(context);
|
||||
List<MetadataField> metadataFields = metadataFieldService.findAll(context);
|
||||
return converter.toRestPage(utils.getPage(metadataFields, pageable), utils.obtainProjection(true));
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
Projection projection = utils.obtainProjection(true);
|
||||
Page<MetadataFieldRest> page = utils.getPage(metadataField, pageable)
|
||||
.map((object) -> converter.toRest(object, projection));
|
||||
return page;
|
||||
}
|
||||
|
||||
@SearchRestMethod(name = "bySchema")
|
||||
public Page<MetadataFieldRest> findBySchema(@Parameter(value = "schema", required = true) String schemaName,
|
||||
Pageable pageable) {
|
||||
Context context = obtainContext();
|
||||
List<MetadataField> metadataFields = null;
|
||||
try {
|
||||
Context context = obtainContext();
|
||||
MetadataSchema schema = metadataSchemaService.find(context, schemaName);
|
||||
if (schema == null) {
|
||||
return null;
|
||||
}
|
||||
metadataFields = metadataFieldService.findAllInSchema(context, schema);
|
||||
List<MetadataField> metadataFields = metadataFieldService.findAllInSchema(context, schema);
|
||||
return converter.toRestPage(utils.getPage(metadataFields, pageable), utils.obtainProjection(true));
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
Projection projection = utils.obtainProjection(true);
|
||||
Page<MetadataFieldRest> page = utils.getPage(metadataFields, pageable)
|
||||
.map((object) -> converter.toRest(object, projection));
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -18,7 +18,6 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.gson.Gson;
|
||||
import org.dspace.app.rest.converter.ConverterService;
|
||||
import org.dspace.app.rest.exception.DSpaceBadRequestException;
|
||||
import org.dspace.app.rest.exception.UnprocessableEntityException;
|
||||
import org.dspace.app.rest.model.MetadataSchemaRest;
|
||||
@@ -46,12 +45,6 @@ public class MetadataSchemaRestRepository extends DSpaceRestRepository<MetadataS
|
||||
@Autowired
|
||||
MetadataSchemaService metadataSchemaService;
|
||||
|
||||
@Autowired
|
||||
ConverterService converter;
|
||||
|
||||
public MetadataSchemaRestRepository() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetadataSchemaRest findOne(Context context, Integer id) {
|
||||
MetadataSchema metadataSchema = null;
|
||||
@@ -68,16 +61,12 @@ public class MetadataSchemaRestRepository extends DSpaceRestRepository<MetadataS
|
||||
|
||||
@Override
|
||||
public Page<MetadataSchemaRest> findAll(Context context, Pageable pageable) {
|
||||
List<MetadataSchema> metadataSchema = null;
|
||||
try {
|
||||
metadataSchema = metadataSchemaService.findAll(context);
|
||||
List<MetadataSchema> metadataSchemas = metadataSchemaService.findAll(context);
|
||||
return converter.toRestPage(utils.getPage(metadataSchemas, pageable), utils.obtainProjection(true));
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
Projection projection = utils.obtainProjection(true);
|
||||
Page<MetadataSchemaRest> page = utils.getPage(metadataSchema, pageable)
|
||||
.map((object) -> converter.toRest(object, projection));
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -17,11 +17,9 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.app.rest.Parameter;
|
||||
import org.dspace.app.rest.SearchRestMethod;
|
||||
import org.dspace.app.rest.converter.ConverterService;
|
||||
import org.dspace.app.rest.exception.RESTAuthorizationException;
|
||||
import org.dspace.app.rest.exception.UnprocessableEntityException;
|
||||
import org.dspace.app.rest.model.PoolTaskRest;
|
||||
import org.dspace.app.rest.projection.Projection;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.authorize.service.AuthorizeService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
@@ -65,9 +63,6 @@ public class PoolTaskRestRepository extends DSpaceRestRepository<PoolTaskRest, I
|
||||
@Autowired
|
||||
PoolTaskService poolTaskService;
|
||||
|
||||
@Autowired
|
||||
ConverterService converter;
|
||||
|
||||
@Autowired
|
||||
XmlWorkflowService workflowService;
|
||||
|
||||
@@ -94,7 +89,6 @@ public class PoolTaskRestRepository extends DSpaceRestRepository<PoolTaskRest, I
|
||||
|
||||
@SearchRestMethod(name = "findByUser")
|
||||
public Page<PoolTaskRest> findByUser(@Parameter(value = "uuid") UUID userID, Pageable pageable) {
|
||||
List<PoolTask> tasks = null;
|
||||
try {
|
||||
Context context = obtainContext();
|
||||
//FIXME this should be secured with annotation but they are currently ignored by search methods
|
||||
@@ -106,7 +100,8 @@ public class PoolTaskRestRepository extends DSpaceRestRepository<PoolTaskRest, I
|
||||
}
|
||||
if (authorizeService.isAdmin(context) || userID.equals(currentUser.getID())) {
|
||||
EPerson ep = epersonService.find(context, userID);
|
||||
tasks = poolTaskService.findByEperson(context, ep);
|
||||
List<PoolTask> tasks = poolTaskService.findByEperson(context, ep);
|
||||
return converter.toRestPage(utils.getPage(tasks, pageable), utils.obtainProjection(true));
|
||||
} else {
|
||||
throw new RESTAuthorizationException("Only administrators can search for pool tasks of other users");
|
||||
}
|
||||
@@ -115,10 +110,6 @@ public class PoolTaskRestRepository extends DSpaceRestRepository<PoolTaskRest, I
|
||||
} catch (SQLException | IOException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
Projection projection = utils.obtainProjection(true);
|
||||
Page<PoolTaskRest> page = utils.getPage(tasks, pageable)
|
||||
.map((object) -> converter.toRest(object, projection));
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -9,7 +9,6 @@ package org.dspace.app.rest.repository;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@@ -20,7 +19,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.app.rest.Parameter;
|
||||
import org.dspace.app.rest.SearchRestMethod;
|
||||
import org.dspace.app.rest.converter.ConverterService;
|
||||
import org.dspace.app.rest.exception.RepositoryMethodNotImplementedException;
|
||||
import org.dspace.app.rest.exception.UnprocessableEntityException;
|
||||
import org.dspace.app.rest.model.RelationshipRest;
|
||||
@@ -39,7 +37,6 @@ import org.dspace.core.Context;
|
||||
import org.dspace.eperson.EPerson;
|
||||
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.rest.webmvc.ResourceNotFoundException;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
@@ -53,7 +50,6 @@ public class RelationshipRestRepository extends DSpaceRestRepository<Relationshi
|
||||
|
||||
private static final Logger log = Logger.getLogger(RelationshipRestRepository.class);
|
||||
|
||||
|
||||
@Autowired
|
||||
private ItemService itemService;
|
||||
|
||||
@@ -63,9 +59,6 @@ public class RelationshipRestRepository extends DSpaceRestRepository<Relationshi
|
||||
@Autowired
|
||||
private RelationshipTypeService relationshipTypeService;
|
||||
|
||||
@Autowired
|
||||
private ConverterService converter;
|
||||
|
||||
@Autowired
|
||||
private AuthorizeService authorizeService;
|
||||
|
||||
@@ -80,19 +73,14 @@ public class RelationshipRestRepository extends DSpaceRestRepository<Relationshi
|
||||
|
||||
@Override
|
||||
public Page<RelationshipRest> findAll(Context context, Pageable pageable) {
|
||||
int total = 0;
|
||||
List<Relationship> relationships = new ArrayList<>();
|
||||
try {
|
||||
total = relationshipService.countTotal(context);
|
||||
relationships = relationshipService.findAll(context,
|
||||
long total = relationshipService.countTotal(context);
|
||||
List<Relationship> relationships = relationshipService.findAll(context,
|
||||
pageable.getPageSize(), pageable.getOffset());
|
||||
return converter.toRestPage(relationships, pageable, total, utils.obtainProjection(true));
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
Projection projection = utils.obtainProjection(true);
|
||||
Page<RelationshipRest> page = new PageImpl<>(relationships, pageable, total)
|
||||
.map((object) -> converter.toRest(object, projection));
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -343,10 +331,6 @@ public class RelationshipRestRepository extends DSpaceRestRepository<Relationshi
|
||||
}
|
||||
}
|
||||
|
||||
Projection projection = utils.obtainProjection(true);
|
||||
Page<RelationshipRest> page = new PageImpl<>(relationships, pageable, total)
|
||||
.map((object) -> converter.toRest(object, projection));
|
||||
return page;
|
||||
|
||||
return converter.toRestPage(relationships, pageable, total, utils.obtainProjection(true));
|
||||
}
|
||||
}
|
||||
|
@@ -10,9 +10,7 @@ package org.dspace.app.rest.repository;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import org.dspace.app.rest.converter.ConverterService;
|
||||
import org.dspace.app.rest.model.RelationshipTypeRest;
|
||||
import org.dspace.app.rest.projection.Projection;
|
||||
import org.dspace.content.RelationshipType;
|
||||
import org.dspace.content.service.RelationshipTypeService;
|
||||
import org.dspace.core.Context;
|
||||
@@ -30,9 +28,6 @@ public class RelationshipTypeRestRepository extends DSpaceRestRepository<Relatio
|
||||
@Autowired
|
||||
private RelationshipTypeService relationshipTypeService;
|
||||
|
||||
@Autowired
|
||||
private ConverterService converter;
|
||||
|
||||
@Override
|
||||
public RelationshipTypeRest findOne(Context context, Integer integer) {
|
||||
try {
|
||||
@@ -44,16 +39,12 @@ public class RelationshipTypeRestRepository extends DSpaceRestRepository<Relatio
|
||||
|
||||
@Override
|
||||
public Page<RelationshipTypeRest> findAll(Context context, Pageable pageable) {
|
||||
List<RelationshipType> relationshipTypeList = null;
|
||||
try {
|
||||
relationshipTypeList = relationshipTypeService.findAll(context);
|
||||
List<RelationshipType> relationshipTypes = relationshipTypeService.findAll(context);
|
||||
return converter.toRestPage(utils.getPage(relationshipTypes, pageable), utils.obtainProjection(true));
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
Projection projection = utils.obtainProjection(true);
|
||||
Page<RelationshipTypeRest> page = utils.getPage(relationshipTypeList, pageable)
|
||||
.map((object) -> converter.toRest(object, projection));
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -9,10 +9,8 @@ package org.dspace.app.rest.repository;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.dspace.app.rest.converter.ConverterService;
|
||||
import org.dspace.app.rest.exception.RepositoryMethodNotImplementedException;
|
||||
import org.dspace.app.rest.model.ResourcePolicyRest;
|
||||
import org.dspace.app.rest.utils.Utils;
|
||||
import org.dspace.authorize.ResourcePolicy;
|
||||
import org.dspace.authorize.service.ResourcePolicyService;
|
||||
import org.dspace.core.Context;
|
||||
@@ -33,12 +31,6 @@ public class ResourcePolicyRestRepository extends DSpaceRestRepository<ResourceP
|
||||
@Autowired
|
||||
ResourcePolicyService resourcePolicyService;
|
||||
|
||||
@Autowired
|
||||
ConverterService converter;
|
||||
|
||||
@Autowired
|
||||
Utils utils;
|
||||
|
||||
@PreAuthorize("hasAuthority('AUTHENTICATED')")
|
||||
@Override
|
||||
public ResourcePolicyRest findOne(Context context, Integer id) {
|
||||
|
@@ -8,14 +8,13 @@
|
||||
package org.dspace.app.rest.repository;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.dspace.app.rest.model.SiteRest;
|
||||
import org.dspace.app.rest.model.patch.Patch;
|
||||
import org.dspace.app.rest.projection.Projection;
|
||||
import org.dspace.app.rest.repository.patch.DSpaceObjectPatch;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Site;
|
||||
@@ -23,7 +22,6 @@ import org.dspace.content.service.SiteService;
|
||||
import org.dspace.core.Context;
|
||||
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.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -61,17 +59,12 @@ public class SiteRestRepository extends DSpaceObjectRestRepository<Site, SiteRes
|
||||
|
||||
@Override
|
||||
public Page<SiteRest> findAll(Context context, Pageable pageable) {
|
||||
List<Site> sites = new ArrayList<Site>();
|
||||
int total = 1;
|
||||
try {
|
||||
sites.add(sitesv.findSite(context));
|
||||
List<Site> sites = Arrays.asList(sitesv.findSite(context));
|
||||
return converter.toRestPage(sites, pageable, 1L, utils.obtainProjection(true));
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
Projection projection = utils.obtainProjection(true);
|
||||
Page<SiteRest> page = new PageImpl<Site>(sites, pageable, total)
|
||||
.map((object) -> converter.toRest(object, projection));
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -13,7 +13,6 @@ import org.springframework.stereotype.Component;
|
||||
@Component(StatisticsSupportRest.CATEGORY + "." + StatisticsSupportRest.NAME)
|
||||
public class StatisticsRestRepository extends AbstractDSpaceRestRepository {
|
||||
|
||||
|
||||
public StatisticsSupportRest getStatisticsSupport() {
|
||||
return new StatisticsSupportRest();
|
||||
}
|
||||
|
@@ -13,9 +13,7 @@ import java.util.UUID;
|
||||
|
||||
import org.dspace.app.rest.Parameter;
|
||||
import org.dspace.app.rest.SearchRestMethod;
|
||||
import org.dspace.app.rest.converter.ConverterService;
|
||||
import org.dspace.app.rest.model.SubmissionDefinitionRest;
|
||||
import org.dspace.app.rest.projection.Projection;
|
||||
import org.dspace.app.util.SubmissionConfig;
|
||||
import org.dspace.app.util.SubmissionConfigReader;
|
||||
import org.dspace.app.util.SubmissionConfigReaderException;
|
||||
@@ -23,9 +21,7 @@ import org.dspace.content.Collection;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.CollectionService;
|
||||
import org.dspace.core.Context;
|
||||
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.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -41,9 +37,6 @@ public class SubmissionDefinitionRestRepository extends DSpaceRestRepository<Sub
|
||||
|
||||
private CollectionService collectionService = ContentServiceFactory.getInstance().getCollectionService();
|
||||
|
||||
@Autowired
|
||||
private ConverterService converter;
|
||||
|
||||
public SubmissionDefinitionRestRepository() throws SubmissionConfigReaderException {
|
||||
submissionConfigReader = new SubmissionConfigReader();
|
||||
}
|
||||
@@ -64,10 +57,7 @@ public class SubmissionDefinitionRestRepository extends DSpaceRestRepository<Sub
|
||||
int total = submissionConfigReader.countSubmissionConfigs();
|
||||
List<SubmissionConfig> subConfs = submissionConfigReader.getAllSubmissionConfigs(
|
||||
pageable.getPageSize(), pageable.getOffset());
|
||||
Projection projection = utils.obtainProjection(true);
|
||||
Page<SubmissionDefinitionRest> page = new PageImpl<>(subConfs, pageable, total)
|
||||
.map((object) -> converter.toRest(object, projection));
|
||||
return page;
|
||||
return converter.toRestPage(subConfs, pageable, total, utils.obtainProjection(true));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('AUTHENTICATED')")
|
||||
|
@@ -7,19 +7,14 @@
|
||||
*/
|
||||
package org.dspace.app.rest.repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.dspace.app.rest.converter.ConverterService;
|
||||
import org.dspace.app.rest.model.SubmissionFormRest;
|
||||
import org.dspace.app.rest.projection.Projection;
|
||||
import org.dspace.app.util.DCInputSet;
|
||||
import org.dspace.app.util.DCInputsReader;
|
||||
import org.dspace.app.util.DCInputsReaderException;
|
||||
import org.dspace.core.Context;
|
||||
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.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -35,9 +30,6 @@ public class SubmissionFormRestRepository extends DSpaceRestRepository<Submissio
|
||||
|
||||
private DCInputsReader inputReader;
|
||||
|
||||
@Autowired
|
||||
private ConverterService converter;
|
||||
|
||||
public SubmissionFormRestRepository() throws DCInputsReaderException {
|
||||
inputReader = new DCInputsReader();
|
||||
}
|
||||
@@ -60,17 +52,13 @@ public class SubmissionFormRestRepository extends DSpaceRestRepository<Submissio
|
||||
@PreAuthorize("hasAuthority('AUTHENTICATED')")
|
||||
@Override
|
||||
public Page<SubmissionFormRest> findAll(Context context, Pageable pageable) {
|
||||
List<DCInputSet> subConfs = new ArrayList<DCInputSet>();
|
||||
int total = inputReader.countInputs();
|
||||
try {
|
||||
subConfs = inputReader.getAllInputs(pageable.getPageSize(), pageable.getOffset());
|
||||
long total = inputReader.countInputs();
|
||||
List<DCInputSet> subConfs = inputReader.getAllInputs(pageable.getPageSize(), pageable.getOffset());
|
||||
return converter.toRestPage(subConfs, pageable, total, utils.obtainProjection(true));
|
||||
} catch (DCInputsReaderException e) {
|
||||
throw new IllegalStateException(e.getMessage(), e);
|
||||
}
|
||||
Projection projection = utils.obtainProjection(true);
|
||||
Page<SubmissionFormRest> page = new PageImpl<>(subConfs, pageable, total)
|
||||
.map((object) -> converter.toRest(object, projection));
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -10,18 +10,14 @@ package org.dspace.app.rest.repository;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.dspace.app.rest.converter.ConverterService;
|
||||
import org.dspace.app.rest.model.SubmissionDefinitionRest;
|
||||
import org.dspace.app.rest.model.SubmissionSectionRest;
|
||||
import org.dspace.app.rest.projection.Projection;
|
||||
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.core.Context;
|
||||
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.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -36,9 +32,6 @@ public class SubmissionPanelRestRepository extends DSpaceRestRepository<Submissi
|
||||
|
||||
private SubmissionConfigReader submissionConfigReader;
|
||||
|
||||
@Autowired
|
||||
private ConverterService converter;
|
||||
|
||||
public SubmissionPanelRestRepository() throws SubmissionConfigReaderException {
|
||||
submissionConfigReader = new SubmissionConfigReader();
|
||||
}
|
||||
@@ -58,9 +51,9 @@ public class SubmissionPanelRestRepository extends DSpaceRestRepository<Submissi
|
||||
@PreAuthorize("hasAuthority('AUTHENTICATED')")
|
||||
@Override
|
||||
public Page<SubmissionSectionRest> findAll(Context context, Pageable pageable) {
|
||||
List<SubmissionConfig> subConfs = new ArrayList<SubmissionConfig>();
|
||||
subConfs = submissionConfigReader.getAllSubmissionConfigs(pageable.getPageSize(), pageable.getOffset());
|
||||
int total = 0;
|
||||
List<SubmissionConfig> subConfs = submissionConfigReader.getAllSubmissionConfigs(
|
||||
pageable.getPageSize(), pageable.getOffset());
|
||||
long total = 0;
|
||||
List<SubmissionStepConfig> stepConfs = new ArrayList<>();
|
||||
for (SubmissionConfig config : subConfs) {
|
||||
total = +config.getNumberOfSteps();
|
||||
@@ -69,10 +62,7 @@ public class SubmissionPanelRestRepository extends DSpaceRestRepository<Submissi
|
||||
stepConfs.add(step);
|
||||
}
|
||||
}
|
||||
Projection projection = utils.obtainProjection(true);
|
||||
Page<SubmissionSectionRest> page = new PageImpl<>(stepConfs, pageable, total)
|
||||
.map((object) -> converter.toRest(object, projection));
|
||||
return page;
|
||||
return converter.toRestPage(stepConfs, pageable, total, utils.obtainProjection(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -12,7 +12,6 @@ import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.converter.ConverterService;
|
||||
import org.dspace.app.rest.model.AccessConditionOptionRest;
|
||||
import org.dspace.app.rest.model.SubmissionUploadRest;
|
||||
import org.dspace.app.rest.projection.Projection;
|
||||
@@ -58,9 +57,6 @@ public class SubmissionUploadRestRepository extends DSpaceRestRepository<Submiss
|
||||
@Autowired
|
||||
GroupService groupService;
|
||||
|
||||
@Autowired
|
||||
ConverterService converter;
|
||||
|
||||
DateMathParser dateMathParser = new DateMathParser();
|
||||
|
||||
public SubmissionUploadRestRepository() throws SubmissionConfigReaderException {
|
||||
|
@@ -17,7 +17,6 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.app.rest.Parameter;
|
||||
import org.dspace.app.rest.SearchRestMethod;
|
||||
import org.dspace.app.rest.converter.ConverterService;
|
||||
import org.dspace.app.rest.exception.DSpaceBadRequestException;
|
||||
import org.dspace.app.rest.exception.RESTAuthorizationException;
|
||||
import org.dspace.app.rest.exception.UnprocessableEntityException;
|
||||
@@ -47,7 +46,6 @@ 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.rest.webmvc.ResourceNotFoundException;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -69,27 +67,29 @@ public class WorkflowItemRestRepository extends DSpaceRestRepository<WorkflowIte
|
||||
|
||||
@Autowired
|
||||
XmlWorkflowItemService wis;
|
||||
|
||||
@Autowired
|
||||
ItemService itemService;
|
||||
|
||||
@Autowired
|
||||
BitstreamService bitstreamService;
|
||||
|
||||
@Autowired
|
||||
BitstreamFormatService bitstreamFormatService;
|
||||
|
||||
@Autowired
|
||||
ConfigurationService configurationService;
|
||||
|
||||
@Autowired
|
||||
ConverterService converter;
|
||||
|
||||
@Autowired
|
||||
SubmissionService submissionService;
|
||||
|
||||
@Autowired
|
||||
EPersonServiceImpl epersonService;
|
||||
|
||||
@Autowired
|
||||
WorkflowService<XmlWorkflowItem> wfs;
|
||||
|
||||
private SubmissionConfigReader submissionConfigReader;
|
||||
private final SubmissionConfigReader submissionConfigReader;
|
||||
|
||||
public WorkflowItemRestRepository() throws SubmissionConfigReaderException {
|
||||
submissionConfigReader = new SubmissionConfigReader();
|
||||
@@ -113,37 +113,28 @@ public class WorkflowItemRestRepository extends DSpaceRestRepository<WorkflowIte
|
||||
@Override
|
||||
@PreAuthorize("hasAuthority('ADMIN')")
|
||||
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());
|
||||
long total = wis.countAll(context);
|
||||
List<XmlWorkflowItem> witems = wis.findAll(context, pageable.getPageNumber(), pageable.getPageSize());
|
||||
return converter.toRestPage(witems, pageable, total, utils.obtainProjection(true));
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
Projection projection = utils.obtainProjection(true);
|
||||
Page<WorkflowItemRest> page = new PageImpl<>(witems, pageable, total)
|
||||
.map((object) -> converter.toRest(object, projection));
|
||||
return page;
|
||||
}
|
||||
|
||||
@SearchRestMethod(name = "findBySubmitter")
|
||||
@PreAuthorize("hasAuthority('ADMIN')")
|
||||
public Page<WorkflowItemRest> findBySubmitter(@Parameter(value = "uuid") UUID submitterID, Pageable pageable) {
|
||||
List<XmlWorkflowItem> witems = null;
|
||||
int total = 0;
|
||||
try {
|
||||
Context context = obtainContext();
|
||||
EPerson ep = epersonService.find(context, submitterID);
|
||||
witems = wis.findBySubmitter(context, ep, pageable.getPageNumber(), pageable.getPageSize());
|
||||
total = wis.countBySubmitter(context, ep);
|
||||
long total = wis.countBySubmitter(context, ep);
|
||||
List<XmlWorkflowItem> witems = wis.findBySubmitter(context, ep, pageable.getPageNumber(),
|
||||
pageable.getPageSize());
|
||||
return converter.toRestPage(witems, pageable, total, utils.obtainProjection(true));
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
Projection projection = utils.obtainProjection(true);
|
||||
Page<WorkflowItemRest> page = new PageImpl<>(witems, pageable, total)
|
||||
.map((object) -> converter.toRest(object, projection));
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -24,7 +24,6 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.Parameter;
|
||||
import org.dspace.app.rest.SearchRestMethod;
|
||||
import org.dspace.app.rest.converter.ConverterService;
|
||||
import org.dspace.app.rest.converter.WorkspaceItemConverter;
|
||||
import org.dspace.app.rest.exception.DSpaceBadRequestException;
|
||||
import org.dspace.app.rest.model.ErrorRest;
|
||||
@@ -63,7 +62,6 @@ import org.dspace.submit.lookup.SubmissionLookupService;
|
||||
import org.dspace.submit.util.ItemSubmissionLookupDTO;
|
||||
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.rest.webmvc.json.patch.PatchException;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -83,22 +81,25 @@ public class WorkspaceItemRestRepository extends DSpaceRestRepository<WorkspaceI
|
||||
|
||||
@Autowired
|
||||
WorkspaceItemService wis;
|
||||
|
||||
@Autowired
|
||||
ItemService itemService;
|
||||
|
||||
@Autowired
|
||||
BitstreamService bitstreamService;
|
||||
|
||||
@Autowired
|
||||
BitstreamFormatService bitstreamFormatService;
|
||||
|
||||
@Autowired
|
||||
ConfigurationService configurationService;
|
||||
|
||||
@Autowired
|
||||
WorkspaceItemConverter workspaceItemConverter;
|
||||
@Autowired
|
||||
ConverterService converter;
|
||||
|
||||
@Autowired
|
||||
SubmissionService submissionService;
|
||||
|
||||
@Autowired
|
||||
EPersonServiceImpl epersonService;
|
||||
|
||||
@@ -132,38 +133,28 @@ public class WorkspaceItemRestRepository extends DSpaceRestRepository<WorkspaceI
|
||||
//TODO @PreAuthorize("hasAuthority('ADMIN')")
|
||||
@Override
|
||||
public Page<WorkspaceItemRest> findAll(Context context, Pageable pageable) {
|
||||
List<WorkspaceItem> witems = null;
|
||||
int total = 0;
|
||||
try {
|
||||
total = wis.countTotal(context);
|
||||
witems = wis.findAll(context, pageable.getPageSize(), pageable.getOffset());
|
||||
long total = wis.countTotal(context);
|
||||
List<WorkspaceItem> witems = wis.findAll(context, pageable.getPageSize(), pageable.getOffset());
|
||||
return converter.toRestPage(witems, pageable, total, utils.obtainProjection(true));
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
Projection projection = utils.obtainProjection(true);
|
||||
Page<WorkspaceItemRest> page = new PageImpl<>(witems, pageable, total)
|
||||
.map((object) -> converter.toRest(object, projection));
|
||||
return page;
|
||||
}
|
||||
|
||||
//TODO @PreAuthorize("hasPermission(#submitterID, 'EPERSON', 'READ')")
|
||||
@SearchRestMethod(name = "findBySubmitter")
|
||||
public Page<WorkspaceItemRest> findBySubmitter(@Parameter(value = "uuid", required = true) UUID submitterID,
|
||||
Pageable pageable) {
|
||||
List<WorkspaceItem> witems = null;
|
||||
int total = 0;
|
||||
try {
|
||||
Context context = obtainContext();
|
||||
EPerson ep = epersonService.find(context, submitterID);
|
||||
witems = wis.findByEPerson(context, ep, pageable.getPageSize(), pageable.getOffset());
|
||||
total = wis.countByEPerson(context, ep);
|
||||
long total = wis.countByEPerson(context, ep);
|
||||
List<WorkspaceItem> witems = wis.findByEPerson(context, ep, pageable.getPageSize(), pageable.getOffset());
|
||||
return converter.toRestPage(witems, pageable, total, utils.obtainProjection(true));
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
Projection projection = utils.obtainProjection(true);
|
||||
Page<WorkspaceItemRest> page = new PageImpl<>(witems, pageable, total)
|
||||
.map((object) -> converter.toRest(object, projection));
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -203,7 +194,6 @@ public class WorkspaceItemRestRepository extends DSpaceRestRepository<WorkspaceI
|
||||
+ " Therefore it cannot be used by the Configurable Submission as the " +
|
||||
"<processing-class>!");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
@@ -436,6 +436,8 @@ public class Utils {
|
||||
return obtainProjection(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Adds embeds or links for all class-level LinkRel annotations for which embeds or links are allowed.
|
||||
*
|
||||
|
Reference in New Issue
Block a user