updated filter for Catalogue Resolver

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-transfer/uri-resolver@141280 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2016-12-20 15:29:50 +00:00
parent 4683ebb9f5
commit cf206452a0
1 changed files with 27 additions and 23 deletions

View File

@ -95,32 +95,36 @@ public class UriResolverRewriteFilter implements Filter{
//String vreName = requestURI.substring(beginIndex)
HttpServletRequest request = (HttpServletRequest) req;
logger.debug("method is: "+request.getMethod());
String[] pathSplit = multiReadRequest.getServletPath().split(PATH_SEPARATOR);
String newURI = SERVLET_CATALOGUE;
if(pathSplit.length==5){
logger.info("Resolving a clear URL to catalogue...");
logger.debug("found VRE name: "+pathSplit[2]);
String gcubeScope = CatalogueRequestParameter.GCUBE_SCOPE.getKey() +"="+pathSplit[2];
String eC = CatalogueRequestParameter.ENTITY_CONTEXT.getKey() +"="+pathSplit[3];
logger.debug("found context name: "+eC);
String eN = CatalogueRequestParameter.ENTITY_NAME.getKey() +"="+pathSplit[4];
logger.debug("found entity name: "+eN);
String encodedQuery = UrlEncoderUtil.encodeQuery(gcubeScope,eC,eN);
if(request.getMethod().compareTo("GET")==0)
newURI+= "?" + PARAMETER_DIRECT_CATALOGUE_LINK + "=" + encodedQuery;
}else{
logger.info("Resolving an encrypted URL to catalogue...");
int lastSlash = requestURI.lastIndexOf(PATH_SEPARATOR);
String toCatalogueLink = requestURI.substring(lastSlash + 1, requestURI.length());
if(request.getMethod().compareTo("GET")==0)
newURI+= "?" + PARAMETER_ENC_CATALOGUE_LINK + "=" + toCatalogueLink;
if(request.getMethod().compareTo("POST")==0){
logger.debug("is POST request...");
logger.debug("forward to: " + SERVLET_CATALOGUE);
multiReadRequest.getRequestDispatcher(SERVLET_CATALOGUE).forward(multiReadRequest, response);
}
else{
logger.debug("is GET request...");
String[] pathSplit = multiReadRequest.getServletPath().split(PATH_SEPARATOR);
String newURI = SERVLET_CATALOGUE;
if(pathSplit.length==5){
logger.info("Resolving a clear URL to catalogue...");
logger.debug("found VRE name: "+pathSplit[2]);
String gcubeScope = CatalogueRequestParameter.GCUBE_SCOPE.getKey() +"="+pathSplit[2];
String eC = CatalogueRequestParameter.ENTITY_CONTEXT.getKey() +"="+pathSplit[3];
logger.debug("found context name: "+eC);
String eN = CatalogueRequestParameter.ENTITY_NAME.getKey() +"="+pathSplit[4];
logger.debug("found entity name: "+eN);
String encodedQuery = UrlEncoderUtil.encodeQuery(gcubeScope,eC,eN);
newURI+= "?" + PARAMETER_DIRECT_CATALOGUE_LINK + "=" + encodedQuery;
}else{
logger.info("Resolving an encrypted URL to catalogue...");
int lastSlash = requestURI.lastIndexOf(PATH_SEPARATOR);
String toCatalogueLink = requestURI.substring(lastSlash + 1, requestURI.length());
newURI+= "?" + PARAMETER_ENC_CATALOGUE_LINK + "=" + toCatalogueLink;
}
logger.debug("forward to: " + newURI);
multiReadRequest.getRequestDispatcher(newURI).forward(multiReadRequest, response);
logger.debug("forward to: " + newURI);
multiReadRequest.getRequestDispatcher(newURI).forward(multiReadRequest, response);
}
//chain.doFilter(multiReadRequest, response);
}else{