//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 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 publicLayers = new ArrayList(); // for(int i=0; i privateLayers = new ArrayList(); // for(int i=0; i 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); // // // // 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 fileReader() throws FileNotFoundException{ // // String fileName = "iccat_name_catalogue.csv"; // //// //read file into stream, try-with-resources //// try (Stream stream = Files.lines(Paths.get(fileName))) { //// //// stream.forEach(System.out::println); //// //// } catch (IOException e) { //// e.printStackTrace(); //// } // // FileReader reportReader = new FileReader(fileName); // //Stream stream = reportBW.lines(); // List 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 listCKAN; // try { // listCKAN = fileReader(); // System.out.println("CKAN Layers are: "+listCKAN.size()); //// for (String line : listCKAN) { //// System.out.println("CKAN UUID: "+line); //// } // // List 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(); // } // // // // } //}