diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/SMPIDResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/SMPIDResolver.java index 75d9a48..3ab915c 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/SMPIDResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/SMPIDResolver.java @@ -56,7 +56,7 @@ public class SMPIDResolver { } } - return StorageManager.resolveStorageId(httpRequest, smpId, fileName, contentType, validation); + return StorageIDResolver.resolveStorageId(httpRequest, smpId, fileName, contentType, validation); } } diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/SMPResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/SMPResolver.java index 708160e..f11b80d 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/SMPResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/SMPResolver.java @@ -57,7 +57,7 @@ public class SMPResolver { } } - return StorageManager.resolveStorageId(httpRequest, smpURI, fileName, contentType, validation); + return StorageIDResolver.resolveStorageId(httpRequest, smpURI, fileName, contentType, validation); } } diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/StorageManager.java b/src/main/java/org/gcube/datatransfer/resolver/services/StorageIDResolver.java similarity index 92% rename from src/main/java/org/gcube/datatransfer/resolver/services/StorageManager.java rename to src/main/java/org/gcube/datatransfer/resolver/services/StorageIDResolver.java index bd7e0e5..7cccead 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/StorageManager.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/StorageIDResolver.java @@ -37,7 +37,7 @@ import org.slf4j.LoggerFactory; * Oct 19, 2018 */ @Path("/") -public class StorageManager { +public class StorageIDResolver { /** * @@ -45,7 +45,7 @@ public class StorageManager { protected static final String STORAGEID_RESOLVER = "storageid-resolver"; private static final String STORAGE_ID = "storage-id"; - private static Logger logger = LoggerFactory.getLogger(StorageManager.class); + private static Logger logger = LoggerFactory.getLogger(StorageIDResolver.class); private static String help = "https://wiki.gcube-system.org/gcube/URI_Resolver#STORAGE-ID_Resolver"; @@ -68,7 +68,7 @@ public class StorageManager { if(storageId==null || storageId.isEmpty()){ logger.error(STORAGE_ID+" not found"); try { - throw new BadRequestException(httpRequest, Status.NOT_ACCEPTABLE, "Missing mandatory path parameter "+STORAGE_ID, StorageManager.class, new URI(help)); + throw new BadRequestException(httpRequest, Status.NOT_ACCEPTABLE, "Missing mandatory path parameter "+STORAGE_ID, StorageIDResolver.class, new URI(help)); } catch (URISyntaxException e) { //silent @@ -96,7 +96,7 @@ public class StorageManager { if (storageId == null || storageId.isEmpty()) { logger.warn("storageId not found"); try { - throw new BadRequestException(httpRequest, Status.NOT_ACCEPTABLE, "Missing mandatory path parameter "+STORAGE_ID, StorageManager.class, new URI(help)); + throw new BadRequestException(httpRequest, Status.NOT_ACCEPTABLE, "Missing mandatory path parameter "+STORAGE_ID, StorageIDResolver.class, new URI(help)); } catch (URISyntaxException e) { //silent @@ -119,7 +119,7 @@ public class StorageManager { }catch(Exception e){ logger.error("Storage Client Exception when getting file from storage: ", e); try { - throw new InternalServerException(httpRequest, Status.INTERNAL_SERVER_ERROR, "Storage Client Exception when getting file from storage with id: "+storageId, StorageManager.class, new URI(help)); + throw new InternalServerException(httpRequest, Status.INTERNAL_SERVER_ERROR, "Storage Client Exception when getting file from storage with id: "+storageId, StorageIDResolver.class, new URI(help)); } catch (URISyntaxException e1) { //silent @@ -129,7 +129,7 @@ public class StorageManager { if(toSEID==null || toSEID.isEmpty()){ logger.error("Decrypted id for storageId: "+storageId +" is null or empty!"); try { - throw new WrongParameterException(httpRequest, Status.BAD_REQUEST, "Error on decrypting the "+STORAGE_ID+ " '"+storageId+"'. Is it a valid id?", StorageManager.class, new URI(help)); + throw new WrongParameterException(httpRequest, Status.BAD_REQUEST, "Error on decrypting the "+STORAGE_ID+ " '"+storageId+"'. Is it a valid id?", StorageIDResolver.class, new URI(help)); } catch (URISyntaxException e) { //silent @@ -268,9 +268,9 @@ public class StorageManager { StorageClient client; if(memory==null) - client=new StorageClient(StorageManager.class.getName(), StorageManager.class.getSimpleName(), STORAGEID_RESOLVER, AccessType.PUBLIC); + client=new StorageClient(StorageIDResolver.class.getName(), StorageIDResolver.class.getSimpleName(), STORAGEID_RESOLVER, AccessType.PUBLIC); else - client=new StorageClient(StorageManager.class.getName(), StorageManager.class.getSimpleName(), STORAGEID_RESOLVER, AccessType.PUBLIC, memory); + client=new StorageClient(StorageIDResolver.class.getName(), StorageIDResolver.class.getSimpleName(), STORAGEID_RESOLVER, AccessType.PUBLIC, memory); return client; } diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverInfo.java b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverInfo.java new file mode 100644 index 0000000..f78b060 --- /dev/null +++ b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverInfo.java @@ -0,0 +1,32 @@ +/** + * + */ +package org.gcube.datatransfer.resolver.services; + +import java.net.URI; +import java.net.URISyntaxException; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.Response; + + +/** + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Oct 22, 2018 + */ +@Path("/") +public class UriResolverInfo { + + @GET + @Path("info") + public Response getInfo(){ + try{ + return Response.seeOther(new URI("index.jsp")).build(); + }catch(URISyntaxException e){ + throw new WebApplicationException("Impossible to get URI Resolver Info"); + } + } +}