changing exception manager
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-transfer/uri-resolver@174889 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
00589289fb
commit
3cc7ad3212
|
@ -15,6 +15,7 @@ import javax.ws.rs.Consumes;
|
||||||
import javax.ws.rs.POST;
|
import javax.ws.rs.POST;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.Produces;
|
import javax.ws.rs.Produces;
|
||||||
|
import javax.ws.rs.WebApplicationException;
|
||||||
import javax.ws.rs.core.Context;
|
import javax.ws.rs.core.Context;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
@ -62,101 +63,113 @@ public class AnalyticsCreateResolver {
|
||||||
@Path("/create")
|
@Path("/create")
|
||||||
@Consumes(MediaType.TEXT_PLAIN)
|
@Consumes(MediaType.TEXT_PLAIN)
|
||||||
@Produces(MediaType.TEXT_PLAIN)
|
@Produces(MediaType.TEXT_PLAIN)
|
||||||
public Response createAnalyticsURL(@Context HttpServletRequest req, String body) {
|
public Response createAnalyticsURL(@Context HttpServletRequest req, String body) throws WebApplicationException{
|
||||||
logger.info(this.getClass().getSimpleName()+" POST starts...");
|
logger.info(this.getClass().getSimpleName()+" POST starts...");
|
||||||
logger.info("body is: "+body);
|
|
||||||
|
|
||||||
DataMinerInvocation jsonRequest = null;
|
try{
|
||||||
try {
|
logger.info("body is: "+body);
|
||||||
|
|
||||||
jsonRequest = DataMinerInvocationManager.getInstance().unmarshaling(IOUtils.toInputStream(body), org.gcube.data.analysis.dminvocation.MediaType.ApplicationJSON, true);
|
DataMinerInvocation jsonRequest = null;
|
||||||
}
|
|
||||||
catch (IOException | JAXBException | SAXException e1) {
|
|
||||||
logger.error("The body is not a valid DataMinerInvocation JSON request",e1);
|
|
||||||
ExceptionManager.throwBadRequestException(req, "Bad 'dataminer-invocation' JSON request: \n"+e1.getCause().getMessage(), this.getClass(), helpURI);
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.debug("The body contains the request: "+jsonRequest.toString());
|
|
||||||
|
|
||||||
String contextToken = SecurityTokenProvider.instance.get();
|
|
||||||
String scope = ScopeProvider.instance.get();
|
|
||||||
// logger.info("SecurityTokenProvider contextToken: "+contextToken);
|
|
||||||
logger.info("ScopeProvider has scope: "+scope);
|
|
||||||
|
|
||||||
String appToken = req.getServletContext().getInitParameter(TokenSetter.ROOT_APP_TOKEN);
|
|
||||||
|
|
||||||
if(contextToken.compareTo(appToken)==0){
|
|
||||||
logger.error("Token not passed, SecurityTokenProvider contains the root app token: "+appToken.substring(0,10)+"...");
|
|
||||||
ExceptionManager.throwUnauthorizedException(req, "You are not authorized. You must pass a token of VRE", this.getClass(), helpURI);
|
|
||||||
}
|
|
||||||
|
|
||||||
String operatorID = jsonRequest.getOperatorId();
|
|
||||||
|
|
||||||
if(scope==null || scope.isEmpty()){
|
|
||||||
logger.error("The parameter 'scope' not found or empty in the JSON object");
|
|
||||||
ExceptionManager.throwBadRequestException(req, "Mandatory body parameter 'scope' not found or empty in the JSON object", this.getClass(), helpURI);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if(operatorID==null || operatorID.isEmpty()){
|
|
||||||
logger.error("The parameter 'operatorId' not found or empty in the JSON object");
|
|
||||||
ExceptionManager.throwBadRequestException(req, "Mandatory body parameter 'operatorId' not found or empty in the JSON object", this.getClass(), helpURI);
|
|
||||||
}
|
|
||||||
|
|
||||||
ScopeBean scopeBean = new ScopeBean(scope);
|
|
||||||
String publicLinkToDMInvFile = "";
|
|
||||||
|
|
||||||
if(scopeBean.is(Type.VRE)){
|
|
||||||
String vreName = scopeBean.name();
|
|
||||||
|
|
||||||
String analyticsGetResolverURL = String.format("%s/%s", Util.getServerURL(req), "analytics/get");
|
|
||||||
//Creating DM invocation file
|
|
||||||
if(jsonRequest.getActionType()==null)
|
|
||||||
jsonRequest.setActionType(ActionType.RUN);
|
|
||||||
|
|
||||||
File tempInvocationFile = null;
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
ByteArrayOutputStream xmlByteArray = DataMinerInvocationManager.getInstance().marshaling(jsonRequest, org.gcube.data.analysis.dminvocation.MediaType.ApplicationXML, true);
|
jsonRequest = DataMinerInvocationManager.getInstance().unmarshaling(IOUtils.toInputStream(body), org.gcube.data.analysis.dminvocation.MediaType.ApplicationJSON, true);
|
||||||
String uniqueName = createDMInvocationFileName(jsonRequest.getOperatorId());
|
|
||||||
tempInvocationFile = createTempFile(uniqueName, ".xml", xmlByteArray.toByteArray());
|
|
||||||
|
|
||||||
//CREATE THE FILE ON STORAGE HUB
|
|
||||||
StorageHubClient shc = new StorageHubClient();
|
|
||||||
logger.info("Created StorageHubClient Instance, uploading file: "+tempInvocationFile.getName());
|
|
||||||
FileContainer fileContainer = shc.getWSRoot().uploadFile(new FileInputStream(tempInvocationFile), tempInvocationFile.getName(), "DataMinerInvocation Request created by "+this.getClass().getSimpleName());
|
|
||||||
logger.info("UPLOADED FILE at: "+fileContainer.getPublicLink());
|
|
||||||
URL thePublicLink = fileContainer.getPublicLink();
|
|
||||||
publicLinkToDMInvFile = thePublicLink!=null?thePublicLink.toString():null;
|
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (IOException | JAXBException | SAXException e1) {
|
||||||
logger.error("Error on creating 'dataminer-invocation:", e);
|
logger.error("The body is not a valid DataMinerInvocation JSON request",e1);
|
||||||
ExceptionManager.throwBadRequestException(req, "Error on creating your 'dataminer-invocation' request with "+jsonRequest+". \nPlease contact the support", this.getClass(), helpURI);
|
throw ExceptionManager.badRequestException(req, "Bad 'dataminer-invocation' JSON request: \n"+e1.getCause().getMessage(), this.getClass(), helpURI);
|
||||||
}finally{
|
}
|
||||||
try{
|
|
||||||
//DELETING THE TEMP FILE
|
logger.debug("The body contains the request: "+jsonRequest.toString());
|
||||||
if(tempInvocationFile!=null && tempInvocationFile.exists())
|
|
||||||
tempInvocationFile.delete();
|
String contextToken = SecurityTokenProvider.instance.get();
|
||||||
}catch(Exception e){
|
String scope = ScopeProvider.instance.get();
|
||||||
//silent
|
// logger.info("SecurityTokenProvider contextToken: "+contextToken);
|
||||||
|
logger.info("ScopeProvider has scope: "+scope);
|
||||||
|
|
||||||
|
String appToken = req.getServletContext().getInitParameter(TokenSetter.ROOT_APP_TOKEN);
|
||||||
|
|
||||||
|
if(contextToken.compareTo(appToken)==0){
|
||||||
|
logger.error("Token not passed, SecurityTokenProvider contains the root app token: "+appToken.substring(0,10)+"...");
|
||||||
|
throw ExceptionManager.unauthorizedException(req, "You are not authorized. You must pass a token of VRE", this.getClass(), helpURI);
|
||||||
|
}
|
||||||
|
|
||||||
|
String operatorID = jsonRequest.getOperatorId();
|
||||||
|
|
||||||
|
if(scope==null || scope.isEmpty()){
|
||||||
|
logger.error("The parameter 'scope' not found or empty in the JSON object");
|
||||||
|
throw ExceptionManager.badRequestException(req, "Mandatory body parameter 'scope' not found or empty in the JSON object", this.getClass(), helpURI);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(operatorID==null || operatorID.isEmpty()){
|
||||||
|
logger.error("The parameter 'operatorId' not found or empty in the JSON object");
|
||||||
|
throw ExceptionManager.badRequestException(req, "Mandatory body parameter 'operatorId' not found or empty in the JSON object", this.getClass(), helpURI);
|
||||||
|
}
|
||||||
|
|
||||||
|
ScopeBean scopeBean = new ScopeBean(scope);
|
||||||
|
String publicLinkToDMInvFile = "";
|
||||||
|
|
||||||
|
if(scopeBean.is(Type.VRE)){
|
||||||
|
String vreName = scopeBean.name();
|
||||||
|
|
||||||
|
String analyticsGetResolverURL = String.format("%s/%s", Util.getServerURL(req), "analytics/get");
|
||||||
|
//Creating DM invocation file
|
||||||
|
if(jsonRequest.getActionType()==null)
|
||||||
|
jsonRequest.setActionType(ActionType.RUN);
|
||||||
|
|
||||||
|
File tempInvocationFile = null;
|
||||||
|
try {
|
||||||
|
|
||||||
|
ByteArrayOutputStream xmlByteArray = DataMinerInvocationManager.getInstance().marshaling(jsonRequest, org.gcube.data.analysis.dminvocation.MediaType.ApplicationXML, true);
|
||||||
|
String uniqueName = createDMInvocationFileName(jsonRequest.getOperatorId());
|
||||||
|
tempInvocationFile = createTempFile(uniqueName, ".xml", xmlByteArray.toByteArray());
|
||||||
|
|
||||||
|
//CREATE THE FILE ON STORAGE HUB
|
||||||
|
StorageHubClient shc = new StorageHubClient();
|
||||||
|
logger.info("Created StorageHubClient Instance, uploading file: "+tempInvocationFile.getName());
|
||||||
|
FileContainer fileContainer = shc.getWSRoot().uploadFile(new FileInputStream(tempInvocationFile), tempInvocationFile.getName(), "DataMinerInvocation Request created by "+this.getClass().getSimpleName());
|
||||||
|
logger.info("UPLOADED FILE at: "+fileContainer.getPublicLink());
|
||||||
|
URL thePublicLink = fileContainer.getPublicLink();
|
||||||
|
publicLinkToDMInvFile = thePublicLink!=null?thePublicLink.toString():null;
|
||||||
}
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
logger.error("Error on creating 'dataminer-invocation:", e);
|
||||||
|
throw ExceptionManager.badRequestException(req, "Error on creating your 'dataminer-invocation' request with "+jsonRequest+". \nPlease contact the support", this.getClass(), helpURI);
|
||||||
|
}finally{
|
||||||
|
try{
|
||||||
|
//DELETING THE TEMP FILE
|
||||||
|
if(tempInvocationFile!=null && tempInvocationFile.exists())
|
||||||
|
tempInvocationFile.delete();
|
||||||
|
}catch(Exception e){
|
||||||
|
//silent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(publicLinkToDMInvFile==null){
|
||||||
|
logger.error("Error on creating the public link to file");
|
||||||
|
throw ExceptionManager.badRequestException(req, "Error on getting link to your 'dataminer-invocation' request. Plese contact the support "+jsonRequest, this.getClass(), helpURI);
|
||||||
|
}
|
||||||
|
|
||||||
|
String dataMinerURL = String.format("%s/%s?%s=%s", analyticsGetResolverURL, vreName, DATAMINER_INVOCATION_MODEL, publicLinkToDMInvFile);
|
||||||
|
logger.info("Returning Analytics URL: "+dataMinerURL);
|
||||||
|
return Response.ok(dataMinerURL).header("Location", dataMinerURL).build();
|
||||||
|
|
||||||
|
}else{
|
||||||
|
logger.error("The input scope "+scope+" is not a VRE");
|
||||||
|
throw ExceptionManager.badRequestException(req, "Working in the "+scope+" scope that is not a VRE. Use a token of VRE", this.getClass(), helpURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(publicLinkToDMInvFile==null){
|
}catch (Exception e) {
|
||||||
logger.error("Error on creating the public link to file");
|
|
||||||
ExceptionManager.throwBadRequestException(req, "Error on getting link to your 'dataminer-invocation' request. Plese contact the support "+jsonRequest, this.getClass(), helpURI);
|
if(!(e instanceof WebApplicationException)){
|
||||||
|
//UNEXPECTED EXCEPTION managing it as WebApplicationException
|
||||||
|
String error = "Error occurred on creating the Analytics for the request "+body+". Please, contact the support!";
|
||||||
|
throw ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI);
|
||||||
}
|
}
|
||||||
|
//ALREADY MANAGED AS WebApplicationException
|
||||||
String dataMinerURL = String.format("%s/%s?%s=%s", analyticsGetResolverURL, vreName, DATAMINER_INVOCATION_MODEL, publicLinkToDMInvFile);
|
logger.error("Exception:", e);
|
||||||
logger.info("Returning Analytics URL: "+dataMinerURL);
|
throw (WebApplicationException) e;
|
||||||
return Response.ok(dataMinerURL).header("Location", dataMinerURL).build();
|
|
||||||
|
|
||||||
}else{
|
|
||||||
logger.error("The input scope "+scope+" is not a VRE");
|
|
||||||
ExceptionManager.throwBadRequestException(req, "Working in the "+scope+" scope that is not a VRE. Use a token of VRE", this.getClass(), helpURI);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.PathParam;
|
import javax.ws.rs.PathParam;
|
||||||
|
import javax.ws.rs.WebApplicationException;
|
||||||
import javax.ws.rs.core.Context;
|
import javax.ws.rs.core.Context;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
@ -50,13 +51,13 @@ public class AnalyticsGetResolver {
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Path("/get/{vreName}")
|
@Path("/get/{vreName}")
|
||||||
public Response resolveAnalyticsURL(@Context HttpServletRequest req, @PathParam("vreName") String vreName) {
|
public Response resolveAnalyticsURL(@Context HttpServletRequest req, @PathParam("vreName") String vreName) throws WebApplicationException{
|
||||||
logger.info(this.getClass().getSimpleName()+" GET starts...");
|
logger.info(this.getClass().getSimpleName()+" GET starts...");
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if(vreName==null || vreName.isEmpty()){
|
if(vreName==null || vreName.isEmpty()){
|
||||||
logger.error("The path parameter 'vreName' not found or empty in the path");
|
logger.error("The path parameter 'vreName' not found or empty in the path");
|
||||||
ExceptionManager.throwBadRequestException(req, "Mandatory path parameter 'vreName' not found or empty", this.getClass(), helpURI);
|
throw ExceptionManager.badRequestException(req, "Mandatory path parameter 'vreName' not found or empty", this.getClass(), helpURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
|
@ -66,7 +67,7 @@ public class AnalyticsGetResolver {
|
||||||
reader = new ApplicationProfileReader(fullScope, APPLICATION_PROFILE, ORG_GCUBE_PORTLETS_USER_DATAMINERMANAGER_SERVER_DATA_MINER_MANAGER_SERVICE_IMPL, false);
|
reader = new ApplicationProfileReader(fullScope, APPLICATION_PROFILE, ORG_GCUBE_PORTLETS_USER_DATAMINERMANAGER_SERVER_DATA_MINER_MANAGER_SERVICE_IMPL, false);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
logger.error("Error on reading the "+APPLICATION_PROFILE+" with APPID: "+ORG_GCUBE_PORTLETS_USER_DATAMINERMANAGER_SERVER_DATA_MINER_MANAGER_SERVICE_IMPL, e);
|
logger.error("Error on reading the "+APPLICATION_PROFILE+" with APPID: "+ORG_GCUBE_PORTLETS_USER_DATAMINERMANAGER_SERVER_DATA_MINER_MANAGER_SERVICE_IMPL, e);
|
||||||
ExceptionManager.throwInternalErrorException(req, "Error on reading the Application Profile for the "+ANALYTICS_EXECUTOR_PORTLET_NAME+". Please contact the support", this.getClass(), helpURI);
|
throw ExceptionManager.internalErrorException(req, "Error on reading the Application Profile for the "+ANALYTICS_EXECUTOR_PORTLET_NAME+". Please contact the support", this.getClass(), helpURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
//READ THE DATAMINER URL PORTLET FROM APPLICATION PROFRILE IN THE SCOPE fullScope
|
//READ THE DATAMINER URL PORTLET FROM APPLICATION PROFRILE IN THE SCOPE fullScope
|
||||||
|
@ -79,14 +80,20 @@ public class AnalyticsGetResolver {
|
||||||
|
|
||||||
}catch (ExecutionException e) {
|
}catch (ExecutionException e) {
|
||||||
logger.error("The input VRE Name "+vreName+" not found", e);
|
logger.error("The input VRE Name "+vreName+" not found", e);
|
||||||
ExceptionManager.throwBadRequestException(req, "The input 'VRE Name' "+"+vreName+"+ "not found on Informatiion System. Is it a valid VRE?", this.getClass(), helpURI);
|
throw ExceptionManager.badRequestException(req, "The input 'VRE Name' "+"+vreName+"+ "not found on Informatiion System. Is it a valid VRE?", this.getClass(), helpURI);
|
||||||
|
//throw new BadRequestException(req, Status.BAD_REQUEST, "", this.getClass(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
logger.error("Error on resolving Anaylitics URL",e);
|
|
||||||
ExceptionManager.throwInternalErrorException(req, "Error occurred when resolving Anaylitics URL", this.getClass(), helpURI);
|
if(!(e instanceof WebApplicationException)){
|
||||||
return null;
|
//UNEXPECTED EXCEPTION managing it as WebApplicationException
|
||||||
|
String error = "Error occurred on resolving the Analytics URL. Please, contact the support!";
|
||||||
|
throw ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI);
|
||||||
|
}
|
||||||
|
//ALREADY MANAGED AS WebApplicationException
|
||||||
|
logger.error("Exception:", e);
|
||||||
|
throw (WebApplicationException) e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class CatalogueResolver {
|
||||||
return Response.seeOther(new URL(itemCatalogueURL).toURI()).build();
|
return Response.seeOther(new URL(itemCatalogueURL).toURI()).build();
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
logger.error("error resolving catalogue link",e);
|
logger.error("error resolving catalogue link",e);
|
||||||
ExceptionManager.throwInternalErrorException(req, "Error occurred resolving catalogue link", this.getClass(), helpURI);
|
ExceptionManager.internalErrorException(req, "Error occurred resolving catalogue link", this.getClass(), helpURI);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,12 +114,12 @@ public class CatalogueResolver {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fullScope==null)
|
if(fullScope==null)
|
||||||
ExceptionManager.throwNotFoundException(req, "The scope '"+scope+"' does not matching any scope in the infrastructure. Is it valid?", this.getClass(), helpURI);
|
ExceptionManager.notFoundException(req, "The scope '"+scope+"' does not matching any scope in the infrastructure. Is it valid?", this.getClass(), helpURI);
|
||||||
|
|
||||||
ResourceCatalogueCodes rc = ResourceCatalogueCodes.valueOfCodeValue(jsonRequest.getEntity_context());
|
ResourceCatalogueCodes rc = ResourceCatalogueCodes.valueOfCodeValue(jsonRequest.getEntity_context());
|
||||||
if(rc==null){
|
if(rc==null){
|
||||||
logger.error("Entity context is null/malformed");
|
logger.error("Entity context is null/malformed");
|
||||||
ExceptionManager.throwBadRequestException(req, "Entity context is null/malformed", this.getClass(), helpURI);
|
ExceptionManager.badRequestException(req, "Entity context is null/malformed", this.getClass(), helpURI);
|
||||||
//throw new WebApplicationException("Entity context is null/malformed", Status.BAD_REQUEST);
|
//throw new WebApplicationException("Entity context is null/malformed", Status.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,12 +129,12 @@ public class GeonetworkResolver {
|
||||||
|
|
||||||
if(scope==null || scope.isEmpty()){
|
if(scope==null || scope.isEmpty()){
|
||||||
logger.error("Path Parameter 'scope' not found");
|
logger.error("Path Parameter 'scope' not found");
|
||||||
ExceptionManager.throwBadRequestException(req, "Missing mandatory path parameter 'scope'", this.getClass(), help);
|
ExceptionManager.badRequestException(req, "Missing mandatory path parameter 'scope'", this.getClass(), help);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mode==null || mode.isEmpty()){
|
if(mode==null || mode.isEmpty()){
|
||||||
logger.error("Path Parameter 'scope' not found");
|
logger.error("Path Parameter 'scope' not found");
|
||||||
ExceptionManager.throwBadRequestException(req, "Missing mandatory path parameter 'mode'", this.getClass(), help);
|
ExceptionManager.badRequestException(req, "Missing mandatory path parameter 'mode'", this.getClass(), help);
|
||||||
}
|
}
|
||||||
|
|
||||||
scope = ScopeUtil.normalizeScope(scope, "|");
|
scope = ScopeUtil.normalizeScope(scope, "|");
|
||||||
|
@ -144,12 +144,12 @@ public class GeonetworkResolver {
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
List<MODE> toPrint = Arrays.asList(MODE.values());
|
List<MODE> toPrint = Arrays.asList(MODE.values());
|
||||||
logger.error("The 'mode' parameter is wrong, Have you pass a valid parameter MODE like "+toPrint+"?");
|
logger.error("The 'mode' parameter is wrong, Have you pass a valid parameter MODE like "+toPrint+"?");
|
||||||
ExceptionManager.throwWrongParameterException(req, "The 'mode' parameter must be value of "+toPrint, this.getClass(), help);
|
ExceptionManager.wrongParameterException(req, "The 'mode' parameter must be value of "+toPrint, this.getClass(), help);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(visibility==null){
|
if(visibility==null){
|
||||||
logger.error("Path Parameter 'visibility' not found");
|
logger.error("Path Parameter 'visibility' not found");
|
||||||
ExceptionManager.throwBadRequestException(req, "Missing mandatory path parameter 'visibility'", this.getClass(), help);
|
ExceptionManager.badRequestException(req, "Missing mandatory path parameter 'visibility'", this.getClass(), help);
|
||||||
}
|
}
|
||||||
|
|
||||||
visibility = visibility.toUpperCase();
|
visibility = visibility.toUpperCase();
|
||||||
|
@ -158,7 +158,7 @@ public class GeonetworkResolver {
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
List<VISIBILITY> toPrint = Arrays.asList(VISIBILITY.values());
|
List<VISIBILITY> toPrint = Arrays.asList(VISIBILITY.values());
|
||||||
logger.error("The 'visibility' parameter is wrong, Have you pass a valid parameter VISIBILITY like "+toPrint+"?");
|
logger.error("The 'visibility' parameter is wrong, Have you pass a valid parameter VISIBILITY like "+toPrint+"?");
|
||||||
ExceptionManager.throwWrongParameterException(req, "The 'visibility' parameter must be value of "+toPrint, this.getClass(), help);
|
ExceptionManager.wrongParameterException(req, "The 'visibility' parameter must be value of "+toPrint, this.getClass(), help);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(resetCache!=null && Boolean.parseBoolean(resetCache)){
|
if(resetCache!=null && Boolean.parseBoolean(resetCache)){
|
||||||
|
@ -202,17 +202,17 @@ public class GeonetworkResolver {
|
||||||
return responseBuilder.build();
|
return responseBuilder.build();
|
||||||
|
|
||||||
case HttpServletResponse.SC_FORBIDDEN:
|
case HttpServletResponse.SC_FORBIDDEN:
|
||||||
ExceptionManager.throwForbiddenException(req, "You are not authorized to perform the request "+gnGetlURL, this.getClass(), help);
|
ExceptionManager.forbiddenException(req, "You are not authorized to perform the request "+gnGetlURL, this.getClass(), help);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ExceptionManager.throwInternalErrorException(req, "Sorry, an error occurred performing the geonetwork request "+gnGetlURL+" with scope "+scope, this.getClass(), help);
|
ExceptionManager.internalErrorException(req, "Sorry, an error occurred performing the geonetwork request "+gnGetlURL+" with scope "+scope, this.getClass(), help);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Exception:", e);
|
logger.error("Exception:", e);
|
||||||
String error = "Sorry, an error occurred on resolving geonetwork request with scope "+scope+". Please, contact support!";
|
String error = "Sorry, an error occurred on resolving geonetwork request with scope "+scope+". Please, contact support!";
|
||||||
ExceptionManager.throwInternalErrorException(req, error, this.getClass(), help);
|
ExceptionManager.internalErrorException(req, error, this.getClass(), help);
|
||||||
}
|
}
|
||||||
|
|
||||||
//An error occurred
|
//An error occurred
|
||||||
|
@ -244,12 +244,12 @@ public class GeonetworkResolver {
|
||||||
|
|
||||||
if(scope==null || scope.isEmpty()){
|
if(scope==null || scope.isEmpty()){
|
||||||
logger.error("Path Parameter 'scope' not found");
|
logger.error("Path Parameter 'scope' not found");
|
||||||
ExceptionManager.throwBadRequestException(req, "Missing mandatory path parameter 'scope'", this.getClass(), help);
|
ExceptionManager.badRequestException(req, "Missing mandatory path parameter 'scope'", this.getClass(), help);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mode==null || mode.isEmpty()){
|
if(mode==null || mode.isEmpty()){
|
||||||
logger.error("Path Parameter 'scope' not found");
|
logger.error("Path Parameter 'scope' not found");
|
||||||
ExceptionManager.throwBadRequestException(req, "Missing mandatory path parameter 'mode'", this.getClass(), help);
|
ExceptionManager.badRequestException(req, "Missing mandatory path parameter 'mode'", this.getClass(), help);
|
||||||
}
|
}
|
||||||
|
|
||||||
scope = ScopeUtil.normalizeScope(scope, "|");
|
scope = ScopeUtil.normalizeScope(scope, "|");
|
||||||
|
@ -259,12 +259,12 @@ public class GeonetworkResolver {
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
List<MODE> toPrint = Arrays.asList(MODE.values());
|
List<MODE> toPrint = Arrays.asList(MODE.values());
|
||||||
logger.error("The 'mode' parameter is wrong, Have you pass a valid parameter MODE like "+toPrint+"?");
|
logger.error("The 'mode' parameter is wrong, Have you pass a valid parameter MODE like "+toPrint+"?");
|
||||||
ExceptionManager.throwWrongParameterException(req, "The 'mode' parameter must be value of "+toPrint, this.getClass(), help);
|
ExceptionManager.wrongParameterException(req, "The 'mode' parameter must be value of "+toPrint, this.getClass(), help);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(visibility==null){
|
if(visibility==null){
|
||||||
logger.error("Path Parameter 'visibility' not found");
|
logger.error("Path Parameter 'visibility' not found");
|
||||||
ExceptionManager.throwBadRequestException(req, "Missing mandatory path parameter 'visibility'", this.getClass(), help);
|
ExceptionManager.badRequestException(req, "Missing mandatory path parameter 'visibility'", this.getClass(), help);
|
||||||
}
|
}
|
||||||
|
|
||||||
visibility = visibility.toUpperCase();
|
visibility = visibility.toUpperCase();
|
||||||
|
@ -273,7 +273,7 @@ public class GeonetworkResolver {
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
List<VISIBILITY> toPrint = Arrays.asList(VISIBILITY.values());
|
List<VISIBILITY> toPrint = Arrays.asList(VISIBILITY.values());
|
||||||
logger.error("The 'visibility' parameter is wrong, Have you pass a valid parameter VISIBILITY like "+toPrint+"?");
|
logger.error("The 'visibility' parameter is wrong, Have you pass a valid parameter VISIBILITY like "+toPrint+"?");
|
||||||
ExceptionManager.throwWrongParameterException(req, "The 'visibility' parameter must be value of "+toPrint, this.getClass(), help);
|
ExceptionManager.wrongParameterException(req, "The 'visibility' parameter must be value of "+toPrint, this.getClass(), help);
|
||||||
}
|
}
|
||||||
|
|
||||||
//HOW TO PASS ANY FILTER?
|
//HOW TO PASS ANY FILTER?
|
||||||
|
@ -378,7 +378,7 @@ public class GeonetworkResolver {
|
||||||
|
|
||||||
if(in==null){
|
if(in==null){
|
||||||
logger.warn("Input stream returned is null, sending "+HttpServletResponse.SC_NOT_FOUND);
|
logger.warn("Input stream returned is null, sending "+HttpServletResponse.SC_NOT_FOUND);
|
||||||
ExceptionManager.throwNotFoundException(req, "Input stream is null to the request "+gnCSWlURL+ " with body: "+byteArray.toString(), this.getClass(), help);
|
ExceptionManager.notFoundException(req, "Input stream is null to the request "+gnCSWlURL+ " with body: "+byteArray.toString(), this.getClass(), help);
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
|
@ -441,19 +441,19 @@ public class GeonetworkResolver {
|
||||||
|
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
logger.error("Error on copy the response to send to client: ", e);
|
logger.error("Error on copy the response to send to client: ", e);
|
||||||
ExceptionManager.throwInternalErrorException(req, "Error on copy the response!", this.getClass(), help);
|
ExceptionManager.internalErrorException(req, "Error on copy the response!", this.getClass(), help);
|
||||||
}finally{
|
}finally{
|
||||||
IOUtils.closeQuietly(in);
|
IOUtils.closeQuietly(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (IllegalArgumentException e){
|
} catch (IllegalArgumentException e){
|
||||||
logger.error("IllegalArgumentException:", e);
|
logger.error("IllegalArgumentException:", e);
|
||||||
ExceptionManager.throwBadRequestException(req, "Illegal argument to carry out the request!", this.getClass(), help);
|
ExceptionManager.badRequestException(req, "Illegal argument to carry out the request!", this.getClass(), help);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Exception:", e);
|
logger.error("Exception:", e);
|
||||||
String error = "Sorry, an error occurred on resolving geonetwork request with scope "+scope+". Please, contact support!";
|
String error = "Sorry, an error occurred on resolving geonetwork request with scope "+scope+". Please, contact support!";
|
||||||
ExceptionManager.throwInternalErrorException(req, error, this.getClass(), help);
|
ExceptionManager.internalErrorException(req, error, this.getClass(), help);
|
||||||
}
|
}
|
||||||
|
|
||||||
//An error occurred
|
//An error occurred
|
||||||
|
|
|
@ -69,12 +69,12 @@ public class GisResolver {
|
||||||
|
|
||||||
if(scope==null || scope.isEmpty()){
|
if(scope==null || scope.isEmpty()){
|
||||||
logger.error("Query Parameter 'scope' not found");
|
logger.error("Query Parameter 'scope' not found");
|
||||||
ExceptionManager.throwBadRequestException(req, "Missing mandatory query parameter 'scope'", this.getClass(), help);
|
ExceptionManager.badRequestException(req, "Missing mandatory query parameter 'scope'", this.getClass(), help);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(gisUUID==null || gisUUID.isEmpty()){
|
if(gisUUID==null || gisUUID.isEmpty()){
|
||||||
logger.error("Path Parameter 'gis-UUID' not found");
|
logger.error("Path Parameter 'gis-UUID' not found");
|
||||||
ExceptionManager.throwBadRequestException(req, "Missing mandatory query parameter 'gis-UUID'", this.getClass(), help);
|
ExceptionManager.badRequestException(req, "Missing mandatory query parameter 'gis-UUID'", this.getClass(), help);
|
||||||
}else
|
}else
|
||||||
isGisLink = true;
|
isGisLink = true;
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ public class GisResolver {
|
||||||
if(!isGisLink && !isGeoExplorerLink){
|
if(!isGisLink && !isGeoExplorerLink){
|
||||||
String err = GIS_UUID+" or "+GEO_EXPLORER_LAYER_UUID+" not found or empty in the query string";
|
String err = GIS_UUID+" or "+GEO_EXPLORER_LAYER_UUID+" not found or empty in the query string";
|
||||||
logger.error(err);
|
logger.error(err);
|
||||||
ExceptionManager.throwBadRequestException(req, err, this.getClass(), help);
|
ExceptionManager.badRequestException(req, err, this.getClass(), help);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -115,7 +115,7 @@ public class GisResolver {
|
||||||
String gisViewerPortletUrl = LoadingGisViewerApplicationURLCache.getCache().get(scope);
|
String gisViewerPortletUrl = LoadingGisViewerApplicationURLCache.getCache().get(scope);
|
||||||
//CHECKING IF THE GisViewer Portlet URL is valid
|
//CHECKING IF THE GisViewer Portlet URL is valid
|
||||||
if(gisViewerPortletUrl==null || gisViewerPortletUrl.isEmpty())
|
if(gisViewerPortletUrl==null || gisViewerPortletUrl.isEmpty())
|
||||||
ExceptionManager.throwNotFoundException(req, "GisViewer Portlet URL not found in the scope: "+scope +". Please contact the support", this.getClass(), help);
|
ExceptionManager.notFoundException(req, "GisViewer Portlet URL not found in the scope: "+scope +". Please contact the support", this.getClass(), help);
|
||||||
|
|
||||||
logger.info("Gis Viewer Application url is: " + gisViewerPortletUrl);
|
logger.info("Gis Viewer Application url is: " + gisViewerPortletUrl);
|
||||||
gisViewerPortletUrl+="?rid="+new Random().nextLong()
|
gisViewerPortletUrl+="?rid="+new Random().nextLong()
|
||||||
|
@ -140,7 +140,7 @@ public class GisResolver {
|
||||||
String geoExplorerPortletUrl = LoadingGeoExplorerApplicationURLCache.getCache().get(scope);
|
String geoExplorerPortletUrl = LoadingGeoExplorerApplicationURLCache.getCache().get(scope);
|
||||||
//CHECKING IF THE GeoExplorer Portlet URL is valid
|
//CHECKING IF THE GeoExplorer Portlet URL is valid
|
||||||
if(geoExplorerPortletUrl==null || geoExplorerPortletUrl.isEmpty())
|
if(geoExplorerPortletUrl==null || geoExplorerPortletUrl.isEmpty())
|
||||||
ExceptionManager.throwNotFoundException(req, "GeoExplorer Portlet URL not found in the scope: "+scope +". Please contact the support", this.getClass(), help);
|
ExceptionManager.notFoundException(req, "GeoExplorer Portlet URL not found in the scope: "+scope +". Please contact the support", this.getClass(), help);
|
||||||
|
|
||||||
logger.info("GeoExplorer Application url is: " + geoExplorerPortletUrl);
|
logger.info("GeoExplorer Application url is: " + geoExplorerPortletUrl);
|
||||||
geoExplorerPortletUrl+="?rid="+new Random().nextLong()
|
geoExplorerPortletUrl+="?rid="+new Random().nextLong()
|
||||||
|
@ -153,13 +153,13 @@ public class GisResolver {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ExceptionManager.throwBadRequestException(req, GIS_UUID+" or "+GEO_EXPLORER_LAYER_UUID+" not found or empty in the query string", this.getClass(), help);
|
ExceptionManager.badRequestException(req, GIS_UUID+" or "+GEO_EXPLORER_LAYER_UUID+" not found or empty in the query string", this.getClass(), help);
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Exception:", e);
|
logger.error("Exception:", e);
|
||||||
String error = "Sorry, an error occurred on resolving request with UUID "+gisUUID+" and scope "+scope+". Please, contact support!";
|
String error = "Sorry, an error occurred on resolving request with UUID "+gisUUID+" and scope "+scope+". Please, contact support!";
|
||||||
ExceptionManager.throwInternalErrorException(req, error, this.getClass(), help);
|
ExceptionManager.internalErrorException(req, error, this.getClass(), help);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class KnimeCreateResolver {
|
||||||
|
|
||||||
if(contextToken.compareTo(appToken)==0){
|
if(contextToken.compareTo(appToken)==0){
|
||||||
logger.error("Token not passed, SecurityTokenProvider contains the root app token: "+appToken.substring(0,10)+"...");
|
logger.error("Token not passed, SecurityTokenProvider contains the root app token: "+appToken.substring(0,10)+"...");
|
||||||
ExceptionManager.throwUnauthorizedException(req, "You are not authorized. You must pass a token of VRE", this.getClass(), helpURI);
|
ExceptionManager.unauthorizedException(req, "You are not authorized. You must pass a token of VRE", this.getClass(), helpURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScopeBean scopeBean = new ScopeBean(scope);
|
ScopeBean scopeBean = new ScopeBean(scope);
|
||||||
|
@ -78,7 +78,7 @@ public class KnimeCreateResolver {
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
logger.error("The input scope "+scope+" is not a VRE");
|
logger.error("The input scope "+scope+" is not a VRE");
|
||||||
ExceptionManager.throwBadRequestException(req, "Working in the "+scope+" scope that is not a VRE. Use a token of VRE", this.getClass(), helpURI);
|
ExceptionManager.badRequestException(req, "Working in the "+scope+" scope that is not a VRE. Use a token of VRE", this.getClass(), helpURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class KnimeGetResolver {
|
||||||
try {
|
try {
|
||||||
if(vreName==null || vreName.isEmpty()){
|
if(vreName==null || vreName.isEmpty()){
|
||||||
logger.error("The path parameter 'vreName' not found or empty in the path");
|
logger.error("The path parameter 'vreName' not found or empty in the path");
|
||||||
ExceptionManager.throwBadRequestException(req, "Mandatory path parameter 'vreName' not found or empty", this.getClass(), helpURI);
|
ExceptionManager.badRequestException(req, "Mandatory path parameter 'vreName' not found or empty", this.getClass(), helpURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
|
@ -65,7 +65,7 @@ public class KnimeGetResolver {
|
||||||
reader = new ApplicationProfileReader(fullScope, APPLICATION_PROFILE, ORG_GCUBE_PORTLETS_USER_KNIMEMODELSIMULATION_MANAGER_SERVICE_IMPL, false);
|
reader = new ApplicationProfileReader(fullScope, APPLICATION_PROFILE, ORG_GCUBE_PORTLETS_USER_KNIMEMODELSIMULATION_MANAGER_SERVICE_IMPL, false);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
logger.error("Error on reading the "+APPLICATION_PROFILE+" with APPID: "+ORG_GCUBE_PORTLETS_USER_KNIMEMODELSIMULATION_MANAGER_SERVICE_IMPL, e);
|
logger.error("Error on reading the "+APPLICATION_PROFILE+" with APPID: "+ORG_GCUBE_PORTLETS_USER_KNIMEMODELSIMULATION_MANAGER_SERVICE_IMPL, e);
|
||||||
ExceptionManager.throwInternalErrorException(req, "Error on reading the Application Profile for the "+KNIME_EXECUTOR_APPLICATION+". Please contact the support", this.getClass(), helpURI);
|
ExceptionManager.internalErrorException(req, "Error on reading the Application Profile for the "+KNIME_EXECUTOR_APPLICATION+". Please contact the support", this.getClass(), helpURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
//READ THE KNIME URL PORTLET FROM APPLICATION PROFRILE IN THE SCOPE fullScope
|
//READ THE KNIME URL PORTLET FROM APPLICATION PROFRILE IN THE SCOPE fullScope
|
||||||
|
@ -78,13 +78,13 @@ public class KnimeGetResolver {
|
||||||
|
|
||||||
}catch (ExecutionException e) {
|
}catch (ExecutionException e) {
|
||||||
logger.error("The input VRE Name "+vreName+" not found", e);
|
logger.error("The input VRE Name "+vreName+" not found", e);
|
||||||
ExceptionManager.throwBadRequestException(req, "The input 'VRE Name' "+"+vreName+"+ "not found on Informatiion System. Is it a valid VRE?", this.getClass(), helpURI);
|
ExceptionManager.badRequestException(req, "The input 'VRE Name' "+"+vreName+"+ "not found on Informatiion System. Is it a valid VRE?", this.getClass(), helpURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
logger.error("Error on resolving Knime URL",e);
|
logger.error("Error on resolving Knime URL",e);
|
||||||
ExceptionManager.throwInternalErrorException(req, "Error occurred when resolving Knime URL", this.getClass(), helpURI);
|
ExceptionManager.internalErrorException(req, "Error occurred when resolving Knime URL", this.getClass(), helpURI);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import javax.ws.rs.POST;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.PathParam;
|
import javax.ws.rs.PathParam;
|
||||||
import javax.ws.rs.Produces;
|
import javax.ws.rs.Produces;
|
||||||
|
import javax.ws.rs.WebApplicationException;
|
||||||
import javax.ws.rs.core.Context;
|
import javax.ws.rs.core.Context;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
@ -78,24 +79,26 @@ public class PartheosRegistryResolver {
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
logger.error("Exception:", e);
|
logger.error("Exception:", e);
|
||||||
String error = "Error occurred on resolving the path "+remainPathParthenosURL+". Please, contact the support!";
|
String error = "Error occurred on resolving the path "+remainPathParthenosURL+". Please, contact the support!";
|
||||||
ExceptionManager.throwInternalErrorException(req, error, this.getClass(), helpURI);
|
ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Post catalogue.
|
* Post catalogue.
|
||||||
*
|
*
|
||||||
* @param req the req
|
* @param req the req
|
||||||
* @param jsonRequest the json request
|
* @param jsonRequest the json request
|
||||||
* @return the response
|
* @return the response
|
||||||
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
@Produces(MediaType.TEXT_PLAIN)
|
@Produces(MediaType.TEXT_PLAIN)
|
||||||
public Response postCatalogue(@Context HttpServletRequest req, ParthenosRequest jsonRequest) {
|
public Response postCatalogue(@Context HttpServletRequest req, ParthenosRequest jsonRequest) throws WebApplicationException{
|
||||||
logger.info(this.getClass().getSimpleName()+" POST starts...");
|
logger.info(this.getClass().getSimpleName()+" POST starts...");
|
||||||
|
|
||||||
try{
|
try{
|
||||||
|
@ -103,7 +106,7 @@ public class PartheosRegistryResolver {
|
||||||
|
|
||||||
if(entityName==null || entityName.isEmpty()){
|
if(entityName==null || entityName.isEmpty()){
|
||||||
logger.error("Entity Name Parameter like 'entity_name' not found or empty");
|
logger.error("Entity Name Parameter like 'entity_name' not found or empty");
|
||||||
ExceptionManager.throwBadRequestException(req, "Mandatory body parameter 'entity_name' not found or empty", this.getClass(), helpURI);
|
ExceptionManager.badRequestException(req, "Mandatory body parameter 'entity_name' not found or empty", this.getClass(), helpURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
//REMOVING FIRST '/' IF EXISTS
|
//REMOVING FIRST '/' IF EXISTS
|
||||||
|
@ -116,10 +119,15 @@ public class PartheosRegistryResolver {
|
||||||
return Response.ok(normalizedEntityName).header("Location", itemCatalogueURLs.getPrivateCataloguePortletURL()).build();
|
return Response.ok(normalizedEntityName).header("Location", itemCatalogueURLs.getPrivateCataloguePortletURL()).build();
|
||||||
|
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
|
|
||||||
|
if(!(e instanceof WebApplicationException)){
|
||||||
|
//UNEXPECTED EXCEPTION managing it as WebApplicationException
|
||||||
|
String error = "Error occurred on transforming the "+jsonRequest+". Please, contact the support!";
|
||||||
|
ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI);
|
||||||
|
}
|
||||||
|
//ALREADY MANAGED AS WebApplicationException
|
||||||
logger.error("Exception:", e);
|
logger.error("Exception:", e);
|
||||||
String error = "Error occurred on transforming the "+jsonRequest+". Please, contact the support!";
|
throw (WebApplicationException) e;
|
||||||
ExceptionManager.throwInternalErrorException(req, error, this.getClass(), helpURI);
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class SMPIDResolver {
|
||||||
//Checking mandatory parameter smpId
|
//Checking mandatory parameter smpId
|
||||||
if(smpId==null || smpId.isEmpty()){
|
if(smpId==null || smpId.isEmpty()){
|
||||||
logger.error(SMP_ID+" not found");
|
logger.error(SMP_ID+" not found");
|
||||||
ExceptionManager.throwBadRequestException(httpRequest, "Missing mandatory parameter "+SMP_ID, SMPIDResolver.class, help);
|
ExceptionManager.badRequestException(httpRequest, "Missing mandatory parameter "+SMP_ID, SMPIDResolver.class, help);
|
||||||
}
|
}
|
||||||
|
|
||||||
return StorageIDResolver.resolveStorageId(httpRequest, smpId, fileName, contentType, validation);
|
return StorageIDResolver.resolveStorageId(httpRequest, smpId, fileName, contentType, validation);
|
||||||
|
|
|
@ -8,6 +8,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.QueryParam;
|
import javax.ws.rs.QueryParam;
|
||||||
|
import javax.ws.rs.WebApplicationException;
|
||||||
import javax.ws.rs.core.Context;
|
import javax.ws.rs.core.Context;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
@ -18,6 +19,7 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The Class SMPResolver.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
* Oct 22, 2018
|
* Oct 22, 2018
|
||||||
|
@ -28,33 +30,56 @@ public class SMPResolver {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final String help = "https://wiki.gcube-system.org/gcube/URI_Resolver#SMP_Resolver";
|
private static final String helpURI = "https://wiki.gcube-system.org/gcube/URI_Resolver#SMP_Resolver";
|
||||||
|
|
||||||
private static final String SMP_URI = "smp-uri";
|
private static final String SMP_URI = "smp-uri";
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(SMPResolver.class);
|
private static Logger logger = LoggerFactory.getLogger(SMPResolver.class);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the smpid.
|
* Gets the smpuri.
|
||||||
*
|
*
|
||||||
* @param smpURI the smp id
|
* @param req the req
|
||||||
|
* @param smpURI the smp uri
|
||||||
* @param fileName the file name
|
* @param fileName the file name
|
||||||
* @param contentType the content type
|
* @param contentType the content type
|
||||||
* @param validation the validation
|
* @param validation the validation
|
||||||
* @return the smpid
|
* @return the smpuri
|
||||||
|
* @throws WebApplicationException the web application exception
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Path("smp")
|
@Path("smp")
|
||||||
public Response getSMPURI(@Context HttpServletRequest httpRequest, @QueryParam(SMP_URI) @Nullable String smpURI, @QueryParam(ConstantsResolver.QUERY_PARAM_FILE_NAME) String fileName, @QueryParam(ConstantsResolver.QUERY_PARAM_CONTENT_TYPE) String contentType, @QueryParam(ConstantsResolver.QUERY_PARAM_VALIDATION) Boolean validation){
|
public Response getSMPURI(@Context HttpServletRequest req,
|
||||||
|
@QueryParam(SMP_URI) @Nullable
|
||||||
|
String smpURI,
|
||||||
|
@QueryParam(ConstantsResolver.QUERY_PARAM_FILE_NAME) String fileName,
|
||||||
|
@QueryParam(ConstantsResolver.QUERY_PARAM_CONTENT_TYPE) String contentType,
|
||||||
|
@QueryParam(ConstantsResolver.QUERY_PARAM_VALIDATION) Boolean validation) throws WebApplicationException{
|
||||||
|
|
||||||
logger.info(this.getClass().getSimpleName()+" GET starts...");
|
logger.info(this.getClass().getSimpleName()+" GET starts...");
|
||||||
|
|
||||||
//Checking mandatory parameter smpURI
|
try{
|
||||||
if(smpURI==null || smpURI.isEmpty()){
|
|
||||||
logger.error(SMP_URI+" not found");
|
|
||||||
ExceptionManager.throwBadRequestException(httpRequest, "Missing mandatory parameter "+SMP_URI, SMPResolver.class, help);
|
|
||||||
}
|
|
||||||
|
|
||||||
return StorageIDResolver.resolveStorageId(httpRequest, smpURI, fileName, contentType, validation);
|
//Checking mandatory parameter smpURI
|
||||||
|
if(smpURI==null || smpURI.isEmpty()){
|
||||||
|
logger.error(SMP_URI+" not found");
|
||||||
|
ExceptionManager.badRequestException(req, "Missing mandatory parameter "+SMP_URI, SMPResolver.class, helpURI);
|
||||||
|
}
|
||||||
|
|
||||||
|
return StorageIDResolver.resolveStorageId(req, smpURI, fileName, contentType, validation);
|
||||||
|
|
||||||
|
}catch (Exception e) {
|
||||||
|
|
||||||
|
if(!(e instanceof WebApplicationException)){
|
||||||
|
//UNEXPECTED EXCEPTION managing it as WebApplicationException
|
||||||
|
String error = "Error occurred on resolving the smpURI "+smpURI+". Please, contact the support!";
|
||||||
|
ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI);
|
||||||
|
}
|
||||||
|
//ALREADY MANAGED AS WebApplicationException
|
||||||
|
logger.error("Exception:", e);
|
||||||
|
throw (WebApplicationException) e;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class StorageHubResolver {
|
||||||
//Checking mandatory parameter id
|
//Checking mandatory parameter id
|
||||||
if(id==null || id.isEmpty()){
|
if(id==null || id.isEmpty()){
|
||||||
logger.error("Path Parameter "+STORAGE_HUB_ID+" not found");
|
logger.error("Path Parameter "+STORAGE_HUB_ID+" not found");
|
||||||
ExceptionManager.throwBadRequestException(httpRequest, "Missing mandatory path parameter "+STORAGE_HUB_ID, StorageHubResolver.class, help);
|
ExceptionManager.badRequestException(httpRequest, "Missing mandatory path parameter "+STORAGE_HUB_ID, StorageHubResolver.class, help);
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
|
@ -53,7 +53,7 @@ public class StorageHubResolver {
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
logger.error("Error on getting file with "+id, e);
|
logger.error("Error on getting file with "+id, e);
|
||||||
String errorMsg = "Error on getting file with hub id '"+id+"'. "+e.getMessage();
|
String errorMsg = "Error on getting file with hub id '"+id+"'. "+e.getMessage();
|
||||||
ExceptionManager.throwInternalErrorException(httpRequest, errorMsg, StorageHubResolver.class, help);
|
ExceptionManager.internalErrorException(httpRequest, errorMsg, StorageHubResolver.class, help);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,13 +68,13 @@ public class StorageHubResolver {
|
||||||
//Checking mandatory parameter id
|
//Checking mandatory parameter id
|
||||||
if(id==null || id.isEmpty()){
|
if(id==null || id.isEmpty()){
|
||||||
logger.error("Path Parameter "+STORAGE_HUB_ID+" not found");
|
logger.error("Path Parameter "+STORAGE_HUB_ID+" not found");
|
||||||
ExceptionManager.throwBadRequestException(httpRequest, "Missing mandatory path parameter "+STORAGE_HUB_ID, StorageHubResolver.class, help);
|
ExceptionManager.badRequestException(httpRequest, "Missing mandatory path parameter "+STORAGE_HUB_ID, StorageHubResolver.class, help);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Checking mandatory parameter id
|
//Checking mandatory parameter id
|
||||||
if(version==null || version.isEmpty()){
|
if(version==null || version.isEmpty()){
|
||||||
logger.error("Parameter 'version' not found");
|
logger.error("Parameter 'version' not found");
|
||||||
ExceptionManager.throwBadRequestException(httpRequest, "Missing mandatory parameter 'version'", StorageHubResolver.class, help);
|
ExceptionManager.badRequestException(httpRequest, "Missing mandatory parameter 'version'", StorageHubResolver.class, help);
|
||||||
}
|
}
|
||||||
try{
|
try{
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ public class StorageHubResolver {
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
String errorMsg = "Error on getting versioned file with hub id '"+id+ "' and version '"+version+"'";
|
String errorMsg = "Error on getting versioned file with hub id '"+id+ "' and version '"+version+"'";
|
||||||
logger.error(errorMsg, e);
|
logger.error(errorMsg, e);
|
||||||
ExceptionManager.throwInternalErrorException(httpRequest, errorMsg, StorageHubResolver.class, help);
|
ExceptionManager.internalErrorException(httpRequest, errorMsg, StorageHubResolver.class, help);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class StorageIDResolver {
|
||||||
//Checking mandatory parameter storageId
|
//Checking mandatory parameter storageId
|
||||||
if(storageId==null || storageId.isEmpty()){
|
if(storageId==null || storageId.isEmpty()){
|
||||||
logger.error(STORAGE_ID+" not found");
|
logger.error(STORAGE_ID+" not found");
|
||||||
ExceptionManager.throwBadRequestException(httpRequest, "Missing mandatory path parameter "+STORAGE_ID, StorageIDResolver.class, help);
|
ExceptionManager.badRequestException(httpRequest, "Missing mandatory path parameter "+STORAGE_ID, StorageIDResolver.class, help);
|
||||||
}
|
}
|
||||||
return resolveStorageId(httpRequest, storageId, fileName, contentType, validation);
|
return resolveStorageId(httpRequest, storageId, fileName, contentType, validation);
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ public class StorageIDResolver {
|
||||||
//Checking mandatory parameter storageId
|
//Checking mandatory parameter storageId
|
||||||
if (storageId == null || storageId.isEmpty()) {
|
if (storageId == null || storageId.isEmpty()) {
|
||||||
logger.error("storageId not found");
|
logger.error("storageId not found");
|
||||||
ExceptionManager.throwBadRequestException(httpRequest, "Missing mandatory path parameter "+STORAGE_ID, StorageIDResolver.class, help);
|
ExceptionManager.badRequestException(httpRequest, "Missing mandatory path parameter "+STORAGE_ID, StorageIDResolver.class, help);
|
||||||
}
|
}
|
||||||
|
|
||||||
StorageClient client = getStorageClientInstance(storageId);
|
StorageClient client = getStorageClientInstance(storageId);
|
||||||
|
@ -104,12 +104,12 @@ public class StorageIDResolver {
|
||||||
logger.info("Decoded ID"+" = "+ toSEID);
|
logger.info("Decoded ID"+" = "+ toSEID);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
logger.error("Storage Client Exception when getting file from storage: ", e);
|
logger.error("Storage Client Exception when getting file from storage: ", e);
|
||||||
ExceptionManager.throwNotFoundException(httpRequest, "Storage Client Exception when getting file from storage with id: "+storageId, StorageIDResolver.class, help);
|
ExceptionManager.notFoundException(httpRequest, "Storage Client Exception when getting file from storage with id: "+storageId, StorageIDResolver.class, help);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(toSEID==null || toSEID.isEmpty()){
|
if(toSEID==null || toSEID.isEmpty()){
|
||||||
logger.error("Decrypted id for storageId: "+storageId +" is null or empty!");
|
logger.error("Decrypted id for storageId: "+storageId +" is null or empty!");
|
||||||
ExceptionManager.throwNotFoundException(httpRequest, "Error on decrypting the "+STORAGE_ID+ " '"+storageId+"'. Is it a valid id?", StorageIDResolver.class, help);
|
ExceptionManager.notFoundException(httpRequest, "Error on decrypting the "+STORAGE_ID+ " '"+storageId+"'. Is it a valid id?", StorageIDResolver.class, help);
|
||||||
}
|
}
|
||||||
|
|
||||||
long size = iClient.getSize().RFileById(toSEID);
|
long size = iClient.getSize().RFileById(toSEID);
|
||||||
|
@ -189,7 +189,7 @@ public class StorageIDResolver {
|
||||||
//Checking mandatory parameter storageId
|
//Checking mandatory parameter storageId
|
||||||
if (storageId == null || storageId.isEmpty()) {
|
if (storageId == null || storageId.isEmpty()) {
|
||||||
logger.warn("storageId not found");
|
logger.warn("storageId not found");
|
||||||
ExceptionManager.throwBadRequestException(httpRequest, "Storage Client Exception when getting file from storage with id: "+storageId, this.getClass(), help);
|
ExceptionManager.badRequestException(httpRequest, "Storage Client Exception when getting file from storage with id: "+storageId, this.getClass(), help);
|
||||||
}
|
}
|
||||||
StorageClient client = getStorageClientInstance(storageId);
|
StorageClient client = getStorageClientInstance(storageId);
|
||||||
String toSEID = null;
|
String toSEID = null;
|
||||||
|
@ -200,12 +200,12 @@ public class StorageIDResolver {
|
||||||
logger.debug("Decoded ID"+" = "+ toSEID);
|
logger.debug("Decoded ID"+" = "+ toSEID);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
logger.error("Storage Client Exception when getting file from storage: ", e);
|
logger.error("Storage Client Exception when getting file from storage: ", e);
|
||||||
ExceptionManager.throwInternalErrorException(httpRequest, "Storage Client Exception when getting file from storage with id: "+storageId, StorageIDResolver.class, help);
|
ExceptionManager.internalErrorException(httpRequest, "Storage Client Exception when getting file from storage with id: "+storageId, StorageIDResolver.class, help);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(toSEID==null || toSEID.isEmpty()){
|
if(toSEID==null || toSEID.isEmpty()){
|
||||||
logger.error("Decrypted id for storageId: "+storageId +" is null or empty!");
|
logger.error("Decrypted id for storageId: "+storageId +" is null or empty!");
|
||||||
ExceptionManager.throwNotFoundException(httpRequest, "Error on decrypting the "+STORAGE_ID+ " '"+storageId+"'. Is it a valid id?", StorageIDResolver.class, help);
|
ExceptionManager.notFoundException(httpRequest, "Error on decrypting the "+STORAGE_ID+ " '"+storageId+"'. Is it a valid id?", StorageIDResolver.class, help);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -223,15 +223,15 @@ public class StorageIDResolver {
|
||||||
IOUtils.closeQuietly(streamToWrite);
|
IOUtils.closeQuietly(streamToWrite);
|
||||||
response = Response.status(HttpStatus.SC_OK);
|
response = Response.status(HttpStatus.SC_OK);
|
||||||
}else
|
}else
|
||||||
ExceptionManager.throwNotFoundException(httpRequest, "The file with id: "+storageId+" is missing in the storage", StorageIDResolver.class, help);
|
ExceptionManager.notFoundException(httpRequest, "The file with id: "+storageId+" is missing in the storage", StorageIDResolver.class, help);
|
||||||
}
|
}
|
||||||
catch (IOException e2) {
|
catch (IOException e2) {
|
||||||
logger.error("Error on validating the file: ",e2);
|
logger.error("Error on validating the file: ",e2);
|
||||||
ExceptionManager.throwInternalErrorException(httpRequest, "Error on validating the file with id: "+storageId, StorageIDResolver.class, help);
|
ExceptionManager.internalErrorException(httpRequest, "Error on validating the file with id: "+storageId, StorageIDResolver.class, help);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(response==null)
|
if(response==null)
|
||||||
ExceptionManager.throwInternalErrorException(httpRequest, "Error on validating the file with id: "+storageId, StorageIDResolver.class, help);
|
ExceptionManager.internalErrorException(httpRequest, "Error on validating the file with id: "+storageId, StorageIDResolver.class, help);
|
||||||
|
|
||||||
return response.build();
|
return response.build();
|
||||||
|
|
||||||
|
|
|
@ -20,107 +20,111 @@ import org.gcube.datatransfer.resolver.services.exceptions.WrongParameterExcepti
|
||||||
/**
|
/**
|
||||||
* The Class ExceptionManager.
|
* The Class ExceptionManager.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
* Oct 23, 2018
|
* Dec 14, 2018
|
||||||
*/
|
*/
|
||||||
public class ExceptionManager {
|
public class ExceptionManager {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Throw internal error exception.
|
* Internal error exception.
|
||||||
*
|
*
|
||||||
* @param httpRequest the http request
|
* @param httpRequest the http request
|
||||||
* @param errorMessage the error message
|
* @param errorMessage the error message
|
||||||
* @param thrownBy the thrown by
|
* @param thrownBy the thrown by
|
||||||
* @param helpURI the help uri
|
* @param helpURI the help uri
|
||||||
|
* @return the internal server exception
|
||||||
*/
|
*/
|
||||||
public static void throwInternalErrorException(HttpServletRequest httpRequest, String errorMessage, Class thrownBy, String helpURI){
|
public static InternalServerException internalErrorException(HttpServletRequest httpRequest, String errorMessage, Class thrownBy, String helpURI){
|
||||||
|
|
||||||
URI theURI = checkURI(helpURI);
|
URI theURI = checkURI(helpURI);
|
||||||
throw new InternalServerException(httpRequest, Status.INTERNAL_SERVER_ERROR, errorMessage, thrownBy, theURI);
|
return new InternalServerException(httpRequest, Status.INTERNAL_SERVER_ERROR, errorMessage, thrownBy, theURI);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Throw bad request exception.
|
* Bad request exception.
|
||||||
*
|
*
|
||||||
* @param httpRequest the http request
|
* @param httpRequest the http request
|
||||||
* @param errorMessage the error message
|
* @param errorMessage the error message
|
||||||
* @param thrownBy the thrown by
|
* @param thrownBy the thrown by
|
||||||
* @param helpURI the help uri
|
* @param helpURI the help uri
|
||||||
|
* @return the bad request exception
|
||||||
*/
|
*/
|
||||||
public static void throwBadRequestException(HttpServletRequest httpRequest, String errorMessage, Class thrownBy, String helpURI){
|
public static BadRequestException badRequestException(HttpServletRequest httpRequest, String errorMessage, Class thrownBy, String helpURI){
|
||||||
|
|
||||||
URI theURI = checkURI(helpURI);
|
URI theURI = checkURI(helpURI);
|
||||||
throw new BadRequestException(httpRequest, Status.BAD_REQUEST, errorMessage, thrownBy, theURI);
|
return new BadRequestException(httpRequest, Status.BAD_REQUEST, errorMessage, thrownBy, theURI);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Throw wrong parameter exception.
|
* Wrong parameter exception.
|
||||||
*
|
*
|
||||||
* @param httpRequest the http request
|
* @param httpRequest the http request
|
||||||
* @param errorMessage the error message
|
* @param errorMessage the error message
|
||||||
* @param thrownBy the thrown by
|
* @param thrownBy the thrown by
|
||||||
* @param helpURI the help uri
|
* @param helpURI the help uri
|
||||||
|
* @return the wrong parameter exception
|
||||||
*/
|
*/
|
||||||
public static void throwWrongParameterException(HttpServletRequest httpRequest, String errorMessage, Class thrownBy, String helpURI){
|
public static WrongParameterException wrongParameterException(HttpServletRequest httpRequest, String errorMessage, Class thrownBy, String helpURI) {
|
||||||
|
|
||||||
URI theURI = checkURI(helpURI);
|
URI theURI = checkURI(helpURI);
|
||||||
throw new WrongParameterException(httpRequest, Status.BAD_REQUEST, errorMessage, thrownBy, theURI);
|
return new WrongParameterException(httpRequest, Status.BAD_REQUEST, errorMessage, thrownBy, theURI);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Throw not found exception.
|
* Not found exception.
|
||||||
*
|
*
|
||||||
* @param httpRequest the http request
|
* @param httpRequest the http request
|
||||||
* @param errorMessage the error message
|
* @param errorMessage the error message
|
||||||
* @param thrownBy the thrown by
|
* @param thrownBy the thrown by
|
||||||
* @param helpURI the help uri
|
* @param helpURI the help uri
|
||||||
|
* @return the not found exception
|
||||||
*/
|
*/
|
||||||
public static void throwNotFoundException(HttpServletRequest httpRequest, String errorMessage, Class thrownBy, String helpURI){
|
public static NotFoundException notFoundException(HttpServletRequest httpRequest, String errorMessage, Class thrownBy, String helpURI) {
|
||||||
|
|
||||||
URI theURI = checkURI(helpURI);
|
URI theURI = checkURI(helpURI);
|
||||||
throw new NotFoundException(httpRequest, Status.NOT_FOUND, errorMessage, thrownBy, theURI);
|
return new NotFoundException(httpRequest, Status.NOT_FOUND, errorMessage, thrownBy, theURI);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Throw unauthorized exception.
|
* Unauthorized exception.
|
||||||
*
|
*
|
||||||
* @param httpRequest the http request
|
* @param httpRequest the http request
|
||||||
* @param errorMessage the error message
|
* @param errorMessage the error message
|
||||||
* @param thrownBy the thrown by
|
* @param thrownBy the thrown by
|
||||||
* @param helpURI the help uri
|
* @param helpURI the help uri
|
||||||
|
* @return the not authorized request exception
|
||||||
*/
|
*/
|
||||||
public static void throwUnauthorizedException(HttpServletRequest httpRequest, String errorMessage, Class thrownBy, String helpURI){
|
public static NotAuthorizedRequestException unauthorizedException(HttpServletRequest httpRequest, String errorMessage, Class thrownBy, String helpURI) {
|
||||||
|
|
||||||
URI theURI = checkURI(helpURI);
|
URI theURI = checkURI(helpURI);
|
||||||
throw new NotAuthorizedRequestException(httpRequest, Status.UNAUTHORIZED, errorMessage, thrownBy, theURI);
|
return new NotAuthorizedRequestException(httpRequest, Status.UNAUTHORIZED, errorMessage, thrownBy, theURI);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Throw forbidden exception.
|
* Forbidden exception.
|
||||||
*
|
*
|
||||||
* @param httpRequest the http request
|
* @param httpRequest the http request
|
||||||
* @param errorMessage the error message
|
* @param errorMessage the error message
|
||||||
* @param thrownBy the thrown by
|
* @param thrownBy the thrown by
|
||||||
* @param helpURI the help uri
|
* @param helpURI the help uri
|
||||||
|
* @return the forbidden request exception
|
||||||
*/
|
*/
|
||||||
public static void throwForbiddenException(HttpServletRequest httpRequest, String errorMessage, Class thrownBy, String helpURI){
|
public static ForbiddenRequestException forbiddenException(HttpServletRequest httpRequest, String errorMessage, Class thrownBy, String helpURI) {
|
||||||
|
|
||||||
URI theURI = checkURI(helpURI);
|
URI theURI = checkURI(helpURI);
|
||||||
throw new ForbiddenRequestException(httpRequest, Status.FORBIDDEN, errorMessage, thrownBy, theURI);
|
return new ForbiddenRequestException(httpRequest, Status.FORBIDDEN, errorMessage, thrownBy, theURI);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check uri.
|
* Check uri.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue