git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/dataminer-pool-manager@151308 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
8b055202c8
commit
28afad7e94
|
@ -67,12 +67,12 @@ public class ProductionPublishingJob extends DMPMJob {
|
|||
String response = "";
|
||||
|
||||
if (exitstatus == 9) {
|
||||
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);
|
||||
}
|
||||
|
||||
if (exitstatus == 0) {
|
||||
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);
|
||||
//writer.close();
|
||||
}
|
||||
|
|
|
@ -21,9 +21,12 @@ import com.jcraft.jsch.SftpATTRS;
|
|||
import com.jcraft.jsch.SftpException;
|
||||
|
||||
public class CheckMethod {
|
||||
|
||||
protected SVNUpdater svnUpdater;
|
||||
|
||||
public CheckMethod() {
|
||||
|
||||
this.svnUpdater = svnUpdater;
|
||||
|
||||
}
|
||||
|
||||
public boolean checkMethod(String machine, String token) throws Exception {
|
||||
|
@ -83,14 +86,20 @@ public class CheckMethod {
|
|||
|
||||
|
||||
public boolean algoExists(Algorithm a) throws Exception{
|
||||
|
||||
|
||||
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()))){
|
||||
this.svnUpdater.updateAlgorithmFiles(file);
|
||||
this.svnUpdater.updateAlgorithmFiles(file2);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
package org.gcube.dataanalysis.dataminer.poolmanager.util;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.tools.ant.FileScanner;
|
||||
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Algorithm;
|
||||
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Dependency;
|
||||
import org.tmatesoft.sqljet.core.internal.lang.SqlParser.column_constraint_check_return;
|
||||
import org.tmatesoft.svn.core.SVNException;
|
||||
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;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
|
@ -167,6 +172,122 @@ public class SVNUpdater {
|
|||
this.updateSVNAlgorithmList(this.configuration.getSVNProdAlgorithmsList(), algorithm, targetVRE, user, env);
|
||||
}
|
||||
|
||||
|
||||
public void updateAlgorithmFiles(File a) throws SVNException{
|
||||
this.updateAlgorithmList(this.configuration.getSVNMainAlgoRepo(), a);
|
||||
}
|
||||
|
||||
|
||||
private void updateAlgorithmList(String svnMainAlgoRepo, File a) throws SVNException {
|
||||
try {
|
||||
System.out.println("Adding .jar file: " + a + " to repository " + svnMainAlgoRepo);
|
||||
|
||||
if (fileExists(svnMainAlgoRepo+File.separator+a.getName(), -1)){
|
||||
this.updateFile(reteriveByteArrayInputStream(a), svnMainAlgoRepo, a.getName());
|
||||
|
||||
}
|
||||
else this.putFile(reteriveByteArrayInputStream(a), svnMainAlgoRepo,a.getName());
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
finally {
|
||||
svnRepository.closeSession();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void putFile(ByteArrayInputStream byteArrayInputStream, String destinationFolder, String fileName)
|
||||
throws SVNException {
|
||||
|
||||
|
||||
final ISVNEditor commitEditor = svnRepository.getCommitEditor("Add algorithm to list", null);
|
||||
commitEditor.openRoot(-1);
|
||||
commitEditor.openDir(destinationFolder, -1);
|
||||
|
||||
|
||||
String filePath = destinationFolder + "/" + fileName;
|
||||
|
||||
|
||||
//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();
|
||||
}
|
||||
|
||||
|
||||
public void updateFile(ByteArrayInputStream byteArrayInputStream, String destinationFolder, String fileName)
|
||||
throws SVNException {
|
||||
|
||||
|
||||
final ISVNEditor commitEditor = svnRepository.getCommitEditor("Add algorithm to list", null);
|
||||
commitEditor.openRoot(-1);
|
||||
commitEditor.openDir(destinationFolder, -1);
|
||||
|
||||
|
||||
String filePath = destinationFolder + "/" + fileName;
|
||||
|
||||
// if (fileExists(filePath, -1)) { // updating existing file
|
||||
|
||||
commitEditor.openFile(filePath, -1);
|
||||
|
||||
//} else { // creating new file
|
||||
|
||||
//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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public boolean fileExists(String path, long revision) throws SVNException {
|
||||
SVNNodeKind kind = svnRepository.checkPath(path, revision);
|
||||
if (kind == SVNNodeKind.FILE) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static ByteArrayInputStream reteriveByteArrayInputStream(File file) throws IOException {
|
||||
|
||||
return new ByteArrayInputStream(FileUtils.readFileToByteArray(file));
|
||||
}
|
||||
|
||||
|
||||
public void updateSVNAlgorithmList(String file, Algorithm algorithm, String targetVRE, String user, String env) {
|
||||
try {
|
||||
System.out.println("Updating algorithm list: " + file);
|
||||
|
@ -423,4 +544,28 @@ public class SVNUpdater {
|
|||
return new ArrayList<>(ss);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) throws SVNException {
|
||||
|
||||
ServiceConfiguration sc = new ServiceConfiguration("/home/ngalante/workspace/dataminer-pool-manager/src/main/resources/service.properties");
|
||||
|
||||
SVNUpdater c = new SVNUpdater(sc);
|
||||
|
||||
//File a = new File("/home/ngalante/Desktop/testCiro");
|
||||
File b = new File ("/home/ngalante/Desktop/testB");
|
||||
|
||||
//c.updateAlgorithmFiles(a);
|
||||
c.updateAlgorithmFiles(b);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -41,6 +41,12 @@ public class ServiceConfiguration {
|
|||
}
|
||||
|
||||
|
||||
public String getSVNMainAlgoRepo(){
|
||||
return props.getProperty("svn.algo.main.repo");
|
||||
}
|
||||
|
||||
|
||||
|
||||
//RProto
|
||||
public String getSVNRProtoAlgorithmsList(){
|
||||
return props.getProperty("svn.rproto.algorithms-list");
|
||||
|
|
|
@ -4,8 +4,11 @@ STAGING_HOST: dataminer1-devnext.d4science.org
|
|||
SVN_REPO: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/RConfiguration/RPackagesManagement/
|
||||
#HAPROXY_CSV: http://data.d4science.org/Yk4zSFF6V3JOSytNd3JkRDlnRFpDUUR5TnRJZEw2QjRHbWJQNStIS0N6Yz0
|
||||
|
||||
|
||||
svn.repository = https://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 =
|
||||
|
|
Loading…
Reference in New Issue