Move master branch changes back to dev 93/393/1 development
authorEby, Robert (re2429) <re2429@att.com>
Mon, 11 Feb 2019 15:57:45 +0000 (10:57 -0500)
committerEby, Robert (re2429) <re2429@att.com>
Mon, 11 Feb 2019 15:57:45 +0000 (10:57 -0500)
Change-Id: Ia91fa9eeac8fc8592a990312b88c5ec0b07a10b7
Signed-off-by: Eby, Robert (re2429) <re2429@att.com>
12 files changed:
akraino/pom.xml
akraino/src/main/java/com/akraino/bpm/delegate/DeployPostVerficationRemoteScriptExecutor.java
akraino/src/main/java/com/akraino/bpm/delegate/DeployRemoteDeploymentVerificationDelegate.java
akraino/src/main/java/com/akraino/bpm/delegate/DeployRemoteScriptExecutorTaskDelegate.java
akraino/src/main/java/com/akraino/bpm/delegate/RemoteDeploymentVerificationDelegate.java
akraino/src/main/java/com/akraino/bpm/delegate/RemoteScriptExecutorTaskDelegate.java
akraino/src/main/java/com/akraino/bpm/service/impl/AsyncProcessExecutorServiceImpl.java
akraino/src/main/java/com/akraino/bpm/service/impl/DeploymentverificationServiceImpl.java
akraino/src/main/java/com/akraino/bpm/service/impl/FileTransferServiceImpl.java
akraino/src/main/java/com/akraino/bpm/service/impl/RemoteScriptExecutionServiceImpl.java
akraino/src/main/java/com/akraino/bpm/service/impl/ScriptExecutionServiceImpl.java
pom.xml

index 515f0bd..68264ec 100644 (file)
@@ -62,7 +62,7 @@
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-tertifartifactId>
       <scope>test</scope>
-      <version>1.5.8.RE</ver</version>
+      <version>1.5.8.RE</version>
     </dependency>
 -->
   </dependencies>
index cca42b0..569936c 100644 (file)
@@ -32,16 +32,14 @@ import com.akraino.bpm.service.RemoteScriptExecutionService;
 @Component
 public class DeployPostVerficationRemoteScriptExecutor implements JavaDelegate {
 
-       
-       
-        private static Logger logger = LoggerFactory.getLogger(DeployPostVerficationRemoteScriptExecutor.class);
-       
+       private static Logger logger = LoggerFactory.getLogger(DeployPostVerficationRemoteScriptExecutor.class);
+
        @Autowired
        RemoteScriptExecutionService remoteScriptExecutionService;
-       
-       @Autowired 
+
+       @Autowired
        DeployResponseSenderService deployResponseSenderService;
-       
+
        public void execute(DelegateExecution ctx) throws Exception {
                String  remotserver=(String)ctx.getVariable("remotserver");
                int  portnumner=(Integer)ctx.getVariable("port");
@@ -57,11 +55,8 @@ public class DeployPostVerficationRemoteScriptExecutor implements JavaDelegate {
                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="sh  " +destdir+"/"+filename+"  "+(fileparams!=null?fileparams.replaceAll(",", "  "):" ");
+               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);
-               
-       
        }
-
 }
index 49f98b4..c46b71f 100644 (file)
@@ -16,7 +16,6 @@
 
 package com.akraino.bpm.delegate;
 
-
 import org.camunda.bpm.engine.delegate.DelegateExecution;
 import org.camunda.bpm.engine.delegate.JavaDelegate;
 import org.slf4j.Logger;
@@ -29,8 +28,6 @@ import com.akraino.bpm.model.BuildResponse;
 import com.akraino.bpm.service.DeployResponseSenderService;
 import com.akraino.bpm.service.RemoteDeploymentVerificationService;
 
-
-
 @Component
 public class DeployRemoteDeploymentVerificationDelegate implements JavaDelegate {
 
@@ -39,11 +36,10 @@ public class DeployRemoteDeploymentVerificationDelegate implements JavaDelegate
        @Autowired
        RemoteDeploymentVerificationService remotedeploymentVerificationService;
        
-       @Autowired 
+       @Autowired
        DeployResponseSenderService deployResponseSenderService;
-       
 
- public void execute(DelegateExecution ctx) throws Exception {
      public void execute(DelegateExecution ctx) throws Exception {
                
                try {
                        String  verifierFilename=(String)ctx.getVariable("verifier");
@@ -63,15 +59,11 @@ public class DeployRemoteDeploymentVerificationDelegate implements JavaDelegate
                        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="sh  " +destdir+"/"+verifierFilename+"  "+(filepparams!=null?filepparams.replaceAll(",", "  "):" ");
+                       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) {
+               } catch(TaskExecutorException ex) {
                        throw ex;
-               }
-               
-               
+               }       
        }
-
 }
-
index e68ae98..247be64 100644 (file)
@@ -27,19 +27,15 @@ import com.akraino.bpm.model.BuildResponse;
 import com.akraino.bpm.service.DeployResponseSenderService;
 import com.akraino.bpm.service.RemoteScriptExecutionService;
 
-
-
 @Component
 public class DeployRemoteScriptExecutorTaskDelegate implements JavaDelegate {
 
-       
-       
-        private static Logger logger = LoggerFactory.getLogger(DeployRemoteScriptExecutorTaskDelegate.class);
+       private static Logger logger = LoggerFactory.getLogger(DeployRemoteScriptExecutorTaskDelegate.class);
        
        @Autowired
        RemoteScriptExecutionService remoteScriptExecutionService;
        
-       @Autowired 
+       @Autowired
        DeployResponseSenderService deployResponseSenderService;
        
        public void execute(DelegateExecution ctx) throws Exception {
@@ -57,9 +53,8 @@ public class DeployRemoteScriptExecutorTaskDelegate implements JavaDelegate {
                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="sh  " +destdir+"/"+filename+"  "+(fileparams!=null?fileparams.replaceAll(",", "  "):" ");
+               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);
        }
-
 }
index 30204bb..80d4670 100644 (file)
@@ -38,7 +38,7 @@ public class RemoteDeploymentVerificationDelegate implements JavaDelegate {
        RemoteDeploymentVerificationService remotedeploymentVerificationService;
        
 
- public void execute(DelegateExecution ctx) throws Exception {
      public void execute(DelegateExecution ctx) throws Exception {
                
                try {
                        String  verifierFilename=(String)ctx.getVariable("verifier");
@@ -55,15 +55,12 @@ public class RemoteDeploymentVerificationDelegate implements JavaDelegate {
                        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="sh  " +destdir+"/"+(verifierFilename!=null?verifierFilename:"  ")+"  "+(filepparams!=null?filepparams.replaceAll(",", "  "):" ");
+                       // This looks wrong!
+                       String command = "/bin/bash  " +destdir+"/"+(verifierFilename!=null?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) {
+               } catch(TaskExecutorException ex) {
                        throw ex;
-               }
-               
-               
+               }       
        }
-
-}
-
+}
\ No newline at end of file
index d5db4f6..5008925 100644 (file)
@@ -25,14 +25,10 @@ import org.springframework.stereotype.Component;
 
 import com.akraino.bpm.service.RemoteScriptExecutionService;
 
-
-
 @Component
 public class RemoteScriptExecutorTaskDelegate implements JavaDelegate {
 
-       
-       
-        private static Logger logger = LoggerFactory.getLogger(RemoteScriptExecutorTaskDelegate.class);
+       private static Logger logger = LoggerFactory.getLogger(RemoteScriptExecutorTaskDelegate.class);
        
        @Autowired
        RemoteScriptExecutionService remoteScriptExecutionService;
@@ -46,13 +42,11 @@ public class RemoteScriptExecutorTaskDelegate implements JavaDelegate {
                String fileparams=(String)ctx.getVariable("fileparams");
                String  srcdir=(String)ctx.getVariable("srcdir");
                String destdir=(String)ctx.getVariable("destdir");
-               
-               
+
                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="cd  "+destdir+ ";"+"sh  "+filename+"  "+(fileparams!=null?fileparams.replaceAll(",", "  "):" ");
+               String command = String.format("cd %s; /bin/bash %s %s", destdir, filename, (fileparams!=null?fileparams.replaceAll(",", "  "):""));
                logger.debug("Execution command {}",command);
                remoteScriptExecutionService.executeRemoteScript(remotserver,username,password,portnumner,filename,fileparams,srcdir,destdir,command);
        }
-
 }
index 695606e..0b79327 100644 (file)
@@ -136,6 +136,7 @@ public class AsyncProcessExecutorServiceImpl implements AsyncProcessExecutorServ
                                .putValue("port", deploy.getPort())
                                .putValue("destdir",deploy.getDestdir())
                                .putValue("remotefilename", deploy.getRemotefilename())
+                               .putValue("filename", deploy.getRemotefilename())       // Needed by DeployRemoteScriptExecutorTaskDelegate.execute()
                                .putValue("fileparams", deploy.getFileparams())
                                .putValue("verifier", deploy.getDeploymentverifier())
                                .putValue("verifierfileparams",  deploy.getDeploymentverifierfileparams())
index dd62a5d..f17ea47 100644 (file)
@@ -27,14 +27,19 @@ import org.springframework.stereotype.Service;
 import com.akraino.bpm.Exception.TaskExecutorException;
 import com.akraino.bpm.service.DeploymentVerificationService;
 
-
 @Service("deploymentVerificationService")
 public class DeploymentverificationServiceImpl implements DeploymentVerificationService{
 
        private static Logger logger = LoggerFactory.getLogger(DeploymentverificationServiceImpl.class);
-       
-       public void executeScript(String filepatch,int waitttime,int iterations)  {
-               
+
+       /**
+        * Execute a script. potentially several times.
+        * @param filepatch the file to execute
+        * @param waitttime how long to wait (in seconds) between executions
+        * @param iterations the maximum number of iterations
+        */
+       public void executeScript(String filepatch, int waitttime, int iterations)  {
+
                boolean issuccess=false;
                for( int i=0;i<=iterations;i++) {
                        try {
@@ -43,32 +48,30 @@ public class DeploymentverificationServiceImpl implements DeploymentVerification
                                Process p = Runtime.getRuntime().exec(filepatch);
                                p.waitFor();
                                BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
-                       String line = "";
-                       while ((line = input.readLine()) != null) {
-                           if(line.equals("0")) {
-                               issuccess=true;
-                           }
-                        }
-                       
-                       logger.debug("Script exit code :"+p.exitValue());
-                   if(p.exitValue()!=0) {
-                       throw new TaskExecutorException("problem while executing the script . exist code :"+p.exitValue());
-                   }
-                   } catch (IOException e) {
-                                       throw new TaskExecutorException(filepatch + " not found.");
+                               String line = "";
+                               while ((line = input.readLine()) != null) {
+                                       if (line.equals("0")) {
+                                               issuccess=true;
+                                       }
+                               }
+
+                               logger.debug("Script exit code :"+p.exitValue());
+                               if(p.exitValue()!=0) {
+                                       throw new TaskExecutorException("problem while executing the script. exit code :"+p.exitValue());
+                               }
+                       } catch (IOException e) {
+                               throw new TaskExecutorException(filepatch + " not found.");
                        } catch (InterruptedException e) {
-                                       throw new TaskExecutorException("problem while executing the script "+filepatch);
+                               throw new TaskExecutorException("problem while executing the script "+filepatch);
                        }
                        if(issuccess) {
                                break;
                        }
-                       
                }
-               
-                if(!issuccess) {
-               logger.debug("verification script returned 1 ");
-               throw new TaskExecutorException("1");
-         }
-       }
 
+               if(!issuccess) {
+                       logger.debug("verification script returned 1 ");
+                       throw new TaskExecutorException("1");
+               }
+       }
 }
index d8b158c..ad8f46b 100644 (file)
@@ -33,61 +33,57 @@ import com.jcraft.jsch.Session;
 
 @Service("fileTransferService")
 public class FileTransferServiceImpl implements FileTransferService {
-       
+
        private static Logger logger = LoggerFactory.getLogger(FileTransferServiceImpl.class);
 
        public void transferFile(String srcdir, String destdir, String filename,String servername,String username,String password,int port) {
-               
-                logger.debug("file transfor filename={},srcdir={},destdir={}",filename,srcdir,destdir);
-                ChannelSftp sftpChannel=null;
-               try {
-                       JSch jsch = new JSch();
-                               Session session = jsch.getSession(username, servername, port);
-                               session.setConfig("StrictHostKeyChecking", "no");
-                               session.setPassword(password);
-                               session.connect();
-                               sftpChannel = (ChannelSftp)session.openChannel("sftp");
-                               sftpChannel.setPty(true);
-                               sftpChannel.connect();
-                               sftpChannel.cd(destdir);
-                               sftpChannel.put(new FileInputStream(new File (srcdir+"/"+filename)), filename);
-                               sftpChannel.chmod(Integer.parseInt("777", 8),filename);
-                       } catch (Exception e) {
-                       logger.error("Exception occured while ftp : "+e);
-                       throw new TaskExecutorException("problem while transfering the file to remote machine :"+e.getMessage());
-               } finally {
-                       sftpChannel.disconnect();
-               }
+
+               logger.debug("file transfor filename={},srcdir={},destdir={}",filename,srcdir,destdir);
+               ChannelSftp sftpChannel=null;
+               try {
+                       JSch jsch = new JSch();
+                       Session session = jsch.getSession(username, servername, port);
+                       session.setConfig("StrictHostKeyChecking", "no");
+                       session.setPassword(password);
+                       session.connect();
+                       sftpChannel = (ChannelSftp)session.openChannel("sftp");
+                       sftpChannel.setPty(true);
+                       sftpChannel.connect();
+                       sftpChannel.cd(destdir);
+                       sftpChannel.put(new FileInputStream(new File (srcdir+"/"+filename)), filename);
+                       sftpChannel.chmod(Integer.parseInt("777", 8),filename);
+               } catch (Exception e) {
+                       logger.error("Exception occurred while FTP : "+e);
+                       throw new TaskExecutorException("problem while transferring the file to remote machine :"+e.getMessage());
+               } finally {
+                       if (sftpChannel != null)
+                               sftpChannel.disconnect();
+               }
        }
-       
 
        public void transferFile(String srcdir, String destdir,String servername,String username,String password,int port) {
-               
+
                List<File> files=getAllfiles(new File(srcdir));
                for(File file: files) {
                        transferFile(srcdir,destdir,file.getName(),servername,username,password,port);
                }
-               
-               
        }
-       
+
        private List<File> getAllfiles(File rootDirectory){
            List<File> results = new ArrayList<File>();
-           
+
            if(rootDirectory==null) {
-               throw new TaskExecutorException("problem while transfering the file to remote machine : src diectory Not found");
-           }
-           
-           for(File currentItem : rootDirectory.listFiles()){
-             if(currentItem.isDirectory()){
-                 results.addAll(getAllfiles(currentItem));
-             }
-             else{
-                 results.add(currentItem);
-             }
+               throw new TaskExecutorException("problem while transferring the file to remote machine : src directory Not found");
            }
+
+               for(File currentItem : rootDirectory.listFiles()){
+                       if(currentItem.isDirectory()){
+                               results.addAll(getAllfiles(currentItem));
+                       }
+                       else{
+                               results.add(currentItem);
+                       }
+               }
            return results;
        }
-       
-
 }
index 1b23bba..b44117b 100644 (file)
@@ -21,7 +21,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
@@ -37,6 +36,18 @@ public class RemoteScriptExecutionServiceImpl implements RemoteScriptExecutionSe
 
        private static Logger logger = LoggerFactory.getLogger(RemoteScriptExecutionServiceImpl.class);
        
+       /**
+        * Execute a command remotely
+        * @param remoteserver the remote server to execute on
+        * @param username the user name on the remote server
+        * @param password the password for the user
+        * @param portnumber the port number on the remote server
+        * @param filename not used
+        * @param fileparams not used 
+        * @param srcdir not used
+        * @param destdir not used
+        * @param command the command to execute
+        */
        public void executeRemoteScript(String remoteserver,String username,String password,int portnumber,String filename,
                        String fileparams,String srcdir,String destdir,String command)  {
                
@@ -63,19 +74,19 @@ public class RemoteScriptExecutionServiceImpl implements RemoteScriptExecutionSe
                        String line;
                        logger.debug("Script output......................");
                        while ((line = reader.readLine()) != null){
-                                logger.debug(line);
+                               logger.debug(line);
                        }
                        
                        channelExec.disconnect();
-               while (!channelExec.isClosed()) {
-
-               }
+                       while (!channelExec.isClosed()) {
+                               // nothing?!
+                       }
 
                        int exitStatus = channelExec.getExitStatus();
                        
             logger.debug("Script exit code :"+exitStatus);
             if(exitStatus!=0) {
-               throw new TaskExecutorException("problem while executing the script . exist code :"+exitStatus);
+               throw new TaskExecutorException("problem while executing the script. exit code :"+exitStatus);
             }
             
                        
@@ -83,7 +94,7 @@ public class RemoteScriptExecutionServiceImpl implements RemoteScriptExecutionSe
                        throw new TaskExecutorException(filename + " not found.");
                } catch (Exception e) {
                        throw new TaskExecutorException("Problem while executing script"+e.getMessage());
-               }finally{
+               } finally {
                        if(reader!=null) {
                                try {
                                        reader.close();
@@ -94,15 +105,6 @@ public class RemoteScriptExecutionServiceImpl implements RemoteScriptExecutionSe
                        if(session!=null) {
                                session.disconnect();
                        }
-               }
-               
-               
-               
+               }       
        }
-       
-       
-       
-
 }
-        
-        
index 36842d3..e545a84 100644 (file)
@@ -32,9 +32,13 @@ import com.akraino.bpm.service.ScriptExecutionService;
 public class ScriptExecutionServiceImpl implements ScriptExecutionService{
 
        private static Logger logger = LoggerFactory.getLogger(ScriptExecutionServiceImpl.class);
-       
+
+       /**
+        * Execute a script
+        * @param filepatch the script to execute
+        */
        public void executeScript(String filepatch)  {
-               
+
                try {
                        logger.debug("Executing the script.............");
                        Process p = Runtime.getRuntime().exec(filepatch);
@@ -46,100 +50,98 @@ public class ScriptExecutionServiceImpl implements ScriptExecutionService{
             p.waitFor();
             logger.debug("Script exit code :"+p.exitValue());
             if(p.exitValue()!=0) {
-               throw new TaskExecutorException("problem while executing the script . exit code :"+p.exitValue());
+               throw new TaskExecutorException("problem while executing the script. exit code :"+p.exitValue());
             }
-            
-                       
+
                } catch (IOException e) {
                        throw new TaskExecutorException(filepatch + " not found.");
                } catch (InterruptedException e) {
                        throw new TaskExecutorException("problem while executing the script "+filepatch);
                }
-               
+
        }
-               public void executeCDScript(String dir,String cmd)  {
-                       
-                       try {
-                               logger.debug("Executing the script.............dir:{},command:{}",dir,cmd);
-                               
-                               String[] command = { "/bin/sh", "-c", "sh  "+cmd };
-                               Process p = Runtime.getRuntime().exec(command, null, new File(dir));
-                               p.waitFor();
-                               BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
-                   String line = "";
-                   while ((line = input.readLine()) != null) {
-                       logger.debug(line);
-                   }
-                   logger.debug("Script exit code :"+p.exitValue());
-                   if(p.exitValue()!=0) {
-                       throw new TaskExecutorException("problem while executing the script . exist code :"+p.exitValue());
-                   }
-                   
-                               
-                       } catch (IOException e) {
-                               throw new TaskExecutorException(cmd + " not found.");
-                       } catch (InterruptedException e) {
-                               throw new TaskExecutorException("problem while executing the script "+cmd);
+
+       /**
+        * Execute a command in a directory
+        * @param dir the directory to execute in
+        * @param cmd the command to execute
+        */
+       public void executeCDScript(String dir,String cmd)  {
+
+               try {
+                       logger.debug("Executing the script.............dir:{},command:{}",dir,cmd);
+
+                       String[] command = { "/bin/bash", "-c", "bash  "+cmd };
+                       Process p = Runtime.getRuntime().exec(command, null, new File(dir));
+                       p.waitFor();
+                       BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
+                       String line = "";
+                       while ((line = input.readLine()) != null) {
+                               logger.debug(line);
                        }
-               
+                       logger.debug("Script exit code :"+p.exitValue());
+                       if(p.exitValue()!=0) {
+                               throw new TaskExecutorException("problem while executing the script. exit code :"+p.exitValue());
+                       }
+               } catch (IOException e) {
+                       throw new TaskExecutorException(cmd + " not found.");
+               } catch (InterruptedException e) {
+                       throw new TaskExecutorException("problem while executing the script "+cmd);
+               }
        }
-               
-               
-               public void executeCDBashScript(String dir,String cmd)  {
-                       
-                       try {
-                               logger.debug("Executing the script.............dir:{},command:{}",dir,cmd);
-                               
-                               String[] command = { "/bin/bash", "-c", "bash  "+cmd };
-                               Process p = Runtime.getRuntime().exec(command, null, new File(dir));
-                               p.waitFor();
-                               BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
-                   String line = "";
-                   while ((line = input.readLine()) != null) {
-                       logger.debug(line);
-                   }
-                   logger.debug("Script exit code :"+p.exitValue());
-                   if(p.exitValue()!=0) {
-                       throw new TaskExecutorException("problem while executing the script . exit code :"+p.exitValue());
-                   }
-                   
-                               
-                       } catch (IOException e) {
-                               throw new TaskExecutorException(cmd + " not found.");
-                       } catch (InterruptedException e) {
-                               throw new TaskExecutorException("problem while executing the script "+cmd);
+
+       /**
+        * Execute a command in a directory
+        * @param dir the directory to execute in
+        * @param cmd the command to execute
+        */
+       public void executeCDBashScript(String dir,String cmd)  {
+
+               try {
+                       logger.debug("Executing the script.............dir:{},command:{}",dir,cmd);
+
+                       String[] command = { "/bin/bash", "-c", "bash  "+cmd };
+                       Process p = Runtime.getRuntime().exec(command, null, new File(dir));
+                       p.waitFor();
+                       BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
+                       String line = "";
+                       while ((line = input.readLine()) != null) {
+                               logger.debug(line);
+                       }
+                       logger.debug("Script exit code :"+p.exitValue());
+                       if(p.exitValue()!=0) {
+                               throw new TaskExecutorException("problem while executing the script . exit code :"+p.exitValue());
                        }
-               
+               } catch (IOException e) {
+                       throw new TaskExecutorException(cmd + " not found.");
+               } catch (InterruptedException e) {
+                       throw new TaskExecutorException("problem while executing the script "+cmd);
+               }
        }
-               
-               
-               
-               
-               /*public void executeAirshipScript(String cmd)  {
-                       
-                       try {
-                               logger.debug("Executing the script.............{}",cmd);
-                               ProcessBuilder pb = new ProcessBuilder(cmd); 
-                               Process shellProcess = pb.start();
-                               
-                               shellProcess.waitFor(); 
-                               BufferedReader input = new BufferedReader(new InputStreamReader(shellProcess.getInputStream()));
-                   String line = "";
-                   while ((line = input.readLine()) != null) {
-                       logger.debug(line);
-                   }
-                   logger.debug("Script exit code :"+shellProcess.exitValue());
-                   if(shellProcess.exitValue()!=0) {
-                       throw new TaskExecutorException("problem while executing the script . exist code :"+shellProcess.exitValue());
-                   }
-                   
-                               
-                       } catch (IOException e) {
-                               throw new TaskExecutorException(cmd + " not found.");
-                       } catch (InterruptedException e) {
-                               throw new TaskExecutorException("problem while executing the script "+cmd);
+
+       /*public void executeAirshipScript(String cmd)  {
+
+               try {
+                       logger.debug("Executing the script.............{}",cmd);
+                       ProcessBuilder pb = new ProcessBuilder(cmd);
+                       Process shellProcess = pb.start();
+
+                       shellProcess.waitFor();
+                       BufferedReader input = new BufferedReader(new InputStreamReader(shellProcess.getInputStream()));
+                       String line = "";
+                       while ((line = input.readLine()) != null) {
+                               logger.debug(line);
                        }
-               
-       }*/
+                       logger.debug("Script exit code :"+shellProcess.exitValue());
+                       if(shellProcess.exitValue()!=0) {
+                               throw new TaskExecutorException("problem while executing the script. exit code :"+shellProcess.exitValue());
+                       }
+
 
+               } catch (IOException e) {
+                       throw new TaskExecutorException(cmd + " not found.");
+               } catch (InterruptedException e) {
+                       throw new TaskExecutorException("problem while executing the script "+cmd);
+               }
+       }*/
 }
diff --git a/pom.xml b/pom.xml
index 515f0bd..68264ec 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -62,7 +62,7 @@
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-tertifartifactId>
       <scope>test</scope>
-      <version>1.5.8.RE</ver</version>
+      <version>1.5.8.RE</version>
     </dependency>
 -->
   </dependencies>