storage resolver moved as a service
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-transfer/uri-resolver@173743 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
afbc94f335
commit
c6adb3126b
|
@ -19,4 +19,8 @@ public class ConstantsResolver {
|
|||
|
||||
protected static final String HPC = "hproxycheck"; //for hproxycheck
|
||||
|
||||
public static final String VALIDATION = "validation";
|
||||
public static final String CONTENT_TYPE = "contentType";
|
||||
public static final String FILE_NAME = "fileName";
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.datatransfer.resolver.services;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
||||
import org.gcube.datatransfer.resolver.services.exceptions.BadRequestException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Oct 22, 2018
|
||||
*/
|
||||
@Path("/")
|
||||
public class SMPIDResolver {
|
||||
|
||||
private static final String SMP_ID = "smp-id";
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(SMPIDResolver.class);
|
||||
/**
|
||||
* Gets the smpid.
|
||||
*
|
||||
* @param smpId the smp id
|
||||
* @param fileName the file name
|
||||
* @param contentType the content type
|
||||
* @param validation the validation
|
||||
* @return the smpid
|
||||
*/
|
||||
@GET
|
||||
@Path("id")
|
||||
public Response getSMPID(@Context HttpServletRequest httpRequest, @QueryParam(SMP_ID) @Nullable String smpId, @QueryParam(ConstantsResolver.FILE_NAME) String fileName, @QueryParam(ConstantsResolver.CONTENT_TYPE) String contentType, @QueryParam(ConstantsResolver.VALIDATION) Boolean validation){
|
||||
logger.info("resolve smp-id called");
|
||||
|
||||
//Checking mandatory parameter smpId
|
||||
if(smpId==null || smpId.isEmpty()){
|
||||
logger.error(SMP_ID+" not found");
|
||||
throw new BadRequestException(httpRequest, Status.NOT_ACCEPTABLE, "Missing mandatory parameter "+SMP_ID, SMPIDResolver.class);
|
||||
}
|
||||
|
||||
return StorageManager.resolveStorageId(httpRequest, smpId, fileName, contentType, validation);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.datatransfer.resolver.services;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
||||
import org.gcube.datatransfer.resolver.services.exceptions.BadRequestException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Oct 22, 2018
|
||||
*/
|
||||
@Path("/")
|
||||
public class SMPResolver {
|
||||
|
||||
private static final String SMP_URI = "smp-uri";
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(SMPResolver.class);
|
||||
|
||||
/**
|
||||
* Gets the smpid.
|
||||
*
|
||||
* @param smpURI the smp id
|
||||
* @param fileName the file name
|
||||
* @param contentType the content type
|
||||
* @param validation the validation
|
||||
* @return the smpid
|
||||
*/
|
||||
@GET
|
||||
@Path("smp")
|
||||
public Response getSMPURI(@Context HttpServletRequest httpRequest, @QueryParam(SMP_URI) @Nullable String smpURI, @QueryParam(ConstantsResolver.FILE_NAME) String fileName, @QueryParam(ConstantsResolver.CONTENT_TYPE) String contentType, @QueryParam(ConstantsResolver.VALIDATION) Boolean validation){
|
||||
logger.info("resolve smp-uri called");
|
||||
|
||||
//Checking mandatory parameter smpURI
|
||||
if(smpURI==null || smpURI.isEmpty()){
|
||||
logger.error(SMP_URI+" not found");
|
||||
throw new BadRequestException(httpRequest, Status.NOT_ACCEPTABLE, "Missing mandatory parameter "+SMP_URI, SMPResolver.class);
|
||||
}
|
||||
|
||||
return StorageManager.resolveStorageId(httpRequest, smpURI, fileName, contentType, validation);
|
||||
|
||||
}
|
||||
}
|
|
@ -2,12 +2,12 @@ package org.gcube.datatransfer.resolver.services;
|
|||
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.ResponseBuilder;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
@ -19,6 +19,9 @@ import org.gcube.contentmanager.storageclient.wrapper.AccessType;
|
|||
import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
|
||||
import org.gcube.datatransfer.resolver.SingleFileStreamingOutput;
|
||||
import org.gcube.datatransfer.resolver.services.exceptions.BadRequestException;
|
||||
import org.gcube.datatransfer.resolver.services.exceptions.InternalServerException;
|
||||
import org.gcube.datatransfer.resolver.services.exceptions.WrongParameterException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -38,71 +41,15 @@ public class StorageManager {
|
|||
*
|
||||
*/
|
||||
protected static final String STORAGEID_RESOLVER = "storageid-resolver";
|
||||
private static final String HPROXYCHECK = "hproxycheck";
|
||||
private static final String CONTENT_TYPE = "contentType";
|
||||
private static final String FILE_NAME = "fileName";
|
||||
private static final String SMP_ID = "smp-id";
|
||||
private static final String SMP_URI = "smp-uri";
|
||||
private static final String STORAGE_ID = "storage-id";
|
||||
protected static final String VALIDATION = "validation";
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(StorageManager.class);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the smpid.
|
||||
*
|
||||
* @param smpURI the smp id
|
||||
* @param fileName the file name
|
||||
* @param contentType the content type
|
||||
* @param validation the validation
|
||||
* @return the smpid
|
||||
*/
|
||||
/*@GET
|
||||
@Path("smp")
|
||||
public Response getSMPURI(@QueryParam(SMP_URI) @Nullable String smpURI, @QueryParam(FILE_NAME) String fileName, @QueryParam(CONTENT_TYPE) String contentType, @QueryParam(VALIDATION) Boolean validation){
|
||||
logger.info("resolve smp-id called");
|
||||
|
||||
//Checking mandatory parameter smpId
|
||||
if(smpURI==null || smpURI.isEmpty()){
|
||||
logger.error(SMP_URI+" not found");
|
||||
return Response.status(Status.BAD_REQUEST).entity(Entity.text("Missing mandatory parameter "+SMP_URI)).build();
|
||||
}
|
||||
|
||||
logger.warn("Sono qui getSMPURI");
|
||||
return getStorageId(smpURI, fileName, contentType, validation);
|
||||
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Gets the smpid.
|
||||
*
|
||||
* @param smpId the smp id
|
||||
* @param fileName the file name
|
||||
* @param contentType the content type
|
||||
* @param validation the validation
|
||||
* @return the smpid
|
||||
*/
|
||||
@GET
|
||||
@Path("id")
|
||||
public Response getSMPID(@QueryParam(SMP_ID) @Nullable String smpId, @QueryParam(FILE_NAME) String fileName, @QueryParam(CONTENT_TYPE) String contentType, @QueryParam(VALIDATION) Boolean validation){
|
||||
logger.info("resolve smp-id called");
|
||||
|
||||
//Checking mandatory parameter smpId
|
||||
if(smpId==null || smpId.isEmpty()){
|
||||
logger.error(SMP_ID+" not found");
|
||||
//return Response.status(400).entity(Entity.text("Missing mandatory parameter "+SMP_ID)).build();
|
||||
throw new WebApplicationException("Missing mandatory parameter "+SMP_ID, Status.BAD_REQUEST);
|
||||
}
|
||||
|
||||
return getStorageId(smpId, fileName, contentType, validation);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the storage id.
|
||||
*
|
||||
* @param httpRequest the http request
|
||||
* @param storageId the storage id
|
||||
* @param fileName the file name
|
||||
* @param contentType the content type
|
||||
|
@ -111,14 +58,35 @@ public class StorageManager {
|
|||
*/
|
||||
@GET
|
||||
@Path("{storage-id:(?!id)[^/?$]*}")
|
||||
public Response getStorageId(@PathParam(STORAGE_ID) String storageId, @QueryParam(FILE_NAME) String fileName, @QueryParam(CONTENT_TYPE) String contentType, @QueryParam(VALIDATION) Boolean validation) {
|
||||
logger.info("resolve Storage Id called");
|
||||
public Response getStorageId(@Context HttpServletRequest httpRequest, @PathParam(STORAGE_ID) String storageId, @QueryParam(ConstantsResolver.FILE_NAME) String fileName, @QueryParam(ConstantsResolver.CONTENT_TYPE) String contentType, @QueryParam(ConstantsResolver.VALIDATION) Boolean validation) {
|
||||
logger.info("resolve Storage-Id called");
|
||||
//Checking mandatory parameter storageId
|
||||
if(storageId==null || storageId.isEmpty()){
|
||||
logger.error(STORAGE_ID+" not found");
|
||||
throw new BadRequestException(httpRequest, Status.NOT_ACCEPTABLE, "Missing mandatory path parameter "+STORAGE_ID, StorageManager.class);
|
||||
}
|
||||
return resolveStorageId(httpRequest, storageId, fileName, contentType, validation);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resolve storage id.
|
||||
*
|
||||
* @param httpRequest the http request
|
||||
* @param storageId the storage id
|
||||
* @param fileName the file name
|
||||
* @param contentType the content type
|
||||
* @param validation the validation
|
||||
* @return the response
|
||||
*/
|
||||
protected static Response resolveStorageId(HttpServletRequest httpRequest, String storageId, String fileName, String contentType, Boolean validation) {
|
||||
|
||||
logger.info("storage-id: "+storageId+", fileName: "+fileName+", contentType: "+contentType+", validation: "+validation);
|
||||
|
||||
//Checking to STORAGE-ID Resolver
|
||||
//Checking mandatory parameter storageId
|
||||
if (storageId == null || storageId.isEmpty()) {
|
||||
logger.warn("storageId not found");
|
||||
throw new WebApplicationException("Missing mandatory parameter "+STORAGE_ID, Status.BAD_REQUEST);
|
||||
throw new BadRequestException(httpRequest, Status.NOT_ACCEPTABLE, "Missing mandatory path parameter "+STORAGE_ID, StorageManager.class);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -136,12 +104,13 @@ public class StorageManager {
|
|||
logger.debug("Decoded ID"+" = "+ toSEID);
|
||||
}catch(Exception e){
|
||||
logger.error("Storage Client Exception when getting file from storage: ", e);
|
||||
throw new WebApplicationException("Storage Client Exception when getting file from storage with id: "+storageId, Status.INTERNAL_SERVER_ERROR);
|
||||
throw new InternalServerException(httpRequest, Status.INTERNAL_SERVER_ERROR, "Storage Client Exception when getting file from storage with id: "+storageId, StorageManager.class);
|
||||
//throw new WebApplicationException("Storage Client Exception when getting file from storage with id: "+storageId, Status.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
if(toSEID==null){
|
||||
String error = "Decrypted id is null, thrown exception!";
|
||||
throw new WebApplicationException(error, Status.BAD_REQUEST);
|
||||
logger.error("Decrypted id for storageId: "+storageId +" is null!");
|
||||
throw new WrongParameterException(httpRequest, Status.BAD_REQUEST, "Error on decrypting the "+STORAGE_ID+ " '"+storageId+"'. Is it a valid id?", StorageManager.class);
|
||||
}
|
||||
|
||||
long size = iClient.getSize().RFileById(toSEID);
|
||||
|
@ -178,6 +147,7 @@ public class StorageManager {
|
|||
.header(ConstantsResolver.CONTENT_LENGTH, size);
|
||||
if (contentType!= null) response.header("Content-Type",contentType);
|
||||
return response.build();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -186,10 +156,7 @@ public class StorageManager {
|
|||
* Http do head.
|
||||
*
|
||||
* @param storageId the storage id
|
||||
* @param hproxycheck the hproxycheck
|
||||
* @return the response
|
||||
* @throws ServletException the servlet exception
|
||||
* @throws IOException Signals that an I/O exception has occurred.
|
||||
*/
|
||||
/*@HEAD
|
||||
@Path("{storage-id}")
|
||||
|
@ -268,7 +235,7 @@ public class StorageManager {
|
|||
* @param storageId the storage id
|
||||
* @return the storage client instance
|
||||
*/
|
||||
protected StorageClient getStorageClientInstance(String storageId){
|
||||
protected static StorageClient getStorageClientInstance(String storageId){
|
||||
|
||||
MemoryType memory=null;
|
||||
if(storageId.endsWith(org.gcube.contentmanagement.blobstorage.transport.backend.util.Costants.VOLATILE_URL_IDENTIFICATOR)){
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.datatransfer.resolver.services;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
|
||||
/**
|
||||
* The Class Util.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Oct 22, 2018
|
||||
*/
|
||||
public class Util {
|
||||
|
||||
/**
|
||||
* Gets the full url.
|
||||
*
|
||||
* @param request the request
|
||||
* @return the full url
|
||||
*/
|
||||
public static String getFullURL(HttpServletRequest request) {
|
||||
StringBuilder requestURL = new StringBuilder(request.getRequestURL().toString());
|
||||
String queryString = request.getQueryString();
|
||||
|
||||
if (queryString == null) {
|
||||
return requestURL.toString();
|
||||
} else {
|
||||
return requestURL.append('?').append(queryString).toString();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.datatransfer.resolver.services.exceptions;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
||||
import org.gcube.datatransfer.resolver.services.Util;
|
||||
;
|
||||
|
||||
|
||||
/**
|
||||
* The Class BadParameterException.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
* Oct 22, 2018
|
||||
*/
|
||||
public class BadParameterException extends WebApplicationException {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -7600028435121268528L;
|
||||
|
||||
/**
|
||||
* Instantiates a new bad parameter exception.
|
||||
*
|
||||
* @param request the request
|
||||
* @param httpReturnStatus the http return status
|
||||
* @param message the message
|
||||
* @param reportedBySource the reported by source
|
||||
*/
|
||||
public BadParameterException(HttpServletRequest request, Status httpReturnStatus, String message, Class reportedBySource) {
|
||||
super(Response.status(httpReturnStatus).entity(new ExceptionReport(Util.getFullURL(request), request.getMethod(), false, new ErrorReport(Status.BAD_REQUEST.getStatusCode(), Status.BAD_REQUEST.name(), message, reportedBySource.getName()))).type(MediaType.APPLICATION_XML).build());
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.datatransfer.resolver.services.exceptions;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
||||
import org.gcube.datatransfer.resolver.services.Util;
|
||||
;
|
||||
|
||||
/**
|
||||
* The Class BadParameterException.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
* Oct 22, 2018
|
||||
*/
|
||||
public class BadRequestException extends WebApplicationException {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -7600028435121268528L;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new bad parameter exception.
|
||||
*
|
||||
* @param request the request
|
||||
* @param httpReturnStatus the http return status
|
||||
* @param message the message
|
||||
* @param reportedBySource the reported by source
|
||||
*/
|
||||
public BadRequestException(HttpServletRequest request, Status httpReturnStatus, String message, Class reportedBySource) {
|
||||
super(Response.status(httpReturnStatus).entity(new ExceptionReport(Util.getFullURL(request), request.getMethod(), false, new ErrorReport(Status.BAD_REQUEST.getStatusCode(), Status.BAD_REQUEST.name(), message, reportedBySource.getName()))).type(MediaType.APPLICATION_XML).build());
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.datatransfer.resolver.services.exceptions;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
|
||||
@XmlRootElement(name="error")
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
public class ErrorReport implements Serializable{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -3114830757465862418L;
|
||||
private Integer httpErrorCode;
|
||||
private String name;
|
||||
private String message;
|
||||
private String reportedBy;
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.datatransfer.resolver.services.exceptions;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Oct 22, 2018
|
||||
*/
|
||||
@XmlRootElement(name="ExceptionReport")
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
public class ExceptionReport implements Serializable{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 7029237703105669823L;
|
||||
|
||||
String request;
|
||||
String method;
|
||||
boolean success;
|
||||
ErrorReport error;
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.datatransfer.resolver.services.exceptions;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.ws.rs.InternalServerErrorException;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
||||
import org.gcube.datatransfer.resolver.services.Util;
|
||||
;
|
||||
|
||||
|
||||
/**
|
||||
* The Class BadParameterException.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
* Oct 22, 2018
|
||||
*/
|
||||
public class InternalServerException extends InternalServerErrorException {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -7600028435121268528L;
|
||||
|
||||
/**
|
||||
* Instantiates a new bad parameter exception.
|
||||
*
|
||||
* @param request the request
|
||||
* @param httpReturnStatus the http return status
|
||||
* @param message the message
|
||||
* @param reportedBySource the reported by source
|
||||
*/
|
||||
public InternalServerException(HttpServletRequest request, Status httpReturnStatus, String message, Class reportedBySource) {
|
||||
super(Response.status(httpReturnStatus).entity(new ExceptionReport(Util.getFullURL(request), request.getMethod(), false, new ErrorReport(Status.INTERNAL_SERVER_ERROR.getStatusCode(), Status.INTERNAL_SERVER_ERROR.name(), message, reportedBySource.getName()))).type(MediaType.APPLICATION_XML).build());
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.datatransfer.resolver.services.exceptions;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
||||
import org.gcube.datatransfer.resolver.services.Util;
|
||||
;
|
||||
|
||||
|
||||
/**
|
||||
* The Class WrongParameterException.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
* Oct 22, 2018
|
||||
*/
|
||||
public class WrongParameterException extends WebApplicationException {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -7600028435121268528L;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new wrong parameter exception.
|
||||
*
|
||||
* @param request the request
|
||||
* @param httpReturnStatus the http return status
|
||||
* @param message the message
|
||||
* @param reportedBySource the reported by source
|
||||
*/
|
||||
public WrongParameterException(HttpServletRequest request, Status httpReturnStatus, String message, Class reportedBySource) {
|
||||
super(Response.status(httpReturnStatus).entity(new ExceptionReport(Util.getFullURL(request), request.getMethod(), false, new ErrorReport(Status.BAD_REQUEST.getStatusCode(), Status.BAD_REQUEST.name(), message, reportedBySource.getName()))).type(MediaType.APPLICATION_XML).build());
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue