Updated test classes

This commit is contained in:
Francesco Mangiacrapa 2019-08-27 14:52:32 +02:00
parent 11530b14c9
commit 14feee5496
4 changed files with 158 additions and 158 deletions

View File

@ -1,6 +1,3 @@
import it.geosolutions.geonetwork.util.GNSearchRequest;
import it.geosolutions.geonetwork.util.GNSearchResponse;
import org.gcube.common.encryption.StringEncrypter; import org.gcube.common.encryption.StringEncrypter;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.spatial.data.geonetwork.GeoNetwork; import org.gcube.spatial.data.geonetwork.GeoNetwork;
@ -12,6 +9,9 @@ import org.gcube.spatial.data.geonetwork.model.Account;
import org.gcube.spatial.data.geonetwork.model.Account.Type; import org.gcube.spatial.data.geonetwork.model.Account.Type;
import org.opengis.metadata.Metadata; import org.opengis.metadata.Metadata;
import it.geosolutions.geonetwork.util.GNSearchRequest;
import it.geosolutions.geonetwork.util.GNSearchResponse;
/** /**
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it

View File

@ -1,128 +1,128 @@
//import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
//import java.io.IOException; import java.io.IOException;
//import java.io.InputStream; import java.io.InputStream;
//import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
//import java.nio.file.Files; import java.nio.file.Files;
//import java.nio.file.Path; import java.nio.file.Path;
//import java.nio.file.Paths; import java.nio.file.Paths;
//import java.util.ArrayList; import java.util.ArrayList;
//import java.util.HashMap; import java.util.HashMap;
//import java.util.Map; import java.util.Map;
//
//import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
//import org.gcube.datatransfer.resolver.gis.geonetwork.GeonetworkResolver; import org.gcube.datatransfer.resolver.services.GeonetworkResolver;
//import org.gcube.datatransfer.resolver.gis.geonetwork.HTTPCallsUtils; import org.gcube.datatransfer.resolver.util.GetResponseRecordFilter;
//import org.gcube.datatransfer.resolver.gis.util.GetResponseRecordFilter; import org.gcube.datatransfer.resolver.util.HTTPCallsUtils;
//import org.gcube.spatial.data.geonetwork.GeoNetwork; import org.gcube.spatial.data.geonetwork.GeoNetwork;
//import org.gcube.spatial.data.geonetwork.GeoNetworkPublisher; import org.gcube.spatial.data.geonetwork.GeoNetworkPublisher;
//import org.gcube.spatial.data.geonetwork.LoginLevel; import org.gcube.spatial.data.geonetwork.LoginLevel;
//import org.gcube.spatial.data.geonetwork.configuration.Configuration; import org.gcube.spatial.data.geonetwork.configuration.Configuration;
//import org.gcube.spatial.data.geonetwork.model.Account; import org.gcube.spatial.data.geonetwork.model.Account;
//import org.gcube.spatial.data.geonetwork.model.Account.Type; import org.gcube.spatial.data.geonetwork.model.Account.Type;
//
//
///** /**
// * *
// */ */
///** /**
// * *
// * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
// * Sep 8, 2016 * Sep 8, 2016
// */ */
//public class GeonetworkResolverTest { public class GeonetworkResolverTest {
//
// private static String scope = "/d4science.research-infrastructures.eu"; private static String scope = "/d4science.research-infrastructures.eu";
//
// private static LoginLevel loginLevel = LoginLevel.SCOPE; private static LoginLevel loginLevel = LoginLevel.SCOPE;
//
// private static Type accountType = Type.CKAN; private static Type accountType = Type.CKAN;
//
// /** /**
// * The main method. * The main method.
// * *
// * @param args the arguments * @param args the arguments
// * @throws UnsupportedEncodingException the unsupported encoding exception * @throws UnsupportedEncodingException the unsupported encoding exception
// */ */
// public static void main(String[] args) throws UnsupportedEncodingException { public static void main(String[] args) throws UnsupportedEncodingException {
//
// /*String scopeValue ="/gcube/devsec/devVRE"; /*String scopeValue ="/gcube/devsec/devVRE";
// String remainValue = "/srv/en/mef.export"; String remainValue = "/srv/en/mef.export";
// String queryString = "scope=/gcube/devsec/devVRE&remainPath=/srv/en/mef.export&version=2.0.2&request=GetCapabilities&service=CSW"; String queryString = "scope=/gcube/devsec/devVRE&remainPath=/srv/en/mef.export&version=2.0.2&request=GetCapabilities&service=CSW";
// ServerParameters geonetworkParams = new ServerParameters("http://geoserver-dev2.d4science-ii.research-infrastructures.eu/geonetwork", "", ""); ServerParameters geonetworkParams = new ServerParameters("http://geoserver-dev2.d4science-ii.research-infrastructures.eu/geonetwork", "", "");
//
// String newQueryString = purgeScopeFromQueryString(scopeValue, queryString); String newQueryString = purgeScopeFromQueryString(scopeValue, queryString);
// logger.info("Purged query string from "+scopeValue+" is: "+newQueryString); logger.info("Purged query string from "+scopeValue+" is: "+newQueryString);
//
// String baseURL = remainValue==null ||remainValue.isEmpty()?geonetworkParams.getUrl()+"/"+CSW_SERVER:geonetworkParams.getUrl()+"/"+CSW_SERVER+remainValue; String baseURL = remainValue==null ||remainValue.isEmpty()?geonetworkParams.getUrl()+"/"+CSW_SERVER:geonetworkParams.getUrl()+"/"+CSW_SERVER+remainValue;
// logger.info("New base URL "+baseURL); logger.info("New base URL "+baseURL);
// newQueryString = purgeRemainFromQueryString(remainValue, newQueryString); newQueryString = purgeRemainFromQueryString(remainValue, newQueryString);
// logger.info("Purged query string from "+remainValue+" is: "+newQueryString); logger.info("Purged query string from "+remainValue+" is: "+newQueryString);
//
// String gnGetlURL = newQueryString==null || newQueryString.isEmpty()? baseURL : baseURL+"?"+newQueryString; String gnGetlURL = newQueryString==null || newQueryString.isEmpty()? baseURL : baseURL+"?"+newQueryString;
// logger.info("Sending get request to URL: "+gnGetlURL);*/ logger.info("Sending get request to URL: "+gnGetlURL);*/
//
// try{ try{
// HTTPCallsUtils httpUtils = new HTTPCallsUtils(); HTTPCallsUtils httpUtils = new HTTPCallsUtils();
// String data =""; String data ="";
//
// ScopeProvider.instance.set(scope); ScopeProvider.instance.set(scope);
// GeoNetworkPublisher reader=GeoNetwork.get(); GeoNetworkPublisher reader=GeoNetwork.get();
//
//
// Configuration config = reader.getConfiguration(); Configuration config = reader.getConfiguration();
// Account account=config.getScopeConfiguration().getAccounts().get(accountType); Account account=config.getScopeConfiguration().getAccounts().get(accountType);
// reader.login(loginLevel); reader.login(loginLevel);
//
// String contentType = "application/xml ; charset=\"UTF-8\""; String contentType = "application/xml ; charset=\"UTF-8\"";
// String uuid = "c15ae8e5-71c0-4b8b-aa29-304cc4e97238"; String uuid = "c15ae8e5-71c0-4b8b-aa29-304cc4e97238";
// String gnCSWlURL = "http://geonetwork.d4science.org/geonetwork/srv/en/csw"; String gnCSWlURL = "http://geonetwork.d4science.org/geonetwork/srv/en/csw";
//// String gnCSWlURL = "http://geoserver-dev2.d4science-ii.research-infrastructures.eu/geonetwork/srv/en//srv/en/mef.export"; // String gnCSWlURL = "http://geoserver-dev2.d4science-ii.research-infrastructures.eu/geonetwork/srv/en//srv/en/mef.export";
//
// /*File file = File.createTempFile(uuid, ".xml"); /*File file = File.createTempFile(uuid, ".xml");
// InputStream response = httpUtils.post(gnCSWlURL, file, contentType);*/ InputStream response = httpUtils.post(gnCSWlURL, file, contentType);*/
//
// //MAP //MAP
// Map<String, String[]> map = new HashMap<String, String[]>(); Map<String, String[]> map = new HashMap<String, String[]>();
// String[] value = new String[1]; String[] value = new String[1];
// value[0]=uuid; value[0]=uuid;
// map.put(GeonetworkResolver.UUID, value); map.put(GeonetworkResolver.UUID, value);
//// data = "<request><uuid>"+uuid+"</uuid></request>"; // data = "<request><uuid>"+uuid+"</uuid></request>";
//
// data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
// "<csw:GetRecordById xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" service=\"CSW\" version=\"2.0.2\" " + "<csw:GetRecordById xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" service=\"CSW\" version=\"2.0.2\" " +
// "outputSchema=\"csw:IsoRecord\" xsi:schemaLocation=\"http://www.opengis.net/cat/csw/2.0.2/CSW-discovery.xsd\" xmlns=\"http://www.opengis.net/cat/csw/2.0.2\" " + "outputSchema=\"csw:IsoRecord\" xsi:schemaLocation=\"http://www.opengis.net/cat/csw/2.0.2/CSW-discovery.xsd\" xmlns=\"http://www.opengis.net/cat/csw/2.0.2\" " +
// "xmlns:ogc=\"http://www.opengis.net/ogc\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dct=\"http://purl.org/dc/terms/\" xmlns:gml=\"http://www.opengis.net/gml\" " + "xmlns:ogc=\"http://www.opengis.net/ogc\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dct=\"http://purl.org/dc/terms/\" xmlns:gml=\"http://www.opengis.net/gml\" " +
// "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"+ "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"+
// "<csw:Id>"+uuid+"</csw:Id>" + "<csw:Id>"+uuid+"</csw:Id>" +
// "<ElementSetName typeNames=\"csw:Record\">full</ElementSetName>" + "<ElementSetName typeNames=\"csw:Record\">full</ElementSetName>" +
// "</csw:GetRecordById>"; "</csw:GetRecordById>";
//
// byte[] byteArray = data.getBytes(); byte[] byteArray = data.getBytes();
// InputStream response = httpUtils.post(gnCSWlURL, new ByteArrayInputStream(byteArray), contentType, map); InputStream response = httpUtils.post(gnCSWlURL, new ByteArrayInputStream(byteArray), contentType, map);
//
//// String respToString = IOUtils.toString(response); // String respToString = IOUtils.toString(response);
//// System.out.println("Response returned by request: \n"+respToString); // System.out.println("Response returned by request: \n"+respToString);
//// InputStream responseToIs = IOUtils.toInputStream(respToString); // InputStream responseToIs = IOUtils.toInputStream(respToString);
// if(response!=null){ if(response!=null){
// try { try {
//
// InputStream re = GetResponseRecordFilter.overrideResponseIdsByListIds(response, new ArrayList<String>(), "Replaced UUID"); InputStream re = GetResponseRecordFilter.overrideResponseIdsByListIds(response, new ArrayList<String>(), "Replaced UUID");
//// String theString = IOUtils.toString(re); // String theString = IOUtils.toString(re);
//// System.out.println("Response returned after overriding: \n"+theString); // System.out.println("Response returned after overriding: \n"+theString);
//
// final Path destination = Paths.get("test.xml"); final Path destination = Paths.get("test.xml");
// Files.copy(re, destination); Files.copy(re, destination);
// } }
// catch (IOException e) { catch (IOException e) {
// // TODO Auto-generated catch block // TODO Auto-generated catch block
// e.printStackTrace(); e.printStackTrace();
// } }
// } }
//
// }catch (Exception e1) { }catch (Exception e1) {
// // TODO Auto-generated catch block // TODO Auto-generated catch block
// e1.printStackTrace(); e1.printStackTrace();
// } }
//
// } }
//} }

View File

@ -2,9 +2,7 @@ import static org.gcube.resources.discovery.icclient.ICFactory.client;
import java.io.StringReader; import java.io.StringReader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;

View File

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