This commit is contained in:
Nunzio Andrea Galante 2017-07-26 09:39:02 +00:00
parent 8a35a0c831
commit 2c3e5c6964
5 changed files with 166 additions and 3 deletions

View File

@ -67,12 +67,12 @@ public class ProductionPublishingJob extends DMPMJob ***REMOVED***
String response = "";
if (exitstatus == 9) ***REMOVED***
response = "SVN REPOSITORY CORRECTLY UPDATED; THE CRON JOB WILL INSTALL THE ALGORITHM "+ this.algorithm.getName() + " IN THE VRE" + targetVREName;
response = "SVN REPOSITORY CORRECTLY UPDATED; THE CRON JOB WILL INSTALL THE ALGORITHM "+ this.algorithm.getName() + " IN THE VRE " + targetVREName;
writer.println(response);
***REMOVED***
if (exitstatus == 0) ***REMOVED***
response = "SVN REPOSITORY UPDATE FAI; THE CRON JOB WILL NOT BE ABLE TO INSTALL THE ALGORITHM "+this.algorithm.getName()+" IN THE VRE" + targetVREName;;
response = "SVN REPOSITORY UPDATE FAI; THE CRON JOB WILL NOT BE ABLE TO INSTALL THE ALGORITHM "+this.algorithm.getName()+" IN THE VRE " + targetVREName;;
writer.println(response);
***REMOVED***writer.close();
***REMOVED***

View File

@ -21,9 +21,12 @@ import com.jcraft.jsch.SftpATTRS;
import com.jcraft.jsch.SftpException;
public class CheckMethod ***REMOVED***
protected SVNUpdater svnUpdater;
public CheckMethod() ***REMOVED***
this.svnUpdater = svnUpdater;
***REMOVED***
public boolean checkMethod(String machine, String token) throws Exception ***REMOVED***
@ -83,14 +86,20 @@ public class CheckMethod ***REMOVED***
public boolean algoExists(Algorithm a) throws Exception***REMOVED***
File file = new File("/home/gcube/wps_algorithms/algorithms/"+a.getName()+".jar");
File file2 = new File("/home/gcube/wps_algorithms/algorithms/"+a.getName()+"_interface.jar");
System.out.println("First file is located to: "+file.getPath());
System.out.println("Second file is located to: "+file2.getPath());
if ((this.doesExist(file.getPath())) && (this.doesExist(file2.getPath())))***REMOVED***
this.svnUpdater.updateAlgorithmFiles(file);
this.svnUpdater.updateAlgorithmFiles(file2);
return true;
***REMOVED***
else

View File

@ -1,8 +1,12 @@
package org.gcube.dataanalysis.dataminer.poolmanager.util;
import org.apache.commons.io.FileUtils;
import org.apache.tools.ant.FileScanner;
***REMOVED***
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Dependency;
import org.tmatesoft.sqljet.core.internal.lang.SqlParser.column_constraint_check_return;
***REMOVED***
import org.tmatesoft.svn.core.SVNNodeKind;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
import org.tmatesoft.svn.core.internal.wc.SVNFileUtil;
@ -15,6 +19,7 @@ import org.tmatesoft.svn.core.wc.SVNWCUtil;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
***REMOVED***
import java.util.*;
@ -167,6 +172,122 @@ public class SVNUpdater ***REMOVED***
this.updateSVNAlgorithmList(this.configuration.getSVNProdAlgorithmsList(), algorithm, targetVRE, user, env);
***REMOVED***
public void updateAlgorithmFiles(File a) throws SVNException***REMOVED***
this.updateAlgorithmList(this.configuration.getSVNMainAlgoRepo(), a);
***REMOVED***
private void updateAlgorithmList(String svnMainAlgoRepo, File a) throws SVNException ***REMOVED***
try ***REMOVED***
System.out.println("Adding .jar file: " + a + " to repository " + svnMainAlgoRepo);
if (fileExists(svnMainAlgoRepo+File.separator+a.getName(), -1))***REMOVED***
this.updateFile(reteriveByteArrayInputStream(a), svnMainAlgoRepo, a.getName());
***REMOVED***
else this.putFile(reteriveByteArrayInputStream(a), svnMainAlgoRepo,a.getName());
***REMOVED*** catch (Exception ex) ***REMOVED***
ex.printStackTrace();
***REMOVED***
finally ***REMOVED***
svnRepository.closeSession();
***REMOVED***
***REMOVED***
public void putFile(ByteArrayInputStream byteArrayInputStream, String destinationFolder, String fileName)
throws SVNException ***REMOVED***
final ISVNEditor commitEditor = svnRepository.getCommitEditor("Add algorithm to list", null);
commitEditor.openRoot(-1);
commitEditor.openDir(destinationFolder, -1);
String filePath = destinationFolder + "/" + fileName;
***REMOVED***commitEditor.openFile(filePath, -1);
commitEditor.addFile(filePath, null, -1);
commitEditor.applyTextDelta(filePath, null);
SVNDeltaGenerator deltaGenerator = new SVNDeltaGenerator();
String checksum = deltaGenerator.sendDelta(filePath, byteArrayInputStream, commitEditor, true);
commitEditor.closeFile(filePath, checksum);
commitEditor.closeDir();
commitEditor.closeDir();
commitEditor.closeEdit();
***REMOVED***
public void updateFile(ByteArrayInputStream byteArrayInputStream, String destinationFolder, String fileName)
throws SVNException ***REMOVED***
final ISVNEditor commitEditor = svnRepository.getCommitEditor("Add algorithm to list", null);
commitEditor.openRoot(-1);
commitEditor.openDir(destinationFolder, -1);
String filePath = destinationFolder + "/" + fileName;
***REMOVED*** if (fileExists(filePath, -1)) ***REMOVED*** ***REMOVED*** updating existing file
commitEditor.openFile(filePath, -1);
***REMOVED******REMOVED*** else ***REMOVED*** ***REMOVED*** creating new file
***REMOVED***commitEditor.addFile(filePath, null, -1);
***REMOVED******REMOVED***
commitEditor.applyTextDelta(filePath, null);
SVNDeltaGenerator deltaGenerator = new SVNDeltaGenerator();
String checksum = deltaGenerator.sendDelta(filePath, byteArrayInputStream, commitEditor, true);
commitEditor.closeFile(filePath, checksum);
commitEditor.closeDir();
commitEditor.closeDir();
commitEditor.closeEdit();
***REMOVED***
public boolean fileExists(String path, long revision) throws SVNException ***REMOVED***
SVNNodeKind kind = svnRepository.checkPath(path, revision);
if (kind == SVNNodeKind.FILE) ***REMOVED***
return true;
***REMOVED***
return false;
***REMOVED***
public static ByteArrayInputStream reteriveByteArrayInputStream(File file) throws IOException ***REMOVED***
return new ByteArrayInputStream(FileUtils.readFileToByteArray(file));
***REMOVED***
public void updateSVNAlgorithmList(String file, Algorithm algorithm, String targetVRE, String user, String env) ***REMOVED***
try ***REMOVED***
System.out.println("Updating algorithm list: " + file);
@ -423,4 +544,28 @@ public class SVNUpdater ***REMOVED***
return new ArrayList<>(ss);
***REMOVED***
public static void main(String[] args) throws SVNException ***REMOVED***
ServiceConfiguration sc = new ServiceConfiguration("/home/ngalante/workspace/dataminer-pool-manager/src/main/resources/service.properties");
SVNUpdater c = new SVNUpdater(sc);
***REMOVED***File a = new File("/home/ngalante/Desktop/testCiro");
File b = new File ("/home/ngalante/Desktop/testB");
***REMOVED***c.updateAlgorithmFiles(a);
c.updateAlgorithmFiles(b);
***REMOVED***
***REMOVED***

View File

@ -41,6 +41,12 @@ public class ServiceConfiguration ***REMOVED***
***REMOVED***
public String getSVNMainAlgoRepo()***REMOVED***
return props.getProperty("svn.algo.main.repo");
***REMOVED***
***REMOVED***RProto
public String getSVNRProtoAlgorithmsList()***REMOVED***
return props.getProperty("svn.rproto.algorithms-list");

View File

@ -4,8 +4,11 @@ STAGING_HOST: dataminer1-devnext.d4science.org
SVN_REPO: https:***REMOVED***svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/RConfiguration/RPackagesManagement/
#HAPROXY_CSV: http:***REMOVED***data.d4science.org/Yk4zSFF6V3JOSytNd3JkRDlnRFpDUUR5TnRJZEw2QjRHbWJQNStIS0N6Yz0
svn.repository = https:***REMOVED***svn.d4science.research-infrastructures.eu/gcube
svn.algo.main.repo = /trunk/data-analysis/DataMinerConfiguration/algorithms
svn.rproto.algorithms-list = /trunk/data-analysis/DataMinerConfiguration/algorithms/proto/algorithms
svn.rproto.deps-linux-compiled =