Added Test classes
This commit is contained in:
parent
938fff31fb
commit
6a6f013689
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -10,8 +10,10 @@
|
|||
|
||||
|
||||
|
||||
<wb-module deploy-name="uri-resolver-2.8.1-SNAPSHOT">
|
||||
|
||||
|
||||
<wb-module deploy-name="uri-resolver-2.8.1">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -23,7 +25,8 @@
|
|||
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -35,7 +38,8 @@
|
|||
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -47,7 +51,8 @@
|
|||
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -59,7 +64,8 @@
|
|||
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -71,7 +77,8 @@
|
|||
|
||||
|
||||
<property name="context-root" value="uri-resolver"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -83,7 +90,8 @@
|
|||
|
||||
|
||||
<property name="java-output-path" value="/uri-resolver/target/classes"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -95,7 +103,8 @@
|
|||
|
||||
|
||||
</wb-module>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,381 @@
|
|||
package gis;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.common.encryption.StringEncrypter;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.spatial.data.geonetwork.GeoNetwork;
|
||||
import org.gcube.spatial.data.geonetwork.GeoNetworkPublisher;
|
||||
import org.gcube.spatial.data.geonetwork.GeoNetworkReader;
|
||||
import org.gcube.spatial.data.geonetwork.LoginLevel;
|
||||
import org.gcube.spatial.data.geonetwork.configuration.Configuration;
|
||||
import org.gcube.spatial.data.geonetwork.model.Account;
|
||||
import org.gcube.spatial.data.geonetwork.model.Account.Type;
|
||||
import org.junit.Test;
|
||||
|
||||
import it.geosolutions.geonetwork.util.GNSearchRequest;
|
||||
import it.geosolutions.geonetwork.util.GNSearchResponse;
|
||||
import it.geosolutions.geonetwork.util.GNSearchResponse.GNMetadata;
|
||||
|
||||
/**
|
||||
* The Class GeonetworkQueryTest.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Aug 31, 2016
|
||||
*/
|
||||
public class GeonetworkQueryTest {
|
||||
|
||||
private static final int MAX = 30;
|
||||
|
||||
//private String[] scopes = {"/gcube/devsec/devVRE"};
|
||||
|
||||
//private String[] scopes = {"/gcube/devsec/StaTabTest"};
|
||||
|
||||
//private String[] scopes = {"/gcube/devsec/devVRE"};
|
||||
|
||||
//private String[] scopes = {"/pred4s/preprod/preVRE"};
|
||||
|
||||
//private String[] scopes = {"/d4science.research-infrastructures.eu"};
|
||||
|
||||
//private String[] scopesProd = {"/d4science.research-infrastructures.eu/gCubeApps/fisheriesandecosystematmii"};
|
||||
|
||||
//private String[] scopesProd = {"/d4science.research-infrastructures.eu/D4Research"};
|
||||
|
||||
//private String[] scopesProd = {"/d4science.research-infrastructures.eu"};
|
||||
|
||||
//private String[] scopes = {"/d4science.research-infrastructures.eu/gCubeApps/BlueBridgeProject"};
|
||||
|
||||
//private String[] scopes = {"/d4science.research-infrastructures.eu/gCubeApps/AquacultureAtlasGeneration"};
|
||||
|
||||
//private String[] scopes = {"/d4science.research-infrastructures.eu/gCubeApps/FrenchTropicalTunaAtlas"};
|
||||
|
||||
private String[] scopes = {"/d4science.research-infrastructures.eu/gCubeApps/BiodiversityLab"};
|
||||
|
||||
//private String[] scopes = {"/d4science.research-infrastructures.eu/gCubeApps/SIASPA"};
|
||||
|
||||
//private String[] scopes = {"/d4science.research-infrastructures.eu/gCubeApps/ICCAT_BFT-E"};
|
||||
|
||||
|
||||
|
||||
private LoginLevel loginLevel = LoginLevel.CKAN;
|
||||
|
||||
private Type accountType = Type.CKAN;
|
||||
|
||||
private String textToSearch = "geo_fea";
|
||||
|
||||
/**
|
||||
* Gets the count.
|
||||
*
|
||||
* @return the count
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
//@Test
|
||||
public void getCount() throws Exception{
|
||||
|
||||
try{
|
||||
for(String scope:scopes){
|
||||
ScopeProvider.instance.set(scope);
|
||||
GeoNetworkPublisher reader=GeoNetwork.get();
|
||||
|
||||
Configuration config = reader.getConfiguration();
|
||||
Account account=config.getScopeConfiguration().getAccounts().get(accountType);
|
||||
|
||||
// Configuration config = gnInstance.getGeonetworkPublisher().getConfiguration();
|
||||
// Account account = config.getScopeConfiguration().getAccounts().get(Type.CKAN);
|
||||
|
||||
//System.out.println("User: "+account.getUser()+", Pwd: "+account.getPassword());
|
||||
System.out.println("Admin: "+config.getAdminAccount().getUser()+", Pwd: "+config.getAdminAccount().getPassword());
|
||||
System.out.println("USER: "+account.getUser()+", Pwd: "+account.getPassword());
|
||||
System.out.println("GN: "+config.getGeoNetworkEndpoint());
|
||||
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();
|
||||
// req.addParam(GNSearchRequest.Param.any,"Thredds");
|
||||
GNSearchResponse resp = reader.query(req);
|
||||
int publicCount=resp.getCount();
|
||||
System.out.println("Public UUIDs are: "+publicCount);
|
||||
Map<Long,String> publicUUIDs = getUUIDs(resp);
|
||||
System.out.println("Filled list of Public UUIDs with: "+publicUUIDs.size());
|
||||
System.out.println("Public layers are: ");
|
||||
printLayers(publicUUIDs);
|
||||
|
||||
reader.login(loginLevel);
|
||||
resp = reader.query(req);
|
||||
int totalCount=resp.getCount();
|
||||
System.out.println("All UUIDs are: "+totalCount);
|
||||
Map<Long,String> allUUIDs = getUUIDs(resp);
|
||||
System.out.println("Filled list of All UUIDs with: "+allUUIDs.size());
|
||||
|
||||
System.out.println("SCOPE "+scope+" found "+totalCount+" (public : "+publicCount+", private :"+(totalCount-publicCount)+")");
|
||||
|
||||
System.out.println("Private layers are: ");
|
||||
allUUIDs.keySet().removeAll(publicUUIDs.keySet());
|
||||
printLayers(allUUIDs);
|
||||
|
||||
/*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());
|
||||
System.out.println(i+") UUID: "+resp.getMetadata(i).getUUID() + " ID: "+resp.getMetadata(i).getId());
|
||||
//System.out.println(i+") is Thredds? "+containsString(xml, "Thredds"));
|
||||
}
|
||||
|
||||
}catch(Exception e ){
|
||||
e.printStackTrace();
|
||||
}*/
|
||||
System.out.println("DONE!!!");
|
||||
}
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prints the layers.
|
||||
*
|
||||
* @param layersUUIDs the layers UUI ds
|
||||
*/
|
||||
public void printLayers(Map<Long,String> layersUUIDs) {
|
||||
int index = 0;
|
||||
|
||||
for (Long key : layersUUIDs.keySet()) {
|
||||
index++;
|
||||
System.out.println(index+") ID: "+key+" - UUID: "+layersUUIDs.get(key));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the UUI ds.
|
||||
*
|
||||
* @param resp the resp
|
||||
* @return the UUI ds
|
||||
*/
|
||||
public static Map<Long,String> getUUIDs(GNSearchResponse resp){
|
||||
|
||||
Map<Long,String> listUUIDs = new HashMap<Long,String>();
|
||||
Iterator<GNMetadata> iterator = resp.iterator();
|
||||
while(iterator.hasNext()) {
|
||||
GNMetadata meta = iterator.next();
|
||||
//listUUIDs.add(new GN_META_REF(meta.getId(), meta.getUUID()));
|
||||
listUUIDs.put(meta.getId(), meta.getUUID());
|
||||
//System.out.println("Added: "+meta.getUUID());
|
||||
}
|
||||
|
||||
return listUUIDs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the layers by search.
|
||||
*
|
||||
* @return the layers by search
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
//@Test
|
||||
public void getLayersBySearch() throws Exception{
|
||||
try{
|
||||
for(String scope:scopes){
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Contains string.
|
||||
*
|
||||
* @param txt the txt
|
||||
* @param value the value
|
||||
* @return true, if successful
|
||||
*/
|
||||
private boolean containsString(String txt, String 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, "1");
|
||||
System.out.println("search by title");
|
||||
}
|
||||
System.out.println("text to search "+textToSearch);
|
||||
|
||||
return req;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class GN_META_REF.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* May 20, 2019
|
||||
*/
|
||||
public static class GN_META_REF{
|
||||
Long id;
|
||||
String uuid;
|
||||
|
||||
/**
|
||||
* Gets the id.
|
||||
*
|
||||
* @return the id
|
||||
*/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the id.
|
||||
*
|
||||
* @param id the new id
|
||||
*/
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the uuid.
|
||||
*
|
||||
* @return the uuid
|
||||
*/
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the uuid.
|
||||
*
|
||||
* @param uuid the new uuid
|
||||
*/
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new gn meta ref.
|
||||
*
|
||||
* @param id the id
|
||||
* @param uuid the uuid
|
||||
*/
|
||||
public GN_META_REF(Long id, String uuid) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("GN_META_REF [id=");
|
||||
builder.append(id);
|
||||
builder.append(", uuid=");
|
||||
builder.append(uuid);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the count prod.
|
||||
*
|
||||
* @return the count prod
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
// @Test
|
||||
public void getCountProd() throws Exception{
|
||||
try{
|
||||
for(String scope:scopes){
|
||||
ScopeProvider.instance.set(scope);
|
||||
GeoNetworkReader reader=GeoNetwork.get();
|
||||
final GNSearchRequest req=new GNSearchRequest();
|
||||
// req.addParam("keyword", "Thredds");
|
||||
// req.addParam(GNSearchRequest.Param.any,"Oscar");
|
||||
int publicCount=reader.query(req).getCount();
|
||||
reader.login(loginLevel);
|
||||
int totalCount=reader.query(req).getCount();
|
||||
System.out.println("SCOPE "+scope+" found "+totalCount+" (public : "+publicCount+", private :"+(totalCount-publicCount)+")");
|
||||
}
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,267 @@
|
|||
//package gis;
|
||||
//import it.geosolutions.geonetwork.util.GNSearchRequest;
|
||||
//import it.geosolutions.geonetwork.util.GNSearchResponse;
|
||||
//
|
||||
//import java.io.BufferedInputStream;
|
||||
//import java.io.BufferedReader;
|
||||
//import java.io.FileNotFoundException;
|
||||
//import java.io.FileReader;
|
||||
//import java.io.IOException;
|
||||
//import java.io.InputStream;
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.List;
|
||||
//import java.util.stream.Collectors;
|
||||
//
|
||||
//import javax.xml.parsers.DocumentBuilder;
|
||||
//import javax.xml.parsers.DocumentBuilderFactory;
|
||||
//
|
||||
//import org.gcube.common.encryption.StringEncrypter;
|
||||
//import org.gcube.common.scope.api.ScopeProvider;
|
||||
//import org.gcube.spatial.data.geonetwork.GeoNetwork;
|
||||
//import org.gcube.spatial.data.geonetwork.GeoNetworkPublisher;
|
||||
//import org.gcube.spatial.data.geonetwork.LoginLevel;
|
||||
//import org.gcube.spatial.data.geonetwork.configuration.Configuration;
|
||||
//import org.gcube.spatial.data.geonetwork.model.Account;
|
||||
//import org.gcube.spatial.data.geonetwork.model.Account.Type;
|
||||
//import org.slf4j.Logger;
|
||||
//import org.slf4j.LoggerFactory;
|
||||
//import org.w3c.dom.Document;
|
||||
//import org.w3c.dom.Element;
|
||||
//import org.w3c.dom.NodeList;
|
||||
//
|
||||
///**
|
||||
// *
|
||||
// * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
// * Aug 31, 2016
|
||||
// */
|
||||
//public class ICCATQueryTest {
|
||||
//
|
||||
// private static final int MAX = 200;
|
||||
//
|
||||
// //private String[] scopes = {"/gcube/devNext/NextNext"};
|
||||
//
|
||||
// //private String[] scopesProd = {"/d4science.research-infrastructures.eu"};
|
||||
//
|
||||
// private static String[] scopesProd = {"/d4science.research-infrastructures.eu/gCubeApps/ICCAT_BFT-E"};
|
||||
//
|
||||
// //private String[] scopesProd = {"/d4science.research-infrastructures.eu/gCubeApps/fisheriesandecosystematmii"};
|
||||
//
|
||||
// //private String[] scopesProd = {"/d4science.research-infrastructures.eu/D4Research"};
|
||||
//
|
||||
// //private String[] scopesProd = {"/d4science.research-infrastructures.eu"};
|
||||
//
|
||||
// private static LoginLevel loginLevel = LoginLevel.CKAN;
|
||||
//
|
||||
// private static Type accountType = Type.SCOPE;
|
||||
//
|
||||
// private static String textToSearch = "geo_fea";
|
||||
//
|
||||
// private static Logger logger = LoggerFactory.getLogger(ICCATQueryTest.class);
|
||||
//
|
||||
// private static enum LAYER_TYPE {PRIVATE, PUBLIC, ALL}
|
||||
//
|
||||
//
|
||||
// public static List<String> getLayers(LAYER_TYPE type) 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();
|
||||
//// req.addParam(GNSearchRequest.Param.any,"Thredds");
|
||||
// GNSearchResponse resp = reader.query(req);
|
||||
// int publicCount=resp.getCount();
|
||||
//
|
||||
// List<String> publicLayers = new ArrayList<String>();
|
||||
// for(int i=0; i<publicCount; i++)
|
||||
// publicLayers.add(resp.getMetadata(i).getUUID());
|
||||
//
|
||||
// System.out.println("Public layers are: "+publicLayers.size());
|
||||
//
|
||||
// //PERFOMING LOGIN TO GET ALL LAYERS
|
||||
// reader.login(loginLevel);
|
||||
// resp = reader.query(req);
|
||||
// int totalCount=resp.getCount();
|
||||
// int privateCount = totalCount-publicCount;
|
||||
//
|
||||
// System.out.println("SCOPE "+scope+" found "+totalCount+" (public : "+publicCount+", private :"+privateCount+")");
|
||||
//
|
||||
// List<String> privateLayers = new ArrayList<String>();
|
||||
// for(int i=0; i<totalCount; i++){
|
||||
//
|
||||
// String uuid = resp.getMetadata(i).getUUID();
|
||||
// //System.out.println("Searching UUID: "+uuid);
|
||||
// if(!publicLayers.contains(uuid)){
|
||||
// privateLayers.add(uuid);
|
||||
// }
|
||||
//
|
||||
//// String xml = reader.getByIdAsRawString(resp.getMetadata(i).getUUID());
|
||||
//// InputStream stream = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8));
|
||||
//// iccatGNUUID.add(toGetFileIdentifier(stream));
|
||||
//
|
||||
// //System.out.println(i+") is Thredds? "+containsString(xml, "Thredds"));
|
||||
// }
|
||||
//
|
||||
// System.out.println("Private layers are: "+privateLayers.size());
|
||||
//
|
||||
//
|
||||
// switch (type) {
|
||||
// case PUBLIC:
|
||||
// return publicLayers;
|
||||
// case PRIVATE:
|
||||
// return privateLayers;
|
||||
// case ALL:
|
||||
// publicLayers.addAll(privateLayers);
|
||||
// return publicLayers;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }catch(Exception e){
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Override summary record.
|
||||
// *
|
||||
// * @param doc the doc
|
||||
// * @param identifier the identifier
|
||||
// * @return true, if successful
|
||||
// */
|
||||
// private static String getFileIdentifierValue(Document doc) {
|
||||
//
|
||||
// // <csw:SummaryRecord> list
|
||||
// NodeList nodes = doc.getElementsByTagName("gmd:MD_Metadata");
|
||||
// logger.debug("gmd:MD_Metadata are: " + nodes.getLength());
|
||||
// for (int i = 0; i < nodes.getLength(); i++) {
|
||||
// Element mdMetadata = (Element) nodes.item(i);
|
||||
//
|
||||
// // <dc:identifier>
|
||||
// NodeList fileIdentifierLst = mdMetadata.getElementsByTagName("gmd:fileIdentifier");
|
||||
// if(fileIdentifierLst==null || fileIdentifierLst.getLength()==0 || fileIdentifierLst.item(0)==null){
|
||||
// logger.info("skipping, it has not fileidentifier");
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// Element id = (Element) fileIdentifierLst.item(0);
|
||||
//
|
||||
// NodeList gcoLst = id.getElementsByTagName("gco:CharacterString");
|
||||
// if(gcoLst==null || gcoLst.getLength()==0 || gcoLst.item(0)==null){
|
||||
// logger.info("skipping, it has not gco:CharacterString");
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// Element gco = (Element) gcoLst.item(0);
|
||||
// String idValue = gco.getTextContent();
|
||||
// logger.trace("Summary gmd:fileIdentifier is: " + idValue);
|
||||
// return idValue;
|
||||
// }
|
||||
//
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Removes the summary ids by list ids.
|
||||
// *
|
||||
// * @param getRecordsResponse the get records response
|
||||
// * @param idsToRemove the ids to remove
|
||||
// * @return the input stream
|
||||
// * @throws IOException Signals that an I/O exception has occurred.
|
||||
// */
|
||||
// public static String toGetFileIdentifier(InputStream getRecordResponse) throws IOException {
|
||||
//
|
||||
// try {
|
||||
// // logger.trace("getRecordsResponse is: "+IOUtils.toString(getRecordsResponse));
|
||||
// BufferedInputStream bis = new BufferedInputStream(getRecordResponse);
|
||||
// DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||
// dbf.setValidating(false);
|
||||
// DocumentBuilder db = dbf.newDocumentBuilder();
|
||||
// Document doc = db.parse(bis);
|
||||
// return getFileIdentifierValue(doc);
|
||||
// }
|
||||
// catch (Exception e) {
|
||||
// logger.error("An error occurred during removing IDS by List: ", e);
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// public static List<String> fileReader() throws FileNotFoundException{
|
||||
//
|
||||
// String fileName = "iccat_name_catalogue.csv";
|
||||
//
|
||||
//// //read file into stream, try-with-resources
|
||||
//// try (Stream<String> stream = Files.lines(Paths.get(fileName))) {
|
||||
////
|
||||
//// stream.forEach(System.out::println);
|
||||
////
|
||||
//// } catch (IOException e) {
|
||||
//// e.printStackTrace();
|
||||
//// }
|
||||
//
|
||||
// FileReader reportReader = new FileReader(fileName);
|
||||
// //Stream<String> stream = reportBW.lines();
|
||||
// List<String> list = new ArrayList<>();
|
||||
// try (BufferedReader reportBW = new BufferedReader(reportReader)){
|
||||
//
|
||||
// list = reportBW.lines().collect(Collectors.toList());
|
||||
//
|
||||
// }catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// return list;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// public static void main(String[] args) {
|
||||
//
|
||||
// List<String> listCKAN;
|
||||
// try {
|
||||
// listCKAN = fileReader();
|
||||
// System.out.println("CKAN Layers are: "+listCKAN.size());
|
||||
//// for (String line : listCKAN) {
|
||||
//// System.out.println("CKAN UUID: "+line);
|
||||
//// }
|
||||
//
|
||||
// List<String> listLayersUUID = getLayers(LAYER_TYPE.PUBLIC);
|
||||
// System.out.println("List Layers UUID are: "+listLayersUUID.size());
|
||||
//// for (String line : listLayersUUID) {
|
||||
//// System.out.println("PRIVATE GN UUID: "+line);
|
||||
//// }
|
||||
//
|
||||
//
|
||||
// listCKAN.removeAll(listLayersUUID);
|
||||
//
|
||||
// System.out.println("\n\n\nCKAN contains other: "+listCKAN.size());
|
||||
// for (String line : listCKAN) {
|
||||
// System.out.println("CKAN UUID: "+line);
|
||||
// }
|
||||
//
|
||||
// }catch (Exception e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// }
|
||||
//}
|
|
@ -0,0 +1,169 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package gis;
|
||||
|
||||
import it.geosolutions.geonetwork.util.GNSearchRequest;
|
||||
import it.geosolutions.geonetwork.util.GNSearchResponse;
|
||||
import resources.GetAllInfrastructureScopes;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.spatial.data.geonetwork.GeoNetwork;
|
||||
import org.gcube.spatial.data.geonetwork.GeoNetworkPublisher;
|
||||
import org.gcube.spatial.data.geonetwork.LoginLevel;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Mar 10, 2017
|
||||
*/
|
||||
public class LayersMatchingGN_CKAN {
|
||||
|
||||
//GN CONFIGURATIONS
|
||||
public static String rootScope = "/d4science.research-infrastructures.eu";
|
||||
//static String rootScope = "/pred4s";
|
||||
// static String rootScope = "/gcube";
|
||||
public static String platformName = "geonetwork";
|
||||
public static LoginLevel loginLevel = LoginLevel.ADMIN;
|
||||
//static Type accountType = Type.SCOPE;
|
||||
public static String textToSearch = "geo_fea";
|
||||
|
||||
public static PrintWriter reportPrintWriter;
|
||||
public static PrintWriter errorPrintWriter;
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
try{
|
||||
FileWriter reportWriter = new FileWriter(rootScope.substring(1,rootScope.length())+"_report_matching_gn_catalogue.csv", true);
|
||||
FileWriter errorWriter = new FileWriter(rootScope.substring(1,rootScope.length())+"_error_matching_gn_catalogue.csv", true);
|
||||
BufferedWriter reportBW = new BufferedWriter(reportWriter);
|
||||
BufferedWriter errorBW = new BufferedWriter(errorWriter);
|
||||
reportPrintWriter = new PrintWriter(reportBW);
|
||||
reportPrintWriter.println("NB.; SCOPE; GN Endpoint; TOTAL LAYERS; PUBLIC LAYERS; PRIVATE LAYERS");
|
||||
errorPrintWriter = new PrintWriter(errorBW);
|
||||
errorPrintWriter.println("SCOPE;");
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// final Path destination = Paths.get("report_matching_gn_catalogue.csv");
|
||||
// Files.w(re, destination);
|
||||
|
||||
List<String> scopesProd = new ArrayList<String>();
|
||||
|
||||
//RuntimeResourceReader readerRR;
|
||||
try {
|
||||
//MODE-1
|
||||
// readerRR = new RuntimeResourceReader(rootScope, platformName, null);
|
||||
// System.out.println(readerRR.toString());
|
||||
// System.out.println("Using GN: "+readerRR.getParameters());
|
||||
// System.out.println("Scopes are: "+readerRR.getScopes().size());
|
||||
// scopesProd.addAll(readerRR.getScopes());
|
||||
|
||||
//MODE-2
|
||||
Map<String,String> mapScopes = GetAllInfrastructureScopes.loadMapOfScopeNameToFullScope(rootScope);
|
||||
scopesProd.addAll(mapScopes.values());
|
||||
}
|
||||
catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
System.out.println("Read "+scopesProd.size() +" VREs from root scope: "+rootScope);
|
||||
int i = 0;
|
||||
for (String vre : scopesProd) {
|
||||
System.out.println(++i +"; "+vre);
|
||||
}
|
||||
|
||||
System.out.println("Scope found: "+scopesProd.size());
|
||||
|
||||
int count = 0;
|
||||
try{
|
||||
|
||||
for(String scope:scopesProd){
|
||||
count++;
|
||||
System.out.println("\n\n#"+count+" of "+scopesProd.size()+ " - Fetching scope: "+scope);
|
||||
ScopeProvider.instance.set(scope);
|
||||
GeoNetworkPublisher reader = null;
|
||||
String gnEP = null;
|
||||
try{
|
||||
reader=GeoNetwork.get();
|
||||
gnEP = reader.getConfiguration().getGeoNetworkEndpoint();
|
||||
|
||||
}catch (Exception e) {
|
||||
System.out.println("GeoNetwork not instanciable in the scope: "+scope);
|
||||
writeError(count+"; "+scope+" ; "+e.getMessage());
|
||||
}
|
||||
|
||||
if(reader!=null){
|
||||
// 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();
|
||||
// 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("SCOPE "+scope+" ; found "+totalCount+" (public : "+publicCount+", private :"+(totalCount-publicCount)+")");
|
||||
writeReport(count+"; "+scope+" ; "+gnEP+"; "+totalCount+" ; "+publicCount+"; "+(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());
|
||||
// System.out.println(i+") is Thredds? "+containsString(xml, "Thredds"));
|
||||
// }
|
||||
// }catch(Exception e ){
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}finally{
|
||||
if(reportPrintWriter!=null)
|
||||
reportPrintWriter.close();
|
||||
|
||||
if(errorPrintWriter!=null)
|
||||
errorPrintWriter.close();
|
||||
|
||||
System.out.println("Performed fetching from "+count+" scopes");
|
||||
System.out.println("FINISHED!!!");
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeReport(String newline){
|
||||
|
||||
reportPrintWriter.println(newline);
|
||||
}
|
||||
|
||||
private static void writeError(String newline){
|
||||
|
||||
errorPrintWriter.println(newline);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,166 @@
|
|||
package gis;
|
||||
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.encryption.StringEncrypter;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* The Class RuntimeResourceReader.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Mar 10, 2017
|
||||
*/
|
||||
public class RuntimeResourceReader {
|
||||
|
||||
// public static final String GEONETWORK_END_POINT =
|
||||
// "http://geonetwork.d4science.org/geonetwork";
|
||||
|
||||
public static final Logger logger = LoggerFactory.getLogger(RuntimeResourceReader.class);
|
||||
|
||||
// private List<String> scopes = new ArrayList<String>();
|
||||
|
||||
private List<ServiceEndpointBean> listSE = new ArrayList<ServiceEndpointBean>();
|
||||
|
||||
/**
|
||||
* Instantiates a new runtime resource reader.
|
||||
*
|
||||
* @param scope the scope
|
||||
* @param platformName the platform name
|
||||
* @param endPoint the end point
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public RuntimeResourceReader(String scope, String platformName, String category, String endPoint) throws Exception {
|
||||
read(scope, platformName, category, endPoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read.
|
||||
*
|
||||
* @param scope the scope
|
||||
* @param platformName the platform name
|
||||
* @param endPoint the end point
|
||||
* @return the server parameters
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
private List<ServiceEndpointBean> read(String scope, String platformName, String category, String endPoint)
|
||||
throws Exception {
|
||||
|
||||
String originalScope = null;
|
||||
try {
|
||||
|
||||
originalScope = ScopeProvider.instance.get();
|
||||
|
||||
ScopeProvider.instance.set(scope);
|
||||
|
||||
SimpleQuery query = queryFor(ServiceEndpoint.class);
|
||||
query.addCondition("$resource/Profile/Platform/Name/text() eq '" + platformName + "'");
|
||||
query.addCondition("$resource/Profile/Category/text() eq '" + category + "'");
|
||||
if (endPoint != null && !endPoint.isEmpty())
|
||||
query.addCondition("$resource/Profile/AccessPoint/Interface/Endpoint/text() eq '" + endPoint + "'");
|
||||
|
||||
// query.addVariable("$prop", "$resource/Profile/AccessPoint/Properties/Property")
|
||||
// .addCondition("$prop/Name/text() eq 'priority'")
|
||||
// .addCondition("$prop/Value/text() eq '1'");
|
||||
|
||||
logger.info("GeoRuntimeReader, using scope: " + scope + ", to get resource: " + platformName);
|
||||
|
||||
DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class);
|
||||
|
||||
List<ServiceEndpoint> listServiceEndpoint = client.submit(query);
|
||||
if (listServiceEndpoint == null || listServiceEndpoint.isEmpty())
|
||||
throw new Exception("Cannot retrieve the runtime resource: " + platformName);
|
||||
|
||||
for (ServiceEndpoint serviceEndpoint : listServiceEndpoint) {
|
||||
|
||||
ServiceEndpointBean seb = new ServiceEndpointBean();
|
||||
|
||||
seb.setRuntime(serviceEndpoint.profile().runtime());
|
||||
|
||||
List<AccessPoint> listAp = new ArrayList<ServiceEndpoint.AccessPoint>();
|
||||
try {
|
||||
for (AccessPoint accessPoint : serviceEndpoint.profile().accessPoints()) {
|
||||
listAp.add(accessPoint);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println("Error on reading Access point not found");
|
||||
}
|
||||
|
||||
System.out.println("sono qui");
|
||||
|
||||
seb.setListAP(listAp);
|
||||
listSE.add(seb);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Sorry, an error occurred on reading parameters in Runtime Resources", e);
|
||||
} finally {
|
||||
if (originalScope != null && !originalScope.isEmpty()) {
|
||||
ScopeProvider.instance.set(originalScope);
|
||||
logger.info("scope provider setted to orginal scope: " + originalScope);
|
||||
} else {
|
||||
ScopeProvider.instance.reset();
|
||||
logger.info("scope provider reset");
|
||||
}
|
||||
}
|
||||
|
||||
return listSE;
|
||||
}
|
||||
|
||||
public List<ServiceEndpointBean> getListSE() {
|
||||
return listSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* The main method.
|
||||
*
|
||||
* @param args the arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
|
||||
String scope = "/gcube/devsec/devVRE";
|
||||
String platformName = "GeoServer";
|
||||
|
||||
//scope = "/pred4s/preprod/preVRE";
|
||||
|
||||
RuntimeResourceReader reader;
|
||||
try {
|
||||
ScopeProvider.instance.set(scope);
|
||||
reader = new RuntimeResourceReader(scope, "postgis", "Database", null);
|
||||
|
||||
for (ServiceEndpointBean seb : reader.getListSE()) {
|
||||
System.out.println("Found: " + seb);
|
||||
|
||||
List<AccessPoint> listAp = seb.getListAP();
|
||||
|
||||
for (AccessPoint ap : listAp) {
|
||||
System.out.println("username: " + ap.username());
|
||||
System.out.println("password: " + ap.password());
|
||||
try{
|
||||
String decryptedPassword = StringEncrypter.getEncrypter().decrypt(ap.password());
|
||||
System.out.println("Decrypted Password: "+decryptedPassword);
|
||||
}catch(Exception e){
|
||||
System.out.println("ignoring exception during pwd decrypting");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,167 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package gis;
|
||||
|
||||
import it.geosolutions.geonetwork.util.GNSearchRequest;
|
||||
import it.geosolutions.geonetwork.util.GNSearchResponse;
|
||||
import resources.GetAllInfrastructureScopes;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.spatial.data.geonetwork.GeoNetwork;
|
||||
import org.gcube.spatial.data.geonetwork.GeoNetworkPublisher;
|
||||
import org.gcube.spatial.data.geonetwork.LoginLevel;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.itextpdf.text.log.SysoCounter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Mar 10, 2017
|
||||
*/
|
||||
public class SE_Harvester_from_IS {
|
||||
|
||||
// GN CONFIGURATIONS
|
||||
public static String rootScope = "/d4science.research-infrastructures.eu";
|
||||
// static String rootScope = "/pred4s";
|
||||
// static String rootScope = "/gcube";
|
||||
public static final String platformName = "geoserver";
|
||||
public static final String category = "Gis";
|
||||
public static LoginLevel loginLevel = LoginLevel.ADMIN;
|
||||
|
||||
public static PrintWriter reportPrintWriter;
|
||||
public static PrintWriter errorPrintWriter;
|
||||
|
||||
public static HashSet<String> uniqueGNs = new HashSet<String>();
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
try {
|
||||
FileWriter reportWriter = new FileWriter(
|
||||
rootScope.substring(1, rootScope.length()) + "_report_" + platformName + "_harvester.csv", true);
|
||||
FileWriter errorWriter = new FileWriter(
|
||||
rootScope.substring(1, rootScope.length()) + "_error_" + platformName + "_harvester.csv", true);
|
||||
BufferedWriter reportBW = new BufferedWriter(reportWriter);
|
||||
BufferedWriter errorBW = new BufferedWriter(errorWriter);
|
||||
reportPrintWriter = new PrintWriter(reportBW);
|
||||
reportPrintWriter.println("NB.; SCOPE; SE Hosted_On; SE AccessPoint;");
|
||||
errorPrintWriter = new PrintWriter(errorBW);
|
||||
errorPrintWriter.println("SCOPE;");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// final Path destination = Paths.get("report_matching_gn_catalogue.csv");
|
||||
// Files.w(re, destination);
|
||||
|
||||
List<String> listScopes = new ArrayList<String>();
|
||||
|
||||
// RuntimeResourceReader readerRR;
|
||||
try {
|
||||
// MODE-1
|
||||
// readerRR = new RuntimeResourceReader(rootScope, platformName, null);
|
||||
// System.out.println(readerRR.toString());
|
||||
// System.out.println("Using GN: "+readerRR.getParameters());
|
||||
// System.out.println("Scopes are: "+readerRR.getScopes().size());
|
||||
// scopesProd.addAll(readerRR.getScopes());
|
||||
|
||||
// MODE-2
|
||||
Map<String, String> mapScopes = GetAllInfrastructureScopes.loadMapOfScopeNameToFullScope(rootScope);
|
||||
listScopes.addAll(mapScopes.values());
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
System.out.println("Read " + listScopes.size() + " VREs from root scope: " + rootScope);
|
||||
int i = 0;
|
||||
for (String vre : listScopes) {
|
||||
System.out.println(++i + "; " + vre);
|
||||
}
|
||||
|
||||
System.out.println("Scope found: " + listScopes.size());
|
||||
try {
|
||||
|
||||
searchFor(listScopes, platformName, category);
|
||||
searchFor(listScopes, "GeoServer", category);
|
||||
|
||||
System.out.println("\n\nUnique " + platformName + " addresses");
|
||||
uniqueGNs.stream().forEach(s -> System.out.println(s));
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (reportPrintWriter != null)
|
||||
reportPrintWriter.close();
|
||||
|
||||
if (errorPrintWriter != null)
|
||||
errorPrintWriter.close();
|
||||
|
||||
System.out.println("Performed fetching from " + listScopes.size() + " scopes");
|
||||
System.out.println("FINISHED!!!");
|
||||
}
|
||||
}
|
||||
|
||||
private static void searchFor(List<String> listScopes, String platformName, String category) {
|
||||
|
||||
int count = 0;
|
||||
int writerCount = 0;
|
||||
try {
|
||||
|
||||
for (String scope : listScopes) {
|
||||
count++;
|
||||
System.out.println("\n\n#" + count + " of " + listScopes.size() + " - Fetching scope: " + scope);
|
||||
|
||||
RuntimeResourceReader rrr = new RuntimeResourceReader(scope, platformName, category, null);
|
||||
|
||||
List<ServiceEndpointBean> listSE = rrr.getListSE();
|
||||
|
||||
for (ServiceEndpointBean seb : listSE) {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (AccessPoint ap : seb.getListAP()) {
|
||||
sb.append(ap.address());
|
||||
sb.append(", ");
|
||||
|
||||
uniqueGNs.add(ap.address());
|
||||
}
|
||||
|
||||
sb.toString();
|
||||
writerCount++;
|
||||
writeReport(
|
||||
writerCount + "; " + scope + " ; " + seb.getRuntime().hostedOn() + "; " + sb.toString());
|
||||
|
||||
}
|
||||
|
||||
Thread.sleep(200);
|
||||
|
||||
// if(count==10)
|
||||
// break;
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeReport(String newline) {
|
||||
|
||||
reportPrintWriter.println(newline);
|
||||
}
|
||||
|
||||
private static void writeError(String newline) {
|
||||
|
||||
errorPrintWriter.println(newline);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package gis;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
||||
|
||||
/**
|
||||
* The Class ServerParameters.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it May 16, 2017
|
||||
*/
|
||||
public class ServiceEndpointBean implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 2459971193655529274L;
|
||||
|
||||
protected org.gcube.common.resources.gcore.ServiceEndpoint.Runtime runtime;
|
||||
protected List<AccessPoint> listAP;
|
||||
|
||||
public ServiceEndpointBean() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public ServiceEndpointBean(org.gcube.common.resources.gcore.ServiceEndpoint.Runtime runtime, List<AccessPoint> listAP) {
|
||||
super();
|
||||
this.runtime = runtime;
|
||||
this.listAP = listAP;
|
||||
}
|
||||
|
||||
public org.gcube.common.resources.gcore.ServiceEndpoint.Runtime getRuntime() {
|
||||
return runtime;
|
||||
}
|
||||
|
||||
public List<AccessPoint> getListAP() {
|
||||
return listAP;
|
||||
}
|
||||
|
||||
public void setRuntime(org.gcube.common.resources.gcore.ServiceEndpoint.Runtime runtime2) {
|
||||
this.runtime = runtime2;
|
||||
}
|
||||
|
||||
public void setListAP(List<AccessPoint> listAP) {
|
||||
this.listAP = listAP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("ServiceEndpoint [runtime=");
|
||||
builder.append(runtime);
|
||||
builder.append(", listAP=");
|
||||
builder.append(listAP);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -49,7 +49,7 @@ public class GeonetworkResolverTest {
|
|||
/*String scopeValue ="/gcube/devsec/devVRE";
|
||||
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";
|
||||
ServerParameters geonetworkParams = new ServerParameters("http://geoserver-dev2.d4science-ii.research-infrastructures.eu/geonetwork", "", "");
|
||||
ServiceEndpointParameters geonetworkParams = new ServiceEndpointParameters("http://geoserver-dev2.d4science-ii.research-infrastructures.eu/geonetwork", "", "");
|
||||
|
||||
String newQueryString = purgeScopeFromQueryString(scopeValue, queryString);
|
||||
logger.info("Purged query string from "+scopeValue+" is: "+newQueryString);
|
||||
|
|
|
@ -18,7 +18,7 @@ public class GisResolverTest {
|
|||
public static void main(String[] args) {
|
||||
GisResolver gisResolver = new GisResolver();
|
||||
ScopeProvider.instance.set(scope);
|
||||
//ServerParameters geonetworkParams = getCachedServerParameters(scope);
|
||||
//ServiceEndpointParameters geonetworkParams = getCachedServerParameters(scope);
|
||||
try {
|
||||
GisLayerItem gisLayerItem = gisResolver.getGisLayerForLayerUUID(null, scope, gisUUID);
|
||||
} catch (Exception e) {
|
||||
|
@ -33,7 +33,7 @@ public class GisResolverTest {
|
|||
String scope = "/gcube/devsec/devVRE";
|
||||
String UUID = "177e1c3c-4a22-4ad9-b015-bfc443d16cb8";
|
||||
try {
|
||||
ServerParameters geonetworkParams = gisResolver.getCachedServerParameters(scope);
|
||||
ServiceEndpointParameters geonetworkParams = gisResolver.getCachedServerParameters(scope);
|
||||
String wmsRequest = gisResolver.getLayerWmsRequest(scope, UUID, geonetworkParams);
|
||||
System.out.println("Final url is: " + wmsRequest);
|
||||
wmsRequest = URLEncoder.encode(wmsRequest, UTF_8);
|
||||
|
|
|
@ -84,7 +84,7 @@ public class ServiceEndpointReader {
|
|||
if (accessPointPwd != null) {
|
||||
accessPointPwd = StringEncrypter.getEncrypter().decrypt(accessPointPwd);
|
||||
LOG.info("Decrypted pwd registered into Access Point '" + accessPoint.name() + "' is: "
|
||||
+ accessPointPwd.substring(0,accessPointPwd.length()/2)+"...");
|
||||
+ accessPointPwd+"...");
|
||||
|
||||
System.out.println("AccessPoint pwd is: "+accessPointPwd);
|
||||
}
|
||||
|
|
|
@ -12,3 +12,9 @@
|
|||
/preprod.gcubekey
|
||||
/pred4s.gcubekey
|
||||
/log4j.properties
|
||||
/D4OS.gcubekey
|
||||
/D4Research.gcubekey
|
||||
/OpenAIRE.gcubekey
|
||||
/ParthenosVO.gcubekey
|
||||
/SmartArea.gcubekey
|
||||
/SoBigData.gcubekey
|
||||
|
|
Loading…
Reference in New Issue