Added ConstantsResolver.SCOPE_SEPARATOR as '/' and bug fixing

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-transfer/uri-resolver@179454 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2019-05-16 12:56:48 +00:00
parent 3491fa0bc6
commit 7ab9bfe155
2 changed files with 10 additions and 6 deletions

View File

@ -28,4 +28,6 @@ public class ConstantsResolver {
//The default resource candidate to manage the input requests not matching any resolver services
public static final String defaultServiceToRedirect= "storage";
public static final String SCOPE_SEPARATOR = "/";
}

View File

@ -19,6 +19,7 @@ import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.scope.impl.ScopeBean;
import org.gcube.common.scope.impl.ScopeBean.Type;
import org.gcube.datatransfer.resolver.caches.LoadingMapOfScopeCache;
import org.gcube.datatransfer.resolver.ConstantsResolver;
import org.gcube.datatransfer.resolver.catalogue.CatalogueRequest;
import org.gcube.datatransfer.resolver.catalogue.ItemCatalogueURLs;
import org.gcube.datatransfer.resolver.catalogue.ResourceCatalogueCodes;
@ -44,6 +45,7 @@ import eu.trentorise.opendata.jackan.model.CkanDataset;
@Path("{entityContext:ctlg(-(o|g|p|d))?}")
public class CatalogueResolver {
private static Logger logger = LoggerFactory.getLogger(CatalogueResolver.class);
private static String helpURI = "https://wiki.gcube-system.org/gcube/URI_Resolver#CATALOGUE_Resolver";
@ -116,14 +118,14 @@ public class CatalogueResolver {
//CHECK IF INPUT SCOPE IS VALID
String scope = jsonRequest.getGcube_scope();
if(!scope.startsWith("/")){
logger.info("Scope not start with char '/' adding it");
scope+="/"+scope;
if(!scope.startsWith(ConstantsResolver.SCOPE_SEPARATOR)){
logger.info("Scope not start with char '{}' adding it",ConstantsResolver.SCOPE_SEPARATOR);
scope+=ConstantsResolver.SCOPE_SEPARATOR+scope;
}
String serverUrl = Util.getServerURL(req);
final String vreName = scope.substring(scope.lastIndexOf("/")+1, scope.length());
final String vreName = scope.substring(scope.lastIndexOf(ConstantsResolver.SCOPE_SEPARATOR)+1, scope.length());
ScopeBean fullScope = null;
//CHECK IF THE vreName has a valid scope, so it is a valid VRE
@ -188,8 +190,8 @@ public class CatalogueResolver {
if(scopeBean.is(Type.VO)) {
logger.info("It is a {} scope", Type.VO);
logger.warn("The Catalogue can't work at {} level, I'm overriding the scope to {} level", Type.VO, Type.INFRASTRUCTURE);
String[] splitScope = fullScope.split("/");
fullScope = splitScope[1]; //THIS IS THE INFRASTRUCTURE SCOPE
String[] splitScope = fullScope.split(ConstantsResolver.SCOPE_SEPARATOR);
fullScope = ConstantsResolver.SCOPE_SEPARATOR+splitScope[1]; //THIS IS THE INFRASTRUCTURE SCOPE
logger.info("Overriden the input scope {} with {} as type: {}", fullScope, Type.INFRASTRUCTURE, fullScope);
}