This commit is contained in:
Ciro Formisano 2017-12-15 15:46:26 +00:00
parent 7362d8efb9
commit 961a980369
12 changed files with 377 additions and 237 deletions

View File

@ -15,14 +15,15 @@ import org.gcube.dataanalysis.dataminer.poolmanager.ansiblebridge.AnsibleBridge;
import org.gcube.dataanalysis.dataminer.poolmanager.clients.configuration.Configuration; import org.gcube.dataanalysis.dataminer.poolmanager.clients.configuration.Configuration;
***REMOVED*** ***REMOVED***
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Cluster; import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Cluster;
import org.gcube.dataanalysis.dataminer.poolmanager.service.exceptions.AnsibleException;
import org.gcube.dataanalysis.dataminer.poolmanager.service.exceptions.UndefinedDependenciesException;
import org.gcube.dataanalysis.dataminer.poolmanager.util.CheckMethod; import org.gcube.dataanalysis.dataminer.poolmanager.util.CheckMethod;
import org.gcube.dataanalysis.dataminer.poolmanager.util.NotificationHelper; import org.gcube.dataanalysis.dataminer.poolmanager.util.NotificationHelper;
import org.gcube.dataanalysis.dataminer.poolmanager.util.SVNUpdater; import org.gcube.dataanalysis.dataminer.poolmanager.util.SVNUpdater;
import org.gcube.dataanalysis.dataminer.poolmanager.util.SendMail; import org.gcube.dataanalysis.dataminer.poolmanager.util.SendMail;
import org.gcube.dataanalysis.dataminer.poolmanager.util.exception.AlgorithmException; import org.gcube.dataanalysis.dataminer.poolmanager.util.exception.DMPMException;
import org.gcube.dataanalysis.dataminer.poolmanager.util.exception.EMailException; import org.gcube.dataanalysis.dataminer.poolmanager.util.exception.EMailException;
import org.gcube.dataanalysis.dataminer.poolmanager.util.exception.SVNCommitException; import org.gcube.dataanalysis.dataminer.poolmanager.util.exception.GenericException;
***REMOVED***
***REMOVED*** ***REMOVED***
***REMOVED*** ***REMOVED***
@ -144,7 +145,7 @@ public abstract class DMPMJob ***REMOVED***
protected abstract void execute (); protected abstract void execute ();
private boolean preInstallation (SendMail sm,NotificationHelper nh, File logFile ) throws SVNException, EMailException private void preInstallation (SendMail sm,NotificationHelper nh, File logFile ) throws GenericException, EMailException,UndefinedDependenciesException
***REMOVED*** ***REMOVED***
this.logger.debug("Checking dependencies..."); this.logger.debug("Checking dependencies...");
@ -155,123 +156,104 @@ public abstract class DMPMJob ***REMOVED***
if (!undefinedDependencies.isEmpty()) if (!undefinedDependencies.isEmpty())
***REMOVED*** ***REMOVED***
this.logger.debug("Some dependencies are not defined"); this.logger.debug("Some dependencies are not defined");
String message = "Following dependencies are not defined:\n"; throw new UndefinedDependenciesException(undefinedDependencies);
for (String n : undefinedDependencies) ***REMOVED***
message += "\n" + n +"\n";
***REMOVED***
this.setStatusInformation(STATUS.FAILED);
String errorMessage = nh.getFailedBody(message+"\n\n"+this.buildInfo());
this.updateLogFile(logFile, errorMessage);
sm.sendNotification(nh.getFailedSubject() +" for "+this.algorithm.getName()+ " algorithm", errorMessage);
return false;
***REMOVED*** ***REMOVED***
else return true;
***REMOVED*** ***REMOVED***
private void installation (SendMail sm,NotificationHelper nh,CheckMethod methodChecker,File logFile ) throws Exception private String installation (SendMail sm,NotificationHelper nh,CheckMethod methodChecker,File logFile ) throws DMPMException
***REMOVED*** ***REMOVED***
this.logger.debug("Installation process started");
methodChecker.deleteFiles(this.algorithm/*, env*/); methodChecker.deleteFiles(this.algorithm/*, env*/);
int ret = this.executeAnsibleWorker(createWorker(this.algorithm, this.cluster, false, "root"),logFile); int ret = this.executeAnsibleWorker(createWorker(this.algorithm, this.cluster, false, "root"),logFile);
System.out.println("Return code= "+ret); this.logger.debug("Return code= "+ret);
if (ret != 0) if (ret != 0) throw new AnsibleException(ret);
***REMOVED***
this.logger.debug("Ansible work failed, return code "+ret);
this.setStatusInformation(STATUS.FAILED);
String errorMessage = nh.getFailedBody("Installation failed. Return code=" + ret)+"\n\n"+this.buildInfo();
sm.sendNotification(nh.getFailedSubject() + " for "+this.algorithm.getName()+ " algorithm",errorMessage);
***REMOVED***
else if (ret == 0) else
***REMOVED*** ***REMOVED***
this.logger.debug("Operation completed"); this.logger.debug("Operation completed");
***REMOVED***this.setStatusInformation(STATUS.PROGRESS); ***REMOVED***this.setStatusInformation(STATUS.PROGRESS);
this.logger.debug("Checking the method..."); this.logger.debug("Checking the method...");
methodChecker.checkMethod(this.configuration.getHost(), SecurityTokenProvider.instance.get());
try methodChecker.copyAlgorithms(this.algorithm);
***REMOVED*** this.logger.debug("Method OK and algo exists");
methodChecker.checkMethod(this.configuration.getHost(), SecurityTokenProvider.instance.get()); this.logger.debug("Interface check ok!");
methodChecker.copyAlgorithms(this.algorithm); this.logger.debug("Both the files exist at the correct path!");
this.logger.debug("Method OK and algo exists"); boolean algorithmListResult = this.svnUpdater.updateSVNAlgorithmList(this.algorithm, this.vREName,this.category, this.algorithm_type,
this.logger.debug("Interface check ok!"); this.algorithm.getFullname());
this.logger.debug("Both the files exist at the correct path!"); this.setStatusInformation(STATUS.COMPLETED);
boolean algorithmListResult = this.svnUpdater.updateSVNAlgorithmList(this.algorithm, this.vREName,this.category, this.algorithm_type, return algorithmListResult ?"":"\nWARNING: algorithm list could not be updated on SVN";
this.algorithm.getFullname());
this.setStatusInformation(STATUS.COMPLETED);
String bodyResponse = algorithmListResult ? nh.getSuccessBody("\n\n"+this.buildInfo()) : nh.getSuccessBody("\n\n"+this.buildInfo())+"\nWARNING: algorithm list could not be updated on SVN";
sm.sendNotification(nh.getSuccessSubject() + " for "+this.algorithm.getName()+ " algorithm", bodyResponse);
***REMOVED*** catch (SVNCommitException e)
***REMOVED***
this.logger.error("Unable to complete the commit operation: "+e.getMessage());
this.setStatusInformation(STATUS.FAILED);
sm.sendNotification(nh.getFailedSubject() + " for "+this.algorithm.getName()+ " algorithm",
nh.getFailedBody(
"\n"+
"Commit operation failed for "+e.getFileName()
+ "the message of the SVN Server is the following:\n"+e.getSvnErrorMessage().getMessage()+"\n\n"
+this.buildInfo()));
***REMOVED*** catch (AlgorithmException ae)
***REMOVED***
this.logger.debug("Operation failed");
this.setStatusInformation(STATUS.FAILED);
sm.sendNotification(nh.getFailedSubject() + " for "+this.algorithm.getName()+ " algorithm",
nh.getFailedBody(
"\n"+
"Installation completed but DataMiner Interface not working correctly or files "
+ this.algorithm.getName() + ".jar and " + this.algorithm.getName()
+ "_interface.jar not availables at the expected path")+"\n\n"+this.buildInfo());
***REMOVED***
***REMOVED*** ***REMOVED***
***REMOVED*** ***REMOVED***
protected void execute(NotificationHelper nh, CheckMethod methodChecker) protected void execute(NotificationHelper nh, CheckMethod methodChecker)
***REMOVED*** ***REMOVED***
SendMail sm = new SendMail(); SendMail sm = new SendMail();
try ***REMOVED*** File logFile = new File(this.jobLogs,this.id);
this.logger.debug("Pre installation operations"); try
File logFile = new File(this.jobLogs,this.id);
***REMOVED***File logFile = new File(this.jobLogs + File.separator + this.id);
boolean preInstallationResponse = preInstallation(sm, nh, logFile);
this.logger.debug("Pre installation operation completed with result "+preInstallationResponse);
if (preInstallationResponse)
***REMOVED***
this.logger.debug("Installation...");
installation(sm, nh, methodChecker, logFile);
this.logger.debug("Installation completed");
***REMOVED*** ***REMOVED***
try ***REMOVED***
this.logger.debug("Pre installation operations");
preInstallation(sm, nh, logFile);
this.logger.debug("Pre installation operation completed");
this.logger.debug("Installation...");
String warning = installation(sm, nh, methodChecker, logFile);
this.logger.debug("Installation completed");
this.logger.debug("Warning message "+warning);
this.setStatusInformation(STATUS.COMPLETED);
String bodyResponse = NotificationHelper.getSuccessBody(warning+"\n\n"+this.buildInfo());
sm.sendNotification(nh.getSuccessSubject() + " for "+this.algorithm.getName()+ " algorithm", bodyResponse);
***REMOVED*** catch (DMPMException dmpme)
***REMOVED***
this.logger.error("Operation failed: "+dmpme.getMessage());
this.logger.error("Exception: ",dmpme);
this.setStatusInformation(STATUS.FAILED);
String errorMessage = "\n"+NotificationHelper.getFailedBody(dmpme.getErrorMessage()+"\n\n"+this.buildInfo());
this.updateLogFile(logFile, errorMessage);
sm.sendNotification(nh.getFailedSubject() +" for "+this.algorithm.getName()+ " algorithm", errorMessage);
***REMOVED***
***REMOVED*** catch (EMailException eme) ***REMOVED*** catch (EMailException eme)
***REMOVED*** ***REMOVED***
this.logger.error("Operation failed and unable to send notification email",eme); this.logger.error("Unable to send notification email",eme);
***REMOVED*** ***REMOVED***
catch (Exception e) ***REMOVED***
e.printStackTrace();
***REMOVED***
***REMOVED*** ***REMOVED***
protected int executeAnsibleWorker(AnsibleWorker worker, File logFile) throws IOException, InterruptedException, SVNException***REMOVED*** protected int executeAnsibleWorker(AnsibleWorker worker, File logFile) throws GenericException
FileOutputStream fos = new FileOutputStream(logFile, true); ***REMOVED***
PrintStream ps = new PrintStream(fos); try
***REMOVED***
FileOutputStream fos = new FileOutputStream(logFile, true);
PrintStream ps = new PrintStream(fos);
***REMOVED*** File m = new File(this.jobLogs + File.separator + this.id + "_exitStatus");
***REMOVED*** PrintWriter fos2 = new PrintWriter(m, "UTF-8");
return worker.execute(ps);
***REMOVED*** catch (Exception e)
***REMOVED***
throw new GenericException(e);
***REMOVED***
***REMOVED*** File m = new File(this.jobLogs + File.separator + this.id + "_exitStatus");
***REMOVED*** PrintWriter fos2 = new PrintWriter(m, "UTF-8");
return worker.execute(ps);
***REMOVED*** ***REMOVED***
public String buildInfo() ***REMOVED*** public String buildInfo() ***REMOVED***

View File

@ -0,0 +1,25 @@
package org.gcube.dataanalysis.dataminer.poolmanager.service.exceptions;
import org.gcube.dataanalysis.dataminer.poolmanager.util.exception.DMPMException;
public class AnsibleException extends DMPMException ***REMOVED***
***REMOVED****
*
***REMOVED***
private static final long serialVersionUID = 6772009633547404120L;
private int returnCode;
public AnsibleException(int returnCode) ***REMOVED***
super ("Ansible work failed");
this.returnCode =returnCode;
***REMOVED***
***REMOVED***
public String getErrorMessage() ***REMOVED***
return "Installation failed. Return code=" + this.returnCode;
***REMOVED***
***REMOVED***

View File

@ -0,0 +1,29 @@
package org.gcube.dataanalysis.dataminer.poolmanager.service.exceptions;
import java.util.Collection;
import org.gcube.dataanalysis.dataminer.poolmanager.util.exception.DMPMException;
public class UndefinedDependenciesException extends DMPMException ***REMOVED***
private String message;
***REMOVED****
*
***REMOVED***
private static final long serialVersionUID = 4504593796352609191L;
public UndefinedDependenciesException(Collection<String> undefinedDependencies) ***REMOVED***
super ("Some dependencies are not defined");
this.message = "Following dependencies are not defined:\n";
for (String n : undefinedDependencies) ***REMOVED***
message += "\n" + n +"\n";
***REMOVED***
***REMOVED***
***REMOVED***
public String getErrorMessage() ***REMOVED***
return this.message;
***REMOVED***
***REMOVED***

View File

@ -14,6 +14,7 @@ import java.util.Properties;
import org.gcube.dataanalysis.dataminer.poolmanager.clients.configuration.Configuration; import org.gcube.dataanalysis.dataminer.poolmanager.clients.configuration.Configuration;
***REMOVED*** ***REMOVED***
import org.gcube.dataanalysis.dataminer.poolmanager.util.exception.AlgorithmException; import org.gcube.dataanalysis.dataminer.poolmanager.util.exception.AlgorithmException;
import org.gcube.dataanalysis.dataminer.poolmanager.util.exception.GenericException;
import org.gcube.dataanalysis.dataminer.poolmanager.util.exception.SVNCommitException; import org.gcube.dataanalysis.dataminer.poolmanager.util.exception.SVNCommitException;
***REMOVED*** ***REMOVED***
***REMOVED*** ***REMOVED***
@ -41,6 +42,7 @@ public abstract class CheckMethod ***REMOVED***
public CheckMethod(Configuration configuration) public CheckMethod(Configuration configuration)
***REMOVED*** ***REMOVED***
this.logger = LoggerFactory.getLogger(CheckMethod.class); this.logger = LoggerFactory.getLogger(CheckMethod.class);
this.configuration = configuration;
sshConfig = new java.util.Properties(); sshConfig = new java.util.Properties();
sshConfig.put("StrictHostKeyChecking", "no"); sshConfig.put("StrictHostKeyChecking", "no");
***REMOVED*** ***REMOVED***
@ -124,20 +126,39 @@ public abstract class CheckMethod ***REMOVED***
public void copyAlgorithms(Algorithm algo/*, String env*/) throws SVNCommitException, Exception***REMOVED*** public void copyAlgorithms(Algorithm algo/*, String env*/) throws SVNCommitException, GenericException, AlgorithmException
***REMOVED***
this.logger.debug("Looking if algo "+algo.getName()+ " exists"); this.logger.debug("Looking if algo "+algo.getName()+ " exists");
File file = new File(this.configuration.getGhostAlgoDirectory()+"/"+algo.getName()+".jar"); File file = new File(this.configuration.getGhostAlgoDirectory()+"/"+algo.getName()+".jar");
File file2 = new File(this.configuration.getGhostAlgoDirectory()+"/"+algo.getName()+"_interface.jar"); File file2 = new File(this.configuration.getGhostAlgoDirectory()+"/"+algo.getName()+"_interface.jar");
this.logger.debug("Looking for files "+file.getPath()+ " "+file.getPath()); this.logger.debug("Looking for files "+file.getPath()+ " "+file.getPath());
boolean fileExists = false;
if ((this.doesExist(file.getPath()/*,env*/)) && (this.doesExist(file2.getPath()/*,env*/))) try
***REMOVED*** ***REMOVED***
this.logger.debug("Files found"); fileExists = (this.doesExist(file.getPath()/*,env*/)) && (this.doesExist(file2.getPath()/*,env*/));
this.copyFromDmToSVN(file/*,env*/);
this.copyFromDmToSVN(file2/*,env*/); ***REMOVED*** catch (Exception e)
this.logger.debug("Files have been copied to SVN"); ***REMOVED***
throw new GenericException(e);
***REMOVED***
if (fileExists)
***REMOVED***
try
***REMOVED***
this.logger.debug("Files found");
this.copyFromDmToSVN(file/*,env*/);
this.copyFromDmToSVN(file2/*,env*/);
this.logger.debug("Files have been copied to SVN");
***REMOVED*** catch (Exception e)
***REMOVED***
throw new GenericException(e);
***REMOVED***
***REMOVED*** ***REMOVED***
else else
***REMOVED*** ***REMOVED***
@ -150,39 +171,47 @@ public abstract class CheckMethod ***REMOVED***
public void deleteFiles(Algorithm a/*,String env*/) throws Exception public void deleteFiles(Algorithm a/*,String env*/) throws GenericException
***REMOVED*** ***REMOVED***
Session session = generateSession(); try
System.out.println("checking existing in env: " + this.configuration.getHost()); ***REMOVED***
Session session = generateSession();
File file = new File(this.configuration.getGhostAlgoDirectory()+"/"+a.getName()+".jar"); this.logger.debug("checking existing in env: " + this.configuration.getHost());
File file2 = new File(this.configuration.getGhostAlgoDirectory()+"/"+a.getName()+"_interface.jar");
System.out.println("First file is located to: "+file.getPath());
System.out.println("Second file is located to: "+file2.getPath());
System.out.println("session created.");
session.setConfig(this.sshConfig);
session.connect();
Channel channel = session.openChannel(SFTP_PROTOCOL);
channel.connect();
System.out.println("shell channel connected....");
ChannelSftp c = (ChannelSftp) channel;
if(doesExist(file.getPath()/*,env*/)&&(doesExist(file2.getPath()/*,env*/)))***REMOVED***
c.rm(file.getPath()); File file = new File(this.configuration.getGhostAlgoDirectory()+"/"+a.getName()+".jar");
c.rm(file2.getPath()); File file2 = new File(this.configuration.getGhostAlgoDirectory()+"/"+a.getName()+"_interface.jar");
System.out.println("Both the files have been deleted");
this.logger.debug("First file is located to: "+file.getPath());
this.logger.debug("Second file is located to: "+file2.getPath());
this.logger.debug("session created.");
session.setConfig(this.sshConfig);
session.connect();
Channel channel = session.openChannel(SFTP_PROTOCOL);
channel.connect();
this.logger.debug("shell channel connected....");
ChannelSftp c = (ChannelSftp) channel;
if(doesExist(file.getPath()/*,env*/)&&(doesExist(file2.getPath()/*,env*/)))***REMOVED***
c.rm(file.getPath());
c.rm(file2.getPath());
this.logger.debug("Both the files have been deleted");
***REMOVED***
else this.logger.debug("Files not found");
channel.disconnect();
c.disconnect();
session.disconnect();
***REMOVED*** catch (Exception e)
***REMOVED***
throw new GenericException(e);
***REMOVED*** ***REMOVED***
else System.out.println("Files not found");
channel.disconnect();
c.disconnect();
session.disconnect();
***REMOVED*** ***REMOVED***

View File

@ -36,13 +36,13 @@ public abstract class NotificationHelper ***REMOVED***
***REMOVED*** ***REMOVED***
public String getSuccessBody(String info) ***REMOVED*** public static String getSuccessBody(String info) ***REMOVED***
String message = String.format("The installation of the algorithm is completed successfully."); String message = String.format("The installation of the algorithm is completed successfully.");
message+="\n\nYou can retrieve experiment results under the '/DataMiner' e-Infrastructure Workspace folder or from the DataMiner interface.\n\n"+ info; message+="\n\nYou can retrieve experiment results under the '/DataMiner' e-Infrastructure Workspace folder or from the DataMiner interface.\n\n"+ info;
return message; return message;
***REMOVED*** ***REMOVED***
public String getFailedBody(String message) ***REMOVED*** public static String getFailedBody(String message) ***REMOVED***
String body = String.format("An error occurred while deploying your algorithm"); String body = String.format("An error occurred while deploying your algorithm");
body+= "\n\nHere are the error details:\n\n" + message; body+= "\n\nHere are the error details:\n\n" + message;
return body; return body;

View File

@ -24,6 +24,7 @@ import java.util.TimeZone;
import org.gcube.dataanalysis.dataminer.poolmanager.clients.configuration.Configuration; import org.gcube.dataanalysis.dataminer.poolmanager.clients.configuration.Configuration;
***REMOVED*** ***REMOVED***
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Dependency; import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Dependency;
import org.gcube.dataanalysis.dataminer.poolmanager.util.exception.GenericException;
import org.gcube.dataanalysis.dataminer.poolmanager.util.exception.SVNCommitException; import org.gcube.dataanalysis.dataminer.poolmanager.util.exception.SVNCommitException;
***REMOVED*** ***REMOVED***
***REMOVED*** ***REMOVED***
@ -162,9 +163,7 @@ public abstract class SVNUpdater ***REMOVED***
if (errorMessage != null) if (errorMessage != null)
***REMOVED*** ***REMOVED***
this.logger.error("Operation failed: "+errorMessage.getFullMessage()); this.logger.error("Operation failed: "+errorMessage.getFullMessage());
SVNCommitException exception = new SVNCommitException(errorMessage); throw new SVNCommitException(errorMessage,fileName);
exception.setFileName(fileName);
throw exception;
***REMOVED*** ***REMOVED***
this.logger.debug("Operation completed"); this.logger.debug("Operation completed");
@ -195,9 +194,8 @@ public abstract class SVNUpdater ***REMOVED***
if (errorMessage != null) if (errorMessage != null)
***REMOVED*** ***REMOVED***
this.logger.error("Operation failed: "+errorMessage.getFullMessage()); this.logger.error("Operation failed: "+errorMessage.getFullMessage());
SVNCommitException exception = new SVNCommitException(errorMessage);
exception.setFileName(fileName+" to be updated"); throw new SVNCommitException(errorMessage,fileName+" to be updated");
throw exception;
***REMOVED*** ***REMOVED***
this.logger.debug("Operation completed"); this.logger.debug("Operation completed");
@ -318,91 +316,100 @@ public abstract class SVNUpdater ***REMOVED***
***REMOVED*** ***REMOVED***
public Collection<String> getUndefinedDependencies(String file, Collection<Dependency> deps) throws SVNException ***REMOVED*** public Collection<String> getUndefinedDependencies(String file, Collection<Dependency> deps) throws GenericException
***REMOVED*** SendMail sm = new SendMail();
***REMOVED*** NotificationHelper nh = new NotificationHelper();
List<String> undefined = new LinkedList<String>();
***REMOVED***to fix in next release: if the file is not present for that language in the service.properties then skip and return null list of string
***REMOVED***just to uncomment the following lines
if(file.isEmpty())***REMOVED***
return undefined;
***REMOVED*** ***REMOVED***
try
System.out.println("Checking dependencies list: " + file);
List<String> validDependencies = new LinkedList<String>();
for (String singlefile: CheckMethod.getFiles(file))***REMOVED***
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
svnRepository.getFile(singlefile, SVNRepository.INVALID_REVISION, null, byteArrayOutputStream);
for(String l: byteArrayOutputStream.toString().split("\\r?\\n"))***REMOVED***
validDependencies.add(l.trim());
***REMOVED******REMOVED***
System.out.println("Valid dependencies are: "+validDependencies);
for(Dependency d: deps)***REMOVED***
String depName = d.getName();
if(!validDependencies.contains(depName))***REMOVED***
undefined.add(depName);
***REMOVED*** ***REMOVED***
***REMOVED*** ***REMOVED*** SendMail sm = new SendMail();
***REMOVED*** NotificationHelper nh = new NotificationHelper();
return undefined; List<String> undefined = new LinkedList<String>();
***REMOVED***
***REMOVED*** ***REMOVED***to fix in next release: if the file is not present for that language in the service.properties then skip and return null list of string
***REMOVED*** for (String a : lines) ***REMOVED*** ***REMOVED***just to uncomment the following lines
***REMOVED*** for (String b : ldep) ***REMOVED***
***REMOVED*** if (b.equals(a)) ***REMOVED*** if(file.isEmpty())***REMOVED***
***REMOVED*** System.out.println("The following dependency is correctly written: " + b); return undefined;
***REMOVED*** ***REMOVED*** else ***REMOVED***
***REMOVED***
***REMOVED*** ***REMOVED***
***REMOVED*** ***REMOVED*** this.logger.debug("Checking dependencies list: " + file);
***REMOVED***
***REMOVED*** boolean check = false;
***REMOVED*** try ***REMOVED*** List<String> validDependencies = new LinkedList<String>();
***REMOVED*** System.out.println("Checking dependencies list: " + file);
***REMOVED*** final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); for (String singlefile: CheckMethod.getFiles(file))***REMOVED***
***REMOVED*** svnRepository.getFile(file, SVNRepository.INVALID_REVISION, null, byteArrayOutputStream);
***REMOVED*** String lines[] = byteArrayOutputStream.toString().split("\\r?\\n"); final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
***REMOVED*** svnRepository.getFile(singlefile, SVNRepository.INVALID_REVISION, null, byteArrayOutputStream);
***REMOVED*** ***REMOVED*** if(deps.isEmpty())***REMOVED***
***REMOVED*** ***REMOVED*** sm.sendNotification(nh.getFailedSubject(), nh.getFailedBody()); for(String l: byteArrayOutputStream.toString().split("\\r?\\n"))***REMOVED***
***REMOVED*** ***REMOVED*** Exception e = new Exception("No dependency specified for this validDependencies.add(l.trim());
***REMOVED*** ***REMOVED*** algorithm"); ***REMOVED******REMOVED***
***REMOVED*** ***REMOVED*** throw e;
***REMOVED*** ***REMOVED*** this.logger.debug("Valid dependencies are: "+validDependencies);
***REMOVED*** ***REMOVED*** ***REMOVED*** for(Dependency d: deps)***REMOVED***
***REMOVED*** String depName = d.getName();
***REMOVED*** ***REMOVED*** else if (!deps.isEmpty()) ***REMOVED*** if(!validDependencies.contains(depName))***REMOVED***
***REMOVED*** List<String> ldep = new LinkedList<>(); undefined.add(depName);
***REMOVED*** for (Dependency d : deps) ***REMOVED*** ***REMOVED***
***REMOVED*** ldep.add(d.getName()); ***REMOVED***
***REMOVED*** ***REMOVED***
return undefined;
***REMOVED***
***REMOVED***
***REMOVED*** for (String a : lines) ***REMOVED*** ***REMOVED*** for (String a : lines) ***REMOVED***
***REMOVED*** for (String b : ldep) ***REMOVED*** ***REMOVED*** for (String b : ldep) ***REMOVED***
***REMOVED*** if (b.equals(a)) ***REMOVED*** ***REMOVED*** if (b.equals(a)) ***REMOVED***
***REMOVED*** System.out.println("The following dependency is correctly written: " + b); ***REMOVED*** System.out.println("The following dependency is correctly written: " + b);
***REMOVED*** check = true;
***REMOVED*** ***REMOVED*** else ***REMOVED*** ***REMOVED*** else
***REMOVED*** check = false; ***REMOVED***
***REMOVED***
***REMOVED*** ***REMOVED*** ***REMOVED*** ***REMOVED***
***REMOVED*** ***REMOVED*** ***REMOVED*** ***REMOVED***
***REMOVED*** ***REMOVED*** ***REMOVED*** ***REMOVED***
***REMOVED*** ***REMOVED*** catch (Exception a) ***REMOVED*** ***REMOVED*** boolean check = false;
***REMOVED*** a.getMessage(); ***REMOVED*** try ***REMOVED***
***REMOVED*** ***REMOVED*** ***REMOVED*** System.out.println("Checking dependencies list: " + file);
***REMOVED*** ***REMOVED*** final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
***REMOVED*** return check; ***REMOVED*** svnRepository.getFile(file, SVNRepository.INVALID_REVISION, null, byteArrayOutputStream);
***REMOVED*** String lines[] = byteArrayOutputStream.toString().split("\\r?\\n");
***REMOVED***
***REMOVED*** ***REMOVED*** if(deps.isEmpty())***REMOVED***
***REMOVED*** ***REMOVED*** sm.sendNotification(nh.getFailedSubject(), nh.getFailedBody());
***REMOVED*** ***REMOVED*** Exception e = new Exception("No dependency specified for this
***REMOVED*** ***REMOVED*** algorithm");
***REMOVED*** ***REMOVED*** throw e;
***REMOVED*** ***REMOVED***
***REMOVED*** ***REMOVED*** ***REMOVED***
***REMOVED***
***REMOVED*** ***REMOVED*** else if (!deps.isEmpty()) ***REMOVED***
***REMOVED*** List<String> ldep = new LinkedList<>();
***REMOVED*** for (Dependency d : deps) ***REMOVED***
***REMOVED*** ldep.add(d.getName());
***REMOVED*** ***REMOVED***
***REMOVED*** for (String a : lines) ***REMOVED***
***REMOVED*** for (String b : ldep) ***REMOVED***
***REMOVED*** if (b.equals(a)) ***REMOVED***
***REMOVED*** System.out.println("The following dependency is correctly written: " + b);
***REMOVED*** check = true;
***REMOVED*** ***REMOVED*** else
***REMOVED*** check = false;
***REMOVED***
***REMOVED*** ***REMOVED***
***REMOVED*** ***REMOVED***
***REMOVED*** ***REMOVED*** ***REMOVED***
***REMOVED*** ***REMOVED*** catch (Exception a) ***REMOVED***
***REMOVED*** a.getMessage();
***REMOVED*** ***REMOVED***
***REMOVED***
***REMOVED*** return check;
***REMOVED*** catch (SVNException e)
***REMOVED***
throw new GenericException(e);
***REMOVED***
***REMOVED*** ***REMOVED***

View File

@ -144,6 +144,7 @@ public class SendMail ***REMOVED***
public String sendPostRequest(String endpoint, String requestParameters) ***REMOVED*** public String sendPostRequest(String endpoint, String requestParameters) ***REMOVED***
this.logger.debug("Sending post request");
***REMOVED*** Build parameter string ***REMOVED*** Build parameter string
String data = requestParameters; String data = requestParameters;
try ***REMOVED*** try ***REMOVED***
@ -169,13 +170,17 @@ public class SendMail ***REMOVED***
writer.close(); writer.close();
reader.close(); reader.close();
this.logger.debug("Operation completed");
String response = answer.toString();
this.logger.debug("Response "+response);
***REMOVED*** Output the response ***REMOVED*** Output the response
return answer.toString(); return response;
***REMOVED*** catch (MalformedURLException ex) ***REMOVED*** ***REMOVED*** catch (MalformedURLException ex) ***REMOVED***
ex.printStackTrace(); this.logger.error("Invalid URL",ex);
***REMOVED*** catch (IOException ex) ***REMOVED*** ***REMOVED*** catch (IOException ex) ***REMOVED***
ex.printStackTrace();
this.logger.error("Error in the IO process",ex);
***REMOVED*** ***REMOVED***
***REMOVED*** ***REMOVED***
***REMOVED*** ***REMOVED***

View File

@ -1,25 +1,34 @@
package org.gcube.dataanalysis.dataminer.poolmanager.util.exception; package org.gcube.dataanalysis.dataminer.poolmanager.util.exception;
public class AlgorithmException extends Exception ***REMOVED*** public class AlgorithmException extends DMPMException***REMOVED***
***REMOVED**** ***REMOVED****
* *
***REMOVED*** ***REMOVED***
private static final long serialVersionUID = -5678597187512954288L; private static final long serialVersionUID = -5678597187512954288L;
private String algorithmName;
public AlgorithmException ()
***REMOVED***
super ();
***REMOVED***
public AlgorithmException (String message)
***REMOVED***
super (message);
***REMOVED***
public AlgorithmException (String message, Throwable cause) public AlgorithmException (String algorithmName)
***REMOVED*** ***REMOVED***
super (message, cause); super ("Algorithm exception");
this.algorithmName = algorithmName;
***REMOVED***
public AlgorithmException (String algorithmName, Throwable cause)
***REMOVED***
super ("Algorithm exception", cause);
this.algorithmName = algorithmName;
***REMOVED***
***REMOVED***
public String getErrorMessage() ***REMOVED***
return "Installation completed but DataMiner Interface not working correctly or files "
+ this.algorithmName + ".jar and " + this.algorithmName
+ "_interface.jar not availables at the expected path";
***REMOVED*** ***REMOVED***

View File

@ -0,0 +1,20 @@
package org.gcube.dataanalysis.dataminer.poolmanager.util.exception;
public abstract class DMPMException extends Exception***REMOVED***
***REMOVED****
*
***REMOVED***
private static final long serialVersionUID = 1L;
public DMPMException (String errorMessage)
***REMOVED***
super (errorMessage);
***REMOVED***
public DMPMException(String errorMessage,Throwable cause) ***REMOVED***
super (errorMessage,cause);
***REMOVED***
public abstract String getErrorMessage ();
***REMOVED***

View File

@ -3,6 +3,7 @@ package org.gcube.dataanalysis.dataminer.poolmanager.util.exception;
public class EMailException extends Exception ***REMOVED*** public class EMailException extends Exception ***REMOVED***
private static final String MESSAGE = "Unable to send email notification";
***REMOVED**** ***REMOVED****
* *
@ -10,10 +11,14 @@ public class EMailException extends Exception ***REMOVED***
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public EMailException() ***REMOVED*** public EMailException() ***REMOVED***
super ("Unable to send email notification"); super (MESSAGE);
***REMOVED*** ***REMOVED***
public EMailException(Throwable cause) ***REMOVED*** public EMailException(Throwable cause) ***REMOVED***
super ("Unable to send email notification",cause); super (MESSAGE,cause);
***REMOVED*** ***REMOVED***
***REMOVED*** ***REMOVED***

View File

@ -0,0 +1,26 @@
package org.gcube.dataanalysis.dataminer.poolmanager.util.exception;
public class GenericException extends DMPMException ***REMOVED***
***REMOVED****
*
***REMOVED***
private static final long serialVersionUID = 6772009633547404120L;
public GenericException(Throwable cause) ***REMOVED***
super ("Generic exception",cause);
***REMOVED***
***REMOVED***
public String getErrorMessage() ***REMOVED***
return this.getCause().getMessage();
***REMOVED***
***REMOVED***

View File

@ -2,7 +2,7 @@ package org.gcube.dataanalysis.dataminer.poolmanager.util.exception;
import org.tmatesoft.svn.core.SVNErrorMessage; import org.tmatesoft.svn.core.SVNErrorMessage;
public class SVNCommitException extends Exception ***REMOVED*** public class SVNCommitException extends DMPMException ***REMOVED***
***REMOVED**** ***REMOVED****
* *
@ -13,28 +13,31 @@ public class SVNCommitException extends Exception ***REMOVED***
private String fileName; private String fileName;
public SVNCommitException(SVNErrorMessage errorMessage) ***REMOVED*** public SVNCommitException(SVNErrorMessage errorMessage, String fileName) ***REMOVED***
super ("Unable to commit"); super ("Unable to commit");
this.svnErrorMessage = errorMessage; this.svnErrorMessage = errorMessage;
this.fileName = fileName;
***REMOVED*** ***REMOVED***
public SVNCommitException(String message,SVNErrorMessage errorMessage) ***REMOVED*** public SVNCommitException(String message,SVNErrorMessage errorMessage,String fileName) ***REMOVED***
super (message); super (message);
this.svnErrorMessage = errorMessage; this.svnErrorMessage = errorMessage;
this.fileName = fileName;
***REMOVED*** ***REMOVED***
public SVNErrorMessage getSvnErrorMessage() ***REMOVED*** public SVNErrorMessage getSvnErrorMessage() ***REMOVED***
return svnErrorMessage; return svnErrorMessage;
***REMOVED*** ***REMOVED***
public void setFileName (String fileName)
***REMOVED***
this.fileName = fileName;
***REMOVED*** ***REMOVED***
public String getErrorMessage() ***REMOVED***
public String getFileName ()
***REMOVED*** return "Commit operation failed for "+this.fileName
return this.fileName; + "the message of the SVN Server is the following:\n"+this.svnErrorMessage.getMessage();
***REMOVED*** ***REMOVED***