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

View File

@ -2,6 +2,7 @@ package org.gcube.dataanalysis.dataminer.poolmanager.util;
***REMOVED***
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.InputStream;
***REMOVED***
@ -22,10 +23,9 @@ import com.jcraft.jsch.SftpException;
public class CheckMethod {
protected SVNUpdater svnUpdater;
public CheckMethod() {
this.svnUpdater = svnUpdater;
***REMOVED***
@ -97,8 +97,9 @@ public class CheckMethod {
if ((this.doesExist(file.getPath())) && (this.doesExist(file2.getPath()))){
this.svnUpdater.updateAlgorithmFiles(file);
this.svnUpdater.updateAlgorithmFiles(file2);
this.copyFromDmToSVN(file);
this.copyFromDmToSVN(file2);
return true;
***REMOVED***
@ -107,9 +108,7 @@ public class CheckMethod {
return false;
***REMOVED***
public boolean doesExist(String path) throws Exception {
JSch jsch = new JSch();
Session session = null;
@ -161,19 +160,84 @@ public class CheckMethod {
***REMOVED***
public void copyFromDmToSVN(File a) throws Exception {
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*** 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", "708e7eb8-11a7-4e9a-816b-c9ed7e7e99fe-98187548")){
***REMOVED*** System.out.println("ciao");***REMOVED***
***REMOVED***
if (a.doesExist("/home/gcube/wps_algorithms/algorithms/XMEANS_interface.jar")){
System.out.println("ciao");
***REMOVED***
***REMOVED******REMOVED***
***REMOVED*** if (a.doesExist("/home/gcube/wps_algorithms/algorithms/XMEANS_interface.jar")){
***REMOVED*** System.out.println("ciao");
***REMOVED******REMOVED***
***REMOVED***
***REMOVED***
***REMOVED******REMOVED***
***REMOVED***
***REMOVED***

View File

@ -178,7 +178,7 @@ public class SVNUpdater {
***REMOVED***
private void updateAlgorithmList(String svnMainAlgoRepo, File a) throws SVNException {
public void updateAlgorithmList(String svnMainAlgoRepo, File a) throws SVNException {
try {
System.out.println("Adding .jar file: " + a + " to repository " + svnMainAlgoRepo);
@ -267,19 +267,6 @@ public class SVNUpdater {
***REMOVED***
public static ByteArrayInputStream reteriveByteArrayInputStream(File file) throws IOException {

View File

@ -148,6 +148,7 @@ public class ServiceConfiguration {
ServiceConfiguration a = new ServiceConfiguration();
System.out.println(a.getStagingHost());
System.out.println(a.getCSVUrl());
System.out.println(a.getSVNMainAlgoRepo());
***REMOVED***