updated init and refactoring performed
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-transfer/uri-resolver@173963 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
04d897ee7c
commit
6a557f5a03
|
@ -1,242 +1,242 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.datatransfer.resolver;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
import org.gcube.datatransfer.resolver.GeonetworkRequestFilterParameters.MODE;
|
||||
import org.gcube.datatransfer.resolver.GeonetworkRequestFilterParameters.VISIBILITY;
|
||||
import org.gcube.datatransfer.resolver.gis.geonetwork.GeonetworkResolver;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
/**
|
||||
* The Class GeonetworkRequestDecoder.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Jul 27, 2016
|
||||
*
|
||||
* This class parses a request from servletpath and queryString
|
||||
*
|
||||
* The request must be: SCOPE#PARMETERS
|
||||
* SCOPE must be: separated by {@link GeonetworkRequestDecoder#SCOPE_SEPARATOR}
|
||||
* PARAMETERS can be:
|
||||
* {@link GeonetworkResolver#PARAMETER_FILTER_PUBLIC_IDS}
|
||||
* {@link GeonetworkResolver#PARAMETER_NO_AUTHENTICATION}
|
||||
*/
|
||||
public class GeonetworkRequestDecoder {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final String SCOPE_SEPARATOR = "|";
|
||||
|
||||
public static final Logger logger = LoggerFactory.getLogger(GeonetworkRequestDecoder.class);
|
||||
|
||||
private String gnResolverUriRequest;
|
||||
|
||||
private GeonetworkRequestCriteria geonetworkRequestCriteria;
|
||||
|
||||
/**
|
||||
* Instantiates a new geonetwork request decoder.
|
||||
*
|
||||
* @param theServletPath the the servlet path
|
||||
* @param queryString the query string
|
||||
* @throws ServletException the servlet exception
|
||||
*/
|
||||
public GeonetworkRequestDecoder(String theServletPath, String queryString) throws ServletException{
|
||||
|
||||
int index = theServletPath.indexOf(GeonetworkRequestFilterParameters.REQUEST_DELIMITIER);
|
||||
|
||||
if(index==-1)
|
||||
throw new BadRequestException("Invalid request. Your request must append the '"+GeonetworkRequestFilterParameters.REQUEST_DELIMITIER+"' as final delimiter");
|
||||
|
||||
int delimiterIndex = index+GeonetworkRequestFilterParameters.REQUEST_DELIMITIER.length();
|
||||
|
||||
String pathWithoutGN = theServletPath.substring(UriResolverRewriteFilter.SERVLET_GEONETWORK.length()+1, index);
|
||||
logger.debug("servlet path without "+UriResolverRewriteFilter.SERVLET_GEONETWORK + " is: " +pathWithoutGN);
|
||||
geonetworkRequestCriteria = getGeonetworkRequestCriteria(pathWithoutGN);
|
||||
logger.info("performing query by filters: "+geonetworkRequestCriteria);
|
||||
logger.debug("scope value is: "+geonetworkRequestCriteria.getScope());
|
||||
//newURI = UriResolverRewriteFilter.SERVLET_GEONETWORK + "?" + GeonetworkResolver.SCOPE + "=" + geonetworkRequestCriteria.getScope() +"&"+ GeonetworkResolver.PARAMETER_FILTER_PUBLIC_IDS +"="+geonetworkRequestCriteria.isValueOfFilterPublicIds() +"&"+GeonetworkResolver.PARAMETER_NO_AUTHENTICATION+"="+geonetworkRequestCriteria.isNoAuthOnGeonetwork();
|
||||
|
||||
gnResolverUriRequest = UriResolverRewriteFilter.SERVLET_GEONETWORK + "?"
|
||||
+ GeonetworkResolver.SCOPE + "=" + geonetworkRequestCriteria.getScope() +"&"
|
||||
+ GeonetworkRequestFilterParameters.MODE.class.getSimpleName() +"="+geonetworkRequestCriteria.getMode() +"&"
|
||||
+ GeonetworkRequestFilterParameters.VISIBILITY.class.getSimpleName()+"="+geonetworkRequestCriteria.getVisibility();
|
||||
|
||||
if(geonetworkRequestCriteria.getOwner()!=null){
|
||||
gnResolverUriRequest+="&"+GeonetworkRequestFilterParameters.OWNER_PARAM +"="+geonetworkRequestCriteria.getOwner();
|
||||
}
|
||||
|
||||
//BUILDING REMAINING PATH WITHOUT GeonetworkRequestFilterParameters.REQUEST_DELIMITIER
|
||||
if(delimiterIndex<theServletPath.length()){
|
||||
String remainPath = theServletPath.substring(delimiterIndex, theServletPath.length());
|
||||
gnResolverUriRequest +="&"+GeonetworkResolver.REMAIN_PATH_PARAM+"="+remainPath;
|
||||
}
|
||||
|
||||
if(queryString!=null && !queryString.isEmpty())
|
||||
gnResolverUriRequest+="&"+queryString;
|
||||
|
||||
logger.info("built Geonetwork Resolver GET Request: "+gnResolverUriRequest);
|
||||
/*
|
||||
String[] params = pathWithoutGN.split("/");
|
||||
if(params[0]==null || params[0].isEmpty()){
|
||||
logger.error("Scope is null or empty, you must set a valid scope /geonetwork/root|vo|vre");
|
||||
throw new ServletException("Scope is null or empty, you must set a valid scope /geonetwork/root"+SCOPE_SEPARATOR+"vo"+SCOPE_SEPARATOR+"vre");
|
||||
}
|
||||
|
||||
geonetworkRequestCriteria = getGeonetworkRequestCriteria(params[0]);
|
||||
logger.debug("scope value is: "+geonetworkRequestCriteria.getScope());
|
||||
newURI = UriResolverRewriteFilter.SERVLET_GEONETWORK + "?" + GeonetworkResolver.SCOPE + "=" + geonetworkRequestCriteria.getScope() +"&"+ GeonetworkResolver.PARAMETER_FILTER_PUBLIC_IDS +"="+geonetworkRequestCriteria.isValueOfFilterPublicIds() +"&"+GeonetworkResolver.PARAMETER_NO_AUTHENTICATION+"="+geonetworkRequestCriteria.isNoAuthOnGeonetwork();
|
||||
logger.debug(GeonetworkResolver.PARAMETER_FILTER_PUBLIC_IDS +" is: "+geonetworkRequestCriteria.isValueOfFilterPublicIds());
|
||||
logger.debug(GeonetworkResolver.PARAMETER_NO_AUTHENTICATION +" is: "+geonetworkRequestCriteria.isNoAuthOnGeonetwork());
|
||||
*/
|
||||
// if(params.length>1){
|
||||
// String remainPath = "";
|
||||
//// newURI +="&remainPath=";
|
||||
// for (int i = 1; i < params.length; i++) {
|
||||
// String httpGetParam = params[i];
|
||||
// if(httpGetParam!=null && !httpGetParam.isEmpty())
|
||||
// remainPath+="/"+httpGetParam;
|
||||
// }
|
||||
// newURI +="&"+GeonetworkResolver.REMAIN_PATH+"="+remainPath;
|
||||
///**
|
||||
// *
|
||||
// */
|
||||
//package org.gcube.datatransfer.resolver;
|
||||
//
|
||||
//import javax.servlet.ServletException;
|
||||
//
|
||||
//import org.gcube.datatransfer.resolver.GeonetworkRequestFilterParameters.MODE;
|
||||
//import org.gcube.datatransfer.resolver.GeonetworkRequestFilterParameters.VISIBILITY;
|
||||
//import org.gcube.datatransfer.resolver.gis.geonetwork.GeonetworkResolver;
|
||||
//import org.slf4j.Logger;
|
||||
//import org.slf4j.LoggerFactory;
|
||||
//
|
||||
//
|
||||
///**
|
||||
// * The Class GeonetworkRequestDecoder.
|
||||
// *
|
||||
// * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
// * Jul 27, 2016
|
||||
// *
|
||||
// * This class parses a request from servletpath and queryString
|
||||
// *
|
||||
// * The request must be: SCOPE#PARMETERS
|
||||
// * SCOPE must be: separated by {@link GeonetworkRequestDecoder#SCOPE_SEPARATOR}
|
||||
// * PARAMETERS can be:
|
||||
// * {@link GeonetworkResolver#PARAMETER_FILTER_PUBLIC_IDS}
|
||||
// * {@link GeonetworkResolver#PARAMETER_NO_AUTHENTICATION}
|
||||
// */
|
||||
//public class GeonetworkRequestDecoder {
|
||||
//
|
||||
// /**
|
||||
// *
|
||||
// */
|
||||
// public static final String SCOPE_SEPARATOR = "|";
|
||||
//
|
||||
// public static final Logger logger = LoggerFactory.getLogger(GeonetworkRequestDecoder.class);
|
||||
//
|
||||
// private String gnResolverUriRequest;
|
||||
//
|
||||
// private GeonetworkRequestCriteria geonetworkRequestCriteria;
|
||||
//
|
||||
// /**
|
||||
// * Instantiates a new geonetwork request decoder.
|
||||
// *
|
||||
// * @param theServletPath the the servlet path
|
||||
// * @param queryString the query string
|
||||
// * @throws ServletException the servlet exception
|
||||
// */
|
||||
// public GeonetworkRequestDecoder(String theServletPath, String queryString) throws ServletException{
|
||||
//
|
||||
// int index = theServletPath.indexOf(GeonetworkRequestFilterParameters.REQUEST_DELIMITIER);
|
||||
//
|
||||
// if(index==-1)
|
||||
// throw new BadRequestException("Invalid request. Your request must append the '"+GeonetworkRequestFilterParameters.REQUEST_DELIMITIER+"' as final delimiter");
|
||||
//
|
||||
// int delimiterIndex = index+GeonetworkRequestFilterParameters.REQUEST_DELIMITIER.length();
|
||||
//
|
||||
// String pathWithoutGN = theServletPath.substring(UriResolverRewriteFilter.SERVLET_GEONETWORK.length()+1, index);
|
||||
// logger.debug("servlet path without "+UriResolverRewriteFilter.SERVLET_GEONETWORK + " is: " +pathWithoutGN);
|
||||
// geonetworkRequestCriteria = getGeonetworkRequestCriteria(pathWithoutGN);
|
||||
// logger.info("performing query by filters: "+geonetworkRequestCriteria);
|
||||
// logger.debug("scope value is: "+geonetworkRequestCriteria.getScope());
|
||||
// //newURI = UriResolverRewriteFilter.SERVLET_GEONETWORK + "?" + GeonetworkResolver.SCOPE + "=" + geonetworkRequestCriteria.getScope() +"&"+ GeonetworkResolver.PARAMETER_FILTER_PUBLIC_IDS +"="+geonetworkRequestCriteria.isValueOfFilterPublicIds() +"&"+GeonetworkResolver.PARAMETER_NO_AUTHENTICATION+"="+geonetworkRequestCriteria.isNoAuthOnGeonetwork();
|
||||
//
|
||||
// gnResolverUriRequest = UriResolverRewriteFilter.SERVLET_GEONETWORK + "?"
|
||||
// + GeonetworkResolver.SCOPE + "=" + geonetworkRequestCriteria.getScope() +"&"
|
||||
// + GeonetworkRequestFilterParameters.MODE.class.getSimpleName() +"="+geonetworkRequestCriteria.getMode() +"&"
|
||||
// + GeonetworkRequestFilterParameters.VISIBILITY.class.getSimpleName()+"="+geonetworkRequestCriteria.getVisibility();
|
||||
//
|
||||
// if(geonetworkRequestCriteria.getOwner()!=null){
|
||||
// gnResolverUriRequest+="&"+GeonetworkRequestFilterParameters.OWNER_PARAM +"="+geonetworkRequestCriteria.getOwner();
|
||||
// }
|
||||
//
|
||||
// //BUILDING REMAINING PATH WITHOUT GeonetworkRequestFilterParameters.REQUEST_DELIMITIER
|
||||
// if(delimiterIndex<theServletPath.length()){
|
||||
// String remainPath = theServletPath.substring(delimiterIndex, theServletPath.length());
|
||||
// gnResolverUriRequest +="&"+GeonetworkResolver.REMAIN_PATH_PARAM+"="+remainPath;
|
||||
// }
|
||||
//
|
||||
// if(queryString!=null && !queryString.isEmpty())
|
||||
// newURI+="&"+queryString;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the geonetwork request criteria.
|
||||
|
||||
* Creates a request criteria from input parameter pathWithoutGN
|
||||
* The parameter pathWithoutGN should be an ordered string (like REST request):
|
||||
* MODE/SCOPE/VISIBILITY/OWNER
|
||||
* MODE must be: {@link MODE}
|
||||
* SCOPE must be: ROOT|VO|VRE
|
||||
* VISIBILITY must be: {@link VISIBILITY}
|
||||
* OWNER (is optional): filter by owner
|
||||
* @param pathWithoutGN the path without Geonetwork base URL
|
||||
*
|
||||
* @return the geonetwork request criteria
|
||||
* @throws ServletException the servlet exception
|
||||
*/
|
||||
private static GeonetworkRequestCriteria getGeonetworkRequestCriteria(String pathWithoutGN) throws ServletException{
|
||||
|
||||
String[] params = pathWithoutGN.split("/");
|
||||
MODE mode = null;
|
||||
String theScope = null;
|
||||
VISIBILITY visibility = null;
|
||||
String owner = null;
|
||||
|
||||
if(params.length < 3){
|
||||
throw new BadRequestException("Bad request. Read the request "+pathWithoutGN+". You must pass a valid request like [GEONETWORK_BASE_URL]/SCOPE/MODE/VISIBILITY/OWNER");
|
||||
}
|
||||
|
||||
//SCOPE
|
||||
if(params[0]!=null && !params[0].isEmpty()){
|
||||
theScope = params[0];
|
||||
logger.debug("Read parameter scope: "+theScope);
|
||||
theScope = theScope.replaceAll("\\"+SCOPE_SEPARATOR, "/");
|
||||
if (!theScope.startsWith("/"))
|
||||
theScope="/"+theScope;
|
||||
}else{
|
||||
logger.error("The first parameter 'scope' is null or empty, you must set a valid scope as ROOT"+SCOPE_SEPARATOR+"VO"+SCOPE_SEPARATOR+"VRE as first parameter");
|
||||
throw new ServletException("Scope is null or empty. You must pass a valid scope as ROOT"+SCOPE_SEPARATOR+"VO"+SCOPE_SEPARATOR+"VRE as first parameter");
|
||||
}
|
||||
|
||||
//MODE
|
||||
if(params[1]!=null && !params[1].isEmpty()){
|
||||
String modeTU = params[1].toUpperCase();
|
||||
logger.debug("Read parameter mode (to upper case): "+modeTU);
|
||||
try{
|
||||
mode = MODE.valueOf(modeTU);
|
||||
if(mode==null){
|
||||
logger.error("Mode is null");
|
||||
throw new Exception("Mode is null");
|
||||
}
|
||||
|
||||
logger.info("MODE IS: "+mode);
|
||||
|
||||
}catch (Exception e) {
|
||||
logger.error("The second parameter is wrong, Have you pass a valid parameter MODE like vre/harvest?");
|
||||
throw new BadRequestException("Bad parameter. You must set a valid MODE parameter as "+MODE.VRE + " or "+MODE.HARVEST+" as second parameter");
|
||||
}
|
||||
}else
|
||||
throw new BadRequestException("The parameter MODE is null or empty. You must pass a valid MODE parameter as "+MODE.VRE + " or "+MODE.HARVEST +" as second parameter");
|
||||
|
||||
//VISIBILITY
|
||||
if(params[2]!=null && !params[2].isEmpty()){
|
||||
String visTU = params[2].toUpperCase();
|
||||
logger.debug("Read parameter mode (to upper case): "+visTU);
|
||||
try{
|
||||
visibility = VISIBILITY.valueOf(visTU);
|
||||
if(visibility==null){
|
||||
logger.error("VISIBILITY is null");
|
||||
throw new Exception("VISIBILITY is null");
|
||||
}
|
||||
|
||||
logger.info("VISIBILITY IS: "+visibility);
|
||||
|
||||
}catch (Exception e) {
|
||||
logger.error("The third parameter is wrong, Have you pass a valid parameter VISIBILITY like vre/harvest?");
|
||||
throw new BadRequestException("Bad parameter. You must set a valid VISIBILITY parameter as "+VISIBILITY.PRV + " or "+VISIBILITY.PUB+ " as third parameter");
|
||||
}
|
||||
}else
|
||||
throw new BadRequestException("The parameter VISIBILITY is null or empty. You must pass a valid VISIBILITY parameter as "+VISIBILITY.PRV + " or "+VISIBILITY.PUB +" as third parameter");
|
||||
|
||||
|
||||
//OWNER
|
||||
if(params.length > 3 && params[3]!=null && params[3]!=GeonetworkRequestFilterParameters.REQUEST_DELIMITIER){
|
||||
owner = params[3];
|
||||
logger.debug("Read parameter owner: "+owner);
|
||||
}
|
||||
|
||||
return new GeonetworkRequestCriteria(theScope, mode, owner, visibility);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the geonetwork resolver uri request.
|
||||
*
|
||||
* @return the geonetwork resolver uri request
|
||||
*/
|
||||
public String getGeonetworkResolverURIRequest() {
|
||||
|
||||
return gnResolverUriRequest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the geonetwork request criteria.
|
||||
*
|
||||
* @return the geonetworkRequestCriteria
|
||||
*/
|
||||
public GeonetworkRequestCriteria getGeonetworkRequestCriteria() {
|
||||
|
||||
return geonetworkRequestCriteria;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("GeonetworkRequestDecoder [gnResolverUriRequest=");
|
||||
builder.append(gnResolverUriRequest);
|
||||
builder.append(", geonetworkRequestCriteria=");
|
||||
builder.append(geonetworkRequestCriteria);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
// gnResolverUriRequest+="&"+queryString;
|
||||
//
|
||||
// logger.info("built Geonetwork Resolver GET Request: "+gnResolverUriRequest);
|
||||
// /*
|
||||
// String[] params = pathWithoutGN.split("/");
|
||||
// if(params[0]==null || params[0].isEmpty()){
|
||||
// logger.error("Scope is null or empty, you must set a valid scope /geonetwork/root|vo|vre");
|
||||
// throw new ServletException("Scope is null or empty, you must set a valid scope /geonetwork/root"+SCOPE_SEPARATOR+"vo"+SCOPE_SEPARATOR+"vre");
|
||||
// }
|
||||
//
|
||||
// geonetworkRequestCriteria = getGeonetworkRequestCriteria(params[0]);
|
||||
// logger.debug("scope value is: "+geonetworkRequestCriteria.getScope());
|
||||
// newURI = UriResolverRewriteFilter.SERVLET_GEONETWORK + "?" + GeonetworkResolver.SCOPE + "=" + geonetworkRequestCriteria.getScope() +"&"+ GeonetworkResolver.PARAMETER_FILTER_PUBLIC_IDS +"="+geonetworkRequestCriteria.isValueOfFilterPublicIds() +"&"+GeonetworkResolver.PARAMETER_NO_AUTHENTICATION+"="+geonetworkRequestCriteria.isNoAuthOnGeonetwork();
|
||||
// logger.debug(GeonetworkResolver.PARAMETER_FILTER_PUBLIC_IDS +" is: "+geonetworkRequestCriteria.isValueOfFilterPublicIds());
|
||||
// logger.debug(GeonetworkResolver.PARAMETER_NO_AUTHENTICATION +" is: "+geonetworkRequestCriteria.isNoAuthOnGeonetwork());
|
||||
// */
|
||||
//// if(params.length>1){
|
||||
//// String remainPath = "";
|
||||
////// newURI +="&remainPath=";
|
||||
//// for (int i = 1; i < params.length; i++) {
|
||||
//// String httpGetParam = params[i];
|
||||
//// if(httpGetParam!=null && !httpGetParam.isEmpty())
|
||||
//// remainPath+="/"+httpGetParam;
|
||||
//// }
|
||||
//// newURI +="&"+GeonetworkResolver.REMAIN_PATH+"="+remainPath;
|
||||
//// }
|
||||
////
|
||||
//// if(queryString!=null && !queryString.isEmpty())
|
||||
//// newURI+="&"+queryString;
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * Gets the geonetwork request criteria.
|
||||
//
|
||||
// * Creates a request criteria from input parameter pathWithoutGN
|
||||
// * The parameter pathWithoutGN should be an ordered string (like REST request):
|
||||
// * MODE/SCOPE/VISIBILITY/OWNER
|
||||
// * MODE must be: {@link MODE}
|
||||
// * SCOPE must be: ROOT|VO|VRE
|
||||
// * VISIBILITY must be: {@link VISIBILITY}
|
||||
// * OWNER (is optional): filter by owner
|
||||
// * @param pathWithoutGN the path without Geonetwork base URL
|
||||
// *
|
||||
// * @return the geonetwork request criteria
|
||||
// * @throws ServletException the servlet exception
|
||||
// */
|
||||
// private static GeonetworkRequestCriteria getGeonetworkRequestCriteria(String pathWithoutGN) throws ServletException{
|
||||
//
|
||||
// String[] params = pathWithoutGN.split("/");
|
||||
// MODE mode = null;
|
||||
// String theScope = null;
|
||||
// VISIBILITY visibility = null;
|
||||
// String owner = null;
|
||||
//
|
||||
// if(params.length < 3){
|
||||
// throw new BadRequestException("Bad request. Read the request "+pathWithoutGN+". You must pass a valid request like [GEONETWORK_BASE_URL]/SCOPE/MODE/VISIBILITY/OWNER");
|
||||
// }
|
||||
//
|
||||
// //SCOPE
|
||||
// if(params[0]!=null && !params[0].isEmpty()){
|
||||
// theScope = params[0];
|
||||
// logger.debug("Read parameter scope: "+theScope);
|
||||
// theScope = theScope.replaceAll("\\"+SCOPE_SEPARATOR, "/");
|
||||
// if (!theScope.startsWith("/"))
|
||||
// theScope="/"+theScope;
|
||||
// }else{
|
||||
// logger.error("The first parameter 'scope' is null or empty, you must set a valid scope as ROOT"+SCOPE_SEPARATOR+"VO"+SCOPE_SEPARATOR+"VRE as first parameter");
|
||||
// throw new ServletException("Scope is null or empty. You must pass a valid scope as ROOT"+SCOPE_SEPARATOR+"VO"+SCOPE_SEPARATOR+"VRE as first parameter");
|
||||
// }
|
||||
//
|
||||
// //MODE
|
||||
// if(params[1]!=null && !params[1].isEmpty()){
|
||||
// String modeTU = params[1].toUpperCase();
|
||||
// logger.debug("Read parameter mode (to upper case): "+modeTU);
|
||||
// try{
|
||||
// mode = MODE.valueOf(modeTU);
|
||||
// if(mode==null){
|
||||
// logger.error("Mode is null");
|
||||
// throw new Exception("Mode is null");
|
||||
// }
|
||||
//
|
||||
// logger.info("MODE IS: "+mode);
|
||||
//
|
||||
// }catch (Exception e) {
|
||||
// logger.error("The second parameter is wrong, Have you pass a valid parameter MODE like vre/harvest?");
|
||||
// throw new BadRequestException("Bad parameter. You must set a valid MODE parameter as "+MODE.VRE + " or "+MODE.HARVEST+" as second parameter");
|
||||
// }
|
||||
// }else
|
||||
// throw new BadRequestException("The parameter MODE is null or empty. You must pass a valid MODE parameter as "+MODE.VRE + " or "+MODE.HARVEST +" as second parameter");
|
||||
//
|
||||
// //VISIBILITY
|
||||
// if(params[2]!=null && !params[2].isEmpty()){
|
||||
// String visTU = params[2].toUpperCase();
|
||||
// logger.debug("Read parameter mode (to upper case): "+visTU);
|
||||
// try{
|
||||
// visibility = VISIBILITY.valueOf(visTU);
|
||||
// if(visibility==null){
|
||||
// logger.error("VISIBILITY is null");
|
||||
// throw new Exception("VISIBILITY is null");
|
||||
// }
|
||||
//
|
||||
// logger.info("VISIBILITY IS: "+visibility);
|
||||
//
|
||||
// }catch (Exception e) {
|
||||
// logger.error("The third parameter is wrong, Have you pass a valid parameter VISIBILITY like vre/harvest?");
|
||||
// throw new BadRequestException("Bad parameter. You must set a valid VISIBILITY parameter as "+VISIBILITY.PRV + " or "+VISIBILITY.PUB+ " as third parameter");
|
||||
// }
|
||||
// }else
|
||||
// throw new BadRequestException("The parameter VISIBILITY is null or empty. You must pass a valid VISIBILITY parameter as "+VISIBILITY.PRV + " or "+VISIBILITY.PUB +" as third parameter");
|
||||
//
|
||||
//
|
||||
// //OWNER
|
||||
// if(params.length > 3 && params[3]!=null && params[3]!=GeonetworkRequestFilterParameters.REQUEST_DELIMITIER){
|
||||
// owner = params[3];
|
||||
// logger.debug("Read parameter owner: "+owner);
|
||||
// }
|
||||
//
|
||||
// return new GeonetworkRequestCriteria(theScope, mode, owner, visibility);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * Gets the geonetwork resolver uri request.
|
||||
// *
|
||||
// * @return the geonetwork resolver uri request
|
||||
// */
|
||||
// public String getGeonetworkResolverURIRequest() {
|
||||
//
|
||||
// return gnResolverUriRequest;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Gets the geonetwork request criteria.
|
||||
// *
|
||||
// * @return the geonetworkRequestCriteria
|
||||
// */
|
||||
// public GeonetworkRequestCriteria getGeonetworkRequestCriteria() {
|
||||
//
|
||||
// return geonetworkRequestCriteria;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /* (non-Javadoc)
|
||||
// * @see java.lang.Object#toString()
|
||||
// */
|
||||
// @Override
|
||||
// public String toString() {
|
||||
//
|
||||
// StringBuilder builder = new StringBuilder();
|
||||
// builder.append("GeonetworkRequestDecoder [gnResolverUriRequest=");
|
||||
// builder.append(gnResolverUriRequest);
|
||||
// builder.append(", geonetworkRequestCriteria=");
|
||||
// builder.append(geonetworkRequestCriteria);
|
||||
// builder.append("]");
|
||||
// return builder.toString();
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//}
|
||||
|
|
|
@ -1,237 +1,237 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.datatransfer.resolver;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.FilterConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.gcube.datatransfer.resolver.catalogue.CatalogueRequestParameter;
|
||||
import org.gcube.datatransfer.resolver.catalogue.UrlEncoderUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The Class UriResolverRewriteFilter.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Dec 5, 2016
|
||||
*/
|
||||
public class UriResolverRewriteFilter implements Filter{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final String SERVLET_URI_RESOLVER = "/uri-resolver";
|
||||
|
||||
private static final String PATH_SEPARATOR = "/";
|
||||
public static final String SERVLET_GEONETWORK = "/geonetwork";
|
||||
public static final String REQUEST_PARAMETER_SEPARATOR = "#";
|
||||
|
||||
public static final String PARAMETER_SMP_ID = "smp-id";
|
||||
public static final String SERVLET_STORAGE_ID = "id";
|
||||
|
||||
public static final String PARAMETER_ENC_CATALOGUE_LINK = "cl";
|
||||
public static final String PARAMETER_DIRECT_CATALOGUE_LINK = "dl";
|
||||
public static final String SERVLET_CATALOGUE = "/catalogue";
|
||||
|
||||
protected static final Logger logger = LoggerFactory.getLogger(UriResolverRewriteFilter.class);
|
||||
private FilterConfig config;
|
||||
|
||||
private static final Set<String> resourceCataloguesCodes = new HashSet<String>(ResourceCatalogueCodes.codes());
|
||||
|
||||
//private ApplicationProfileReaderForCatalogueResolver appPrfCatResolver = new ApplicationProfileReaderForCatalogueResolver(scope, useRootScope)
|
||||
|
||||
/**
|
||||
* Gets the config.
|
||||
*
|
||||
* @return the config
|
||||
*/
|
||||
public FilterConfig getConfig() {
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see javax.servlet.Filter#destroy()
|
||||
*/
|
||||
@Override
|
||||
public void destroy() {
|
||||
logger.trace("run destroy");
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
|
||||
*/
|
||||
@Override
|
||||
public void doFilter(ServletRequest req, ServletResponse response, FilterChain chain) throws IOException, ServletException {
|
||||
/* wrap the request in order to read the inputstream multiple times */
|
||||
MultiReadHttpServletRequest multiReadRequest = new MultiReadHttpServletRequest((HttpServletRequest) req);
|
||||
String requestURI = multiReadRequest.getRequestURI();
|
||||
String queryString = multiReadRequest.getQueryString();
|
||||
String servletPath = multiReadRequest.getServletPath();
|
||||
logger.debug("Request URI: " + requestURI + ", QueryString: " +queryString+ ", Servlet path: "+servletPath);
|
||||
|
||||
try{
|
||||
//IS A REQUEST FOR GEONETWORK AUTHENTICATION? (CKAN HARVESTING?)
|
||||
if(servletPath.startsWith(SERVLET_GEONETWORK) || servletPath.startsWith(SERVLET_URI_RESOLVER+SERVLET_GEONETWORK)){
|
||||
logger.debug("It is a request to geonetwork");
|
||||
GeonetworkRequestDecoder grd = new GeonetworkRequestDecoder(servletPath, queryString);
|
||||
logger.debug("forward to: "+grd.getGeonetworkResolverURIRequest());
|
||||
multiReadRequest.getRequestDispatcher(grd.getGeonetworkResolverURIRequest()).forward(multiReadRequest, response);
|
||||
|
||||
}else{
|
||||
logger.debug("checking if it is a request to catologue...");
|
||||
boolean isCatalogueServletReference = servletPath.startsWith(SERVLET_CATALOGUE);
|
||||
|
||||
String idCodeCatalogue = null;
|
||||
boolean isIdCodeCatalogue = false;
|
||||
String splittedServletPath[] = servletPath.split(PATH_SEPARATOR);
|
||||
if(!isCatalogueServletReference){
|
||||
idCodeCatalogue = splittedServletPath[1];
|
||||
logger.trace("checking if the code: "+idCodeCatalogue+" belongs to a catalogue code");
|
||||
isIdCodeCatalogue = resourceCataloguesCodes.contains(idCodeCatalogue);
|
||||
logger.debug("\tIs it a catalogue code? "+isIdCodeCatalogue);
|
||||
}
|
||||
|
||||
if(isCatalogueServletReference || isIdCodeCatalogue){
|
||||
|
||||
//int startIndex = requestURI.indexOf(SERVLET_CATALOGUE))+SERVLET_CATALOGUE.length();
|
||||
//String vreName = requestURI.substring(beginIndex)
|
||||
HttpServletRequest request = (HttpServletRequest) req;
|
||||
logger.trace("method is: "+request.getMethod());
|
||||
|
||||
if(request.getMethod().compareToIgnoreCase("POST")==0){
|
||||
logger.debug("Managing as Catalogue POST request..");
|
||||
logger.debug("forward to: " + SERVLET_CATALOGUE);
|
||||
multiReadRequest.getRequestDispatcher(SERVLET_CATALOGUE).forward(multiReadRequest, response);
|
||||
}else{
|
||||
logger.debug("Managing as Catalogue GET request..");
|
||||
String newURI = SERVLET_CATALOGUE;
|
||||
//String[] pathSplit = newServletPath.split(PATH_SEPARATOR);
|
||||
if(isIdCodeCatalogue){
|
||||
//TO BUILD A COMPLETE URL
|
||||
// logger.debug("is a catalogue code, rebuilding complete url...");
|
||||
// ResourceCatalogueCodes rcc = ResourceCatalogueCodes.valueOfId(idCodeCatalogue);
|
||||
// newServletPath = SERVLET_CATALOGUE+splittedServletPath[2]+PATH_SEPARATOR+rcc.getValue()+PATH_SEPARATOR+splittedServletPath[3];
|
||||
// logger.debug("rebuilded complete url: "+newServletPath);
|
||||
logger.debug("is a catalogue code, resolving a short url in clear ...");
|
||||
ResourceCatalogueCodes rcc = ResourceCatalogueCodes.valueOfCodeId(idCodeCatalogue);
|
||||
logger.debug("found VRE name: "+splittedServletPath[2]);
|
||||
String gcubeScope = CatalogueRequestParameter.GCUBE_SCOPE.getKey() +"="+splittedServletPath[2];
|
||||
String eC = CatalogueRequestParameter.ENTITY_CONTEXT.getKey() +"="+rcc.getValue();
|
||||
logger.debug("found id code: "+idCodeCatalogue+", resolving it with context name: "+eC);
|
||||
String eN = CatalogueRequestParameter.ENTITY_NAME.getKey() +"="+splittedServletPath[3];
|
||||
logger.debug("found entity name: "+eN);
|
||||
String encodedQuery = UrlEncoderUtil.encodeQuery(gcubeScope,eC,eN);
|
||||
newURI+= "?" + PARAMETER_DIRECT_CATALOGUE_LINK + "=" + encodedQuery;
|
||||
}else
|
||||
if(splittedServletPath.length==5){
|
||||
logger.info("resolving a complete URL in clear...");
|
||||
logger.debug("found VRE name: "+splittedServletPath[2]);
|
||||
String gcubeScope = CatalogueRequestParameter.GCUBE_SCOPE.getKey() +"="+splittedServletPath[2];
|
||||
String eC = CatalogueRequestParameter.ENTITY_CONTEXT.getKey() +"="+splittedServletPath[3];
|
||||
logger.debug("found context name: "+eC);
|
||||
String eN = CatalogueRequestParameter.ENTITY_NAME.getKey() +"="+splittedServletPath[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);
|
||||
}
|
||||
|
||||
//chain.doFilter(multiReadRequest, response);
|
||||
}else{
|
||||
logger.debug("It is a request to workspace/storage");
|
||||
//LAST CASE, IS WORKSPACE REQUEST?
|
||||
if (queryString == null) { // IS A /XXXXX
|
||||
logger.debug("QueryString is null, is It a new SMP public uri by ID?");
|
||||
int lastSlash = requestURI.lastIndexOf(PATH_SEPARATOR);
|
||||
if (lastSlash + 1 == requestURI.length()) {
|
||||
logger.debug("'/' is last index, doFilter Request");
|
||||
// req.getRequestDispatcher("/").forward(req, res);
|
||||
chain.doFilter(multiReadRequest, response);
|
||||
}
|
||||
else {
|
||||
String toStorageID = requestURI.substring(lastSlash + 1, requestURI.length());
|
||||
// String newURI = requestURI.replace(toReplace,
|
||||
// SERVLET_RESOLVER_BY_ID+"?"+SMP_ID+"="+toReplace);
|
||||
String newURI = SERVLET_STORAGE_ID + "?" + PARAMETER_SMP_ID + "=" + toStorageID;
|
||||
logger.debug("forward to: " + newURI);
|
||||
multiReadRequest.getRequestDispatcher(newURI).forward(multiReadRequest, response);
|
||||
}
|
||||
}
|
||||
else {
|
||||
logger.debug("It is NOT a SMP public uri by ID, doFilter Request");
|
||||
chain.doFilter(multiReadRequest, response);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}catch(BadRequestException bre){
|
||||
if (response instanceof HttpServletResponse){
|
||||
HttpServletResponse httpResponse = (HttpServletResponse) response;
|
||||
httpResponse.sendError(HttpServletResponse.SC_BAD_REQUEST, bre.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the scope.
|
||||
*
|
||||
* @param scope the scope
|
||||
* @return the scope
|
||||
*/
|
||||
private static String getScope(String scope){
|
||||
logger.debug("Read scope path: "+scope);
|
||||
// String scope = servletPath.substring(servletPath.indexOf("/"), servletPath.length());
|
||||
return PATH_SEPARATOR+scope.replaceAll("_", PATH_SEPARATOR);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
|
||||
*/
|
||||
@Override
|
||||
public void init(FilterConfig config) throws ServletException {
|
||||
logger.trace("run init");
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
/*public static void main(String[] args) {
|
||||
|
||||
String split = "/catalogue/NextNext/dataset/sarda-sarda";
|
||||
|
||||
String[] array = split.split("/");
|
||||
|
||||
System.out.println(array.length);
|
||||
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
System.out.println(i+" "+array[i]);
|
||||
}
|
||||
|
||||
System.out.println(array[2]);
|
||||
|
||||
}*/
|
||||
}
|
||||
///**
|
||||
// *
|
||||
// */
|
||||
//package org.gcube.datatransfer.resolver;
|
||||
//
|
||||
//import java.io.IOException;
|
||||
//import java.util.HashSet;
|
||||
//import java.util.Set;
|
||||
//
|
||||
//import javax.servlet.Filter;
|
||||
//import javax.servlet.FilterChain;
|
||||
//import javax.servlet.FilterConfig;
|
||||
//import javax.servlet.ServletException;
|
||||
//import javax.servlet.ServletRequest;
|
||||
//import javax.servlet.ServletResponse;
|
||||
//import javax.servlet.http.HttpServletRequest;
|
||||
//import javax.servlet.http.HttpServletResponse;
|
||||
//
|
||||
//import org.gcube.datatransfer.resolver.catalogue.CatalogueRequestParameter;
|
||||
//import org.gcube.datatransfer.resolver.catalogue.UrlEncoderUtil;
|
||||
//import org.slf4j.Logger;
|
||||
//import org.slf4j.LoggerFactory;
|
||||
//
|
||||
//
|
||||
//
|
||||
///**
|
||||
// * The Class UriResolverRewriteFilter.
|
||||
// *
|
||||
// * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
// * Dec 5, 2016
|
||||
// */
|
||||
//public class UriResolverRewriteFilter implements Filter{
|
||||
//
|
||||
// /**
|
||||
// *
|
||||
// */
|
||||
// public static final String SERVLET_URI_RESOLVER = "/uri-resolver";
|
||||
//
|
||||
// private static final String PATH_SEPARATOR = "/";
|
||||
// public static final String SERVLET_GEONETWORK = "/geonetwork";
|
||||
// public static final String REQUEST_PARAMETER_SEPARATOR = "#";
|
||||
//
|
||||
// public static final String PARAMETER_SMP_ID = "smp-id";
|
||||
// public static final String SERVLET_STORAGE_ID = "id";
|
||||
//
|
||||
// public static final String PARAMETER_ENC_CATALOGUE_LINK = "cl";
|
||||
// public static final String PARAMETER_DIRECT_CATALOGUE_LINK = "dl";
|
||||
// public static final String SERVLET_CATALOGUE = "/catalogue";
|
||||
//
|
||||
// protected static final Logger logger = LoggerFactory.getLogger(UriResolverRewriteFilter.class);
|
||||
// private FilterConfig config;
|
||||
//
|
||||
// private static final Set<String> resourceCataloguesCodes = new HashSet<String>(ResourceCatalogueCodes.codes());
|
||||
//
|
||||
// //private ApplicationProfileReaderForCatalogueResolver appPrfCatResolver = new ApplicationProfileReaderForCatalogueResolver(scope, useRootScope)
|
||||
//
|
||||
// /**
|
||||
// * Gets the config.
|
||||
// *
|
||||
// * @return the config
|
||||
// */
|
||||
// public FilterConfig getConfig() {
|
||||
//
|
||||
// return config;
|
||||
// }
|
||||
//
|
||||
// /* (non-Javadoc)
|
||||
// * @see javax.servlet.Filter#destroy()
|
||||
// */
|
||||
// @Override
|
||||
// public void destroy() {
|
||||
// logger.trace("run destroy");
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /* (non-Javadoc)
|
||||
// * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
|
||||
// */
|
||||
// @Override
|
||||
// public void doFilter(ServletRequest req, ServletResponse response, FilterChain chain) throws IOException, ServletException {
|
||||
// /* wrap the request in order to read the inputstream multiple times */
|
||||
// MultiReadHttpServletRequest multiReadRequest = new MultiReadHttpServletRequest((HttpServletRequest) req);
|
||||
// String requestURI = multiReadRequest.getRequestURI();
|
||||
// String queryString = multiReadRequest.getQueryString();
|
||||
// String servletPath = multiReadRequest.getServletPath();
|
||||
// logger.debug("Request URI: " + requestURI + ", QueryString: " +queryString+ ", Servlet path: "+servletPath);
|
||||
//
|
||||
// try{
|
||||
// //IS A REQUEST FOR GEONETWORK AUTHENTICATION? (CKAN HARVESTING?)
|
||||
// if(servletPath.startsWith(SERVLET_GEONETWORK) || servletPath.startsWith(SERVLET_URI_RESOLVER+SERVLET_GEONETWORK)){
|
||||
// logger.debug("It is a request to geonetwork");
|
||||
// GeonetworkRequestDecoder grd = new GeonetworkRequestDecoder(servletPath, queryString);
|
||||
// logger.debug("forward to: "+grd.getGeonetworkResolverURIRequest());
|
||||
// multiReadRequest.getRequestDispatcher(grd.getGeonetworkResolverURIRequest()).forward(multiReadRequest, response);
|
||||
//
|
||||
// }else{
|
||||
// logger.debug("checking if it is a request to catologue...");
|
||||
// boolean isCatalogueServletReference = servletPath.startsWith(SERVLET_CATALOGUE);
|
||||
//
|
||||
// String idCodeCatalogue = null;
|
||||
// boolean isIdCodeCatalogue = false;
|
||||
// String splittedServletPath[] = servletPath.split(PATH_SEPARATOR);
|
||||
// if(!isCatalogueServletReference){
|
||||
// idCodeCatalogue = splittedServletPath[1];
|
||||
// logger.trace("checking if the code: "+idCodeCatalogue+" belongs to a catalogue code");
|
||||
// isIdCodeCatalogue = resourceCataloguesCodes.contains(idCodeCatalogue);
|
||||
// logger.debug("\tIs it a catalogue code? "+isIdCodeCatalogue);
|
||||
// }
|
||||
//
|
||||
// if(isCatalogueServletReference || isIdCodeCatalogue){
|
||||
//
|
||||
// //int startIndex = requestURI.indexOf(SERVLET_CATALOGUE))+SERVLET_CATALOGUE.length();
|
||||
// //String vreName = requestURI.substring(beginIndex)
|
||||
// HttpServletRequest request = (HttpServletRequest) req;
|
||||
// logger.trace("method is: "+request.getMethod());
|
||||
//
|
||||
// if(request.getMethod().compareToIgnoreCase("POST")==0){
|
||||
// logger.debug("Managing as Catalogue POST request..");
|
||||
// logger.debug("forward to: " + SERVLET_CATALOGUE);
|
||||
// multiReadRequest.getRequestDispatcher(SERVLET_CATALOGUE).forward(multiReadRequest, response);
|
||||
// }else{
|
||||
// logger.debug("Managing as Catalogue GET request..");
|
||||
// String newURI = SERVLET_CATALOGUE;
|
||||
// //String[] pathSplit = newServletPath.split(PATH_SEPARATOR);
|
||||
// if(isIdCodeCatalogue){
|
||||
// //TO BUILD A COMPLETE URL
|
||||
// // logger.debug("is a catalogue code, rebuilding complete url...");
|
||||
// // ResourceCatalogueCodes rcc = ResourceCatalogueCodes.valueOfId(idCodeCatalogue);
|
||||
// // newServletPath = SERVLET_CATALOGUE+splittedServletPath[2]+PATH_SEPARATOR+rcc.getValue()+PATH_SEPARATOR+splittedServletPath[3];
|
||||
// // logger.debug("rebuilded complete url: "+newServletPath);
|
||||
// logger.debug("is a catalogue code, resolving a short url in clear ...");
|
||||
// ResourceCatalogueCodes rcc = ResourceCatalogueCodes.valueOfCodeId(idCodeCatalogue);
|
||||
// logger.debug("found VRE name: "+splittedServletPath[2]);
|
||||
// String gcubeScope = CatalogueRequestParameter.GCUBE_SCOPE.getKey() +"="+splittedServletPath[2];
|
||||
// String eC = CatalogueRequestParameter.ENTITY_CONTEXT.getKey() +"="+rcc.getValue();
|
||||
// logger.debug("found id code: "+idCodeCatalogue+", resolving it with context name: "+eC);
|
||||
// String eN = CatalogueRequestParameter.ENTITY_NAME.getKey() +"="+splittedServletPath[3];
|
||||
// logger.debug("found entity name: "+eN);
|
||||
// String encodedQuery = UrlEncoderUtil.encodeQuery(gcubeScope,eC,eN);
|
||||
// newURI+= "?" + PARAMETER_DIRECT_CATALOGUE_LINK + "=" + encodedQuery;
|
||||
// }else
|
||||
// if(splittedServletPath.length==5){
|
||||
// logger.info("resolving a complete URL in clear...");
|
||||
// logger.debug("found VRE name: "+splittedServletPath[2]);
|
||||
// String gcubeScope = CatalogueRequestParameter.GCUBE_SCOPE.getKey() +"="+splittedServletPath[2];
|
||||
// String eC = CatalogueRequestParameter.ENTITY_CONTEXT.getKey() +"="+splittedServletPath[3];
|
||||
// logger.debug("found context name: "+eC);
|
||||
// String eN = CatalogueRequestParameter.ENTITY_NAME.getKey() +"="+splittedServletPath[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);
|
||||
// }
|
||||
//
|
||||
// //chain.doFilter(multiReadRequest, response);
|
||||
// }else{
|
||||
// logger.debug("It is a request to workspace/storage");
|
||||
// //LAST CASE, IS WORKSPACE REQUEST?
|
||||
// if (queryString == null) { // IS A /XXXXX
|
||||
// logger.debug("QueryString is null, is It a new SMP public uri by ID?");
|
||||
// int lastSlash = requestURI.lastIndexOf(PATH_SEPARATOR);
|
||||
// if (lastSlash + 1 == requestURI.length()) {
|
||||
// logger.debug("'/' is last index, doFilter Request");
|
||||
// // req.getRequestDispatcher("/").forward(req, res);
|
||||
// chain.doFilter(multiReadRequest, response);
|
||||
// }
|
||||
// else {
|
||||
// String toStorageID = requestURI.substring(lastSlash + 1, requestURI.length());
|
||||
// // String newURI = requestURI.replace(toReplace,
|
||||
// // SERVLET_RESOLVER_BY_ID+"?"+SMP_ID+"="+toReplace);
|
||||
// String newURI = SERVLET_STORAGE_ID + "?" + PARAMETER_SMP_ID + "=" + toStorageID;
|
||||
// logger.debug("forward to: " + newURI);
|
||||
// multiReadRequest.getRequestDispatcher(newURI).forward(multiReadRequest, response);
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// logger.debug("It is NOT a SMP public uri by ID, doFilter Request");
|
||||
// chain.doFilter(multiReadRequest, response);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }catch(BadRequestException bre){
|
||||
// if (response instanceof HttpServletResponse){
|
||||
// HttpServletResponse httpResponse = (HttpServletResponse) response;
|
||||
// httpResponse.sendError(HttpServletResponse.SC_BAD_REQUEST, bre.getMessage());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * Gets the scope.
|
||||
// *
|
||||
// * @param scope the scope
|
||||
// * @return the scope
|
||||
// */
|
||||
// private static String getScope(String scope){
|
||||
// logger.debug("Read scope path: "+scope);
|
||||
//// String scope = servletPath.substring(servletPath.indexOf("/"), servletPath.length());
|
||||
// return PATH_SEPARATOR+scope.replaceAll("_", PATH_SEPARATOR);
|
||||
// }
|
||||
//
|
||||
// /* (non-Javadoc)
|
||||
// * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
|
||||
// */
|
||||
// @Override
|
||||
// public void init(FilterConfig config) throws ServletException {
|
||||
// logger.trace("run init");
|
||||
// this.config = config;
|
||||
// }
|
||||
//
|
||||
// /*public static void main(String[] args) {
|
||||
//
|
||||
// String split = "/catalogue/NextNext/dataset/sarda-sarda";
|
||||
//
|
||||
// String[] array = split.split("/");
|
||||
//
|
||||
// System.out.println(array.length);
|
||||
//
|
||||
// for (int i = 0; i < array.length; i++) {
|
||||
// System.out.println(i+" "+array[i]);
|
||||
// }
|
||||
//
|
||||
// System.out.println(array[2]);
|
||||
//
|
||||
// }*/
|
||||
//}
|
||||
|
|
|
@ -18,16 +18,15 @@ import com.google.common.cache.RemovalListener;
|
|||
import com.google.common.cache.RemovalNotification;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The Class CatalogueApplicationProfilesCache.
|
||||
* The Class LoadingCatalogueApplicationProfilesCache.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
* Nov 5, 2018
|
||||
*/
|
||||
public class CatalogueApplicationProfilesCache {
|
||||
public class LoadingCatalogueApplicationProfilesCache {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(CatalogueApplicationProfilesCache.class);
|
||||
private static Logger logger = LoggerFactory.getLogger(LoadingCatalogueApplicationProfilesCache.class);
|
||||
private static LoadingCache<String, String> catalogueApplicationProfiles;
|
||||
|
||||
static{
|
||||
|
@ -38,7 +37,7 @@ public class CatalogueApplicationProfilesCache {
|
|||
public String load(String vreName)
|
||||
throws Exception {
|
||||
|
||||
logger.info(CatalogueApplicationProfilesCache.class.getSimpleName() +" loaded");
|
||||
logger.info(LoadingCatalogueApplicationProfilesCache.class.getSimpleName() +" loaded");
|
||||
return loadApplicationProfiles(vreName);
|
||||
}
|
||||
|
||||
|
@ -49,7 +48,7 @@ public class CatalogueApplicationProfilesCache {
|
|||
@Override
|
||||
public void onRemoval(RemovalNotification<String, String> arg0) {
|
||||
|
||||
logger.info(CatalogueApplicationProfilesCache.class.getSimpleName() +" cache expired");
|
||||
logger.info(LoadingCatalogueApplicationProfilesCache.class.getSimpleName() +" cache expired");
|
||||
|
||||
}
|
||||
};
|
||||
|
@ -62,7 +61,7 @@ public class CatalogueApplicationProfilesCache {
|
|||
ApplicationProfileReaderForCatalogueResolver appPrCatResolver = new ApplicationProfileReaderForCatalogueResolver(UriResolverStartupListener.getContextScope(), true);
|
||||
catalogueApplicationProfiles.asMap().putAll(appPrCatResolver.getHashVreNameScope());
|
||||
|
||||
logger.info(CatalogueApplicationProfilesCache.class.getSimpleName() +" instancied "+catalogueApplicationProfiles);
|
||||
logger.info(LoadingCatalogueApplicationProfilesCache.class.getSimpleName() +" instancied "+catalogueApplicationProfiles);
|
||||
logger.info("Pre-Loaded cache is: "+catalogueApplicationProfiles.toString());
|
||||
|
||||
}
|
|
@ -20,14 +20,14 @@ import com.google.common.cache.RemovalNotification;
|
|||
|
||||
|
||||
/**
|
||||
* The Class GeoExplorerApplicationURLCache.
|
||||
* The Class LoadingGeoExplorerApplicationURLCache.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
* Nov 5, 2018
|
||||
*/
|
||||
public class GeoExplorerApplicationURLCache {
|
||||
public class LoadingGeoExplorerApplicationURLCache {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(GeoExplorerApplicationURLCache.class);
|
||||
private static Logger logger = LoggerFactory.getLogger(LoadingGeoExplorerApplicationURLCache.class);
|
||||
|
||||
//A cache (Scope, GeoExplorer-URL)
|
||||
private static LoadingCache<String, String> geoExplorerApplicationURLCache;
|
||||
|
@ -38,14 +38,14 @@ public class GeoExplorerApplicationURLCache {
|
|||
@Override
|
||||
public String load(String scope)
|
||||
throws Exception {
|
||||
logger.info(GeoExplorerApplicationURLCache.class.getSimpleName() +" loaded");
|
||||
logger.info(LoadingGeoExplorerApplicationURLCache.class.getSimpleName() +" loaded");
|
||||
return loadGeoExplorerApplicationURL(scope);
|
||||
}
|
||||
};
|
||||
|
||||
RemovalListener<String, String> removalListener = new RemovalListener<String, String>() {
|
||||
public void onRemoval(RemovalNotification<String, String> removal) {
|
||||
logger.info(GeoExplorerApplicationURLCache.class.getSimpleName() +" cache expired");
|
||||
logger.info(LoadingGeoExplorerApplicationURLCache.class.getSimpleName() +" cache expired");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -54,7 +54,7 @@ public class GeoExplorerApplicationURLCache {
|
|||
1, TimeUnit.DAYS).removalListener(removalListener).
|
||||
build(loader);
|
||||
|
||||
logger.info(GeoExplorerApplicationURLCache.class.getSimpleName() +" instancied");
|
||||
logger.info(LoadingGeoExplorerApplicationURLCache.class.getSimpleName() +" instancied");
|
||||
}
|
||||
|
||||
/**
|
|
@ -20,16 +20,15 @@ import com.google.common.cache.RemovalListener;
|
|||
import com.google.common.cache.RemovalNotification;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The Class GeonetworkInstanceCache.
|
||||
* The Class LoadingGeonetworkInstanceCache.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
* Nov 5, 2018
|
||||
*/
|
||||
public class GeonetworkInstanceCache {
|
||||
public class LoadingGeonetworkInstanceCache {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(GeonetworkInstanceCache.class);
|
||||
private static Logger logger = LoggerFactory.getLogger(LoadingGeonetworkInstanceCache.class);
|
||||
|
||||
//A cache (Scope, GeonetworkInstance)
|
||||
private static LoadingCache<String, GeonetworkInstance> geonetworkInstancesCache;
|
||||
|
@ -40,14 +39,14 @@ public class GeonetworkInstanceCache {
|
|||
@Override
|
||||
public GeonetworkInstance load(String scope)
|
||||
throws Exception {
|
||||
logger.info(GeonetworkInstanceCache.class.getSimpleName() +" loaded");
|
||||
logger.info(LoadingGeonetworkInstanceCache.class.getSimpleName() +" loaded");
|
||||
return loadGeonetworkInstance(scope);
|
||||
}
|
||||
};
|
||||
|
||||
RemovalListener<String, GeonetworkInstance> removalListener = new RemovalListener<String, GeonetworkInstance>() {
|
||||
public void onRemoval(RemovalNotification<String, GeonetworkInstance> removal) {
|
||||
logger.info(GeonetworkInstanceCache.class.getSimpleName() +" cache expired");
|
||||
logger.info(LoadingGeonetworkInstanceCache.class.getSimpleName() +" cache expired");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -56,7 +55,7 @@ public class GeonetworkInstanceCache {
|
|||
1, TimeUnit.DAYS).removalListener(removalListener).
|
||||
build(loader);
|
||||
|
||||
logger.info(GeonetworkInstanceCache.class.getSimpleName() +" instancied");
|
||||
logger.info(LoadingGeonetworkInstanceCache.class.getSimpleName() +" instancied");
|
||||
}
|
||||
|
||||
|
|
@ -18,15 +18,16 @@ import com.google.common.cache.RemovalListener;
|
|||
import com.google.common.cache.RemovalNotification;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The Class GisViewerApplicationURLCache.
|
||||
* The Class LoadingGisViewerApplicationURLCache.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
* Nov 5, 2018
|
||||
*/
|
||||
public class GisViewerApplicationURLCache {
|
||||
public class LoadingGisViewerApplicationURLCache {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(GisViewerApplicationURLCache.class);
|
||||
private static Logger logger = LoggerFactory.getLogger(LoadingGisViewerApplicationURLCache.class);
|
||||
|
||||
//A cache (Scope, GisViewerApplication-URL)
|
||||
private static LoadingCache<String, String> gisViewerApplicationURLCache;
|
||||
|
@ -37,14 +38,14 @@ public class GisViewerApplicationURLCache {
|
|||
@Override
|
||||
public String load(String scope)
|
||||
throws Exception {
|
||||
logger.info(GisViewerApplicationURLCache.class.getSimpleName() +" loaded");
|
||||
logger.info(LoadingGisViewerApplicationURLCache.class.getSimpleName() +" loaded");
|
||||
return loadGisViewerApplicationURL(scope);
|
||||
}
|
||||
};
|
||||
|
||||
RemovalListener<String, String> removalListener = new RemovalListener<String, String>() {
|
||||
public void onRemoval(RemovalNotification<String, String> removal) {
|
||||
logger.info(GisViewerApplicationURLCache.class.getSimpleName() +" cache expired");
|
||||
logger.info(LoadingGisViewerApplicationURLCache.class.getSimpleName() +" cache expired");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -53,7 +54,7 @@ public class GisViewerApplicationURLCache {
|
|||
1, TimeUnit.DAYS).removalListener(removalListener).
|
||||
build(loader);
|
||||
|
||||
logger.info(GisViewerApplicationURLCache.class.getSimpleName() +" instancied");
|
||||
logger.info(LoadingGisViewerApplicationURLCache.class.getSimpleName() +" instancied");
|
||||
}
|
||||
|
||||
|
|
@ -15,8 +15,9 @@ import javax.servlet.ServletContextListener;
|
|||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebListener;
|
||||
|
||||
import org.gcube.datatransfer.resolver.caches.GeonetworkInstanceCache;
|
||||
import org.gcube.datatransfer.resolver.caches.GisViewerApplicationURLCache;
|
||||
import org.gcube.datatransfer.resolver.caches.LoadingCatalogueApplicationProfilesCache;
|
||||
import org.gcube.datatransfer.resolver.caches.LoadingGeonetworkInstanceCache;
|
||||
import org.gcube.datatransfer.resolver.caches.LoadingGisViewerApplicationURLCache;
|
||||
import org.gcube.datatransfer.resolver.gis.property.ApplicationProfileGenericResourceReader;
|
||||
import org.gcube.datatransfer.resolver.gis.property.PropertyFileNotFoundException;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -70,13 +71,14 @@ public class UriResolverStartupListener implements ServletContextListener {
|
|||
|
||||
gisViewerProfile = loadApplicationProfile(event.getServletContext(), GIS_VIEWER_GENERIC_RESOURCE_GCUBE_APPS_PROPERTIES);
|
||||
geoExplorerProfile = loadApplicationProfile(event.getServletContext(), GEO_EXPLORER_GENERIC_RESOURCE_GCUBE_APPS_PROPERTIES);
|
||||
new GeonetworkInstanceCache();
|
||||
new GisViewerApplicationURLCache();
|
||||
new LoadingGeonetworkInstanceCache();
|
||||
new LoadingGisViewerApplicationURLCache();
|
||||
new LoadingCatalogueApplicationProfilesCache();
|
||||
|
||||
logger.info("Context initialized with: ");
|
||||
logger.info("Scope: "+contextScope);
|
||||
logger.info("GisViewerProfile: "+gisViewerProfile);
|
||||
logger.info("GeoExplorerProfile: "+geoExplorerProfile);
|
||||
logger.info("GisViewerProfile: "+gisViewerProfile.getAppId() + " "+gisViewerProfile.getGenericResource());
|
||||
logger.info("GeoExplorerProfile: "+geoExplorerProfile. getAppId() + " "+geoExplorerProfile.getGenericResource());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -18,7 +18,7 @@ import javax.ws.rs.core.Response.Status;
|
|||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.datatransfer.resolver.ResourceCatalogueCodes;
|
||||
import org.gcube.datatransfer.resolver.applicationprofile.ApplicationProfileNotFoundException;
|
||||
import org.gcube.datatransfer.resolver.caches.CatalogueApplicationProfilesCache;
|
||||
import org.gcube.datatransfer.resolver.caches.LoadingCatalogueApplicationProfilesCache;
|
||||
import org.gcube.datatransfer.resolver.catalogue.CatalogueRequest;
|
||||
import org.gcube.datatransfer.resolver.catalogue.resource.ApplicationProfileReaderForCatalogueResolver;
|
||||
import org.gcube.datatransfer.resolver.catalogue.resource.CkanCatalogueConfigurationsReader;
|
||||
|
@ -51,7 +51,7 @@ public class CatalogueResolver {
|
|||
|
||||
//ApplicationProfileReaderForCatalogueResolver appPrCatResolver = new ApplicationProfileReaderForCatalogueResolver(vreName, true);
|
||||
|
||||
String fullScope = CatalogueApplicationProfilesCache.getCache().get(vreName);
|
||||
String fullScope = LoadingCatalogueApplicationProfilesCache.getCache().get(vreName);
|
||||
logger.debug("Read fullScope: "+fullScope + " for VRE_NAME: "+vreName +" into Application Profile "+ApplicationProfileReaderForCatalogueResolver.RESOURCE_NAME);
|
||||
|
||||
//String fullScope = appPrCatResolver.getHashVreNameScope().get(vreName);
|
||||
|
|
|
@ -15,9 +15,9 @@ import javax.ws.rs.core.Context;
|
|||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.datatransfer.resolver.caches.GeoExplorerApplicationURLCache;
|
||||
import org.gcube.datatransfer.resolver.caches.GeonetworkInstanceCache;
|
||||
import org.gcube.datatransfer.resolver.caches.GisViewerApplicationURLCache;
|
||||
import org.gcube.datatransfer.resolver.caches.LoadingGeoExplorerApplicationURLCache;
|
||||
import org.gcube.datatransfer.resolver.caches.LoadingGeonetworkInstanceCache;
|
||||
import org.gcube.datatransfer.resolver.caches.LoadingGisViewerApplicationURLCache;
|
||||
import org.gcube.datatransfer.resolver.gis.GeonetworkInstance;
|
||||
import org.gcube.datatransfer.resolver.gis.MetadataConverter;
|
||||
import org.gcube.datatransfer.resolver.gis.entity.GisLayerItem;
|
||||
|
@ -155,11 +155,11 @@ public class GisResolver {
|
|||
protected String getGisViewerApplicationURL(String scope) throws Exception{
|
||||
|
||||
logger.info("Tentative of recovering gis viewer application hostname from cache for scope: "+scope);
|
||||
String gisViewerAppHostname = GisViewerApplicationURLCache.getCache().get(scope);
|
||||
String gisViewerAppHostname = LoadingGisViewerApplicationURLCache.getCache().get(scope);
|
||||
if(gisViewerAppHostname==null){
|
||||
logger.info("Gis viewer application hostname is null, reading from application profile..");
|
||||
String url = GisViewerApplicationURLCache.loadGisViewerApplicationURL(scope);
|
||||
GisViewerApplicationURLCache.getCache().put(scope, url);
|
||||
String url = LoadingGisViewerApplicationURLCache.loadGisViewerApplicationURL(scope);
|
||||
LoadingGisViewerApplicationURLCache.getCache().put(scope, url);
|
||||
logger.info("Updated GisViewerApplication cache! Scope "+scope+" linking "+url);
|
||||
return url;
|
||||
}else
|
||||
|
@ -203,13 +203,13 @@ public class GisResolver {
|
|||
protected GeonetworkInstance getCachedGeonetworkInstance(String scope) throws Exception{
|
||||
|
||||
logger.info("Attempt to get the GeonetworkInstance from cache by scope: "+scope);
|
||||
GeonetworkInstance geonInstance = GeonetworkInstanceCache.getCache().get(scope);
|
||||
GeonetworkInstance geonInstance = LoadingGeonetworkInstanceCache.getCache().get(scope);
|
||||
|
||||
if(geonInstance==null){
|
||||
logger.info("GeonetworkInstance is null in cache, reading from library...");
|
||||
try {
|
||||
geonInstance = GeonetworkInstanceCache.loadGeonetworkInstance(scope);
|
||||
GeonetworkInstanceCache.getCache().put(scope, geonInstance);
|
||||
geonInstance = LoadingGeonetworkInstanceCache.loadGeonetworkInstance(scope);
|
||||
LoadingGeonetworkInstanceCache.getCache().put(scope, geonInstance);
|
||||
logger.info("Updated GeonetworkInstance cache! Scope "+scope+" linking "+geonInstance);
|
||||
} catch (Exception e) {
|
||||
logger.error("An error occurred on getting GeonetworkInstance for scope: "+scope, e);
|
||||
|
@ -234,11 +234,11 @@ public class GisResolver {
|
|||
protected String getGeoExplorerApplicationURL(String scope) throws Exception{
|
||||
|
||||
logger.info("Tentative of recovering geo explorer application hostname from cache for scope: "+scope);
|
||||
String geoExplorerApplicationHostname = GeoExplorerApplicationURLCache.getCache().get(scope);
|
||||
String geoExplorerApplicationHostname = LoadingGeoExplorerApplicationURLCache.getCache().get(scope);
|
||||
if(geoExplorerApplicationHostname==null){
|
||||
logger.info("GeoExplorer application hostname is null, reading from application profile..");
|
||||
String url = GeoExplorerApplicationURLCache.loadGeoExplorerApplicationURL(scope);
|
||||
GeoExplorerApplicationURLCache.getCache().put(scope, url);
|
||||
String url = LoadingGeoExplorerApplicationURLCache.loadGeoExplorerApplicationURL(scope);
|
||||
LoadingGeoExplorerApplicationURLCache.getCache().put(scope, url);
|
||||
logger.info("Updated GeoExplorerApplication cache! Scope "+scope+" linking "+url);
|
||||
return url;
|
||||
}else
|
||||
|
|
|
@ -1,43 +1,43 @@
|
|||
import javax.servlet.ServletException;
|
||||
|
||||
import org.gcube.datatransfer.resolver.GeonetworkRequestDecoder;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Jul 27, 2016
|
||||
*/
|
||||
public class GeonetworkRequestDecoderTest {
|
||||
|
||||
|
||||
//@Test
|
||||
public void test1() throws ServletException{
|
||||
String request = "/geonetwork/gcube|devsec|devVRE#filterpublicids";
|
||||
System.out.println("Testing request: "+request);
|
||||
GeonetworkRequestDecoder gd = new GeonetworkRequestDecoder(request,"");
|
||||
System.out.println(gd);
|
||||
}
|
||||
|
||||
//@Test
|
||||
public void test2() throws ServletException{
|
||||
String request = "/geonetwork/gcube|devsec|devVRE#noauthentication";
|
||||
System.out.println("Testing request: "+request);
|
||||
GeonetworkRequestDecoder gd = new GeonetworkRequestDecoder(request,"");
|
||||
System.out.println(gd);
|
||||
}
|
||||
|
||||
|
||||
//@Test
|
||||
public void test3() throws ServletException{
|
||||
String request = "/geonetwork/gcube#filterpublicids";
|
||||
System.out.println("Testing request: "+request);
|
||||
GeonetworkRequestDecoder gd = new GeonetworkRequestDecoder(request,"");
|
||||
System.out.println(gd);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//import javax.servlet.ServletException;
|
||||
//
|
||||
//import org.gcube.datatransfer.resolver.GeonetworkRequestDecoder;
|
||||
//
|
||||
//
|
||||
///**
|
||||
// *
|
||||
// */
|
||||
///**
|
||||
// *
|
||||
// * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
// * Jul 27, 2016
|
||||
// */
|
||||
//public class GeonetworkRequestDecoderTest {
|
||||
//
|
||||
//
|
||||
// //@Test
|
||||
// public void test1() throws ServletException{
|
||||
// String request = "/geonetwork/gcube|devsec|devVRE#filterpublicids";
|
||||
// System.out.println("Testing request: "+request);
|
||||
// GeonetworkRequestDecoder gd = new GeonetworkRequestDecoder(request,"");
|
||||
// System.out.println(gd);
|
||||
// }
|
||||
//
|
||||
// //@Test
|
||||
// public void test2() throws ServletException{
|
||||
// String request = "/geonetwork/gcube|devsec|devVRE#noauthentication";
|
||||
// System.out.println("Testing request: "+request);
|
||||
// GeonetworkRequestDecoder gd = new GeonetworkRequestDecoder(request,"");
|
||||
// System.out.println(gd);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// //@Test
|
||||
// public void test3() throws ServletException{
|
||||
// String request = "/geonetwork/gcube#filterpublicids";
|
||||
// System.out.println("Testing request: "+request);
|
||||
// GeonetworkRequestDecoder gd = new GeonetworkRequestDecoder(request,"");
|
||||
// System.out.println(gd);
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
||||
|
|
Loading…
Reference in New Issue