dataminer-pool-manager/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/clients/DMPMClientConfigurator.java

463 lines
18 KiB
Java

package org.gcube.dataanalysis.dataminer.poolmanager.clients;
import static org.gcube.resources.discovery.icclient.ICFactory.client;
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
***REMOVED***
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.StringWriter;
***REMOVED***
***REMOVED***
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedList;
***REMOVED***
import java.util.Map;
import java.util.Scanner;
***REMOVED***
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Vector;
***REMOVED***
import org.gcube.common.resources.gcore.GenericResource;
import org.gcube.common.resources.gcore.Resources;
import org.gcube.common.resources.gcore.ServiceEndpoint;
***REMOVED***
***REMOVED***
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Cluster;
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Dependency;
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Domain;
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Host;
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.comparator.HostComparator;
***REMOVED***
import org.gcube.informationsystem.publisher.AdvancedScopedPublisher;
import org.gcube.informationsystem.publisher.RegistryPublisherFactory;
import org.gcube.informationsystem.publisher.ScopedPublisher;
import org.gcube.informationsystem.publisher.exception.RegistryNotFoundException;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
***REMOVED***
***REMOVED***
import org.tmatesoft.svn.core.SVNDepth;
***REMOVED***
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory;
import org.tmatesoft.svn.core.io.SVNRepository;
import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
import org.tmatesoft.svn.core.wc.ISVNOptions;
import org.tmatesoft.svn.core.wc.SVNClientManager;
import org.tmatesoft.svn.core.wc.SVNRevision;
import org.tmatesoft.svn.core.wc.SVNUpdateClient;
import org.tmatesoft.svn.core.wc.SVNWCUtil;
import au.com.bytecode.opencsv.CSVReader;
public class DMPMClientConfigurator ***REMOVED***
private static final Logger LOGGER = LoggerFactory.getLogger(DMPMClientConfigurator.class);
public String getStagingHost() ***REMOVED***
***REMOVED***
String ghost = "";
SimpleQuery query = queryFor(GenericResource.class);
query.addCondition("$resource/Profile/SecondaryType/text() eq 'DMPMConfigurator'").setResult("$resource/Profile/Body/stage/ghost/text()");
DiscoveryClient<String> client = client();
List<String> ds = client.submit(query);
for (String a : ds) ***REMOVED***
ghost = a;
***REMOVED***
return ghost.trim();
***REMOVED***
public String getProdHost() ***REMOVED***
***REMOVED***
String ghost = "";
SimpleQuery query = queryFor(GenericResource.class);
query.addCondition("$resource/Profile/SecondaryType/text() eq 'DMPMConfigurator'").setResult("$resource/Profile/Body/prod/ghost/text()");
DiscoveryClient<String> client = client();
List<String> ds = client.submit(query);
for (String a : ds) ***REMOVED***
ghost = a;
***REMOVED***
return ghost.trim();
***REMOVED***
public String getSVNStagingAlgorithmsList() ***REMOVED***
***REMOVED***
String ghost = "";
SimpleQuery query = queryFor(GenericResource.class);
query.addCondition("$resource/Profile/SecondaryType/text() eq 'DMPMConfigurator'").setResult("$resource/Profile/Body/stage/svn.stage.algorithms-list/text()");
DiscoveryClient<String> client = client();
List<String> ds = client.submit(query);
for (String a : ds) ***REMOVED***
ghost = a;
***REMOVED***
return ghost.trim();
***REMOVED***
public String getStageRepository() ***REMOVED***
***REMOVED***
String ghost = "";
SimpleQuery query = queryFor(GenericResource.class);
query.addCondition("$resource/Profile/SecondaryType/text() eq 'DMPMConfigurator'").setResult("$resource/Profile/Body/stage/svn.stage.software.repo/text()");
DiscoveryClient<String> client = client();
List<String> ds = client.submit(query);
for (String a : ds) ***REMOVED***
ghost = a;
***REMOVED***
return ghost.trim();
***REMOVED***
public String getGhostAlgoDirectory() ***REMOVED***
***REMOVED***
String ghost = "";
SimpleQuery query = queryFor(GenericResource.class);
query.addCondition("$resource/Profile/SecondaryType/text() eq 'DMPMConfigurator'").setResult("$resource/Profile/Body/stage/svn.stage.algo.ghost.repo/text()");
DiscoveryClient<String> client = client();
List<String> ds = client.submit(query);
for (String a : ds) ***REMOVED***
ghost = a;
***REMOVED***
return ghost.trim();
***REMOVED***
public String getSVNStagingLinuxCompiledDepsList() ***REMOVED***
***REMOVED***
String ghost = "";
SimpleQuery query = queryFor(GenericResource.class);
query.addCondition("$resource/Profile/SecondaryType/text() eq 'DMPMConfigurator'").setResult("$resource/Profile/Body/stage/svn.stage.deps-linux-compiled/text()");
DiscoveryClient<String> client = client();
List<String> ds = client.submit(query);
for (String a : ds) ***REMOVED***
ghost = a;
***REMOVED***
return ghost.trim();
***REMOVED***
public String getSVNStagingPreInstalledDepsList() ***REMOVED***
***REMOVED***
String ghost = "";
SimpleQuery query = queryFor(GenericResource.class);
query.addCondition("$resource/Profile/SecondaryType/text() eq 'DMPMConfigurator'").setResult("$resource/Profile/Body/stage/svn.stage.deps-pre-installed/text()");
DiscoveryClient<String> client = client();
List<String> ds = client.submit(query);
for (String a : ds) ***REMOVED***
ghost = a;
***REMOVED***
return ghost.trim();
***REMOVED***
public String getSVNStagingRBDepsList() ***REMOVED***
***REMOVED***
String ghost = "";
SimpleQuery query = queryFor(GenericResource.class);
query.addCondition("$resource/Profile/SecondaryType/text() eq 'DMPMConfigurator'").setResult("$resource/Profile/Body/stage/svn.stage.deps-r-blackbox/text()");
DiscoveryClient<String> client = client();
List<String> ds = client.submit(query);
for (String a : ds) ***REMOVED***
ghost = a;
***REMOVED***
return ghost.trim();
***REMOVED***
public String getSVNStagingCRANDepsList() ***REMOVED***
***REMOVED***
String ghost = "";
SimpleQuery query = queryFor(GenericResource.class);
query.addCondition("$resource/Profile/SecondaryType/text() eq 'DMPMConfigurator'").setResult("$resource/Profile/Body/stage/svn.stage.deps-r/text()");
DiscoveryClient<String> client = client();
List<String> ds = client.submit(query);
for (String a : ds) ***REMOVED***
ghost = a;
***REMOVED***
return ghost.trim();
***REMOVED***
public String getSVNStagingJavaDepsList() ***REMOVED***
***REMOVED***
String ghost = "";
SimpleQuery query = queryFor(GenericResource.class);
query.addCondition("$resource/Profile/SecondaryType/text() eq 'DMPMConfigurator'").setResult("$resource/Profile/Body/stage/svn.stage.deps-java/text()");
DiscoveryClient<String> client = client();
List<String> ds = client.submit(query);
for (String a : ds) ***REMOVED***
ghost = a;
***REMOVED***
return ghost.trim();
***REMOVED***
public String getSVNStagingKWDepsList() ***REMOVED***
***REMOVED***
String ghost = "";
SimpleQuery query = queryFor(GenericResource.class);
query.addCondition("$resource/Profile/SecondaryType/text() eq 'DMPMConfigurator'").setResult("$resource/Profile/Body/stage/svn.stage.deps-knime-workflow/text()");
DiscoveryClient<String> client = client();
List<String> ds = client.submit(query);
for (String a : ds) ***REMOVED***
ghost = a;
***REMOVED***
return ghost.trim();
***REMOVED***
public String getSVNStagingOctaveDepsList() ***REMOVED***
***REMOVED***
String ghost = "";
SimpleQuery query = queryFor(GenericResource.class);
query.addCondition("$resource/Profile/SecondaryType/text() eq 'DMPMConfigurator'").setResult("$resource/Profile/Body/stage/svn.stage.deps-octave/text()");
DiscoveryClient<String> client = client();
List<String> ds = client.submit(query);
for (String a : ds) ***REMOVED***
ghost = a;
***REMOVED***
return ghost.trim();
***REMOVED***
public String getSVNStagingPythonDepsList() ***REMOVED***
***REMOVED***
String ghost = "";
SimpleQuery query = queryFor(GenericResource.class);
query.addCondition("$resource/Profile/SecondaryType/text() eq 'DMPMConfigurator'").setResult("$resource/Profile/Body/stage/svn.stage.deps-python/text()");
DiscoveryClient<String> client = client();
List<String> ds = client.submit(query);
for (String a : ds) ***REMOVED***
ghost = a;
***REMOVED***
return ghost.trim();
***REMOVED***
public String getSVNStagingWCDepsList() ***REMOVED***
***REMOVED***
String ghost = "";
SimpleQuery query = queryFor(GenericResource.class);
query.addCondition("$resource/Profile/SecondaryType/text() eq 'DMPMConfigurator'").setResult("$resource/Profile/Body/stage/svn.stage.deps-windows-compiled/text()");
DiscoveryClient<String> client = client();
List<String> ds = client.submit(query);
for (String a : ds) ***REMOVED***
ghost = a;
***REMOVED***
return ghost.trim();
***REMOVED***
public String getSVNProdAlgorithmsList() ***REMOVED***
***REMOVED***
String ghost = "";
SimpleQuery query = queryFor(GenericResource.class);
query.addCondition("$resource/Profile/SecondaryType/text() eq 'DMPMConfigurator'").setResult("$resource/Profile/Body/prod/svn.prod.algorithms-list/text()");
DiscoveryClient<String> client = client();
List<String> ds = client.submit(query);
for (String a : ds) ***REMOVED***
ghost = a;
***REMOVED***
return ghost.trim();
***REMOVED***
public String getProdRepository() ***REMOVED***
***REMOVED***
String ghost = "";
SimpleQuery query = queryFor(GenericResource.class);
query.addCondition("$resource/Profile/SecondaryType/text() eq 'DMPMConfigurator'").setResult("$resource/Profile/Body/prod/svn.prod.software.repo/text()");
DiscoveryClient<String> client = client();
List<String> ds = client.submit(query);
for (String a : ds) ***REMOVED***
ghost = a;
***REMOVED***
return ghost.trim();
***REMOVED***
public String getProdGhostAlgoDirectory() ***REMOVED***
***REMOVED***
String ghost = "";
SimpleQuery query = queryFor(GenericResource.class);
query.addCondition("$resource/Profile/SecondaryType/text() eq 'DMPMConfigurator'").setResult("$resource/Profile/Body/prod/svn.prod.algo.ghost.repo/text()");
DiscoveryClient<String> client = client();
List<String> ds = client.submit(query);
for (String a : ds) ***REMOVED***
ghost = a;
***REMOVED***
return ghost.trim();
***REMOVED***
public String getSVNProdLinuxCompiledDepsList() ***REMOVED***
***REMOVED***
String ghost = "";
SimpleQuery query = queryFor(GenericResource.class);
query.addCondition("$resource/Profile/SecondaryType/text() eq 'DMPMConfigurator'").setResult("$resource/Profile/Body/prod/svn.prod.deps-linux-compiled/text()");
DiscoveryClient<String> client = client();
List<String> ds = client.submit(query);
for (String a : ds) ***REMOVED***
ghost = a;
***REMOVED***
return ghost.trim();
***REMOVED***
public String getSVNProdPreInstalledDepsList() ***REMOVED***
***REMOVED***
String ghost = "";
SimpleQuery query = queryFor(GenericResource.class);
query.addCondition("$resource/Profile/SecondaryType/text() eq 'DMPMConfigurator'").setResult("$resource/Profile/Body/prod/svn.prod.deps-pre-installed/text()");
DiscoveryClient<String> client = client();
List<String> ds = client.submit(query);
for (String a : ds) ***REMOVED***
ghost = a;
***REMOVED***
return ghost.trim();
***REMOVED***
public String getSVNProdRBDepsList() ***REMOVED***
***REMOVED***
String ghost = "";
SimpleQuery query = queryFor(GenericResource.class);
query.addCondition("$resource/Profile/SecondaryType/text() eq 'DMPMConfigurator'").setResult("$resource/Profile/Body/prod/svn.prod.deps-r-blackbox/text()");
DiscoveryClient<String> client = client();
List<String> ds = client.submit(query);
for (String a : ds) ***REMOVED***
ghost = a;
***REMOVED***
return ghost.trim();
***REMOVED***
public String getSVNProdCRANDepsList() ***REMOVED***
***REMOVED***
String ghost = "";
SimpleQuery query = queryFor(GenericResource.class);
query.addCondition("$resource/Profile/SecondaryType/text() eq 'DMPMConfigurator'").setResult("$resource/Profile/Body/prod/svn.prod.deps-r/text()");
DiscoveryClient<String> client = client();
List<String> ds = client.submit(query);
for (String a : ds) ***REMOVED***
ghost = a;
***REMOVED***
return ghost.trim();
***REMOVED***
public String getSVNProdJavaDepsList() ***REMOVED***
***REMOVED***
String ghost = "";
SimpleQuery query = queryFor(GenericResource.class);
query.addCondition("$resource/Profile/SecondaryType/text() eq 'DMPMConfigurator'").setResult("$resource/Profile/Body/prod/svn.prod.deps-java/text()");
DiscoveryClient<String> client = client();
List<String> ds = client.submit(query);
for (String a : ds) ***REMOVED***
ghost = a;
***REMOVED***
return ghost.trim();
***REMOVED***
public String getSVNProdKWDepsList() ***REMOVED***
***REMOVED***
String ghost = "";
SimpleQuery query = queryFor(GenericResource.class);
query.addCondition("$resource/Profile/SecondaryType/text() eq 'DMPMConfigurator'").setResult("$resource/Profile/Body/prod/svn.prod.deps-knime-workflow/text()");
DiscoveryClient<String> client = client();
List<String> ds = client.submit(query);
for (String a : ds) ***REMOVED***
ghost = a;
***REMOVED***
return ghost.trim();
***REMOVED***
public String getSVNProdOctaveDepsList() ***REMOVED***
***REMOVED***
String ghost = "";
SimpleQuery query = queryFor(GenericResource.class);
query.addCondition("$resource/Profile/SecondaryType/text() eq 'DMPMConfigurator'").setResult("$resource/Profile/Body/prod/svn.prod.deps-octave/text()");
DiscoveryClient<String> client = client();
List<String> ds = client.submit(query);
for (String a : ds) ***REMOVED***
ghost = a;
***REMOVED***
return ghost.trim();
***REMOVED***
public String getSVNProdPythonDepsList() ***REMOVED***
***REMOVED***
String ghost = "";
SimpleQuery query = queryFor(GenericResource.class);
query.addCondition("$resource/Profile/SecondaryType/text() eq 'DMPMConfigurator'").setResult("$resource/Profile/Body/prod/svn.prod.deps-python/text()");
DiscoveryClient<String> client = client();
List<String> ds = client.submit(query);
for (String a : ds) ***REMOVED***
ghost = a;
***REMOVED***
return ghost.trim();
***REMOVED***
public String getSVNProdWCDepsList() ***REMOVED***
***REMOVED***
String ghost = "";
SimpleQuery query = queryFor(GenericResource.class);
query.addCondition("$resource/Profile/SecondaryType/text() eq 'DMPMConfigurator'").setResult("$resource/Profile/Body/prod/svn.prod.deps-windows-compiled/text()");
DiscoveryClient<String> client = client();
List<String> ds = client.submit(query);
for (String a : ds) ***REMOVED***
ghost = a;
***REMOVED***
return ghost.trim();
***REMOVED***
public String getSVNRepository() ***REMOVED***
***REMOVED***
String ghost = "";
SimpleQuery query = queryFor(GenericResource.class);
query.addCondition("$resource/Profile/SecondaryType/text() eq 'DMPMConfigurator'").setResult("$resource");
DiscoveryClient<GenericResource> client = clientFor(GenericResource.class);
List<GenericResource> ds = client.submit(query);
for (GenericResource a : ds) ***REMOVED***
ghost = a.profile().body().getElementsByTagName("svn.repository").item(0).getTextContent();
***REMOVED***
return ghost.trim();
***REMOVED***
***REMOVED*** public String getSVNRepo() ***REMOVED***
***REMOVED******REMOVED***
***REMOVED***
***REMOVED*** String ghost = "";
***REMOVED*** SimpleQuery query = queryFor(GenericResource.class);
***REMOVED*** query.addCondition("$resource/Profile/SecondaryType/text() eq 'DMPMConfigurator'").setResult("$resource");
***REMOVED*** DiscoveryClient<GenericResource> client = clientFor(GenericResource.class);
***REMOVED*** List<GenericResource> ds = client.submit(query);
***REMOVED*** for (GenericResource a : ds) ***REMOVED***
***REMOVED*** ghost = a.profile().body().getElementsByTagName("svn_repo").item(0).getTextContent();
***REMOVED*** ***REMOVED***
***REMOVED*** return ghost;
***REMOVED******REMOVED***
public String getSVNMainAlgoRepo() ***REMOVED***
***REMOVED***
String ghost = "";
SimpleQuery query = queryFor(GenericResource.class);
query.addCondition("$resource/Profile/SecondaryType/text() eq 'DMPMConfigurator'").setResult("$resource");
DiscoveryClient<GenericResource> client = clientFor(GenericResource.class);
List<GenericResource> ds = client.submit(query);
for (GenericResource a : ds) ***REMOVED***
ghost = a.profile().body().getElementsByTagName("svn.algo.main.repo").item(0).getTextContent();
***REMOVED***
return ghost.trim();
***REMOVED***
public static void main(String[] args) throws IOException, SVNException ***REMOVED***
DMPMClientConfigurator a = new DMPMClientConfigurator();
ScopeProvider.instance.set("/gcube/devNext/NextNext");
***REMOVED***SecurityTokenProvider.instance.set("***REMOVED***");
System.out.println(a.getSVNProdCRANDepsList());
***REMOVED***System.out.println(a.getRepo());
***REMOVED***System.out.println(a.getAlgoRepo());
***REMOVED***System.out.println(a.getSVNRepo());
***REMOVED***
***REMOVED***