Working on Feature #7350

Updated pom version at 1.11.0

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-transfer/uri-resolver@144784 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2017-03-09 10:22:02 +00:00
parent c6e3ac624d
commit 31c3ad2775
8 changed files with 300 additions and 93 deletions

View File

@ -4,6 +4,9 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/> <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/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="uri-resolver-manager-1.3.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/uri-resolver-manager-TRUNK/uri-resolver-manager-TRUNK">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="context-root" value="uri-resolver"/> <property name="context-root" value="uri-resolver"/>
<property name="java-output-path" value="/uri-resolver/target/classes"/> <property name="java-output-path" value="/uri-resolver/target/classes"/>
</wb-module> </wb-module>

View File

@ -67,4 +67,8 @@
<Change>[Task #6492] Catalogue Resolver: "improve"/"build better" public URLs to products</Change> <Change>[Task #6492] Catalogue Resolver: "improve"/"build better" public URLs to products</Change>
<Change>[Task #6952] Catalogue Resolver: update on the fly the Application Profile for VRE's used to resolve Product URL</Change> <Change>[Task #6952] Catalogue Resolver: update on the fly the Application Profile for VRE's used to resolve Product URL</Change>
</Changeset> </Changeset>
<Changeset component="org.gcube.data-transfer.uri-resolver.1-11-0"
date="2017-03-09">
<Change>[Feature #7350] GeoExplorer Resolver: resolve a GeoExplorer Link</Change>
</Changeset>
</ReleaseNotes> </ReleaseNotes>

View File

@ -8,7 +8,7 @@
</parent> </parent>
<groupId>org.gcube.data.transfer</groupId> <groupId>org.gcube.data.transfer</groupId>
<artifactId>uri-resolver</artifactId> <artifactId>uri-resolver</artifactId>
<version>1.10.0-SNAPSHOT</version> <version>1.11.0-SNAPSHOT</version>
<packaging>war</packaging> <packaging>war</packaging>
<description>The URI Resolver is an HTTP URI resolver implemented as an HTTP servlet which gives access trough HTTP to different protocols URIs. </description> <description>The URI Resolver is an HTTP URI resolver implemented as an HTTP servlet which gives access trough HTTP to different protocols URIs. </description>

View File

@ -25,7 +25,7 @@ import org.gcube.datatransfer.resolver.gis.GeonetworkAccessParameter.GeonetworkL
import org.gcube.datatransfer.resolver.gis.entity.ServerParameters; import org.gcube.datatransfer.resolver.gis.entity.ServerParameters;
import org.gcube.datatransfer.resolver.gis.exception.GeonetworkInstanceException; import org.gcube.datatransfer.resolver.gis.exception.GeonetworkInstanceException;
import org.gcube.datatransfer.resolver.gis.exception.IllegalArgumentException; import org.gcube.datatransfer.resolver.gis.exception.IllegalArgumentException;
import org.gcube.datatransfer.resolver.gis.property.GisViewerAppGenericResourcePropertyReader; import org.gcube.datatransfer.resolver.gis.property.ApplicationProfileGenericResourcePropertyReader;
import org.gcube.datatransfer.resolver.gis.property.PropertyFileNotFoundException; import org.gcube.datatransfer.resolver.gis.property.PropertyFileNotFoundException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -47,15 +47,22 @@ public class GisResolver extends HttpServlet{
public static final String GIS_UUID = "gis-UUID"; public static final String GIS_UUID = "gis-UUID";
public static final String SCOPE = "scope"; public static final String SCOPE = "scope";
public static final String GEO_EXPLORER_LAYER_UUID = "geo-exp";
protected static final String GIS_VIEWER_GENERIC_RESOURCE_GCUBE_APPS_PROPERTIES = "gisviewerappgenericresource.properties";
protected static final String GEO_EXPLORER_GENERIC_RESOURCE_GCUBE_APPS_PROPERTIES = "geoexplorerappgenericresource.properties";
/** The logger. */ /** The logger. */
private static final Logger logger = LoggerFactory.getLogger(GisResolver.class); private static final Logger logger = LoggerFactory.getLogger(GisResolver.class);
protected Map<String, ServerParameters> cachedServerParams; //A cache: scope - geonetwork parameters protected Map<String, ServerParameters> cachedServerParams; //A cache: scope - geonetwork parameters
protected Map<String, String> cachedGisViewerApplHostname; //A cache: scope - GisViewerApp hostname protected Map<String, String> cachedGisViewerApplHostname; //A cache: scope - GisViewerApp hostname
protected Map<String, String> cachedGeoExplorerApplHostname; //A cache: scope - GisViewerApp hostname
private Timer timer; private Timer timer;
private GisViewerAppGenericResourcePropertyReader gisViewerAppPropertyReader; private ApplicationProfileGenericResourcePropertyReader gisViewerAppPropertyReader;
private ApplicationProfileGenericResourcePropertyReader geoEplorerAppPropertyReader;
//THIRTY MINUTES //THIRTY MINUTES
public static final long CACHE_RESET_TIME = 30*60*1000; public static final long CACHE_RESET_TIME = 30*60*1000;
@ -77,6 +84,7 @@ public class GisResolver extends HttpServlet{
reseCacheServerParameters(); reseCacheServerParameters();
resetGisViewerAppEndPoint(); resetGisViewerAppEndPoint();
reseCacheGisViewerApplicationHostname(); reseCacheGisViewerApplicationHostname();
reseCacheGeoExplorerApplicationHostname();
} }
}, CACHE_RESET_DELAY, CACHE_RESET_TIME); }, CACHE_RESET_DELAY, CACHE_RESET_TIME);
} }
@ -131,18 +139,39 @@ public class GisResolver extends HttpServlet{
logger.info("Cache Gis Viewer Hostname reset!"); logger.info("Cache Gis Viewer Hostname reset!");
} }
/**
* Rese cache geo explorer application hostname.
*/
private void reseCacheGeoExplorerApplicationHostname() {
cachedGeoExplorerApplHostname = new HashMap<String, String>();
logger.info("Cache Geo Explorer Hostname reset!");
}
/** /**
* Reset gis viewer app end point. * Reset gis viewer app end point.
*/ */
private void resetGisViewerAppEndPoint(){ private void resetGisViewerAppEndPoint(){
try { try {
gisViewerAppPropertyReader = new GisViewerAppGenericResourcePropertyReader(); gisViewerAppPropertyReader = new ApplicationProfileGenericResourcePropertyReader(GIS_VIEWER_GENERIC_RESOURCE_GCUBE_APPS_PROPERTIES);
logger.info("GisViewerApp end point updated!"); logger.info("GisViewerApp end point updated!");
} catch (PropertyFileNotFoundException e) { } catch (PropertyFileNotFoundException e) {
logger.error("Error on reset GisViewerAppEndPoint ",e); logger.error("Error on reset GisViewerAppEndPoint ",e);
} }
} }
/**
* Reset geo explorer app end point.
*/
private void resetGeoExplorerAppEndPoint(){
try {
geoEplorerAppPropertyReader = new ApplicationProfileGenericResourcePropertyReader(GEO_EXPLORER_GENERIC_RESOURCE_GCUBE_APPS_PROPERTIES);
logger.info("GeoExplorer end point updated!");
} catch (PropertyFileNotFoundException e) {
logger.error("Error on reset GeoExplorerEndPoint ",e);
}
}
/** /**
* Gets the gis viewer application url. * Gets the gis viewer application url.
* *
@ -168,9 +197,40 @@ public class GisResolver extends HttpServlet{
logger.info("Updated GisViewerApplication cache! Scope "+scope+" linking "+url); logger.info("Updated GisViewerApplication cache! Scope "+scope+" linking "+url);
return url; return url;
}else }else
logger.info("Cache Gis viewer application is not null using it"); logger.info("Cache for GisViewerApplication end point is not null using it");
return gisViewerAppHostname; return gisViewerAppHostname;
}
/**
* Gets the geo explorer application url.
*
* @param scope the scope
* @return the geo explorer application url
* @throws Exception the exception
*/
protected String getGeoExplorerApplicationURL(String scope) throws Exception{
if(cachedGeoExplorerApplHostname==null)
reseCacheGeoExplorerApplicationHostname();
logger.info("Tentative of recovering geo explorer application hostname from cache for scope: "+scope);
String geoExplorerApplicationHostname = cachedGeoExplorerApplHostname.get(scope);
if(geoExplorerApplicationHostname==null){
logger.info("GeoExplorer application hostname is null, reading from application profile..");
if(geoEplorerAppPropertyReader==null)
resetGeoExplorerAppEndPoint();
ApplicationProfileReader reader = new ApplicationProfileReader(scope, geoEplorerAppPropertyReader.getGenericResource(), geoEplorerAppPropertyReader.getAppId(), true);
String url = reader.getApplicationProfile().getUrl();
cachedGeoExplorerApplHostname.put(scope, url);
logger.info("Updated GeoExplorerApplication cache! Scope "+scope+" linking "+url);
return url;
}else
logger.info("Cache for GeoExplorerApplication end point is not null using it");
return geoExplorerApplicationHostname;
} }
@ -182,47 +242,75 @@ public class GisResolver extends HttpServlet{
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
logger.info("The http session id is: " + req.getSession().getId()); logger.info("The http session id is: " + req.getSession().getId());
String gisUUID = req.getParameter(GIS_UUID);
if (gisUUID == null || gisUUID.equals("")) {
logger.debug("GIS UUID not found");
sendError(resp, HttpServletResponse.SC_BAD_REQUEST, GIS_UUID+" not found or empty");
return;
}
logger.info("GIS UUID is: " + gisUUID);
String scope = req.getParameter(SCOPE); String scope = req.getParameter(SCOPE);
if (scope == null || scope.equals("")) { if (scope == null || scope.isEmpty()) {
logger.debug("Scope not found"); logger.error(SCOPE+" not found");
sendError(resp, HttpServletResponse.SC_BAD_REQUEST, SCOPE+" not found or empty"); sendError(resp, HttpServletResponse.SC_BAD_REQUEST, SCOPE+" not found or empty");
return; return;
} }
logger.info("SCOPE is: " + scope); logger.info("SCOPE is: " + scope);
boolean isGisLink = false;
boolean isGeoExplorerLink = false;
String gisUUID = req.getParameter(GIS_UUID);
if (gisUUID == null || gisUUID.isEmpty()) {
logger.debug(GIS_UUID+" not found");
}else
isGisLink = true;
logger.info(GIS_UUID +" is: " + gisUUID);
String geoExplorerUUID = req.getParameter(GEO_EXPLORER_LAYER_UUID);
if (geoExplorerUUID == null || geoExplorerUUID.isEmpty()) {
logger.debug(GEO_EXPLORER_LAYER_UUID+ " not found");
}else
isGeoExplorerLink = true;
logger.info(GEO_EXPLORER_LAYER_UUID +" is: " + geoExplorerUUID);
if(!isGisLink && !isGeoExplorerLink){
String err = GIS_UUID+" and "+GEO_EXPLORER_LAYER_UUID+" not found or empty";
logger.error(err);
sendError(resp, HttpServletResponse.SC_BAD_REQUEST, err);
return;
}
try { try {
ScopeProvider.instance.set(scope);
ServerParameters geonetworkParams = getCachedServerParameters(scope);
String wmsRequest = getLayerWmsRequest(scope, gisUUID, geonetworkParams);
logger.info("wms url is: " + wmsRequest);
wmsRequest = URLEncoder.encode(wmsRequest, UTF_8);
logger.info("encoded WMS url is: " + wmsRequest);
String gisPortletUrl = getGisViewerApplicationURL(scope); if(isGisLink){
logger.info("Gis Viewer Application url is: " + gisPortletUrl); ScopeProvider.instance.set(scope);
gisPortletUrl+="?rid="+new Random().nextLong() ServerParameters geonetworkParams = getCachedServerParameters(scope);
+"&wmsrequest="+wmsRequest String wmsRequest = getLayerWmsRequest(scope, gisUUID, geonetworkParams);
+"&uuid="+URLEncoder.encode(gisUUID, "UTF-8"); logger.info("wms url is: " + wmsRequest);
wmsRequest = URLEncoder.encode(wmsRequest, UTF_8);
logger.info("encoded WMS url is: " + wmsRequest);
/*resp.setContentType(TEXT_PLAIN); String gisViewerPortletUrl = getGisViewerApplicationURL(scope);
resp.setCharacterEncoding(UTF_8); logger.info("Gis Viewer Application url is: " + gisViewerPortletUrl);
PrintWriter out = resp.getWriter(); gisViewerPortletUrl+="?rid="+new Random().nextLong()
out.println(gisPortletUrl); +"&wmsrequest="+wmsRequest
logger.info("returning link: " + gisPortletUrl); +"&uuid="+URLEncoder.encode(gisUUID, "UTF-8");
out.close();*/
urlRedirect(req, resp, gisPortletUrl); /*resp.setContentType(TEXT_PLAIN);
resp.setCharacterEncoding(UTF_8);
PrintWriter out = resp.getWriter();
out.println(gisPortletUrl);
logger.info("returning link: " + gisPortletUrl);
out.close();*/
urlRedirect(req, resp, gisViewerPortletUrl);
}
if(isGeoExplorerLink){
ScopeProvider.instance.set(scope);
String geoExplorerPortletUrl = getGeoExplorerApplicationURL(scope);
logger.info("GeoExplorer Application url is: " + geoExplorerPortletUrl);
geoExplorerPortletUrl+="?rid="+new Random().nextLong()
+"&luuid="+URLEncoder.encode(geoExplorerUUID, "UTF-8");
urlRedirect(req, resp, geoExplorerPortletUrl);
}
} catch (IllegalArgumentException e){ } catch (IllegalArgumentException e){
logger.error("IllegalArgumentException:", e); logger.error("IllegalArgumentException:", e);
@ -334,7 +422,6 @@ public class GisResolver extends HttpServlet{
*/ */
protected void urlRedirect(HttpServletRequest req, HttpServletResponse response, String redirectTo) throws IOException { protected void urlRedirect(HttpServletRequest req, HttpServletResponse response, String redirectTo) throws IOException {
response.sendRedirect(response.encodeRedirectURL(redirectTo)); response.sendRedirect(response.encodeRedirectURL(redirectTo));
return;
} }
/** /**
@ -366,27 +453,36 @@ public class GisResolver extends HttpServlet{
return url.toString(); return url.toString();
} }
/**
* The main method.
*
* @param args the arguments
*/
public static void main(String[] args) { public static void main(String[] args) {
GisResolver gisResolver = new GisResolver(); GisResolver gisResolver = new GisResolver();
String scope = "/gcube/devsec/devVRE"; String scope = "/gcube/devsec/devVRE";
String UUID = "177e1c3c-4a22-4ad9-b015-bfc443d16cb8"; String UUID = "177e1c3c-4a22-4ad9-b015-bfc443d16cb8";
try { try {
ScopeProvider.instance.set(scope); // ScopeProvider.instance.set(scope);
ServerParameters geonetworkParams = gisResolver.getCachedServerParameters(scope); // ServerParameters geonetworkParams = gisResolver.getCachedServerParameters(scope);
String wmsRequest = gisResolver.getLayerWmsRequest(scope, UUID, geonetworkParams); // String wmsRequest = gisResolver.getLayerWmsRequest(scope, UUID, geonetworkParams);
logger.info("Final url is: " + wmsRequest); // logger.info("Final url is: " + wmsRequest);
wmsRequest = URLEncoder.encode(wmsRequest, UTF_8); // wmsRequest = URLEncoder.encode(wmsRequest, UTF_8);
logger.info("Encoded WMS request is: " + wmsRequest); // logger.info("Encoded WMS request is: " + wmsRequest);
String gisPortletUrl = gisResolver.getGisViewerApplicationURL(scope); // String gisPortletUrl = gisResolver.getGisViewerApplicationURL(scope);
logger.info("Gis Viewer Application url is: " + gisPortletUrl); // logger.info("Gis Viewer Application url is: " + gisPortletUrl);
// logger.info("WmsRequest is: " + wmsRequest); //// logger.info("WmsRequest is: " + wmsRequest);
// wmsRequest = encodeURLWithParamDelimiter(wmsRequest); //// wmsRequest = encodeURLWithParamDelimiter(wmsRequest);
// logger.info("Encoded url is: " + wmsRequest); //// logger.info("Encoded url is: " + wmsRequest);
// wmsRequest = appendParamReplacement(wmsRequest); //// wmsRequest = appendParamReplacement(wmsRequest);
gisPortletUrl+="?wmsrequest="+wmsRequest; // gisPortletUrl+="?wmsrequest="+wmsRequest;
//
System.out.println(gisPortletUrl); // System.out.println(gisPortletUrl);
// urlRedirect(req, resp, gisPortletUrl); // urlRedirect(req, resp, gisPortletUrl);
ScopeProvider.instance.set(scope);
String geoExplorerURL = gisResolver.getGeoExplorerApplicationURL(scope);
logger.info("GeoExplorer url is: " + geoExplorerURL);
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();

View File

@ -6,33 +6,36 @@ import java.util.Properties;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* The Class GisViewerAppGenericResourcePropertyReader. * The Class ApplicationProfileGenericResourcePropertyReader.
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jan 13, 2016 * Mar 9, 2017
*/ */
public class GisViewerAppGenericResourcePropertyReader { public class ApplicationProfileGenericResourcePropertyReader {
protected static final String GENERIC_RESOURCE_GCUBE_APPS_PROPERTIES = "gisviewerappgenericresource.properties"; //protected static final String GENERIC_RESOURCE_GCUBE_APPS_PROPERTIES = "gisviewerappgenericresource.properties";
protected static final String SECONDARY_TYPE = "SECONDARY_TYPE"; protected static final String SECONDARY_TYPE = "SECONDARY_TYPE";
protected static final String APP_ID = "APP_ID"; protected static final String APP_ID = "APP_ID";
private String appId; private String appId;
private String genericResource; private String genericResource;
private Logger logger = Logger.getLogger(GisViewerAppGenericResourcePropertyReader.class); private Logger logger = Logger.getLogger(ApplicationProfileGenericResourcePropertyReader.class);
/** /**
* Instantiates a new gis viewer app generic resource property reader. * Instantiates a new gis viewer app generic resource property reader.
* *
* @param fileNameProperty the file name property
* @throws PropertyFileNotFoundException the property file not found exception * @throws PropertyFileNotFoundException the property file not found exception
*/ */
public GisViewerAppGenericResourcePropertyReader() throws PropertyFileNotFoundException { public ApplicationProfileGenericResourcePropertyReader(String fileNameProperty) throws PropertyFileNotFoundException {
Properties prop = new Properties(); Properties prop = new Properties();
try { try {
InputStream in = (InputStream) GisViewerAppGenericResourcePropertyReader.class.getResourceAsStream(GENERIC_RESOURCE_GCUBE_APPS_PROPERTIES); InputStream in = ApplicationProfileGenericResourcePropertyReader.class.getResourceAsStream(fileNameProperty);
// load a properties file // load a properties file
prop.load(in); prop.load(in);
// get the property value - the application Id // get the property value - the application Id

View File

@ -0,0 +1,11 @@
# Property files
#
# author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
# created 02/2013
#
# The generic resource that describes the properties to open
# an item from workspace
#
SECONDARY_TYPE = ApplicationProfile
APP_ID = org.gcube.portlets.user.geoexplorer.server.GeoExplorerServiceImpl

View File

@ -23,15 +23,21 @@ public class GeonetworkQueryTest {
//private String[] scopes = {"/gcube/devNext/NextNext"}; //private String[] scopes = {"/gcube/devNext/NextNext"};
//private String[] scopesProd = {"/d4science.research-infrastructures.eu/gCubeApps/BiodiversityLab"}; //private String[] scopesProd = {"/d4science.research-infrastructures.eu/gCubeApps"};
private String[] scopesProd = {"/d4science.research-infrastructures.eu/gCubeApps/SIASPA"}; //private String[] scopesProd = {"/d4science.research-infrastructures.eu/gCubeApps/fisheriesandecosystematmii"};
private LoginLevel loginLevel = LoginLevel.CKAN; private String[] scopesProd = {"/d4science.research-infrastructures.eu/D4Research"};
//private String[] scopesProd = {"/d4science.research-infrastructures.eu"};
private LoginLevel loginLevel = LoginLevel.SCOPE;
private Type accountType = Type.SCOPE; private Type accountType = Type.SCOPE;
@Test private String textToSearch = "salinity";
//@Test
public void getCount() throws Exception{ public void getCount() throws Exception{
try{ try{
for(String scope:scopesProd){ for(String scope:scopesProd){
@ -79,10 +85,93 @@ public class GeonetworkQueryTest {
} }
@Test
public void getLayersBySearch() throws Exception{
try{
for(String scope:scopesProd){
ScopeProvider.instance.set(scope);
GeoNetworkPublisher reader=GeoNetwork.get();
Configuration config = reader.getConfiguration();
Account account=config.getScopeConfiguration().getAccounts().get(accountType);
//System.out.println("User: "+account.getUser()+", Pwd: "+account.getPassword());
System.out.println("Admin: "+config.getAdminAccount().getUser()+", Pwd: "+config.getAdminAccount().getPassword());
try{
String decryptedPassword = StringEncrypter.getEncrypter().decrypt(account.getPassword());
System.out.println("Decrypted Password: "+decryptedPassword);
}catch(Exception e){
System.out.println("ignoring exception during pwd decrypting");
}
// req.addParam("keyword", "Thredds");
//final GNSearchRequest req=new GNSearchRequest();
final GNSearchRequest req = getRequest(true, textToSearch);
// req.addParam(GNSearchRequest.Param.any,"Thredds");
GNSearchResponse resp = reader.query(req);
int publicCount=resp.getCount();
reader.login(loginLevel);
int totalCount=reader.query(req).getCount();
System.out.println("QUERY "+textToSearch);
System.out.println("SCOPE "+scope+" found "+totalCount+" (public : "+publicCount+", private :"+(totalCount-publicCount)+")");
// if(totalCount==0)
// return;
// try{
// int last = totalCount>MAX?totalCount:MAX;
//
// for(int i=0; i<last; i++){
// //String xml = reader.getByIdAsRawString(resp.getMetadata(i).getUUID());
// GNMetadata xml = resp.getMetadata(i);
// //System.out.println(i+") is Thredds? "+containsString(xml, "Thredds"));
// System.out.println(xml.toString());
// }
// }catch(Exception e ){
// e.printStackTrace();
// }
}
}catch(Exception e){
e.printStackTrace();
}
}
private boolean containsString(String txt, String value){ private boolean containsString(String txt, String value){
return txt.contains(value); return txt.contains(value);
} }
/**
* Gets the request.
*
* @param sortByTitle the sort by title
* @param textToSearch the text to search
* @return the request
*/
public GNSearchRequest getRequest(boolean sortByTitle, String textToSearch) {
GNSearchRequest req = new GNSearchRequest();
if(sortByTitle)
req.addConfig(GNSearchRequest.Config.sortBy, "title");
if(textToSearch==null || textToSearch.isEmpty()){
req.addParam(GNSearchRequest.Param.any, textToSearch);
System.out.println("search by any text");
}else{
req.addParam(GNSearchRequest.Param.title, textToSearch);
req.addConfig(GNSearchRequest.Config.similarity, Integer.toString(1));
System.out.println("search by title");
}
System.out.println("text to search "+textToSearch);
return req;
}
// @Test // @Test
public void getCountProd() throws Exception{ public void getCountProd() throws Exception{

View File

@ -1,5 +1,6 @@
/** /**
* *
*/ */
@ -11,29 +12,29 @@
public class GisResolverTest { public class GisResolverTest {
// public void resolve(){ /*public void resolve(){
// GisResolver gisResolver = new GisResolver(); GisResolver gisResolver = new GisResolver();
// String scope = "/gcube/devsec/devVRE"; String scope = "/gcube/devsec/devVRE";
// String UUID = "177e1c3c-4a22-4ad9-b015-bfc443d16cb8"; String UUID = "177e1c3c-4a22-4ad9-b015-bfc443d16cb8";
// try { try {
// ServerParameters geonetworkParams = gisResolver.getCachedServerParameters(scope); ServerParameters geonetworkParams = gisResolver.getCachedServerParameters(scope);
// String wmsRequest = gisResolver.getLayerWmsRequest(scope, UUID, geonetworkParams); String wmsRequest = gisResolver.getLayerWmsRequest(scope, UUID, geonetworkParams);
// System.out.println("Final url is: " + wmsRequest); System.out.println("Final url is: " + wmsRequest);
// wmsRequest = URLEncoder.encode(wmsRequest, UTF_8); wmsRequest = URLEncoder.encode(wmsRequest, UTF_8);
// System.out.println("Encoded WMS request is: " + wmsRequest); System.out.println("Encoded WMS request is: " + wmsRequest);
// String gisPortletUrl = gisResolver.getGisViewerApplicationURL(scope); String gisPortletUrl = gisResolver.getGisViewerApplicationURL(scope);
// System.out.println("Gis Viewer Application url is: " + gisPortletUrl); System.out.println("Gis Viewer Application url is: " + gisPortletUrl);
//// logger.info("WmsRequest is: " + wmsRequest); // logger.info("WmsRequest is: " + wmsRequest);
//// wmsRequest = encodeURLWithParamDelimiter(wmsRequest); // wmsRequest = encodeURLWithParamDelimiter(wmsRequest);
//// logger.info("Encoded url is: " + wmsRequest); // logger.info("Encoded url is: " + wmsRequest);
//// wmsRequest = appendParamReplacement(wmsRequest); // wmsRequest = appendParamReplacement(wmsRequest);
// gisPortletUrl+="?wmsrequest="+wmsRequest; gisPortletUrl+="?wmsrequest="+wmsRequest;
//
// System.out.println(gisPortletUrl); System.out.println(gisPortletUrl);
//// urlRedirect(req, resp, gisPortletUrl); // urlRedirect(req, resp, gisPortletUrl);
// } catch (Exception e) { } catch (Exception e) {
// // TODO Auto-generated catch block // TODO Auto-generated catch block
// e.printStackTrace(); e.printStackTrace();
// } }
// } }*/
} }