This commit is contained in:
Nunzio Andrea Galante 2017-07-26 12:05:12 +00:00
parent 2c3e5c6964
commit 1142c87af6
3 changed files with 79 additions and 27 deletions

View File

@ -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***
@ -108,8 +109,6 @@ public class CheckMethod ***REMOVED***
***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******REMOVED***
***REMOVED*** if (a.doesExist("/home/gcube/wps_algorithms/algorithms/XMEANS_interface.jar"))***REMOVED***
***REMOVED*** System.out.println("ciao");
***REMOVED******REMOVED***
***REMOVED***
if (a.doesExist("/home/gcube/wps_algorithms/algorithms/XMEANS_interface.jar"))***REMOVED***
System.out.println("ciao");
***REMOVED***
***REMOVED******REMOVED***
***REMOVED***
***REMOVED***

View File

@ -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);
@ -269,19 +269,6 @@ public class SVNUpdater ***REMOVED***
public static ByteArrayInputStream reteriveByteArrayInputStream(File file) throws IOException ***REMOVED***
return new ByteArrayInputStream(FileUtils.readFileToByteArray(file));

View File

@ -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***