managing exceptions
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-transfer/uri-resolver@174890 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
3cc7ad3212
commit
97312b0a47
|
@ -163,7 +163,7 @@ public class AnalyticsCreateResolver {
|
|||
|
||||
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!";
|
||||
String error = "Error occurred on creating the Analytics for the request "+body+". Please, contact the support!"+"\nCause: "+e.getCause().getMessage();
|
||||
throw ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI);
|
||||
}
|
||||
//ALREADY MANAGED AS WebApplicationException
|
||||
|
|
|
@ -88,7 +88,7 @@ public class AnalyticsGetResolver {
|
|||
|
||||
if(!(e instanceof WebApplicationException)){
|
||||
//UNEXPECTED EXCEPTION managing it as WebApplicationException
|
||||
String error = "Error occurred on resolving the Analytics URL. Please, contact the support!";
|
||||
String error = "Error occurred on resolving the Analytics URL. Please, contact the support!"+"\nCause: "+e.getCause().getMessage();
|
||||
throw ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI);
|
||||
}
|
||||
//ALREADY MANAGED AS WebApplicationException
|
||||
|
|
|
@ -10,6 +10,7 @@ import javax.ws.rs.POST;
|
|||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
@ -53,10 +54,15 @@ public class CatalogueResolver {
|
|||
*/
|
||||
@GET
|
||||
@Path("{entityContext:ctlg(-(o|g|p|d))?}/{vreName}/{entityName}")
|
||||
public Response resolveCatalogue(@Context HttpServletRequest req, @PathParam("entityName") String entityName, @PathParam("vreName") String vreName, @PathParam("entityContext") String entityContext) {
|
||||
InnerMethodName.instance.set("resolveCataloguePublicLink");
|
||||
logger.info(CatalogueResolver.class.getSimpleName()+" GET starts...");
|
||||
public Response resolveCatalogue(@Context HttpServletRequest req,
|
||||
@PathParam("entityName") String entityName,
|
||||
@PathParam("vreName") String vreName,
|
||||
@PathParam("entityContext") String entityContext) throws WebApplicationException{
|
||||
|
||||
logger.info(this.getClass().getSimpleName()+" GET starts...");
|
||||
|
||||
try {
|
||||
InnerMethodName.instance.set("resolveCataloguePublicLink");
|
||||
ItemCatalogueURLs itemCatalogueURLs = getItemCatalogueURLs(vreName, entityContext, entityName);
|
||||
|
||||
String itemCatalogueURL;
|
||||
|
@ -71,9 +77,15 @@ public class CatalogueResolver {
|
|||
|
||||
return Response.seeOther(new URL(itemCatalogueURL).toURI()).build();
|
||||
}catch (Exception e) {
|
||||
logger.error("error resolving catalogue link",e);
|
||||
ExceptionManager.internalErrorException(req, "Error occurred resolving catalogue link", this.getClass(), helpURI);
|
||||
return null;
|
||||
|
||||
if(!(e instanceof WebApplicationException)){
|
||||
//UNEXPECTED EXCEPTION managing it as WebApplicationException
|
||||
String error = "Error occurred on resolving the Catalgoue URL. Please, contact the support!"+"\nCause: "+e.getCause().getMessage();
|
||||
throw ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI);
|
||||
}
|
||||
//ALREADY MANAGED AS WebApplicationException
|
||||
logger.error("Exception:", e);
|
||||
throw (WebApplicationException) e;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,11 +100,13 @@ public class CatalogueResolver {
|
|||
@Path("catalogue")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
public Response postCatalogue(@Context HttpServletRequest req, CatalogueRequest jsonRequest) {
|
||||
public Response postCatalogue(@Context HttpServletRequest req, CatalogueRequest jsonRequest) throws WebApplicationException{
|
||||
logger.info(this.getClass().getSimpleName()+" POST starts...");
|
||||
|
||||
try{
|
||||
|
||||
InnerMethodName.instance.set("postCataloguePublicLink");
|
||||
logger.info(CatalogueResolver.class.getSimpleName()+" POST starts...");
|
||||
logger.info("The body contains the request: "+jsonRequest.toString());
|
||||
//final CatalogueEntityRequest cer = new CatalogueEntityRequest();
|
||||
|
||||
//CHECK IF INPUT SCOPE IS VALID
|
||||
String scope = jsonRequest.getGcube_scope();
|
||||
|
@ -114,18 +128,29 @@ public class CatalogueResolver {
|
|||
}
|
||||
|
||||
if(fullScope==null)
|
||||
ExceptionManager.notFoundException(req, "The scope '"+scope+"' does not matching any scope in the infrastructure. Is it valid?", this.getClass(), helpURI);
|
||||
throw 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());
|
||||
if(rc==null){
|
||||
logger.error("Entity context is null/malformed");
|
||||
ExceptionManager.badRequestException(req, "Entity context is null/malformed", this.getClass(), helpURI);
|
||||
//throw new WebApplicationException("Entity context is null/malformed", Status.BAD_REQUEST);
|
||||
throw ExceptionManager.badRequestException(req, "Entity context is null/malformed", this.getClass(), helpURI);
|
||||
}
|
||||
|
||||
String linkURL = String.format("%s/%s/%s/%s", serverUrl, rc.getId(), vreName, jsonRequest.getEntity_name());
|
||||
logger.info("Returining Catalogue URL: "+linkURL);
|
||||
return Response.ok(linkURL).header("Location", linkURL).build();
|
||||
|
||||
}catch (Exception e) {
|
||||
|
||||
if(!(e instanceof WebApplicationException)){
|
||||
//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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -172,7 +197,7 @@ public class CatalogueResolver {
|
|||
String privatePortletURL = String.format("%s?path=/%s/%s",ckanCatalogueReference.getPrivatePortletURL(),entityContextValue, entityName);
|
||||
return new ItemCatalogueURLs(entityName, isPublicItem, privatePortletURL, publicPorltetURL);
|
||||
}catch (Exception e) {
|
||||
logger.error("error resolving catalogue link",e);
|
||||
logger.error("Error when resolving CatalogueURL:", e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,8 +3,6 @@ package org.gcube.datatransfer.resolver.services;
|
|||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
@ -19,6 +17,7 @@ import javax.ws.rs.POST;
|
|||
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;
|
||||
|
@ -37,7 +36,6 @@ import org.gcube.datatransfer.resolver.gis.geonetwork.GeonetworkRequestFilterPar
|
|||
import org.gcube.datatransfer.resolver.gis.geonetwork.GeonetworkRequestFilterParameters.VISIBILITY;
|
||||
import org.gcube.datatransfer.resolver.gis.geonetwork.ReusableInputStream;
|
||||
import org.gcube.datatransfer.resolver.services.error.ExceptionManager;
|
||||
import org.gcube.datatransfer.resolver.services.exceptions.InternalServerException;
|
||||
import org.gcube.datatransfer.resolver.util.GetResponseRecordFilter;
|
||||
import org.gcube.datatransfer.resolver.util.HTTPCallsUtils;
|
||||
import org.gcube.datatransfer.resolver.util.HTTPCallsUtils.HttpResponse;
|
||||
|
@ -89,7 +87,7 @@ public class GeonetworkResolver {
|
|||
|
||||
protected Map<String, GeonetworkInstance> cacheGNInstances;
|
||||
|
||||
private String help = "https://wiki.gcube-system.org/gcube/GCube_Resource_Catalogue#Geonetwork_Resolver";
|
||||
private String helpURI = "https://wiki.gcube-system.org/gcube/GCube_Resource_Catalogue#Geonetwork_Resolver";
|
||||
|
||||
/**
|
||||
* Gets the geonetwork request criteria.
|
||||
|
@ -122,19 +120,22 @@ public class GeonetworkResolver {
|
|||
@PathParam("filterValue") @Nullable String filterValue,
|
||||
@PathParam(PATH_PARAM_REMAINPATH) @Nullable String remainPath,
|
||||
@QueryParam(QUERY_PARAM_RESET_CACHE_PARAM) @Nullable String resetCache,
|
||||
@QueryParam(QUERY_PARAM_RESET_CACHED_SCOPE_PARAM) @Nullable String resetScope) {
|
||||
@QueryParam(QUERY_PARAM_RESET_CACHED_SCOPE_PARAM) @Nullable String resetScope) throws WebApplicationException{
|
||||
|
||||
logger.info(this.getClass().getSimpleName()+" GET starts...");
|
||||
String gnGetlURL = null;
|
||||
|
||||
try {
|
||||
logger.info("Params are [mode: "+mode+", scope: "+scope+", visibility: "+visibility+", filterKey: "+filterKey+", filterValue: "+filterValue+", remainPath: "+remainPath+"]");
|
||||
|
||||
if(scope==null || scope.isEmpty()){
|
||||
logger.error("Path Parameter 'scope' not found");
|
||||
ExceptionManager.badRequestException(req, "Missing mandatory path parameter 'scope'", this.getClass(), help);
|
||||
throw ExceptionManager.badRequestException(req, "Missing mandatory path parameter 'scope'", this.getClass(), helpURI);
|
||||
}
|
||||
|
||||
if(mode==null || mode.isEmpty()){
|
||||
logger.error("Path Parameter 'scope' not found");
|
||||
ExceptionManager.badRequestException(req, "Missing mandatory path parameter 'mode'", this.getClass(), help);
|
||||
throw ExceptionManager.badRequestException(req, "Missing mandatory path parameter 'mode'", this.getClass(), helpURI);
|
||||
}
|
||||
|
||||
scope = ScopeUtil.normalizeScope(scope, "|");
|
||||
|
@ -144,12 +145,12 @@ public class GeonetworkResolver {
|
|||
}catch(Exception e){
|
||||
List<MODE> toPrint = Arrays.asList(MODE.values());
|
||||
logger.error("The 'mode' parameter is wrong, Have you pass a valid parameter MODE like "+toPrint+"?");
|
||||
ExceptionManager.wrongParameterException(req, "The 'mode' parameter must be value of "+toPrint, this.getClass(), help);
|
||||
throw ExceptionManager.wrongParameterException(req, "The 'mode' parameter must be value of "+toPrint, this.getClass(), helpURI);
|
||||
}
|
||||
|
||||
if(visibility==null){
|
||||
logger.error("Path Parameter 'visibility' not found");
|
||||
ExceptionManager.badRequestException(req, "Missing mandatory path parameter 'visibility'", this.getClass(), help);
|
||||
throw ExceptionManager.badRequestException(req, "Missing mandatory path parameter 'visibility'", this.getClass(), helpURI);
|
||||
}
|
||||
|
||||
visibility = visibility.toUpperCase();
|
||||
|
@ -158,7 +159,7 @@ public class GeonetworkResolver {
|
|||
}catch (Exception e) {
|
||||
List<VISIBILITY> toPrint = Arrays.asList(VISIBILITY.values());
|
||||
logger.error("The 'visibility' parameter is wrong, Have you pass a valid parameter VISIBILITY like "+toPrint+"?");
|
||||
ExceptionManager.wrongParameterException(req, "The 'visibility' parameter must be value of "+toPrint, this.getClass(), help);
|
||||
throw ExceptionManager.wrongParameterException(req, "The 'visibility' parameter must be value of "+toPrint, this.getClass(), helpURI);
|
||||
}
|
||||
|
||||
if(resetCache!=null && Boolean.parseBoolean(resetCache)){
|
||||
|
@ -170,7 +171,6 @@ public class GeonetworkResolver {
|
|||
}
|
||||
|
||||
logger.info("Remaining path is: "+remainPath);
|
||||
String gnGetlURL = null;
|
||||
try {
|
||||
|
||||
GeonetworkInstance gnInstance = getGeonetworkInstanceForScope(scope);
|
||||
|
@ -202,27 +202,28 @@ public class GeonetworkResolver {
|
|||
return responseBuilder.build();
|
||||
|
||||
case HttpServletResponse.SC_FORBIDDEN:
|
||||
ExceptionManager.forbiddenException(req, "You are not authorized to perform the request "+gnGetlURL, this.getClass(), help);
|
||||
break;
|
||||
throw ExceptionManager.forbiddenException(req, "You are not authorized to perform the request "+gnGetlURL, this.getClass(), helpURI);
|
||||
|
||||
default:
|
||||
ExceptionManager.internalErrorException(req, "Sorry, an error occurred performing the geonetwork request "+gnGetlURL+" with scope "+scope, this.getClass(), help);
|
||||
throw ExceptionManager.internalErrorException(req, "Sorry, an error occurred performing the geonetwork request "+gnGetlURL+" with scope "+scope, this.getClass(), helpURI);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Exception:", e);
|
||||
String error = "Sorry, an error occurred on resolving geonetwork request with scope "+scope+". Please, contact support!";
|
||||
ExceptionManager.internalErrorException(req, error, this.getClass(), help);
|
||||
throw ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI);
|
||||
}
|
||||
|
||||
//An error occurred
|
||||
try {
|
||||
}catch (Exception e) {
|
||||
|
||||
throw new InternalServerException(req, javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR, "Error during perform GET operation to: "+gnGetlURL, this.getClass(), new URI(help));
|
||||
if(!(e instanceof WebApplicationException)){
|
||||
//UNEXPECTED EXCEPTION managing it as WebApplicationException
|
||||
String error = "Error during perform GET operation to: "+gnGetlURL+". Please, contact the support!";
|
||||
throw ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI);
|
||||
}
|
||||
catch (URISyntaxException e) {
|
||||
//silent
|
||||
return null;
|
||||
//ALREADY MANAGED AS WebApplicationException
|
||||
logger.error("Exception:", e);
|
||||
throw (WebApplicationException) e;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -237,19 +238,22 @@ public class GeonetworkResolver {
|
|||
@PathParam("filterValue") @Nullable String filterValue,
|
||||
@PathParam(PATH_PARAM_REMAINPATH) @Nullable String remainPath,
|
||||
@QueryParam(QUERY_PARAM_RESET_CACHE_PARAM) @Nullable String resetCache,
|
||||
@QueryParam(QUERY_PARAM_RESET_CACHED_SCOPE_PARAM) @Nullable String resetScope) {
|
||||
@QueryParam(QUERY_PARAM_RESET_CACHED_SCOPE_PARAM) @Nullable String resetScope) throws WebApplicationException{
|
||||
|
||||
logger.info(this.getClass().getSimpleName()+" POST starts...");
|
||||
String gnCSWlURL = null;
|
||||
|
||||
try{
|
||||
logger.info("Params are [mode: "+mode+", scope: "+scope+", visibility: "+visibility+", filterKey: "+filterKey+", filterValue: "+filterValue+", remainPath: "+remainPath+"]");
|
||||
|
||||
if(scope==null || scope.isEmpty()){
|
||||
logger.error("Path Parameter 'scope' not found");
|
||||
ExceptionManager.badRequestException(req, "Missing mandatory path parameter 'scope'", this.getClass(), help);
|
||||
throw ExceptionManager.badRequestException(req, "Missing mandatory path parameter 'scope'", this.getClass(), helpURI);
|
||||
}
|
||||
|
||||
if(mode==null || mode.isEmpty()){
|
||||
logger.error("Path Parameter 'scope' not found");
|
||||
ExceptionManager.badRequestException(req, "Missing mandatory path parameter 'mode'", this.getClass(), help);
|
||||
ExceptionManager.badRequestException(req, "Missing mandatory path parameter 'mode'", this.getClass(), helpURI);
|
||||
}
|
||||
|
||||
scope = ScopeUtil.normalizeScope(scope, "|");
|
||||
|
@ -259,12 +263,12 @@ public class GeonetworkResolver {
|
|||
}catch(Exception e){
|
||||
List<MODE> toPrint = Arrays.asList(MODE.values());
|
||||
logger.error("The 'mode' parameter is wrong, Have you pass a valid parameter MODE like "+toPrint+"?");
|
||||
ExceptionManager.wrongParameterException(req, "The 'mode' parameter must be value of "+toPrint, this.getClass(), help);
|
||||
throw ExceptionManager.wrongParameterException(req, "The 'mode' parameter must be value of "+toPrint, this.getClass(), helpURI);
|
||||
}
|
||||
|
||||
if(visibility==null){
|
||||
logger.error("Path Parameter 'visibility' not found");
|
||||
ExceptionManager.badRequestException(req, "Missing mandatory path parameter 'visibility'", this.getClass(), help);
|
||||
throw ExceptionManager.badRequestException(req, "Missing mandatory path parameter 'visibility'", this.getClass(), helpURI);
|
||||
}
|
||||
|
||||
visibility = visibility.toUpperCase();
|
||||
|
@ -273,7 +277,7 @@ public class GeonetworkResolver {
|
|||
}catch (Exception e) {
|
||||
List<VISIBILITY> toPrint = Arrays.asList(VISIBILITY.values());
|
||||
logger.error("The 'visibility' parameter is wrong, Have you pass a valid parameter VISIBILITY like "+toPrint+"?");
|
||||
ExceptionManager.wrongParameterException(req, "The 'visibility' parameter must be value of "+toPrint, this.getClass(), help);
|
||||
throw ExceptionManager.wrongParameterException(req, "The 'visibility' parameter must be value of "+toPrint, this.getClass(), helpURI);
|
||||
}
|
||||
|
||||
//HOW TO PASS ANY FILTER?
|
||||
|
@ -287,7 +291,7 @@ public class GeonetworkResolver {
|
|||
}
|
||||
}
|
||||
|
||||
String gnCSWlURL = null;
|
||||
|
||||
try {
|
||||
|
||||
GeonetworkServiceInterface gntwAccess = new GeonetworkAccessParameter(scope);
|
||||
|
@ -378,7 +382,7 @@ public class GeonetworkResolver {
|
|||
|
||||
if(in==null){
|
||||
logger.warn("Input stream returned is null, sending "+HttpServletResponse.SC_NOT_FOUND);
|
||||
ExceptionManager.notFoundException(req, "Input stream is null to the request "+gnCSWlURL+ " with body: "+byteArray.toString(), this.getClass(), help);
|
||||
throw ExceptionManager.notFoundException(req, "Input stream is null to the request "+gnCSWlURL+ " with body: "+byteArray.toString(), this.getClass(), helpURI);
|
||||
}
|
||||
|
||||
try{
|
||||
|
@ -441,29 +445,31 @@ public class GeonetworkResolver {
|
|||
|
||||
}catch(Exception e){
|
||||
logger.error("Error on copy the response to send to client: ", e);
|
||||
ExceptionManager.internalErrorException(req, "Error on copy the response!", this.getClass(), help);
|
||||
throw ExceptionManager.internalErrorException(req, "Error on copy the response!", this.getClass(), helpURI);
|
||||
}finally{
|
||||
IOUtils.closeQuietly(in);
|
||||
}
|
||||
|
||||
} catch (IllegalArgumentException e){
|
||||
logger.error("IllegalArgumentException:", e);
|
||||
ExceptionManager.badRequestException(req, "Illegal argument to carry out the request!", this.getClass(), help);
|
||||
throw ExceptionManager.badRequestException(req, "Illegal argument to carry out the request!", this.getClass(), helpURI);
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Exception:", e);
|
||||
String error = "Sorry, an error occurred on resolving geonetwork request with scope "+scope+". Please, contact support!";
|
||||
ExceptionManager.internalErrorException(req, error, this.getClass(), help);
|
||||
throw ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI);
|
||||
}
|
||||
|
||||
//An error occurred
|
||||
try {
|
||||
}catch (Exception e) {
|
||||
|
||||
throw new InternalServerException(req, javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR, "Error during perform POST operation to: "+gnCSWlURL, this.getClass(), new URI(help));
|
||||
if(!(e instanceof WebApplicationException)){
|
||||
//UNEXPECTED EXCEPTION managing it as WebApplicationException
|
||||
String error = "Error during perform POST operation to: "+gnCSWlURL+". Please, contact the support!"+"\nCause: "+e.getCause().getMessage();
|
||||
throw ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI);
|
||||
}
|
||||
catch (URISyntaxException e) {
|
||||
//silent
|
||||
return null;
|
||||
//ALREADY MANAGED AS WebApplicationException
|
||||
logger.error("Exception:", e);
|
||||
throw (WebApplicationException) e;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
|
@ -29,11 +30,12 @@ import org.slf4j.LoggerFactory;
|
|||
import com.google.common.cache.CacheLoader.InvalidCacheLoadException;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The Class GisResolver.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Nov 2, 2018
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
* Dec 14, 2018
|
||||
*/
|
||||
@Path("gis")
|
||||
public class GisResolver {
|
||||
|
@ -57,24 +59,29 @@ public class GisResolver {
|
|||
* @param gisUUID the gis uuid
|
||||
* @param geoExplorerUUID the geo explorer uuid
|
||||
* @return the response
|
||||
* @throws WebApplicationException the web application exception
|
||||
*/
|
||||
@GET
|
||||
@Path("")
|
||||
public Response submitGet(@Context HttpServletRequest req, @QueryParam(SCOPE) String scope, @QueryParam(GIS_UUID) String gisUUID, @QueryParam(GEO_EXPLORER_LAYER_UUID) String geoExplorerUUID){
|
||||
public Response submitGet(@Context HttpServletRequest req, @
|
||||
QueryParam(SCOPE) String scope,
|
||||
@QueryParam(GIS_UUID) String gisUUID,
|
||||
@QueryParam(GEO_EXPLORER_LAYER_UUID) String geoExplorerUUID) throws WebApplicationException{
|
||||
|
||||
logger.info(this.getClass().getSimpleName()+" GET starts...");
|
||||
|
||||
try{
|
||||
boolean isGisLink = false;
|
||||
boolean isGeoExplorerLink = false;
|
||||
|
||||
if(scope==null || scope.isEmpty()){
|
||||
logger.error("Query Parameter 'scope' not found");
|
||||
ExceptionManager.badRequestException(req, "Missing mandatory query parameter 'scope'", this.getClass(), help);
|
||||
throw ExceptionManager.badRequestException(req, "Missing mandatory query parameter 'scope'", this.getClass(), help);
|
||||
}
|
||||
|
||||
if(gisUUID==null || gisUUID.isEmpty()){
|
||||
logger.error("Path Parameter 'gis-UUID' not found");
|
||||
ExceptionManager.badRequestException(req, "Missing mandatory query parameter 'gis-UUID'", this.getClass(), help);
|
||||
throw ExceptionManager.badRequestException(req, "Missing mandatory query parameter 'gis-UUID'", this.getClass(), help);
|
||||
}else
|
||||
isGisLink = true;
|
||||
|
||||
|
@ -91,10 +98,10 @@ public class GisResolver {
|
|||
if(!isGisLink && !isGeoExplorerLink){
|
||||
String err = GIS_UUID+" or "+GEO_EXPLORER_LAYER_UUID+" not found or empty in the query string";
|
||||
logger.error(err);
|
||||
ExceptionManager.badRequestException(req, err, this.getClass(), help);
|
||||
throw ExceptionManager.badRequestException(req, err, this.getClass(), help);
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
|
||||
if(isGisLink){
|
||||
ScopeProvider.instance.set(scope);
|
||||
|
@ -115,7 +122,7 @@ public class GisResolver {
|
|||
String gisViewerPortletUrl = LoadingGisViewerApplicationURLCache.getCache().get(scope);
|
||||
//CHECKING IF THE GisViewer Portlet URL is valid
|
||||
if(gisViewerPortletUrl==null || gisViewerPortletUrl.isEmpty())
|
||||
ExceptionManager.notFoundException(req, "GisViewer Portlet URL not found in the scope: "+scope +". Please contact the support", this.getClass(), help);
|
||||
throw 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);
|
||||
gisViewerPortletUrl+="?rid="+new Random().nextLong()
|
||||
|
@ -140,7 +147,7 @@ public class GisResolver {
|
|||
String geoExplorerPortletUrl = LoadingGeoExplorerApplicationURLCache.getCache().get(scope);
|
||||
//CHECKING IF THE GeoExplorer Portlet URL is valid
|
||||
if(geoExplorerPortletUrl==null || geoExplorerPortletUrl.isEmpty())
|
||||
ExceptionManager.notFoundException(req, "GeoExplorer Portlet URL not found in the scope: "+scope +". Please contact the support", this.getClass(), help);
|
||||
throw 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);
|
||||
geoExplorerPortletUrl+="?rid="+new Random().nextLong()
|
||||
|
@ -149,18 +156,22 @@ public class GisResolver {
|
|||
return Response.seeOther(new URI(geoExplorerPortletUrl)).build();
|
||||
}catch (InvalidCacheLoadException e) {
|
||||
logger.error("Error on getting GeoExplorer Portlet URL for scope: "+scope, e);
|
||||
//ExceptionManager.throwNotFoundException(req, "GeoExplorer Portlet URL not found in the scope: "+scope +". Please add it or contact the support", this.getClass(), help);
|
||||
throw ExceptionManager.notFoundException(req, "GeoExplorer Portlet URL not found in the scope: "+scope +". Please add it or contact the support", 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;
|
||||
throw ExceptionManager.badRequestException(req, GIS_UUID+" or "+GEO_EXPLORER_LAYER_UUID+" not found or empty in the query string", this.getClass(), help);
|
||||
|
||||
}catch (Exception e) {
|
||||
|
||||
if(!(e instanceof WebApplicationException)){
|
||||
//UNEXPECTED EXCEPTION managing it as WebApplicationException
|
||||
String error = "Sorry, an error occurred on resolving request with UUID "+gisUUID+" and scope "+scope+". Please, contact support!"+"\n Cause: "+e.getCause().getMessage();
|
||||
throw ExceptionManager.internalErrorException(req, error, this.getClass(), help);
|
||||
}
|
||||
//ALREADY MANAGED AS WebApplicationException
|
||||
logger.error("Exception:", e);
|
||||
String error = "Sorry, an error occurred on resolving request with UUID "+gisUUID+" and scope "+scope+". Please, contact support!";
|
||||
ExceptionManager.internalErrorException(req, error, this.getClass(), help);
|
||||
return null;
|
||||
throw (WebApplicationException) e;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -79,8 +79,7 @@ public class PartheosRegistryResolver {
|
|||
}catch (Exception e) {
|
||||
logger.error("Exception:", e);
|
||||
String error = "Error occurred on resolving the path "+remainPathParthenosURL+". Please, contact the support!";
|
||||
ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI);
|
||||
return null;
|
||||
throw ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue