Fixing exception mapper response code

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@146733 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2017-04-10 15:37:58 +00:00
parent 8a20df8e90
commit 4eca4513da
2 changed files with 7 additions and 4 deletions

View File

@ -67,7 +67,7 @@ public class Access {
@GET
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
public String query(@QueryParam(AccessPath.QUERY_PARAM) String query,
@QueryParam(AccessPath.LIMIT_PARAM) int limit,
@QueryParam(AccessPath.LIMIT_PARAM) Integer limit,
@QueryParam(AccessPath.FETCH_PLAN_PARAM) String fetchPlan)
throws InvalidQueryException {
logger.info("Requested query (fetch plan {}, limit : {}):\n{}",

View File

@ -8,6 +8,7 @@ import javax.ws.rs.ext.Provider;
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.er.ERAlreadyPresentException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.er.ERAvailableInAnotherContextException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.er.ERNotFoundException;
/**
@ -23,11 +24,13 @@ public class ResourceRegistryExceptionMapper implements ExceptionMapper<Resource
if(ERNotFoundException.class.isAssignableFrom(exception.getClass())){
status = Status.NOT_FOUND;
}else if(ERAlreadyPresentException.class.isAssignableFrom(exception.getClass())){
status = Status.FORBIDDEN;
} else if(ERAlreadyPresentException.class.isAssignableFrom(exception.getClass())){
status = Status.CONFLICT;
} else if(ERAvailableInAnotherContextException.class.isAssignableFrom(exception.getClass())){
status = Status.CONFLICT;
} else if(exception.getClass() == ResourceRegistryException.class){
status = Status.INTERNAL_SERVER_ERROR;
}
}
try {
String entity = org.gcube.informationsystem.resourceregistry.api.exceptions.ExceptionMapper.marshal(exception);