Merge remote-tracking branch 'community/master' into w2p-62955_change-endpoint-to-search-relationships-by-label-update

This commit is contained in:
Ben Bosman
2019-06-25 11:22:00 +02:00
38 changed files with 376 additions and 206 deletions

View File

@@ -528,7 +528,7 @@ public class SolrServiceImpl implements SearchService, IndexingService {
try { try {
getSolr().deleteByQuery( getSolr().deleteByQuery(
"search.resourcetype:[" + Constants.ITEM + " TO " + Constants.COMMUNITY + "]" + "search.resourcetype:[" + Constants.ITEM + " TO " + Constants.COMMUNITY + "]" +
" AND " + " OR " +
"search.resourcetype:[" + Constants.WORKSPACEITEM + " TO " + Constants.CLAIMEDTASK + "]"); "search.resourcetype:[" + Constants.WORKSPACEITEM + " TO " + Constants.CLAIMEDTASK + "]");
} catch (Exception e) { } catch (Exception e) {
throw new SearchServiceException(e.getMessage(), e); throw new SearchServiceException(e.getMessage(), e);
@@ -559,7 +559,7 @@ public class SolrServiceImpl implements SearchService, IndexingService {
SolrQuery query = new SolrQuery(); SolrQuery query = new SolrQuery();
// Query for all indexed Items, Collections and Communities, // Query for all indexed Items, Collections and Communities,
// returning just their handle // returning just their handle
query.setFields(HANDLE_FIELD); query.setFields(HANDLE_FIELD, RESOURCE_UNIQUE_ID, RESOURCE_ID_FIELD, RESOURCE_TYPE_FIELD);
query.setQuery(RESOURCE_TYPE_FIELD + ":" + type); query.setQuery(RESOURCE_TYPE_FIELD + ":" + type);
QueryResponse rsp = getSolr().query(query, SolrRequest.METHOD.POST); QueryResponse rsp = getSolr().query(query, SolrRequest.METHOD.POST);
SolrDocumentList docs = rsp.getResults(); SolrDocumentList docs = rsp.getResults();
@@ -2207,10 +2207,14 @@ public class SolrServiceImpl implements SearchService, IndexingService {
/** /**
* Find the indexable object by type and UUID * Find the indexable object by type and UUID
* *
* @param context The relevant DSpace Context. * @param context
* @param doc the solr document * The relevant DSpace Context.
* @param doc
* the solr document, the following fields MUST be present RESOURCE_TYPE_FIELD, RESOURCE_ID_FIELD and
* HANDLE_FIELD
* @return an IndexableObject * @return an IndexableObject
* @throws SQLException An exception that provides information on a database access error or other errors. * @throws SQLException
* An exception that provides information on a database access error or other errors.
*/ */
protected IndexableObject findIndexableObject(Context context, SolrDocument doc) throws SQLException { protected IndexableObject findIndexableObject(Context context, SolrDocument doc) throws SQLException {
Integer type = (Integer) doc.getFirstValue(RESOURCE_TYPE_FIELD); Integer type = (Integer) doc.getFirstValue(RESOURCE_TYPE_FIELD);

View File

@@ -31,8 +31,8 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.atteo.evo.inflector.English; import org.atteo.evo.inflector.English;
import org.dspace.app.rest.converter.JsonPatchConverter; import org.dspace.app.rest.converter.JsonPatchConverter;
import org.dspace.app.rest.exception.DSpaceBadRequestException;
import org.dspace.app.rest.exception.PaginationException; import org.dspace.app.rest.exception.PaginationException;
import org.dspace.app.rest.exception.PatchBadRequestException;
import org.dspace.app.rest.exception.RepositoryMethodNotImplementedException; import org.dspace.app.rest.exception.RepositoryMethodNotImplementedException;
import org.dspace.app.rest.exception.RepositoryNotFoundException; import org.dspace.app.rest.exception.RepositoryNotFoundException;
import org.dspace.app.rest.exception.RepositorySearchMethodNotFoundException; import org.dspace.app.rest.exception.RepositorySearchMethodNotFoundException;
@@ -729,7 +729,7 @@ public class RestResourceController implements InitializingBean {
Patch patch = patchConverter.convert(jsonNode); Patch patch = patchConverter.convert(jsonNode);
modelObject = repository.patch(request, apiCategory, model, id, patch); modelObject = repository.patch(request, apiCategory, model, id, patch);
} catch (RepositoryMethodNotImplementedException | UnprocessableEntityException | } catch (RepositoryMethodNotImplementedException | UnprocessableEntityException |
PatchBadRequestException | ResourceNotFoundException e) { DSpaceBadRequestException | ResourceNotFoundException e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
throw e; throw e;
} }
@@ -832,7 +832,7 @@ public class RestResourceController implements InitializingBean {
link = linkTo(this.getClass(), apiCategory, model).slash(uuid) link = linkTo(this.getClass(), apiCategory, model).slash(uuid)
.slash(subpath + '?' + querystring).withSelfRel(); .slash(subpath + '?' + querystring).withSelfRel();
} else { } else {
link = linkTo(this.getClass(), apiCategory, model).slash(uuid).withSelfRel(); link = linkTo(this.getClass(), apiCategory, model).slash(uuid).slash(subpath).withSelfRel();
} }
Page<HALResource> halResources = pageResult.map(linkRepository::wrapResource); Page<HALResource> halResources = pageResult.map(linkRepository::wrapResource);

View File

@@ -11,21 +11,18 @@ import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.ResponseStatus;
/** /**
* Malformed patch document (taken from rfc5789#section-2.2) - When the server * When a request is malformed, we use this exception to indicate this to the client
* determines that the patch document provided by the client is not properly
* formatted, it SHOULD return a 400 (Bad Request) response. The definition of
* badly formatted depends on the patch document chosen.
* *
* @author Luigi Andrea Pascarelli (luigiandrea.pascarelli at 4science.it) * @author Luigi Andrea Pascarelli (luigiandrea.pascarelli at 4science.it)
*/ */
@ResponseStatus(value = HttpStatus.BAD_REQUEST, reason = "Bad Request") @ResponseStatus(value = HttpStatus.BAD_REQUEST, reason = "Bad Request")
public class PatchBadRequestException extends RuntimeException { public class DSpaceBadRequestException extends RuntimeException {
public PatchBadRequestException(String message) { public DSpaceBadRequestException(String message) {
this(message, null); this(message, null);
} }
public PatchBadRequestException(String message, Exception e) { public DSpaceBadRequestException(String message, Exception e) {
super(message, e); super(message, e);
} }
} }

View File

@@ -1,17 +0,0 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.app.rest.exception;
/**
* This class creates an Exception to be used when the given DSpaceObjectType is invalid
*/
public class InvalidDSpaceObjectTypeException extends InvalidRequestException {
public InvalidDSpaceObjectTypeException(String message) {
super(message);
}
}

View File

@@ -1,21 +0,0 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.app.rest.exception;
/**
* This class provides an exception for when the given request is invalid
*/
public class InvalidRequestException extends Exception {
public InvalidRequestException(String message) {
super(message);
}
public InvalidRequestException(String message, Throwable cause) {
super(message, cause);
}
}

View File

@@ -1,17 +0,0 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.app.rest.exception;
/**
* Exception thrown when the search endpoint receives an invalid facet name
*/
public class InvalidSearchFacetException extends InvalidRequestException {
public InvalidSearchFacetException(final String message) {
super(message);
}
}

View File

@@ -1,21 +0,0 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.app.rest.exception;
/**
* This class provides an exception to be used when the SearchFilter given is invalid
*/
public class InvalidSearchFilterException extends InvalidRequestException {
public InvalidSearchFilterException(String message, Throwable cause) {
super(message, cause);
}
public InvalidSearchFilterException(final String message) {
super(message);
}
}

View File

@@ -1,17 +0,0 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.app.rest.exception;
/**
* This class makes an Exception to be used when a certain sorting is invalid
*/
public class InvalidSortingException extends InvalidRequestException {
public InvalidSortingException(String message) {
super(message);
}
}

View File

@@ -54,13 +54,13 @@ public class BrowseEntryHalLinkFactory extends HalLinkFactory<BrowseEntryResourc
return BrowseEntryResource.class; return BrowseEntryResource.class;
} }
// TODO use the reflaction to discover the link repository and additional information on the link annotation to // TODO use the reflection to discover the link repository and additional information on the link annotation to
// build the parameters? // build the parameters?
private UriComponentsBuilder addFilterParams(UriComponentsBuilder uriComponentsBuilder, private UriComponentsBuilder addFilterParams(UriComponentsBuilder uriComponentsBuilder,
final BrowseEntryRest data) { final BrowseEntryRest data) {
UriComponentsBuilder result; UriComponentsBuilder result;
if (data.getAuthority() != null) { if (data.getAuthority() != null) {
result = uriComponentsBuilder.queryParam("filterValue", data.getAuthority()); result = uriComponentsBuilder.queryParam("filterAuthority", data.getAuthority());
} else { } else {
result = uriComponentsBuilder.queryParam("filterValue", data.getValue()); result = uriComponentsBuilder.queryParam("filterValue", data.getValue());
} }

View File

@@ -14,7 +14,6 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
import javax.servlet.ServletInputStream; import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.BadRequestException;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
@@ -23,6 +22,7 @@ import org.dspace.app.rest.Parameter;
import org.dspace.app.rest.SearchRestMethod; import org.dspace.app.rest.SearchRestMethod;
import org.dspace.app.rest.converter.CollectionConverter; import org.dspace.app.rest.converter.CollectionConverter;
import org.dspace.app.rest.converter.MetadataConverter; import org.dspace.app.rest.converter.MetadataConverter;
import org.dspace.app.rest.exception.DSpaceBadRequestException;
import org.dspace.app.rest.exception.RepositoryMethodNotImplementedException; import org.dspace.app.rest.exception.RepositoryMethodNotImplementedException;
import org.dspace.app.rest.exception.UnprocessableEntityException; import org.dspace.app.rest.exception.UnprocessableEntityException;
import org.dspace.app.rest.model.CollectionRest; import org.dspace.app.rest.model.CollectionRest;
@@ -191,7 +191,7 @@ public class CollectionRestRepository extends DSpaceObjectRestRepository<Collect
UUID parentCommunityUuid = UUIDUtils.fromString(parentCommunityString); UUID parentCommunityUuid = UUIDUtils.fromString(parentCommunityString);
if (parentCommunityUuid == null) { if (parentCommunityUuid == null) {
throw new BadRequestException("The given parent was invalid: " throw new DSpaceBadRequestException("The given parent was invalid: "
+ parentCommunityString); + parentCommunityString);
} }
@@ -201,7 +201,7 @@ public class CollectionRestRepository extends DSpaceObjectRestRepository<Collect
+ parentCommunityUuid + " not found"); + parentCommunityUuid + " not found");
} }
} else { } else {
throw new BadRequestException("The parent parameter cannot be left empty," + throw new DSpaceBadRequestException("The parent parameter cannot be left empty," +
"collections require a parent community."); "collections require a parent community.");
} }
collection = cs.create(context, parent); collection = cs.create(context, parent);

View File

@@ -14,7 +14,6 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
import javax.servlet.ServletInputStream; import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.BadRequestException;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
@@ -23,6 +22,7 @@ import org.dspace.app.rest.Parameter;
import org.dspace.app.rest.SearchRestMethod; import org.dspace.app.rest.SearchRestMethod;
import org.dspace.app.rest.converter.CommunityConverter; import org.dspace.app.rest.converter.CommunityConverter;
import org.dspace.app.rest.converter.MetadataConverter; import org.dspace.app.rest.converter.MetadataConverter;
import org.dspace.app.rest.exception.DSpaceBadRequestException;
import org.dspace.app.rest.exception.RepositoryMethodNotImplementedException; import org.dspace.app.rest.exception.RepositoryMethodNotImplementedException;
import org.dspace.app.rest.exception.UnprocessableEntityException; import org.dspace.app.rest.exception.UnprocessableEntityException;
import org.dspace.app.rest.model.CommunityRest; import org.dspace.app.rest.model.CommunityRest;
@@ -92,7 +92,7 @@ public class CommunityRestRepository extends DSpaceObjectRestRepository<Communit
UUID parentCommunityUuid = UUIDUtils.fromString(parentCommunityString); UUID parentCommunityUuid = UUIDUtils.fromString(parentCommunityString);
if (parentCommunityUuid == null) { if (parentCommunityUuid == null) {
throw new BadRequestException("The given parent parameter was invalid: " throw new DSpaceBadRequestException("The given parent parameter was invalid: "
+ parentCommunityString); + parentCommunityString);
} }

View File

@@ -17,7 +17,7 @@ import javax.servlet.http.HttpServletRequest;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.dspace.app.rest.exception.PatchBadRequestException; import org.dspace.app.rest.exception.DSpaceBadRequestException;
import org.dspace.app.rest.exception.RESTAuthorizationException; import org.dspace.app.rest.exception.RESTAuthorizationException;
import org.dspace.app.rest.exception.RepositoryMethodNotImplementedException; import org.dspace.app.rest.exception.RepositoryMethodNotImplementedException;
import org.dspace.app.rest.exception.UnprocessableEntityException; import org.dspace.app.rest.exception.UnprocessableEntityException;
@@ -369,10 +369,10 @@ public abstract class DSpaceRestRepository<T extends RestAddressableModel, ID ex
* @return * @return
* @throws HttpRequestMethodNotSupportedException * @throws HttpRequestMethodNotSupportedException
* @throws UnprocessableEntityException * @throws UnprocessableEntityException
* @throws PatchBadRequestException * @throws DSpaceBadRequestException
*/ */
public T patch(HttpServletRequest request, String apiCategory, String model, ID id, Patch patch) public T patch(HttpServletRequest request, String apiCategory, String model, ID id, Patch patch)
throws HttpRequestMethodNotSupportedException, UnprocessableEntityException, PatchBadRequestException { throws HttpRequestMethodNotSupportedException, UnprocessableEntityException, DSpaceBadRequestException {
Context context = obtainContext(); Context context = obtainContext();
try { try {
@@ -401,7 +401,7 @@ public abstract class DSpaceRestRepository<T extends RestAddressableModel, ID ex
* @return the full new state of the REST object after patching * @return the full new state of the REST object after patching
* @throws HttpRequestMethodNotSupportedException * @throws HttpRequestMethodNotSupportedException
* @throws UnprocessableEntityException * @throws UnprocessableEntityException
* @throws PatchBadRequestException * @throws DSpaceBadRequestException
* @throws RepositoryMethodNotImplementedException * @throws RepositoryMethodNotImplementedException
* returned by the default implementation when the operation is not supported for the entity * returned by the default implementation when the operation is not supported for the entity
* *

View File

@@ -17,7 +17,6 @@ import org.dspace.app.rest.converter.DiscoverFacetResultsConverter;
import org.dspace.app.rest.converter.DiscoverFacetsConverter; import org.dspace.app.rest.converter.DiscoverFacetsConverter;
import org.dspace.app.rest.converter.DiscoverResultConverter; import org.dspace.app.rest.converter.DiscoverResultConverter;
import org.dspace.app.rest.converter.DiscoverSearchSupportConverter; import org.dspace.app.rest.converter.DiscoverSearchSupportConverter;
import org.dspace.app.rest.exception.InvalidRequestException;
import org.dspace.app.rest.model.FacetConfigurationRest; import org.dspace.app.rest.model.FacetConfigurationRest;
import org.dspace.app.rest.model.FacetResultsRest; import org.dspace.app.rest.model.FacetResultsRest;
import org.dspace.app.rest.model.SearchConfigurationRest; import org.dspace.app.rest.model.SearchConfigurationRest;
@@ -91,8 +90,7 @@ public class DiscoveryRestRepository extends AbstractDSpaceRestRepository {
public SearchResultsRest getSearchObjects(final String query, final String dsoType, final String dsoScope, public SearchResultsRest getSearchObjects(final String query, final String dsoType, final String dsoScope,
final String configuration, final String configuration,
final List<SearchFilter> searchFilters, final Pageable page) final List<SearchFilter> searchFilters, final Pageable page) {
throws InvalidRequestException {
Context context = obtainContext(); Context context = obtainContext();
IndexableObject scopeObject = scopeResolver.resolveScope(context, dsoScope); IndexableObject scopeObject = scopeResolver.resolveScope(context, dsoScope);
DiscoveryConfiguration discoveryConfiguration = searchConfigurationService DiscoveryConfiguration discoveryConfiguration = searchConfigurationService
@@ -131,8 +129,7 @@ public class DiscoveryRestRepository extends AbstractDSpaceRestRepository {
} }
public FacetResultsRest getFacetObjects(String facetName, String prefix, String query, String dsoType, public FacetResultsRest getFacetObjects(String facetName, String prefix, String query, String dsoType,
String dsoScope, final String configuration, List<SearchFilter> searchFilters, Pageable page) String dsoScope, final String configuration, List<SearchFilter> searchFilters, Pageable page) {
throws InvalidRequestException {
Context context = obtainContext(); Context context = obtainContext();
@@ -158,7 +155,7 @@ public class DiscoveryRestRepository extends AbstractDSpaceRestRepository {
} }
public SearchResultsRest getAllFacets(String query, String dsoType, String dsoScope, String configuration, public SearchResultsRest getAllFacets(String query, String dsoType, String dsoScope, String configuration,
List<SearchFilter> searchFilters) throws InvalidRequestException { List<SearchFilter> searchFilters) {
Context context = obtainContext(); Context context = obtainContext();
Pageable page = new PageRequest(1, 1); Pageable page = new PageRequest(1, 1);

View File

@@ -15,7 +15,6 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
import javax.servlet.ServletInputStream; import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.BadRequestException;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
@@ -23,6 +22,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.dspace.app.rest.converter.ItemConverter; import org.dspace.app.rest.converter.ItemConverter;
import org.dspace.app.rest.converter.MetadataConverter; import org.dspace.app.rest.converter.MetadataConverter;
import org.dspace.app.rest.exception.DSpaceBadRequestException;
import org.dspace.app.rest.exception.RepositoryMethodNotImplementedException; import org.dspace.app.rest.exception.RepositoryMethodNotImplementedException;
import org.dspace.app.rest.exception.UnprocessableEntityException; import org.dspace.app.rest.exception.UnprocessableEntityException;
import org.dspace.app.rest.model.ItemRest; import org.dspace.app.rest.model.ItemRest;
@@ -199,12 +199,12 @@ public class ItemRestRepository extends DSpaceObjectRestRepository<Item, ItemRes
} }
if (itemRest.getInArchive() == false) { if (itemRest.getInArchive() == false) {
throw new BadRequestException("InArchive attribute should not be set to false for the create"); throw new DSpaceBadRequestException("InArchive attribute should not be set to false for the create");
} }
UUID owningCollectionUuid = UUIDUtils.fromString(owningCollectionUuidString); UUID owningCollectionUuid = UUIDUtils.fromString(owningCollectionUuidString);
Collection collection = collectionService.find(context, owningCollectionUuid); Collection collection = collectionService.find(context, owningCollectionUuid);
if (collection == null) { if (collection == null) {
throw new BadRequestException("The given owningCollection parameter is invalid: " throw new DSpaceBadRequestException("The given owningCollection parameter is invalid: "
+ owningCollectionUuid); + owningCollectionUuid);
} }
WorkspaceItem workspaceItem = workspaceItemService.create(context, collection, false); WorkspaceItem workspaceItem = workspaceItemService.create(context, collection, false);

View File

@@ -22,7 +22,7 @@ import com.google.gson.Gson;
import org.dspace.app.rest.Parameter; import org.dspace.app.rest.Parameter;
import org.dspace.app.rest.SearchRestMethod; import org.dspace.app.rest.SearchRestMethod;
import org.dspace.app.rest.converter.MetadataFieldConverter; import org.dspace.app.rest.converter.MetadataFieldConverter;
import org.dspace.app.rest.exception.PatchBadRequestException; import org.dspace.app.rest.exception.DSpaceBadRequestException;
import org.dspace.app.rest.exception.UnprocessableEntityException; import org.dspace.app.rest.exception.UnprocessableEntityException;
import org.dspace.app.rest.model.MetadataFieldRest; import org.dspace.app.rest.model.MetadataFieldRest;
import org.dspace.app.rest.model.hateoas.MetadataFieldResource; import org.dspace.app.rest.model.hateoas.MetadataFieldResource;
@@ -127,7 +127,7 @@ public class MetadataFieldRestRepository extends DSpaceRestRepository<MetadataFi
MetadataFieldRest.class MetadataFieldRest.class
); );
} catch (IOException excIO) { } catch (IOException excIO) {
throw new PatchBadRequestException("error parsing request body", excIO); throw new DSpaceBadRequestException("error parsing request body", excIO);
} }
// validate fields // validate fields

View File

@@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson; import com.google.gson.Gson;
import org.dspace.app.rest.converter.MetadataSchemaConverter; import org.dspace.app.rest.converter.MetadataSchemaConverter;
import org.dspace.app.rest.exception.PatchBadRequestException; import org.dspace.app.rest.exception.DSpaceBadRequestException;
import org.dspace.app.rest.exception.UnprocessableEntityException; import org.dspace.app.rest.exception.UnprocessableEntityException;
import org.dspace.app.rest.model.MetadataSchemaRest; import org.dspace.app.rest.model.MetadataSchemaRest;
import org.dspace.app.rest.model.hateoas.MetadataSchemaResource; import org.dspace.app.rest.model.hateoas.MetadataSchemaResource;
@@ -101,7 +101,7 @@ public class MetadataSchemaRestRepository extends DSpaceRestRepository<MetadataS
MetadataSchemaRest.class MetadataSchemaRest.class
); );
} catch (IOException excIO) { } catch (IOException excIO) {
throw new PatchBadRequestException("error parsing request body", excIO); throw new DSpaceBadRequestException("error parsing request body", excIO);
} }
// validate fields // validate fields

View File

@@ -19,7 +19,7 @@ import org.apache.log4j.Logger;
import org.dspace.app.rest.Parameter; import org.dspace.app.rest.Parameter;
import org.dspace.app.rest.SearchRestMethod; import org.dspace.app.rest.SearchRestMethod;
import org.dspace.app.rest.converter.WorkflowItemConverter; import org.dspace.app.rest.converter.WorkflowItemConverter;
import org.dspace.app.rest.exception.PatchBadRequestException; import org.dspace.app.rest.exception.DSpaceBadRequestException;
import org.dspace.app.rest.exception.RESTAuthorizationException; import org.dspace.app.rest.exception.RESTAuthorizationException;
import org.dspace.app.rest.exception.UnprocessableEntityException; import org.dspace.app.rest.exception.UnprocessableEntityException;
import org.dspace.app.rest.model.ErrorRest; import org.dspace.app.rest.model.ErrorRest;
@@ -238,7 +238,7 @@ public class WorkflowItemRestRepository extends DSpaceRestRepository<WorkflowIte
String section = path[1]; String section = path[1];
evaluatePatch(context, request, source, wsi, section, op); evaluatePatch(context, request, source, wsi, section, op);
} else { } else {
throw new PatchBadRequestException( throw new DSpaceBadRequestException(
"Patch path operation need to starts with '" + OPERATION_PATH_SECTIONS + "'"); "Patch path operation need to starts with '" + OPERATION_PATH_SECTIONS + "'");
} }
} }
@@ -273,7 +273,7 @@ public class WorkflowItemRestRepository extends DSpaceRestRepository<WorkflowIte
stepProcessing.doPatchProcessing(context, getRequestService().getCurrentRequest(), source, op); stepProcessing.doPatchProcessing(context, getRequestService().getCurrentRequest(), source, op);
stepProcessing.doPostProcessing(context, source); stepProcessing.doPostProcessing(context, source);
} else { } else {
throw new PatchBadRequestException( throw new DSpaceBadRequestException(
"The submission step class specified by '" + stepConfig.getProcessingClassName() + "The submission step class specified by '" + stepConfig.getProcessingClassName() +
"' does not extend the class org.dspace.submit.AbstractProcessingStep!" + "' does not extend the class org.dspace.submit.AbstractProcessingStep!" +
" Therefore it cannot be used by the Configurable Submission as the <processing-class>!"); " Therefore it cannot be used by the Configurable Submission as the <processing-class>!");

View File

@@ -26,7 +26,7 @@ import org.apache.logging.log4j.Logger;
import org.dspace.app.rest.Parameter; import org.dspace.app.rest.Parameter;
import org.dspace.app.rest.SearchRestMethod; import org.dspace.app.rest.SearchRestMethod;
import org.dspace.app.rest.converter.WorkspaceItemConverter; import org.dspace.app.rest.converter.WorkspaceItemConverter;
import org.dspace.app.rest.exception.PatchBadRequestException; import org.dspace.app.rest.exception.DSpaceBadRequestException;
import org.dspace.app.rest.model.ErrorRest; import org.dspace.app.rest.model.ErrorRest;
import org.dspace.app.rest.model.WorkspaceItemRest; import org.dspace.app.rest.model.WorkspaceItemRest;
import org.dspace.app.rest.model.hateoas.WorkspaceItemResource; import org.dspace.app.rest.model.hateoas.WorkspaceItemResource;
@@ -280,7 +280,7 @@ public class WorkspaceItemRestRepository extends DSpaceRestRepository<WorkspaceI
String section = path[1]; String section = path[1];
evaluatePatch(context, request, source, wsi, section, op); evaluatePatch(context, request, source, wsi, section, op);
} else { } else {
throw new PatchBadRequestException( throw new DSpaceBadRequestException(
"Patch path operation need to starts with '" + OPERATION_PATH_SECTIONS + "'"); "Patch path operation need to starts with '" + OPERATION_PATH_SECTIONS + "'");
} }
} }
@@ -315,7 +315,7 @@ public class WorkspaceItemRestRepository extends DSpaceRestRepository<WorkspaceI
stepProcessing.doPatchProcessing(context, getRequestService().getCurrentRequest(), source, op); stepProcessing.doPatchProcessing(context, getRequestService().getCurrentRequest(), source, op);
stepProcessing.doPostProcessing(context, source); stepProcessing.doPostProcessing(context, source);
} else { } else {
throw new PatchBadRequestException( throw new DSpaceBadRequestException(
"The submission step class specified by '" + stepConfig.getProcessingClassName() + "The submission step class specified by '" + stepConfig.getProcessingClassName() +
"' does not extend the class org.dspace.submit.AbstractProcessingStep!" + "' does not extend the class org.dspace.submit.AbstractProcessingStep!" +
" Therefore it cannot be used by the Configurable Submission as the <processing-class>!"); " Therefore it cannot be used by the Configurable Submission as the <processing-class>!");

View File

@@ -9,7 +9,7 @@ package org.dspace.app.rest.repository.patch;
import java.util.List; import java.util.List;
import org.dspace.app.rest.exception.PatchBadRequestException; import org.dspace.app.rest.exception.DSpaceBadRequestException;
import org.dspace.app.rest.exception.UnprocessableEntityException; import org.dspace.app.rest.exception.UnprocessableEntityException;
import org.dspace.app.rest.model.RestModel; import org.dspace.app.rest.model.RestModel;
import org.dspace.app.rest.model.patch.Operation; import org.dspace.app.rest.model.patch.Operation;
@@ -28,7 +28,7 @@ public abstract class AbstractResourcePatch<R extends RestModel> {
* @param restModel the rest resource to patch * @param restModel the rest resource to patch
* @param operations list of patch operations * @param operations list of patch operations
* @throws UnprocessableEntityException * @throws UnprocessableEntityException
* @throws PatchBadRequestException * @throws DSpaceBadRequestException
*/ */
public R patch(R restModel, List<Operation> operations) { public R patch(R restModel, List<Operation> operations) {
@@ -53,7 +53,7 @@ public abstract class AbstractResourcePatch<R extends RestModel> {
continue ops; continue ops;
default: default:
// JsonPatchConverter should have thrown error before this point. // JsonPatchConverter should have thrown error before this point.
throw new PatchBadRequestException("Missing or illegal patch operation: " + op.getOp()); throw new DSpaceBadRequestException("Missing or illegal patch operation: " + op.getOp());
} }
} }
@@ -63,14 +63,14 @@ public abstract class AbstractResourcePatch<R extends RestModel> {
// The default patch methods throw an error when no sub-class implementation is provided. // The default patch methods throw an error when no sub-class implementation is provided.
protected R add(R restModel, Operation operation) protected R add(R restModel, Operation operation)
throws UnprocessableEntityException, PatchBadRequestException { throws UnprocessableEntityException, DSpaceBadRequestException {
throw new UnprocessableEntityException( throw new UnprocessableEntityException(
"The add operation is not supported." "The add operation is not supported."
); );
} }
protected R replace(R restModel, Operation operation) protected R replace(R restModel, Operation operation)
throws UnprocessableEntityException, PatchBadRequestException { throws UnprocessableEntityException, DSpaceBadRequestException {
throw new UnprocessableEntityException( throw new UnprocessableEntityException(
"The replace operation is not supported." "The replace operation is not supported."
); );
@@ -78,21 +78,21 @@ public abstract class AbstractResourcePatch<R extends RestModel> {
protected R remove(R restModel, Operation operation) protected R remove(R restModel, Operation operation)
throws UnprocessableEntityException, PatchBadRequestException { throws UnprocessableEntityException, DSpaceBadRequestException {
throw new UnprocessableEntityException( throw new UnprocessableEntityException(
"The remove operation is not supported." "The remove operation is not supported."
); );
} }
protected R copy(R restModel, Operation operation) protected R copy(R restModel, Operation operation)
throws UnprocessableEntityException, PatchBadRequestException { throws UnprocessableEntityException, DSpaceBadRequestException {
throw new UnprocessableEntityException( throw new UnprocessableEntityException(
"The copy operation is not supported." "The copy operation is not supported."
); );
} }
protected R move(R restModel, Operation operation) protected R move(R restModel, Operation operation)
throws UnprocessableEntityException, PatchBadRequestException { throws UnprocessableEntityException, DSpaceBadRequestException {
throw new UnprocessableEntityException( throw new UnprocessableEntityException(
"The move operation is not supported." "The move operation is not supported."
); );

View File

@@ -7,7 +7,7 @@
*/ */
package org.dspace.app.rest.repository.patch; package org.dspace.app.rest.repository.patch;
import org.dspace.app.rest.exception.PatchBadRequestException; import org.dspace.app.rest.exception.DSpaceBadRequestException;
import org.dspace.app.rest.exception.UnprocessableEntityException; import org.dspace.app.rest.exception.UnprocessableEntityException;
import org.dspace.app.rest.model.EPersonRest; import org.dspace.app.rest.model.EPersonRest;
import org.dspace.app.rest.model.patch.Operation; import org.dspace.app.rest.model.patch.Operation;
@@ -32,7 +32,7 @@ public class EPersonPatch extends DSpaceObjectPatch<EPersonRest> {
* @param eperson the eperson rest representation * @param eperson the eperson rest representation
* @param operation the replace operation * @param operation the replace operation
* @throws UnprocessableEntityException * @throws UnprocessableEntityException
* @throws PatchBadRequestException * @throws DSpaceBadRequestException
*/ */
protected EPersonRest replace(EPersonRest eperson, Operation operation) { protected EPersonRest replace(EPersonRest eperson, Operation operation) {
ResourcePatchOperation<EPersonRest> patchOperation = ResourcePatchOperation<EPersonRest> patchOperation =

View File

@@ -7,7 +7,7 @@
*/ */
package org.dspace.app.rest.repository.patch; package org.dspace.app.rest.repository.patch;
import org.dspace.app.rest.exception.PatchBadRequestException; import org.dspace.app.rest.exception.DSpaceBadRequestException;
import org.dspace.app.rest.exception.UnprocessableEntityException; import org.dspace.app.rest.exception.UnprocessableEntityException;
import org.dspace.app.rest.model.ItemRest; import org.dspace.app.rest.model.ItemRest;
import org.dspace.app.rest.model.patch.Operation; import org.dspace.app.rest.model.patch.Operation;
@@ -32,7 +32,7 @@ public class ItemPatch extends DSpaceObjectPatch<ItemRest> {
* @param item the rest representation of the item * @param item the rest representation of the item
* @param operation the replace operation * @param operation the replace operation
* @throws UnprocessableEntityException * @throws UnprocessableEntityException
* @throws PatchBadRequestException * @throws DSpaceBadRequestException
*/ */
protected ItemRest replace(ItemRest item, Operation operation) { protected ItemRest replace(ItemRest item, Operation operation) {

View File

@@ -7,7 +7,7 @@
*/ */
package org.dspace.app.rest.repository.patch.factories; package org.dspace.app.rest.repository.patch.factories;
import org.dspace.app.rest.exception.PatchBadRequestException; import org.dspace.app.rest.exception.DSpaceBadRequestException;
import org.dspace.app.rest.model.EPersonRest; import org.dspace.app.rest.model.EPersonRest;
import org.dspace.app.rest.repository.patch.factories.impl.EPersonCertificateReplaceOperation; import org.dspace.app.rest.repository.patch.factories.impl.EPersonCertificateReplaceOperation;
import org.dspace.app.rest.repository.patch.factories.impl.EPersonEmailReplaceOperation; import org.dspace.app.rest.repository.patch.factories.impl.EPersonEmailReplaceOperation;
@@ -51,7 +51,7 @@ public class EPersonOperationFactory {
* *
* @param path the operation path * @param path the operation path
* @return the patch operation implementation * @return the patch operation implementation
* @throws PatchBadRequestException * @throws DSpaceBadRequestException
*/ */
public ResourcePatchOperation<EPersonRest> getReplaceOperationForPath(String path) { public ResourcePatchOperation<EPersonRest> getReplaceOperationForPath(String path) {
@@ -67,7 +67,7 @@ public class EPersonOperationFactory {
case OPERATION_SET_EMAIL: case OPERATION_SET_EMAIL:
return emailReplaceOperation; return emailReplaceOperation;
default: default:
throw new PatchBadRequestException("Missing patch operation for: " + path); throw new DSpaceBadRequestException("Missing patch operation for: " + path);
} }
} }

View File

@@ -7,7 +7,7 @@
*/ */
package org.dspace.app.rest.repository.patch.factories; package org.dspace.app.rest.repository.patch.factories;
import org.dspace.app.rest.exception.PatchBadRequestException; import org.dspace.app.rest.exception.DSpaceBadRequestException;
import org.dspace.app.rest.model.ItemRest; import org.dspace.app.rest.model.ItemRest;
import org.dspace.app.rest.repository.patch.factories.impl.ItemDiscoverableReplaceOperation; import org.dspace.app.rest.repository.patch.factories.impl.ItemDiscoverableReplaceOperation;
import org.dspace.app.rest.repository.patch.factories.impl.ItemWithdrawReplaceOperation; import org.dspace.app.rest.repository.patch.factories.impl.ItemWithdrawReplaceOperation;
@@ -37,7 +37,7 @@ public class ItemOperationFactory {
* *
* @param path the operation path * @param path the operation path
* @return the patch operation implementation * @return the patch operation implementation
* @throws PatchBadRequestException * @throws DSpaceBadRequestException
*/ */
public ResourcePatchOperation<ItemRest> getReplaceOperationForPath(String path) { public ResourcePatchOperation<ItemRest> getReplaceOperationForPath(String path) {
@@ -47,7 +47,7 @@ public class ItemOperationFactory {
case OPERATION_PATH_WITHDRAW: case OPERATION_PATH_WITHDRAW:
return itemWithdrawReplaceOperation; return itemWithdrawReplaceOperation;
default: default:
throw new PatchBadRequestException("Missing patch operation for: " + path); throw new DSpaceBadRequestException("Missing patch operation for: " + path);
} }
} }
} }

View File

@@ -7,7 +7,7 @@
*/ */
package org.dspace.app.rest.repository.patch.factories.impl; package org.dspace.app.rest.repository.patch.factories.impl;
import org.dspace.app.rest.exception.PatchBadRequestException; import org.dspace.app.rest.exception.DSpaceBadRequestException;
import org.dspace.app.rest.model.EPersonRest; import org.dspace.app.rest.model.EPersonRest;
import org.dspace.app.rest.model.patch.Operation; import org.dspace.app.rest.model.patch.Operation;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -42,7 +42,7 @@ public class EPersonCertificateReplaceOperation extends ReplacePatchOperation<EP
// So perhaps the error to throw in this case is different...IllegalStateException? // So perhaps the error to throw in this case is different...IllegalStateException?
// Or perhaps do nothing (no check is required). // Or perhaps do nothing (no check is required).
if ((Object) resource.isRequireCertificate() == null) { if ((Object) resource.isRequireCertificate() == null) {
throw new PatchBadRequestException("Attempting to replace a non-existent value."); throw new DSpaceBadRequestException("Attempting to replace a non-existent value.");
} }
} }

View File

@@ -7,7 +7,7 @@
*/ */
package org.dspace.app.rest.repository.patch.factories.impl; package org.dspace.app.rest.repository.patch.factories.impl;
import org.dspace.app.rest.exception.PatchBadRequestException; import org.dspace.app.rest.exception.DSpaceBadRequestException;
import org.dspace.app.rest.model.EPersonRest; import org.dspace.app.rest.model.EPersonRest;
import org.dspace.app.rest.model.patch.Operation; import org.dspace.app.rest.model.patch.Operation;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -36,7 +36,7 @@ public class EPersonEmailReplaceOperation extends ReplacePatchOperation<EPersonR
@Override @Override
void checkModelForExistingValue(EPersonRest resource, Operation operation) { void checkModelForExistingValue(EPersonRest resource, Operation operation) {
if (resource.getEmail() == null) { if (resource.getEmail() == null) {
throw new PatchBadRequestException("Attempting to replace a non-existent value."); throw new DSpaceBadRequestException("Attempting to replace a non-existent value.");
} }
} }

View File

@@ -7,7 +7,7 @@
*/ */
package org.dspace.app.rest.repository.patch.factories.impl; package org.dspace.app.rest.repository.patch.factories.impl;
import org.dspace.app.rest.exception.PatchBadRequestException; import org.dspace.app.rest.exception.DSpaceBadRequestException;
import org.dspace.app.rest.model.EPersonRest; import org.dspace.app.rest.model.EPersonRest;
import org.dspace.app.rest.model.patch.Operation; import org.dspace.app.rest.model.patch.Operation;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -38,7 +38,7 @@ public class EPersonLoginReplaceOperation extends ReplacePatchOperation<EPersonR
@Override @Override
void checkModelForExistingValue(EPersonRest resource, Operation operation) { void checkModelForExistingValue(EPersonRest resource, Operation operation) {
if ((Object) resource.isCanLogIn() == null) { if ((Object) resource.isCanLogIn() == null) {
throw new PatchBadRequestException("Attempting to replace a non-existent value."); throw new DSpaceBadRequestException("Attempting to replace a non-existent value.");
} }
} }

View File

@@ -7,7 +7,7 @@
*/ */
package org.dspace.app.rest.repository.patch.factories.impl; package org.dspace.app.rest.repository.patch.factories.impl;
import org.dspace.app.rest.exception.PatchBadRequestException; import org.dspace.app.rest.exception.DSpaceBadRequestException;
import org.dspace.app.rest.model.EPersonRest; import org.dspace.app.rest.model.EPersonRest;
import org.dspace.app.rest.model.patch.Operation; import org.dspace.app.rest.model.patch.Operation;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -38,7 +38,7 @@ public class EPersonNetidReplaceOperation extends ReplacePatchOperation<EPersonR
@Override @Override
void checkModelForExistingValue(EPersonRest resource, Operation operation) { void checkModelForExistingValue(EPersonRest resource, Operation operation) {
if (resource.getNetid() == null) { if (resource.getNetid() == null) {
throw new PatchBadRequestException("Attempting to replace a non-existent value."); throw new DSpaceBadRequestException("Attempting to replace a non-existent value.");
} }
} }

View File

@@ -8,7 +8,7 @@
package org.dspace.app.rest.repository.patch.factories.impl; package org.dspace.app.rest.repository.patch.factories.impl;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.dspace.app.rest.exception.PatchBadRequestException; import org.dspace.app.rest.exception.DSpaceBadRequestException;
import org.dspace.app.rest.model.ItemRest; import org.dspace.app.rest.model.ItemRest;
import org.dspace.app.rest.model.patch.Operation; import org.dspace.app.rest.model.patch.Operation;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -42,7 +42,7 @@ public class ItemDiscoverableReplaceOperation extends ReplacePatchOperation<Item
@Override @Override
void checkModelForExistingValue(ItemRest resource, Operation operation) { void checkModelForExistingValue(ItemRest resource, Operation operation) {
if ((Object) resource.getDiscoverable() == null) { if ((Object) resource.getDiscoverable() == null) {
throw new PatchBadRequestException("Attempting to replace a non-existent value."); throw new DSpaceBadRequestException("Attempting to replace a non-existent value.");
} }
} }

View File

@@ -8,7 +8,7 @@
package org.dspace.app.rest.repository.patch.factories.impl; package org.dspace.app.rest.repository.patch.factories.impl;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.dspace.app.rest.exception.PatchBadRequestException; import org.dspace.app.rest.exception.DSpaceBadRequestException;
import org.dspace.app.rest.exception.UnprocessableEntityException; import org.dspace.app.rest.exception.UnprocessableEntityException;
import org.dspace.app.rest.model.ItemRest; import org.dspace.app.rest.model.ItemRest;
import org.dspace.app.rest.model.patch.Operation; import org.dspace.app.rest.model.patch.Operation;
@@ -65,7 +65,7 @@ public class ItemWithdrawReplaceOperation extends ReplacePatchOperation<ItemRest
@Override @Override
void checkModelForExistingValue(ItemRest resource, Operation operation) { void checkModelForExistingValue(ItemRest resource, Operation operation) {
if ((Object) resource.getWithdrawn() == null) { if ((Object) resource.getWithdrawn() == null) {
throw new PatchBadRequestException("Attempting to replace a non-existent value."); throw new DSpaceBadRequestException("Attempting to replace a non-existent value.");
} }
} }

View File

@@ -8,7 +8,7 @@
package org.dspace.app.rest.repository.patch.factories.impl; package org.dspace.app.rest.repository.patch.factories.impl;
import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.BooleanUtils;
import org.dspace.app.rest.exception.PatchBadRequestException; import org.dspace.app.rest.exception.DSpaceBadRequestException;
import org.dspace.app.rest.model.RestModel; import org.dspace.app.rest.model.RestModel;
import org.dspace.app.rest.model.patch.Operation; import org.dspace.app.rest.model.patch.Operation;
@@ -26,7 +26,7 @@ public abstract class PatchOperation<R extends RestModel, T>
* @param resource the rest model. * @param resource the rest model.
* @param operation the patch operation. * @param operation the patch operation.
* @return the updated rest model. * @return the updated rest model.
* @throws PatchBadRequestException * @throws DSpaceBadRequestException
*/ */
public abstract R perform(R resource, Operation operation); public abstract R perform(R resource, Operation operation);
@@ -37,7 +37,7 @@ public abstract class PatchOperation<R extends RestModel, T>
*/ */
void checkOperationValue(Object value) { void checkOperationValue(Object value) {
if (value == null) { if (value == null) {
throw new PatchBadRequestException("No value provided for the operation."); throw new DSpaceBadRequestException("No value provided for the operation.");
} }
} }
@@ -46,7 +46,7 @@ public abstract class PatchOperation<R extends RestModel, T>
* *
* @param value the operation value * @param value the operation value
* @return the original or derived boolean value * @return the original or derived boolean value
* @throws PatchBadRequestException * @throws DSpaceBadRequestException
*/ */
Boolean getBooleanOperationValue(Object value) { Boolean getBooleanOperationValue(Object value) {
Boolean bool; Boolean bool;
@@ -54,7 +54,8 @@ public abstract class PatchOperation<R extends RestModel, T>
if (value instanceof String) { if (value instanceof String) {
bool = BooleanUtils.toBooleanObject((String) value); bool = BooleanUtils.toBooleanObject((String) value);
if (bool == null) { if (bool == null) {
throw new PatchBadRequestException("Boolean value not provided."); // make sure the string was converted to boolean.
throw new DSpaceBadRequestException("Boolean value not provided.");
} }
} else { } else {
bool = (Boolean) value; bool = (Boolean) value;

View File

@@ -7,7 +7,7 @@
*/ */
package org.dspace.app.rest.repository.patch.factories.impl; package org.dspace.app.rest.repository.patch.factories.impl;
import org.dspace.app.rest.exception.PatchBadRequestException; import org.dspace.app.rest.exception.DSpaceBadRequestException;
import org.dspace.app.rest.exception.UnprocessableEntityException; import org.dspace.app.rest.exception.UnprocessableEntityException;
import org.dspace.app.rest.model.RestModel; import org.dspace.app.rest.model.RestModel;
import org.dspace.app.rest.model.patch.Operation; import org.dspace.app.rest.model.patch.Operation;
@@ -29,7 +29,7 @@ public abstract class ReplacePatchOperation<R extends RestModel, T>
* @param resource the rest model. * @param resource the rest model.
* @param operation the replace patch operation. * @param operation the replace patch operation.
* @return the updated rest model. * @return the updated rest model.
* @throws PatchBadRequestException * @throws DSpaceBadRequestException
* @throws UnprocessableEntityException * @throws UnprocessableEntityException
*/ */
@Override @Override
@@ -47,7 +47,7 @@ public abstract class ReplacePatchOperation<R extends RestModel, T>
* @param resource the rest model. * @param resource the rest model.
* @param operation the replace patch operation. * @param operation the replace patch operation.
* @return the updated rest model. * @return the updated rest model.
* @throws PatchBadRequestException * @throws DSpaceBadRequestException
* @throws UnprocessableEntityException * @throws UnprocessableEntityException
*/ */
abstract R replace(R resource, Operation operation); abstract R replace(R resource, Operation operation);
@@ -59,7 +59,7 @@ public abstract class ReplacePatchOperation<R extends RestModel, T>
* to assure that the replace operation acts only on an existing value. * to assure that the replace operation acts only on an existing value.
* *
* @param resource the rest model. * @param resource the rest model.
* @throws PatchBadRequestException * @throws DSpaceBadRequestException
*/ */
abstract void checkModelForExistingValue(R resource, Operation operation); abstract void checkModelForExistingValue(R resource, Operation operation);

View File

@@ -7,7 +7,7 @@
*/ */
package org.dspace.app.rest.repository.patch.factories.impl; package org.dspace.app.rest.repository.patch.factories.impl;
import org.dspace.app.rest.exception.PatchBadRequestException; import org.dspace.app.rest.exception.DSpaceBadRequestException;
import org.dspace.app.rest.model.RestModel; import org.dspace.app.rest.model.RestModel;
import org.dspace.app.rest.model.patch.Operation; import org.dspace.app.rest.model.patch.Operation;
@@ -18,6 +18,6 @@ import org.dspace.app.rest.model.patch.Operation;
public interface ResourcePatchOperation<R extends RestModel> { public interface ResourcePatchOperation<R extends RestModel> {
R perform(R resource, Operation operation) R perform(R resource, Operation operation)
throws PatchBadRequestException; throws DSpaceBadRequestException;
} }

View File

@@ -16,11 +16,7 @@ import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.dspace.app.rest.converter.query.SearchQueryConverter; import org.dspace.app.rest.converter.query.SearchQueryConverter;
import org.dspace.app.rest.exception.InvalidDSpaceObjectTypeException; import org.dspace.app.rest.exception.DSpaceBadRequestException;
import org.dspace.app.rest.exception.InvalidRequestException;
import org.dspace.app.rest.exception.InvalidSearchFacetException;
import org.dspace.app.rest.exception.InvalidSearchFilterException;
import org.dspace.app.rest.exception.InvalidSortingException;
import org.dspace.app.rest.parameter.SearchFilter; import org.dspace.app.rest.parameter.SearchFilter;
import org.dspace.core.Constants; import org.dspace.core.Constants;
import org.dspace.core.Context; import org.dspace.core.Context;
@@ -71,7 +67,7 @@ public class DiscoverQueryBuilder implements InitializingBean {
DiscoveryConfiguration discoveryConfiguration, DiscoveryConfiguration discoveryConfiguration,
String query, List<SearchFilter> searchFilters, String query, List<SearchFilter> searchFilters,
String dsoType, Pageable page) String dsoType, Pageable page)
throws InvalidRequestException { throws DSpaceBadRequestException {
DiscoverQuery queryArgs = buildCommonDiscoverQuery(context, discoveryConfiguration, query, searchFilters, DiscoverQuery queryArgs = buildCommonDiscoverQuery(context, discoveryConfiguration, query, searchFilters,
dsoType); dsoType);
@@ -104,7 +100,7 @@ public class DiscoverQueryBuilder implements InitializingBean {
DiscoveryConfiguration discoveryConfiguration, DiscoveryConfiguration discoveryConfiguration,
String prefix, String query, List<SearchFilter> searchFilters, String prefix, String query, List<SearchFilter> searchFilters,
String dsoType, Pageable page, String facetName) String dsoType, Pageable page, String facetName)
throws InvalidRequestException { throws DSpaceBadRequestException {
DiscoverQuery queryArgs = buildCommonDiscoverQuery(context, discoveryConfiguration, query, searchFilters, DiscoverQuery queryArgs = buildCommonDiscoverQuery(context, discoveryConfiguration, query, searchFilters,
dsoType); dsoType);
@@ -129,7 +125,7 @@ public class DiscoverQueryBuilder implements InitializingBean {
private DiscoverQuery addFacetingForFacets(Context context, IndexableObject scope, String prefix, private DiscoverQuery addFacetingForFacets(Context context, IndexableObject scope, String prefix,
DiscoverQuery queryArgs, DiscoveryConfiguration discoveryConfiguration, String facetName, Pageable page) DiscoverQuery queryArgs, DiscoveryConfiguration discoveryConfiguration, String facetName, Pageable page)
throws InvalidSearchFacetException { throws DSpaceBadRequestException {
DiscoverySearchFilterFacet facet = discoveryConfiguration.getSidebarFacet(facetName); DiscoverySearchFilterFacet facet = discoveryConfiguration.getSidebarFacet(facetName);
if (facet != null) { if (facet != null) {
@@ -139,7 +135,7 @@ public class DiscoverQueryBuilder implements InitializingBean {
fillFacetIntoQueryArgs(context, scope, prefix, queryArgs, facet, pageSize); fillFacetIntoQueryArgs(context, scope, prefix, queryArgs, facet, pageSize);
} else { } else {
throw new InvalidSearchFacetException(facetName + " is not a valid search facet"); throw new DSpaceBadRequestException(facetName + " is not a valid search facet");
} }
return queryArgs; return queryArgs;
@@ -173,7 +169,7 @@ public class DiscoverQueryBuilder implements InitializingBean {
private DiscoverQuery buildCommonDiscoverQuery(Context context, DiscoveryConfiguration discoveryConfiguration, private DiscoverQuery buildCommonDiscoverQuery(Context context, DiscoveryConfiguration discoveryConfiguration,
String query, String query,
List<SearchFilter> searchFilters, String dsoType) List<SearchFilter> searchFilters, String dsoType)
throws InvalidSearchFilterException, InvalidDSpaceObjectTypeException { throws DSpaceBadRequestException {
DiscoverQuery queryArgs = buildBaseQueryForConfiguration(discoveryConfiguration); DiscoverQuery queryArgs = buildBaseQueryForConfiguration(discoveryConfiguration);
//Add search filters //Add search filters
@@ -202,7 +198,7 @@ public class DiscoverQueryBuilder implements InitializingBean {
} }
private void configureSorting(Pageable page, DiscoverQuery queryArgs, private void configureSorting(Pageable page, DiscoverQuery queryArgs,
DiscoverySortConfiguration searchSortConfiguration) throws InvalidSortingException { DiscoverySortConfiguration searchSortConfiguration) throws DSpaceBadRequestException {
String sortBy = null; String sortBy = null;
String sortOrder = null; String sortOrder = null;
@@ -237,11 +233,11 @@ public class DiscoverQueryBuilder implements InitializingBean {
} else if ("desc".equalsIgnoreCase(sortOrder)) { } else if ("desc".equalsIgnoreCase(sortOrder)) {
queryArgs.setSortField(sortField, DiscoverQuery.SORT_ORDER.desc); queryArgs.setSortField(sortField, DiscoverQuery.SORT_ORDER.desc);
} else { } else {
throw new InvalidSortingException(sortOrder + " is not a valid sort order"); throw new DSpaceBadRequestException(sortOrder + " is not a valid sort order");
} }
} else { } else {
throw new InvalidSortingException(sortBy + " is not a valid sort field"); throw new DSpaceBadRequestException(sortBy + " is not a valid sort field");
} }
} }
@@ -273,16 +269,16 @@ public class DiscoverQueryBuilder implements InitializingBean {
} }
} }
private int getDsoTypeId(String dsoType) throws InvalidDSpaceObjectTypeException { private int getDsoTypeId(String dsoType) throws DSpaceBadRequestException {
int index = ArrayUtils.indexOf(Constants.typeText, dsoType.toUpperCase()); int index = ArrayUtils.indexOf(Constants.typeText, dsoType.toUpperCase());
if (index < 0) { if (index < 0) {
throw new InvalidDSpaceObjectTypeException(dsoType + " is not a valid DSpace Object type"); throw new DSpaceBadRequestException(dsoType + " is not a valid DSpace Object type");
} }
return index; return index;
} }
private String[] convertFilters(Context context, DiscoveryConfiguration discoveryConfiguration, private String[] convertFilters(Context context, DiscoveryConfiguration discoveryConfiguration,
List<SearchFilter> searchFilters) throws InvalidSearchFilterException { List<SearchFilter> searchFilters) throws DSpaceBadRequestException {
ArrayList<String> filterQueries = new ArrayList<>(CollectionUtils.size(searchFilters)); ArrayList<String> filterQueries = new ArrayList<>(CollectionUtils.size(searchFilters));
SearchQueryConverter searchQueryConverter = new SearchQueryConverter(); SearchQueryConverter searchQueryConverter = new SearchQueryConverter();
@@ -291,7 +287,7 @@ public class DiscoverQueryBuilder implements InitializingBean {
for (SearchFilter searchFilter : CollectionUtils.emptyIfNull(transformedFilters)) { for (SearchFilter searchFilter : CollectionUtils.emptyIfNull(transformedFilters)) {
DiscoverySearchFilter filter = discoveryConfiguration.getSearchFilter(searchFilter.getName()); DiscoverySearchFilter filter = discoveryConfiguration.getSearchFilter(searchFilter.getName());
if (filter == null) { if (filter == null) {
throw new InvalidSearchFilterException(searchFilter.getName() + " is not a valid search filter"); throw new DSpaceBadRequestException(searchFilter.getName() + " is not a valid search filter");
} }
DiscoverFilterQuery filterQuery = searchService.toFilterQuery(context, DiscoverFilterQuery filterQuery = searchService.toFilterQuery(context,
@@ -304,7 +300,7 @@ public class DiscoverQueryBuilder implements InitializingBean {
} }
} }
} catch (SQLException e) { } catch (SQLException e) {
throw new InvalidSearchFilterException("There was a problem parsing the search filters.", e); throw new DSpaceBadRequestException("There was a problem parsing the search filters.", e);
} }
return filterQueries.toArray(new String[filterQueries.size()]); return filterQueries.toArray(new String[filterQueries.size()]);

View File

@@ -387,6 +387,78 @@ public class BrowsesResourceControllerIT extends AbstractControllerIntegrationTe
not(matchMetadata("dc.title", "Internal publication"))))); not(matchMetadata("dc.title", "Internal publication")))));
} }
@Test
/**
* This test was introduced to reproduce the bug DS-4269 Pagination links must be consistent also when there is not
* explicit pagination parameters in the request (i.e. defaults apply)
*
* @throws Exception
*/
public void browsePaginationWithoutExplicitParams() throws Exception {
context.turnOffAuthorisationSystem();
//** GIVEN **
//1. A community-collection structure with one parent community and one collection.
parentCommunity = CommunityBuilder.createCommunity(context)
.withName("Parent Community")
.build();
Collection col1 = CollectionBuilder.createCollection(context, parentCommunity).withName("Collection 1").build();
//2. Twenty-one public items that are readable by Anonymous
for (int i = 0; i <= 20; i++) {
ItemBuilder.createItem(context, col1)
.withTitle("Public item " + String.format("%02d", i))
.withIssueDate("2017-10-17")
.withAuthor("Test, Author" + String.format("%02d", i))
.withSubject("Java").withSubject("Unit Testing")
.build();
}
context.restoreAuthSystemState();
//** WHEN **
//An anonymous user browses the items in the Browse by item endpoint
getClient().perform(get("/api/discover/browses/title/items"))
//** THEN **
//The status has to be 200 OK
.andExpect(status().isOk())
//We expect the content type to be "application/hal+json;charset=UTF-8"
.andExpect(content().contentType(contentType))
//We expect 21 public items
.andExpect(jsonPath("$.page.size", is(20)))
.andExpect(jsonPath("$.page.totalElements", is(21)))
.andExpect(jsonPath("$.page.totalPages", is(2)))
.andExpect(jsonPath("$.page.number", is(0)))
// embedded items are already checked by other test, we focus on links here
.andExpect(jsonPath("$._links.next.href", Matchers.containsString("/api/discover/browses/title/items?")))
.andExpect(jsonPath("$._links.last.href", Matchers.containsString("/api/discover/browses/title/items?")))
.andExpect(
jsonPath("$._links.first.href", Matchers.containsString("/api/discover/browses/title/items?")))
.andExpect(jsonPath("$._links.self.href", Matchers.endsWith("/api/discover/browses/title/items")));
//** WHEN **
//An anonymous user browses the items in the Browse by item endpoint
getClient().perform(get("/api/discover/browses/author/entries"))
//** THEN **
//The status has to be 200 OK
.andExpect(status().isOk())
//We expect the content type to be "application/hal+json;charset=UTF-8"
.andExpect(content().contentType(contentType))
//We expect 21 public items
.andExpect(jsonPath("$.page.size", is(20)))
.andExpect(jsonPath("$.page.totalElements", is(21)))
.andExpect(jsonPath("$.page.totalPages", is(2)))
.andExpect(jsonPath("$.page.number", is(0)))
// embedded items are already checked by other test, we focus on links here
.andExpect(jsonPath("$._links.next.href",
Matchers.containsString("/api/discover/browses/author/entries?")))
.andExpect(jsonPath("$._links.last.href",
Matchers.containsString("/api/discover/browses/author/entries?")))
.andExpect(jsonPath("$._links.first.href",
Matchers.containsString("/api/discover/browses/author/entries?")))
.andExpect(jsonPath("$._links.self.href", Matchers.endsWith("/api/discover/browses/author/entries")));
}
@Test @Test
public void testPaginationBrowseByDateIssuedItems() throws Exception { public void testPaginationBrowseByDateIssuedItems() throws Exception {
context.turnOffAuthorisationSystem(); context.turnOffAuthorisationSystem();

View File

@@ -646,4 +646,80 @@ public class CollectionRestRepositoryIT extends AbstractControllerIntegrationTes
new MetadataPatchSuite().runWith(getClient(token), "/api/core/collections/" + col.getID(), expectedStatus); new MetadataPatchSuite().runWith(getClient(token), "/api/core/collections/" + col.getID(), expectedStatus);
} }
@Test
public void createTestInvalidParentCommunityUUIDBadRequestException() throws Exception {
context.turnOffAuthorisationSystem();
//** GIVEN **
//1. A community-collection structure with one parent community with sub-community and one collection.
parentCommunity = CommunityBuilder.createCommunity(context)
.withName("Parent Community")
.withLogo("ThisIsSomeDummyText")
.build();
ObjectMapper mapper = new ObjectMapper();
CollectionRest collectionRest = new CollectionRest();
// We send a name but the created collection should set this to the title
collectionRest.setName("Collection");
collectionRest.setMetadata(new MetadataRest()
.put("dc.description",
new MetadataValueRest("<p>Some cool HTML code here</p>"))
.put("dc.description.abstract",
new MetadataValueRest("top-level community created via the REST API"))
.put("dc.description.tableofcontents",
new MetadataValueRest("<p>HTML News</p>"))
.put("dc.rights",
new MetadataValueRest("Custom Copyright Text"))
.put("dc.title",
new MetadataValueRest("Title Text")));
String authToken = getAuthToken(admin.getEmail(), password);
getClient(authToken).perform(post("/api/core/collections")
.content(mapper.writeValueAsBytes(collectionRest))
.param("parent", "123")
.contentType(contentType))
.andExpect(status().isBadRequest());
}
@Test
public void createTestWithoutParentCommunityUUIDBadRequestException() throws Exception {
context.turnOffAuthorisationSystem();
//** GIVEN **
//1. A community-collection structure with one parent community with sub-community and one collection.
parentCommunity = CommunityBuilder.createCommunity(context)
.withName("Parent Community")
.withLogo("ThisIsSomeDummyText")
.build();
ObjectMapper mapper = new ObjectMapper();
CollectionRest collectionRest = new CollectionRest();
// We send a name but the created collection should set this to the title
collectionRest.setName("Collection");
collectionRest.setMetadata(new MetadataRest()
.put("dc.description",
new MetadataValueRest("<p>Some cool HTML code here</p>"))
.put("dc.description.abstract",
new MetadataValueRest("top-level community created via the REST API"))
.put("dc.description.tableofcontents",
new MetadataValueRest("<p>HTML News</p>"))
.put("dc.rights",
new MetadataValueRest("Custom Copyright Text"))
.put("dc.title",
new MetadataValueRest("Title Text")));
String authToken = getAuthToken(admin.getEmail(), password);
getClient(authToken).perform(post("/api/core/collections")
.content(mapper.writeValueAsBytes(collectionRest))
.contentType(contentType))
.andExpect(status().isBadRequest());
}
} }

View File

@@ -901,4 +901,45 @@ public class CommunityRestRepositoryIT extends AbstractControllerIntegrationTest
new MetadataPatchSuite().runWith(getClient(token), "/api/core/communities/" new MetadataPatchSuite().runWith(getClient(token), "/api/core/communities/"
+ parentCommunity.getID(), expectedStatus); + parentCommunity.getID(), expectedStatus);
} }
@Test
public void createTestInvalidParentCommunityBadRequest() throws Exception {
context.turnOffAuthorisationSystem();
ObjectMapper mapper = new ObjectMapper();
CommunityRest comm = new CommunityRest();
// We send a name but the created community should set this to the title
comm.setName("Test Top-Level Community");
MetadataRest metadataRest = new MetadataRest();
MetadataValueRest description = new MetadataValueRest();
description.setValue("<p>Some cool HTML code here</p>");
metadataRest.put("dc.description", description);
MetadataValueRest abs = new MetadataValueRest();
abs.setValue("Sample top-level community created via the REST API");
metadataRest.put("dc.description.abstract", abs);
MetadataValueRest contents = new MetadataValueRest();
contents.setValue("<p>HTML News</p>");
metadataRest.put("dc.description.tableofcontents", contents);
MetadataValueRest copyright = new MetadataValueRest();
copyright.setValue("Custom Copyright Text");
metadataRest.put("dc.rights", copyright);
MetadataValueRest title = new MetadataValueRest();
title.setValue("Title Text");
metadataRest.put("dc.title", title);
comm.setMetadata(metadataRest);
String authToken = getAuthToken(admin.getEmail(), password);
getClient(authToken).perform(post("/api/core/communities")
.param("parent", "123")
.content(mapper.writeValueAsBytes(comm))
.contentType(contentType))
.andExpect(status().isBadRequest());
}
} }

View File

@@ -1768,4 +1768,86 @@ public class ItemRestRepositoryIT extends AbstractControllerIntegrationTest {
new MetadataPatchSuite().runWith(getClient(token), "/api/core/items/" + item.getID(), expectedStatus); new MetadataPatchSuite().runWith(getClient(token), "/api/core/items/" + item.getID(), expectedStatus);
} }
/**
* This test will try creating an item with the InArchive property set to false. This endpoint does not allow
* us to create Items which aren't final (final means that they'd be in archive) and thus it'll throw a
* BadRequestException which is what we're testing for
* @throws Exception If something goes wrong
*/
@Test
public void testCreateItemInArchiveFalseBadRequestException() throws Exception {
context.turnOffAuthorisationSystem();
//** GIVEN **
//1. A community-collection structure with one parent community with sub-community and two collections.
parentCommunity = CommunityBuilder.createCommunity(context)
.withName("Parent Community")
.build();
Community child1 = CommunityBuilder.createSubCommunity(context, parentCommunity)
.withName("Sub Community")
.build();
Collection col1 = CollectionBuilder.createCollection(context, child1).withName("Collection 1").build();
ObjectMapper mapper = new ObjectMapper();
ItemRest itemRest = new ItemRest();
itemRest.setName("Practices of research data curation in institutional repositories:" +
" A qualitative view from repository staff");
itemRest.setInArchive(false);
itemRest.setDiscoverable(true);
itemRest.setWithdrawn(false);
itemRest.setMetadata(new MetadataRest()
.put("dc.description", new MetadataValueRest("<p>Some cool HTML code here</p>"))
.put("dc.description.abstract",
new MetadataValueRest("Sample item created via the REST API"))
.put("dc.description.tableofcontents", new MetadataValueRest("<p>HTML News</p>"))
.put("dc.rights", new MetadataValueRest("Custom Copyright Text"))
.put("dc.title", new MetadataValueRest("Title Text")));
String token = getAuthToken(admin.getEmail(), password);
getClient(token).perform(post("/api/core/items?owningCollection=" + col1.getID().toString())
.content(mapper.writeValueAsBytes(itemRest)).contentType(contentType))
.andExpect(status().isBadRequest());
}
@Test
public void testCreateItemInvalidCollectionBadRequestException() throws Exception {
context.turnOffAuthorisationSystem();
//** GIVEN **
//1. A community-collection structure with one parent community with sub-community and two collections.
parentCommunity = CommunityBuilder.createCommunity(context)
.withName("Parent Community")
.build();
Community child1 = CommunityBuilder.createSubCommunity(context, parentCommunity)
.withName("Sub Community")
.build();
Collection col1 = CollectionBuilder.createCollection(context, child1).withName("Collection 1").build();
ObjectMapper mapper = new ObjectMapper();
ItemRest itemRest = new ItemRest();
itemRest.setName("Practices of research data curation in institutional repositories:" +
" A qualitative view from repository staff");
itemRest.setInArchive(false);
itemRest.setDiscoverable(true);
itemRest.setWithdrawn(false);
itemRest.setMetadata(new MetadataRest()
.put("dc.description", new MetadataValueRest("<p>Some cool HTML code here</p>"))
.put("dc.description.abstract",
new MetadataValueRest("Sample item created via the REST API"))
.put("dc.description.tableofcontents", new MetadataValueRest("<p>HTML News</p>"))
.put("dc.rights", new MetadataValueRest("Custom Copyright Text"))
.put("dc.title", new MetadataValueRest("Title Text")));
String token = getAuthToken(admin.getEmail(), password);
getClient(token).perform(post("/api/core/items?owningCollection=" + parentCommunity.getID().toString())
.content(mapper.writeValueAsBytes(itemRest)).contentType(contentType))
.andExpect(status().isBadRequest());
}
} }

View File

@@ -23,10 +23,7 @@ import java.util.Arrays;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.dspace.app.rest.exception.InvalidDSpaceObjectTypeException; import org.dspace.app.rest.exception.DSpaceBadRequestException;
import org.dspace.app.rest.exception.InvalidSearchFacetException;
import org.dspace.app.rest.exception.InvalidSearchFilterException;
import org.dspace.app.rest.exception.InvalidSortingException;
import org.dspace.app.rest.parameter.SearchFilter; import org.dspace.app.rest.parameter.SearchFilter;
import org.dspace.core.Constants; import org.dspace.core.Constants;
import org.dspace.core.Context; import org.dspace.core.Context;
@@ -245,20 +242,20 @@ public class DiscoverQueryBuilderTest {
new ReflectionEquals(new DiscoverHitHighlightingField("fulltext", 0, 3)))); new ReflectionEquals(new DiscoverHitHighlightingField("fulltext", 0, 3))));
} }
@Test(expected = InvalidDSpaceObjectTypeException.class) @Test(expected = DSpaceBadRequestException.class)
public void testInvalidDSOType() throws Exception { public void testInvalidDSOType() throws Exception {
queryBuilder queryBuilder
.buildQuery(context, scope, discoveryConfiguration, query, Arrays.asList(searchFilter), "TEST", page); .buildQuery(context, scope, discoveryConfiguration, query, Arrays.asList(searchFilter), "TEST", page);
} }
@Test(expected = InvalidSortingException.class) @Test(expected = DSpaceBadRequestException.class)
public void testInvalidSortField() throws Exception { public void testInvalidSortField() throws Exception {
page = new PageRequest(2, 10, Sort.Direction.ASC, "test"); page = new PageRequest(2, 10, Sort.Direction.ASC, "test");
queryBuilder queryBuilder
.buildQuery(context, scope, discoveryConfiguration, query, Arrays.asList(searchFilter), "ITEM", page); .buildQuery(context, scope, discoveryConfiguration, query, Arrays.asList(searchFilter), "ITEM", page);
} }
@Test(expected = InvalidSearchFilterException.class) @Test(expected = DSpaceBadRequestException.class)
public void testInvalidSearchFilter1() throws Exception { public void testInvalidSearchFilter1() throws Exception {
searchFilter = new SearchFilter("test", "equals", "Smith, Donald"); searchFilter = new SearchFilter("test", "equals", "Smith, Donald");
@@ -266,7 +263,7 @@ public class DiscoverQueryBuilderTest {
.buildQuery(context, scope, discoveryConfiguration, query, Arrays.asList(searchFilter), "ITEM", page); .buildQuery(context, scope, discoveryConfiguration, query, Arrays.asList(searchFilter), "ITEM", page);
} }
@Test(expected = InvalidSearchFilterException.class) @Test(expected = DSpaceBadRequestException.class)
public void testInvalidSearchFilter2() throws Exception { public void testInvalidSearchFilter2() throws Exception {
when(searchService.toFilterQuery(any(Context.class), any(String.class), any(String.class), any(String.class))) when(searchService.toFilterQuery(any(Context.class), any(String.class), any(String.class), any(String.class)))
.thenThrow(SQLException.class); .thenThrow(SQLException.class);
@@ -297,7 +294,7 @@ public class DiscoverQueryBuilderTest {
)); ));
} }
@Test(expected = InvalidSearchFacetException.class) @Test(expected = DSpaceBadRequestException.class)
public void testInvalidSearchFacet() throws Exception { public void testInvalidSearchFacet() throws Exception {
queryBuilder.buildFacetQuery(context, scope, discoveryConfiguration, null, query, queryBuilder.buildFacetQuery(context, scope, discoveryConfiguration, null, query,
Arrays.asList(searchFilter), "item", page, "test"); Arrays.asList(searchFilter), "item", page, "test");