From 2975451165bc522859c9608d12a3419bea9f7fc3 Mon Sep 17 00:00:00 2001 From: davidplunkett Date: Thu, 28 Feb 2019 01:55:21 +0000 Subject: [PATCH] skip workflow tasks if filename is null Change-Id: Ibe8328282df45fdb572be9f0c470fe0f390fdbc3 Signed-off-by: davidplunkett --- .../DeployPostVerficationRemoteScriptExecutor.java | 68 +++++++++++--------- ...DeployRemoteDeploymentVerificationDelegate.java | 74 ++++++++++++---------- 2 files changed, 79 insertions(+), 63 deletions(-) diff --git a/akraino/src/main/java/com/akraino/bpm/delegate/DeployPostVerficationRemoteScriptExecutor.java b/akraino/src/main/java/com/akraino/bpm/delegate/DeployPostVerficationRemoteScriptExecutor.java index 569936c..ac0e438 100644 --- a/akraino/src/main/java/com/akraino/bpm/delegate/DeployPostVerficationRemoteScriptExecutor.java +++ b/akraino/src/main/java/com/akraino/bpm/delegate/DeployPostVerficationRemoteScriptExecutor.java @@ -23,40 +23,50 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import com.akraino.bpm.Exception.TaskExecutorException; import com.akraino.bpm.model.BuildResponse; import com.akraino.bpm.service.DeployResponseSenderService; import com.akraino.bpm.service.RemoteScriptExecutionService; - - @Component public class DeployPostVerficationRemoteScriptExecutor implements JavaDelegate { - private static Logger logger = LoggerFactory.getLogger(DeployPostVerficationRemoteScriptExecutor.class); - - @Autowired - RemoteScriptExecutionService remoteScriptExecutionService; - - @Autowired - DeployResponseSenderService deployResponseSenderService; - - public void execute(DelegateExecution ctx) throws Exception { - String remotserver=(String)ctx.getVariable("remotserver"); - int portnumner=(Integer)ctx.getVariable("port"); - String username=(String)ctx.getVariable("username"); - String password=(String)ctx.getVariable("password"); - String filename=(String)ctx.getVariable("postverificationscript"); - String fileparams=(String)ctx.getVariable("postverificationScriptparams"); - String srcdir=(String)ctx.getVariable("srcdir"); - String destdir=(String)ctx.getVariable("destdir"); - String sitename=(String)ctx.getVariable("sitename"); - - deployResponseSenderService.sendResponse(new BuildResponse("completed", "completed", "completed", "completed","inprogress",sitename,null,null,null)); - logger.debug("task execution started remotserver {} , portnumner {},username {}, password {},filename : {} ,fileparams={},src dir={},dest dir={}", - remotserver,portnumner,username,password,filename,fileparams,srcdir,destdir); - - String command = String.format("/bin/bash %s/%s %s", destdir, filename, (fileparams!=null?fileparams.replaceAll(",", " "):"")); - logger.debug("Execution command {}",command); - remoteScriptExecutionService.executeRemoteScript(remotserver,username,password,portnumner,filename,fileparams,srcdir,destdir,command); - } + private static Logger logger = LoggerFactory.getLogger(DeployPostVerficationRemoteScriptExecutor.class); + + @Autowired + RemoteScriptExecutionService remoteScriptExecutionService; + + @Autowired + DeployResponseSenderService deployResponseSenderService; + + public void execute(DelegateExecution ctx) throws Exception { + + try { + String remoteserver =(String) ctx.getVariable("remotserver"); + int portnumner =(Integer)ctx.getVariable("port"); + String username =(String) ctx.getVariable("username"); + String password =(String) ctx.getVariable("password"); + String filename =(String) ctx.getVariable("postverificationscript"); + String fileparams =(String) ctx.getVariable("postverificationScriptparams"); + String srcdir =(String) ctx.getVariable("srcdir"); + String destdir =(String) ctx.getVariable("destdir"); + String sitename =(String) ctx.getVariable("sitename"); + String blueprint =(String) ctx.getVariable("blueprint"); + + deployResponseSenderService.sendResponse(new BuildResponse("completed", "completed", "completed", "completed","inprogress",sitename,null,null,null)); + logger.debug("task execution started blueprint {}, remoteserver {}, portnumner {}, username {}, password {}, filename {}, fileparams {}, src dir={}, dest dir={}", + blueprint,remoteserver,portnumner,username,password,filename,fileparams,srcdir,destdir); + + String command = String.format("/bin/bash %s/%s %s", destdir, filename, (fileparams!=null?fileparams.replaceAll(",", " "):"")); + if ( !filename.equals("null") || !filename.equals("") ) { + logger.debug("Execution command {}",command); + remoteScriptExecutionService.executeRemoteScript(remoteserver,username,password,portnumner,filename,fileparams,srcdir,destdir,command); + } else { + logger.debug("Skipping invalid verification command: {}", command); + } + } catch(TaskExecutorException ex) { + throw ex; + } + } } + diff --git a/akraino/src/main/java/com/akraino/bpm/delegate/DeployRemoteDeploymentVerificationDelegate.java b/akraino/src/main/java/com/akraino/bpm/delegate/DeployRemoteDeploymentVerificationDelegate.java index c46b71f..6d40629 100644 --- a/akraino/src/main/java/com/akraino/bpm/delegate/DeployRemoteDeploymentVerificationDelegate.java +++ b/akraino/src/main/java/com/akraino/bpm/delegate/DeployRemoteDeploymentVerificationDelegate.java @@ -31,39 +31,45 @@ import com.akraino.bpm.service.RemoteDeploymentVerificationService; @Component public class DeployRemoteDeploymentVerificationDelegate implements JavaDelegate { - private static Logger logger = LoggerFactory.getLogger(DeployRemoteDeploymentVerificationDelegate.class); - - @Autowired - RemoteDeploymentVerificationService remotedeploymentVerificationService; - - @Autowired - DeployResponseSenderService deployResponseSenderService; + private static Logger logger = LoggerFactory.getLogger(DeployRemoteDeploymentVerificationDelegate.class); - public void execute(DelegateExecution ctx) throws Exception { - - try { - String verifierFilename=(String)ctx.getVariable("verifier"); - int waittime=(Integer)ctx.getVariable("waittime"); - int iterations=(Integer)ctx.getVariable("iterations"); - String remotserver=(String)ctx.getVariable("remotserver"); - int portnumner=(Integer)ctx.getVariable("port"); - String username=(String)ctx.getVariable("username"); - String password=(String)ctx.getVariable("password"); - String srcdir=(String)ctx.getVariable("srcdir"); - String destdir=(String)ctx.getVariable("destdir"); - String filepparams=(String)ctx.getVariable("verifierfileparams"); - String sitename=(String)ctx.getVariable("sitename"); - - deployResponseSenderService.sendResponse(new BuildResponse("completed", "completed", "completed", "inprogress","not started", sitename,null,null,null)); - - logger.debug("task execution started remotserver {} , portnumner {},username {}, password {},filename : {} , waittime : {},No of iterations :{}", - remotserver,portnumner,username,password,verifierFilename,srcdir,destdir,waittime,iterations); - - String command = String.format("/bin/bash %s/%s %s", destdir, verifierFilename, (filepparams!=null?filepparams.replaceAll(",", " "):"")); - logger.debug("Execution command {}",command); - remotedeploymentVerificationService.executeScript(remotserver,username,password,portnumner,verifierFilename,filepparams,srcdir,destdir,waittime,iterations,command); - } catch(TaskExecutorException ex) { - throw ex; - } - } + @Autowired + RemoteDeploymentVerificationService remotedeploymentVerificationService; + + @Autowired + DeployResponseSenderService deployResponseSenderService; + + public void execute(DelegateExecution ctx) throws Exception { + + try { + String remoteserver =(String) ctx.getVariable("remotserver"); + int portnumner =(Integer)ctx.getVariable("port"); + String username =(String) ctx.getVariable("username"); + String password =(String) ctx.getVariable("password"); + String filename =(String) ctx.getVariable("verifier"); + String fileparams =(String) ctx.getVariable("verifierfileparams"); + String srcdir =(String) ctx.getVariable("srcdir"); + String destdir =(String) ctx.getVariable("destdir"); + String sitename =(String) ctx.getVariable("sitename"); + String blueprint =(String) ctx.getVariable("blueprint"); + int waittime =(Integer)ctx.getVariable("waittime"); + int iterations =(Integer)ctx.getVariable("iterations"); + + deployResponseSenderService.sendResponse(new BuildResponse("completed", "completed", "completed", "inprogress","not started", sitename,null,null,null)); + + logger.debug("task execution started blueprint {}, remoteserver {}, portnumner {}, username {}, password {}, filename {}, waittime {}, No of iterations {}", + blueprint,remoteserver,portnumner,username,password,filename,srcdir,destdir,waittime,iterations); + + String command = String.format("/bin/bash %s/%s %s", destdir, filename, (fileparams!=null?fileparams.replaceAll(",", " "):"")); + if ( !filename.equals("null") || !filename.equals("") ) { + logger.debug("Execution command: {}",command); + remotedeploymentVerificationService.executeScript(remoteserver,username,password,portnumner,filename,fileparams,srcdir,destdir,waittime,iterations,command); + } else { + logger.debug("Skipping invalid verification command: {}", command); + } + } catch(TaskExecutorException ex) { + throw ex; + } + } } + -- 2.16.6