Added classed to backward compatibility with the property URL_RESOLVER declared in the production CKanDataCatalogue endpoints [uri-resolver-hostname]/uri-resolver/catalogue
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-transfer/uri-resolver@178897 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
ccab9de9c2
commit
b75f9d5f90
|
@ -4,6 +4,9 @@
|
|||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||
<dependent-module archiveName="ckan-util-library-2.9.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/ckan-util-library-TRUNK/ckan-util-library-TRUNK">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<property name="context-root" value="uri-resolver"/>
|
||||
<property name="java-output-path" value="/uri-resolver/target/classes"/>
|
||||
</wb-module>
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.gcube.data.analysis.dminvocation.model.DataMinerInvocation;
|
|||
import org.gcube.datatransfer.resolver.init.UriResolverSmartGearManagerInit;
|
||||
import org.gcube.datatransfer.resolver.requesthandler.RequestHandler;
|
||||
import org.gcube.datatransfer.resolver.services.CatalogueResolver;
|
||||
import org.gcube.datatransfer.resolver.services.tobackward.BackCatalogueResolver;
|
||||
import org.gcube.smartgears.annotations.ManagedBy;
|
||||
import org.glassfish.jersey.server.ResourceConfig;
|
||||
|
||||
|
@ -15,7 +16,7 @@ public class UriResolver extends ResourceConfig {
|
|||
|
||||
public UriResolver() {
|
||||
// Register all resources present under the package.
|
||||
packages(CatalogueResolver.class.getPackage().getName(), RequestHandler.class.getPackage().getName());
|
||||
packages(CatalogueResolver.class.getPackage().getName(), RequestHandler.class.getPackage().getName(), BackCatalogueResolver.class.getPackage().getName());
|
||||
packages(DataMinerInvocation.class.getPackage().getName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ public class UriResolverServices {
|
|||
if(listResourcePath.isEmpty()){
|
||||
log.info("Reference to the List of Resources/Services is empty, creating it...");
|
||||
readResources(applicationClasses);
|
||||
log.info("Hard-Coding the resource/s: ");
|
||||
log.info("Hard-Coding the resource/s: "+ConstantsResolver.resourcesHardCoded);
|
||||
listResourcePath.addAll(Arrays.asList(ConstantsResolver.resourcesHardCoded));
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ import java.util.List;
|
|||
public enum ResourceCatalogueCodes {
|
||||
|
||||
CTLG("ctlg","dataset", "Catalogue Product/Dataset"),
|
||||
CTLGP("ctlg-p","product", "Catalogue Product"),
|
||||
//CTLGP("ctlg-p","product", "Catalogue Product"),
|
||||
CTLGD("ctlg-d","dataset", "Catalogue Dataset"),
|
||||
CTLGO("ctlg-o","organization", "Catalogue Organization"),
|
||||
CTLGG("ctlg-g","group", "Catalogue Group");
|
||||
|
|
|
@ -86,15 +86,39 @@ public class RequestHandler implements ContainerRequestFilter, ContainerResponse
|
|||
try {
|
||||
splittePath = path.split("/");
|
||||
if(splittePath!=null && splittePath.length>0) {
|
||||
String resourceName = splittePath[0];
|
||||
if(resourceName!=null && !resourceName.isEmpty()) {
|
||||
String requestedResourceName = splittePath[0];
|
||||
log.debug("The resource requested is: {}",requestedResourceName);
|
||||
|
||||
if(requestedResourceName!=null && !requestedResourceName.isEmpty()) {
|
||||
for (String resource : listOfPath) {
|
||||
if(resource.startsWith(resourceName)) {
|
||||
candidateResource = resourceName;
|
||||
log.trace("Is resource '{}' starting with '{}' ?",resource,requestedResourceName);
|
||||
if(resource.startsWith(requestedResourceName)) {
|
||||
log.trace("Yes it starts!");
|
||||
candidateResource = requestedResourceName;
|
||||
log.info("The candidate resource to manage the request is: {}",candidateResource);
|
||||
resourceToRedirectFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Try to manage as Catalogue Request ctlg, ctlg-p, etc.
|
||||
if(!resourceToRedirectFound) {
|
||||
log.info("Trying to manage as hard-coded case: {}", ConstantsResolver.resourcesHardCoded.toString());
|
||||
String[] hardCode = ConstantsResolver.resourcesHardCoded;
|
||||
|
||||
for (String resource : hardCode) {
|
||||
log.trace("Is requested resource '{}' starting with hard-coded resource '{}'?",requestedResourceName,resource);
|
||||
if(requestedResourceName.startsWith(resource)) {
|
||||
log.trace("Yes it starts!");
|
||||
candidateResource = resource;
|
||||
log.info("The candidate resource to manage the request is the hard-coded resource: {}",candidateResource);
|
||||
resourceToRedirectFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}else
|
||||
log.warn("It was not possible to get the resource name from the splitted path {}. No action performed", path);
|
||||
}else {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.datatransfer.resolver.services;
|
||||
package org.gcube.datatransfer.resolver.services.tobackward;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.ws.rs.Consumes;
|
||||
|
@ -11,6 +11,7 @@ import javax.ws.rs.core.MediaType;
|
|||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.gcube.datatransfer.resolver.catalogue.CatalogueRequest;
|
||||
import org.gcube.datatransfer.resolver.services.CatalogueResolver;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
package org.gcube.datatransfer.resolver.services.tobackward;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
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;
|
||||
|
||||
import org.gcube.datatransfer.resolver.catalogue.CatalogueRequest;
|
||||
import org.gcube.datatransfer.resolver.services.CatalogueResolver;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* The Class CatalogueResolver.
|
||||
*
|
||||
* To Backward compatibility
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
* Nov 16, 2018
|
||||
*/
|
||||
@Path("uri-resolver/catalogue")
|
||||
public class BackUriResolverCatalogueResolver {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(BackUriResolverCatalogueResolver.class);
|
||||
|
||||
@POST
|
||||
@Path("")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
public Response postCatalogue(@Context HttpServletRequest req, CatalogueRequest jsonRequest) throws WebApplicationException{
|
||||
logger.info(this.getClass().getSimpleName()+" POST starts...");
|
||||
return new CatalogueResolver().postCatalogue(req, jsonRequest);
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue