60 lines
1.8 KiB
Java
60 lines
1.8 KiB
Java
/**
|
|
*
|
|
*/
|
|
package org.gcube.datatransfer.resolver.services;
|
|
|
|
import javax.annotation.Nullable;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.ws.rs.GET;
|
|
import javax.ws.rs.Path;
|
|
import javax.ws.rs.QueryParam;
|
|
import javax.ws.rs.core.Context;
|
|
import javax.ws.rs.core.Response;
|
|
|
|
import org.gcube.datatransfer.resolver.ConstantsResolver;
|
|
import org.gcube.datatransfer.resolver.services.error.ExceptionManager;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
/**
|
|
*
|
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
|
* Oct 22, 2018
|
|
*/
|
|
@Path("/")
|
|
public class SMPIDResolver {
|
|
|
|
/**
|
|
*
|
|
*/
|
|
private static final String help = "https://wiki.gcube-system.org/gcube/URI_Resolver#SMP-ID_Resolver";
|
|
|
|
private static final String SMP_ID = "smp-id";
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(SMPIDResolver.class);
|
|
/**
|
|
* Gets the smpid.
|
|
*
|
|
* @param smpId the smp id
|
|
* @param fileName the file name
|
|
* @param contentType the content type
|
|
* @param validation the validation
|
|
* @return the smpid
|
|
*/
|
|
@GET
|
|
@Path("id")
|
|
public Response getSMPID(@Context HttpServletRequest httpRequest, @QueryParam(SMP_ID) @Nullable String smpId, @QueryParam(ConstantsResolver.QUERY_PARAM_FILE_NAME) String fileName, @QueryParam(ConstantsResolver.QUERY_PARAM_CONTENT_TYPE) String contentType, @QueryParam(ConstantsResolver.QUERY_PARAM_VALIDATION) Boolean validation){
|
|
logger.info(this.getClass().getSimpleName()+" GET starts...");
|
|
|
|
//Checking mandatory parameter smpId
|
|
if(smpId==null || smpId.isEmpty()){
|
|
logger.error(SMP_ID+" not found");
|
|
ExceptionManager.throwBadRequestException(httpRequest, "Missing mandatory parameter "+SMP_ID, SMPIDResolver.class, help);
|
|
}
|
|
|
|
return StorageIDResolver.resolveStorageId(httpRequest, smpId, fileName, contentType, validation);
|
|
|
|
}
|
|
}
|