From 1142c87af65de039846c366df5dda3b8c7250020 Mon Sep 17 00:00:00 2001 From: Nunzio Andrea Galante Date: Wed, 26 Jul 2017 12:05:12 +0000 Subject: [PATCH] git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/dataminer-pool-manager@151319 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../poolmanager/util/CheckMethod.java | 90 ++++++++++++++++--- .../poolmanager/util/SVNUpdater.java | 15 +--- .../util/ServiceConfiguration.java | 1 + 3 files changed, 79 insertions(+), 27 deletions(-) diff --git a/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/util/CheckMethod.java b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/util/CheckMethod.java index f0dcdd1..bd9394b 100644 --- a/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/util/CheckMethod.java +++ b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/util/CheckMethod.java @@ -2,6 +2,7 @@ package org.gcube.dataanalysis.dataminer.poolmanager.util; import java.io.BufferedReader; import java.io.File; +import java.io.FileOutputStream; import java.io.FileWriter; import java.io.InputStream; import java.io.InputStreamReader; @@ -22,10 +23,9 @@ import com.jcraft.jsch.SftpException; public class CheckMethod ***REMOVED*** - protected SVNUpdater svnUpdater; + public CheckMethod() ***REMOVED*** - this.svnUpdater = svnUpdater; ***REMOVED*** @@ -97,8 +97,9 @@ public class CheckMethod ***REMOVED*** if ((this.doesExist(file.getPath())) && (this.doesExist(file2.getPath())))***REMOVED*** - this.svnUpdater.updateAlgorithmFiles(file); - this.svnUpdater.updateAlgorithmFiles(file2); + this.copyFromDmToSVN(file); + this.copyFromDmToSVN(file2); + return true; ***REMOVED*** @@ -107,9 +108,7 @@ public class CheckMethod ***REMOVED*** return false; ***REMOVED*** - - - + public boolean doesExist(String path) throws Exception ***REMOVED*** JSch jsch = new JSch(); Session session = null; @@ -161,19 +160,84 @@ public class CheckMethod ***REMOVED*** ***REMOVED*** + + + + public void copyFromDmToSVN(File a) throws Exception ***REMOVED*** + JSch jsch = new JSch(); + Session session = null; + ServiceConfiguration sc = new ServiceConfiguration(); + SVNUpdater svnUpdater = new SVNUpdater(sc); + + ServiceConfiguration p = new ServiceConfiguration(); + + jsch.setKnownHosts("~/.ssh/known_hosts"); + String privateKey = "~/.ssh/id_rsa"; + + jsch.addIdentity(privateKey); + System.out.println("Private Key Added."); + + session = jsch.getSession("root", p.getStagingHost()); + System.out.println("session created."); + + java.util.Properties config = new java.util.Properties(); + config.put("StrictHostKeyChecking", "no"); + + session.setConfig(config); + session.connect(); + + Channel channel = session.openChannel("sftp"); + channel.connect(); + + ChannelSftp sftp = (ChannelSftp) channel; + + sftp.cd("/home/gcube/wps_algorithms/algorithms/"); + + System.out.println("REMOTE : /home/gcube/wps_algorithms/algorithms/"+a.getName()); + System.out.println("LOCAL : /tmp/"+a.getName()); + + sftp.get("/home/gcube/wps_algorithms/algorithms/"+a.getName(),"/tmp/"+a.getName()); + + channel.disconnect(); + session.disconnect(); + + File f = new File("/tmp/"+a.getName()); + svnUpdater.updateAlgorithmFiles(f); + f.delete(); +***REMOVED*** + + + + + + + + + + + + + public static void main(String[] args) throws Exception ***REMOVED*** ***REMOVED*** ServiceConfiguration a = new ServiceConfiguration(); ***REMOVED*** System.out.println(a.getStagingHost()); CheckMethod a = new CheckMethod(); + File aa = new File("OCTAVEBLACKBOX.jar"); + System.out.println(aa.getName()); + System.out.println(aa.getPath()); + + + a.copyFromDmToSVN(aa); ***REMOVED*** if (a.checkMethod("dataminer1-devnext.d4science.org", "***REMOVED***"))***REMOVED*** ***REMOVED*** System.out.println("ciao");***REMOVED*** -***REMOVED*** - if (a.doesExist("/home/gcube/wps_algorithms/algorithms/XMEANS_interface.jar"))***REMOVED*** - System.out.println("ciao"); -***REMOVED*** - +***REMOVED******REMOVED*** +***REMOVED*** if (a.doesExist("/home/gcube/wps_algorithms/algorithms/XMEANS_interface.jar"))***REMOVED*** +***REMOVED*** System.out.println("ciao"); +***REMOVED******REMOVED*** +***REMOVED*** +***REMOVED*** +***REMOVED******REMOVED*** ***REMOVED*** - ***REMOVED*** diff --git a/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/util/SVNUpdater.java b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/util/SVNUpdater.java index 9d858af..0fc47a9 100644 --- a/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/util/SVNUpdater.java +++ b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/util/SVNUpdater.java @@ -178,7 +178,7 @@ public class SVNUpdater ***REMOVED*** ***REMOVED*** - private void updateAlgorithmList(String svnMainAlgoRepo, File a) throws SVNException ***REMOVED*** + public void updateAlgorithmList(String svnMainAlgoRepo, File a) throws SVNException ***REMOVED*** try ***REMOVED*** System.out.println("Adding .jar file: " + a + " to repository " + svnMainAlgoRepo); @@ -267,19 +267,6 @@ public class SVNUpdater ***REMOVED*** ***REMOVED*** - - - - - - - - - - - - - public static ByteArrayInputStream reteriveByteArrayInputStream(File file) throws IOException ***REMOVED*** diff --git a/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/util/ServiceConfiguration.java b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/util/ServiceConfiguration.java index 073a154..7a697db 100644 --- a/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/util/ServiceConfiguration.java +++ b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/util/ServiceConfiguration.java @@ -148,6 +148,7 @@ public class ServiceConfiguration ***REMOVED*** ServiceConfiguration a = new ServiceConfiguration(); System.out.println(a.getStagingHost()); System.out.println(a.getCSVUrl()); + System.out.println(a.getSVNMainAlgoRepo()); ***REMOVED***