added UriResolverInfo and refactor
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-transfer/uri-resolver@173750 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
437c706cc1
commit
88e87cfe43
|
@ -56,7 +56,7 @@ public class SMPIDResolver {
|
|||
}
|
||||
}
|
||||
|
||||
return StorageManager.resolveStorageId(httpRequest, smpId, fileName, contentType, validation);
|
||||
return StorageIDResolver.resolveStorageId(httpRequest, smpId, fileName, contentType, validation);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class SMPResolver {
|
|||
}
|
||||
}
|
||||
|
||||
return StorageManager.resolveStorageId(httpRequest, smpURI, fileName, contentType, validation);
|
||||
return StorageIDResolver.resolveStorageId(httpRequest, smpURI, fileName, contentType, validation);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue