2018-10-22 12:56:04 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
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;
|
|
|
|
|
2018-10-22 14:29:57 +02:00
|
|
|
import org.gcube.datatransfer.resolver.Util;
|
2018-10-22 14:17:16 +02:00
|
|
|
import org.gcube.datatransfer.resolver.services.error.ErrorReport;
|
|
|
|
import org.gcube.datatransfer.resolver.services.error.ExceptionReport;
|
2018-10-22 12:56:04 +02:00
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|