diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/StorageManager.java b/src/main/java/org/gcube/datatransfer/resolver/services/StorageManager.java index e945db9..9f87008 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/StorageManager.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/StorageManager.java @@ -1,24 +1,18 @@ package org.gcube.datatransfer.resolver.services; -import java.io.IOException; import java.io.InputStream; import javax.annotation.Nullable; -import javax.servlet.ServletException; import javax.ws.rs.GET; -import javax.ws.rs.HEAD; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.QueryParam; import javax.ws.rs.WebApplicationException; -import javax.ws.rs.client.Entity; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.ResponseBuilder; import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.StreamingOutput; -import org.apache.commons.io.IOUtils; -import org.apache.http.HttpStatus; import org.gcube.contentmanagement.blobstorage.resource.MyFile; import org.gcube.contentmanagement.blobstorage.service.IClient; import org.gcube.contentmanager.storageclient.wrapper.AccessType; @@ -97,10 +91,10 @@ public class StorageManager { //Checking mandatory parameter smpId if(smpId==null || smpId.isEmpty()){ logger.error(SMP_ID+" not found"); - return Response.status(400).entity(Entity.text("Missing mandatory parameter "+SMP_ID)).build(); + //return Response.status(400).entity(Entity.text("Missing mandatory parameter "+SMP_ID)).build(); + throw new WebApplicationException("Missing mandatory parameter "+SMP_ID, Status.BAD_REQUEST); } - logger.warn("Sono qui getSMPID"); return getStorageId(smpId, fileName, contentType, validation); } @@ -127,8 +121,10 @@ public class StorageManager { throw new WebApplicationException("Missing mandatory parameter "+STORAGE_ID, Status.BAD_REQUEST); } + /* if(validation!=null && validation) return validationPayload(storageId); + */ StorageClient client = getStorageClientInstance(storageId); String toSEID = null; @@ -154,7 +150,9 @@ public class StorageManager { MyFile file = iClient.getMetaFile().RFile(toSEID); logger.debug("MetaFile retrieved from storage? "+ (file!=null)); - fileName= file.getName(); + //Reading the fileName from Storage Metadata only if the passed fileName is null + if(fileName==null || fileName.isEmpty()) + fileName= file.getName(); //Reading the contentType from Storage Metadata only if the passed contentType is null if(contentType==null || contentType.isEmpty()) @@ -193,7 +191,7 @@ public class StorageManager { * @throws ServletException the servlet exception * @throws IOException Signals that an I/O exception has occurred. */ - @HEAD + /*@HEAD @Path("{storage-id}") public Response httpDoHead(@PathParam(STORAGE_ID) String storageId, @QueryParam(HPROXYCHECK) Boolean hproxycheck) throws ServletException, IOException { logger.info("doHead working.."); @@ -206,7 +204,7 @@ public class StorageManager { } return validationPayload(storageId); - } + }*/ /** @@ -215,7 +213,7 @@ public class StorageManager { * @param storageId the storage id * @return the response */ - protected Response validationPayload(String storageId){ + /*protected Response validationPayload(String storageId){ //Checking to STORAGE-ID Resolver if (storageId == null || storageId.isEmpty()) { @@ -261,7 +259,7 @@ public class StorageManager { throw new WebApplicationException("Error on validating the file with id: "+storageId, Status.INTERNAL_SERVER_ERROR); } - } + }*/ /**