From 6daeede27430d158742f4b74e72be5b7c85d48e4 Mon Sep 17 00:00:00 2001 From: narendervemula Date: Sun, 29 Jul 2018 14:26:50 +0000 Subject: [PATCH] added authentication Change-Id: Ic3eb52b52eb38b9084e0e32dce05968e4afea52f --- akraino/.gitignore | 12 + akraino/.springBeans | 16 + akraino/RemoteSystemsTempFiles/.project | 12 - akraino/pom.xml | 49 ++- .../akraino/bpm/AkrainoSpringBootApplication.java | 38 ++ .../com/akraino/bpm/config/CamundaCorsFilter.java | 319 ++++++++-------- .../bpm/controller/CamundaRestController.java | 328 ++++++----------- .../DeployPostVerficationRemoteScriptExecutor.java | 133 +++---- ...DeployRemoteDeploymentVerificationDelegate.java | 153 ++++---- .../DeployRemoteScriptExecutorTaskDelegate.java | 129 +++---- .../delegate/DeployScriptExecutorTaskDelegate.java | 101 +++-- .../delegate/DeploymentVerificationDelegate.java | 128 +++---- .../akraino/bpm/delegate/WinScpScriptDelegate.java | 107 +++--- .../main/java/com/akraino/bpm/model/Airship.java | 248 +++++++------ .../main/java/com/akraino/bpm/model/Apache.java | 402 ++++++++++---------- .../src/main/java/com/akraino/bpm/model/Build.java | 115 +++--- .../java/com/akraino/bpm/model/BuildResponse.java | 248 +++++++------ .../main/java/com/akraino/bpm/model/Deploy.java | 340 +++++++++-------- .../src/main/java/com/akraino/bpm/model/Onap.java | 403 ++++++++++---------- .../main/java/com/akraino/bpm/model/Tempest.java | 406 +++++++++++---------- .../bpm/service/AsyncProcessExecutorService.java | 39 ++ .../impl/AsyncProcessExecutorServiceImpl.java | 228 ++++++++++++ .../impl/DeployResponseSenderServiceImpl.java | 123 ++++--- .../bpm/service/impl/FileTransferServiceImpl.java | 186 +++++----- .../RemoteDeploymentverificationServiceImpl.java | 220 +++++------ .../impl/RemoteScriptExecutionServiceImpl.java | 214 +++++------ .../service/impl/ScriptExecutionServiceImpl.java | 230 ++++++------ akraino/src/main/resources/application.yaml | 27 +- config/application.yaml | 3 +- config/deploy.bpmn | 77 ++-- config/singledeploy.bpmn | 54 +++ 31 files changed, 2745 insertions(+), 2343 deletions(-) create mode 100644 akraino/.gitignore create mode 100644 akraino/.springBeans delete mode 100644 akraino/RemoteSystemsTempFiles/.project create mode 100644 akraino/src/main/java/com/akraino/bpm/service/AsyncProcessExecutorService.java create mode 100644 akraino/src/main/java/com/akraino/bpm/service/impl/AsyncProcessExecutorServiceImpl.java create mode 100644 config/singledeploy.bpmn diff --git a/akraino/.gitignore b/akraino/.gitignore new file mode 100644 index 0000000..b7d7dc6 --- /dev/null +++ b/akraino/.gitignore @@ -0,0 +1,12 @@ +*.class + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* \ No newline at end of file diff --git a/akraino/.springBeans b/akraino/.springBeans new file mode 100644 index 0000000..009ac9b --- /dev/null +++ b/akraino/.springBeans @@ -0,0 +1,16 @@ + + + 1 + + + + + + + java:com.akraino.bpm.AkrainoSpringBootApplication + + + + + + diff --git a/akraino/RemoteSystemsTempFiles/.project b/akraino/RemoteSystemsTempFiles/.project deleted file mode 100644 index 5447a64..0000000 --- a/akraino/RemoteSystemsTempFiles/.project +++ /dev/null @@ -1,12 +0,0 @@ - - - RemoteSystemsTempFiles - - - - - - - org.eclipse.rse.ui.remoteSystemsTempNature - - diff --git a/akraino/pom.xml b/akraino/pom.xml index f142d61..3cb3945 100644 --- a/akraino/pom.xml +++ b/akraino/pom.xml @@ -4,7 +4,7 @@ camunda_workflow 0.0.1-SNAPSHOT jar - + @@ -16,7 +16,7 @@ - + org.camunda.bpm.springboot @@ -27,25 +27,44 @@ com.h2database h2 + org.yaml snakeyaml 1.21 + - commons-net - commons-net - 3.3 + commons-net + commons-net + 3.3 + + + + com.jcraft + jsch + 0.1.54 + + + io.springfox + springfox-swagger2 + 2.7.0 + - com.jcraft - jsch - 0.1.54 + io.springfox + springfox-swagger-ui + 2.7.0 - + + - - + + + + + + org.springframework.boot spring-boot-maven-plugin @@ -57,6 +76,8 @@ - - - \ No newline at end of file + + + + + diff --git a/akraino/src/main/java/com/akraino/bpm/AkrainoSpringBootApplication.java b/akraino/src/main/java/com/akraino/bpm/AkrainoSpringBootApplication.java index d93e52f..68eb570 100644 --- a/akraino/src/main/java/com/akraino/bpm/AkrainoSpringBootApplication.java +++ b/akraino/src/main/java/com/akraino/bpm/AkrainoSpringBootApplication.java @@ -16,13 +16,51 @@ package com.akraino.bpm; +import java.util.HashSet; +import java.util.Set; + import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.http.MediaType; +import org.springframework.scheduling.annotation.EnableAsync; + +import io.swagger.annotations.Api; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; @SpringBootApplication +@EnableAsync +@EnableSwagger2 public class AkrainoSpringBootApplication { public static void main(String... args) { System.setProperty("server.connection-timeout","36000000"); SpringApplication.run(AkrainoSpringBootApplication.class, args); } + + @Bean + public Docket api() { + Set mediaTypes = new HashSet(); + mediaTypes.add(MediaType.APPLICATION_JSON_VALUE); + + return new Docket(DocumentationType.SWAGGER_2).select().apis(RequestHandlerSelectors.withClassAnnotation(Api.class)) + .paths(PathSelectors.any()).build().pathMapping("/").consumes(mediaTypes).produces(mediaTypes) + .apiInfo(apiInfo()).useDefaultResponseMessages(false); + } + + @Bean + public ApiInfo apiInfo() { + final ApiInfoBuilder builder = new ApiInfoBuilder(); + builder.title("Akraino Camunda Workflow REST Api").version("1.0").license("(C) Copyright AT&T Inc.") + .description("The API provides a Workflow Engine for Akraino"); + return builder.build(); + } + + + } diff --git a/akraino/src/main/java/com/akraino/bpm/config/CamundaCorsFilter.java b/akraino/src/main/java/com/akraino/bpm/config/CamundaCorsFilter.java index 5b3c294..3d0da27 100644 --- a/akraino/src/main/java/com/akraino/bpm/config/CamundaCorsFilter.java +++ b/akraino/src/main/java/com/akraino/bpm/config/CamundaCorsFilter.java @@ -1,147 +1,172 @@ -/* - * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.akraino.bpm.config; - - -import java.io.IOException; - - -import javax.sql.DataSource; - -import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.camunda.bpm.engine.impl.jobexecutor.CallerRunsRejectedJobsHandler; -import org.camunda.bpm.engine.impl.jobexecutor.JobExecutor; -import org.camunda.bpm.engine.spring.SpringProcessEngineConfiguration; -import org.camunda.bpm.engine.spring.components.jobexecutor.SpringJobExecutor; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.web.client.RestTemplateBuilder; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; -import org.springframework.core.io.support.PathMatchingResourcePatternResolver; -import org.springframework.core.task.TaskExecutor; -import org.springframework.jdbc.datasource.DataSourceTransactionManager; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.cors.CorsConfiguration; -import org.springframework.web.cors.UrlBasedCorsConfigurationSource; -import org.springframework.web.filter.CorsFilter; - - - -@Configuration - - public class CamundaCorsFilter { - - - @Value("${camunda.bpm.buildresponseurl}") - private String buildresponseurl; - - @Autowired - private DataSource dataSource; - - @Autowired - private PlatformTransactionManager transactionManager; - - @Autowired - private JobExecutor jobExecutor; - - public String getBuildresponseurl() { - return buildresponseurl; - } - - public void setBuildresponseurl(String buildresponseurl) { - this.buildresponseurl = buildresponseurl; - } - - @Bean - public RestTemplate restTemplate(RestTemplateBuilder builder) { - // Do any additional configuration here - return builder.build(); - } - - /*@Bean - public JobExecutor jobExecutor() { - final JobExecutor jobExecutor = new RuntimeContainerJobExecutor(); - jobExecutor.setWaitTimeInMillis(5000); - jobExecutor.setLockTimeInMillis(18000000); - return jobExecutor; - } - @Bean - - public ProcessEngineConfiguration SpringProcessEngineConfiguration () { - - ProcessEngineConfiguration ProcessEngineConfiguration=new SpringProcessEngineConfiguration().setJobExecutor(jobexecutor).setProcessEngineName("default"); - return ProcessEngineConfiguration; - }*/ - - @Bean - @Primary - public static JobExecutor jobExecutor(@Qualifier("camundaTaskExecutor") final TaskExecutor taskExecutor) { - final SpringJobExecutor springJobExecutor = new SpringJobExecutor(); - springJobExecutor.setTaskExecutor(taskExecutor); - springJobExecutor.setRejectedJobsHandler(new CallerRunsRejectedJobsHandler()); - springJobExecutor.setWaitTimeInMillis(5000); - springJobExecutor.setLockTimeInMillis(36000000); - return springJobExecutor; - } - - @Bean - @Primary - public ProcessEngineConfigurationImpl processEngineConfiguration() throws IOException { - SpringProcessEngineConfiguration config = (SpringProcessEngineConfiguration) new SpringProcessEngineConfiguration().setJobExecutor(jobExecutor); - config.setDataSource(dataSource); - config.setTransactionManager(transactionManager); - config.setDatabaseSchemaUpdate("true"); - config.setJobExecutorActivate(true); - config.setAuthorizationEnabled(true); - config.setDefaultSerializationFormat("application/json"); - PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); - config.setDeploymentResources(resolver.getResources("classpath:*.bpmn")); - return config; - } - - @Bean - public PlatformTransactionManager getTransactionManager() { - PlatformTransactionManager ptm=new DataSourceTransactionManager(dataSource); - return ptm; - } - - - @Bean - public CorsFilter corsFilter() { - UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); - CorsConfiguration config = new CorsConfiguration(); - config.setAllowCredentials(true); - config.addAllowedOrigin("*"); - config.addAllowedHeader("*"); - config.addAllowedMethod("OPTIONS"); - config.addAllowedMethod("GET"); - config.addAllowedMethod("POST"); - config.addAllowedMethod("PATCH"); - config.addAllowedMethod("PUT"); - config.addAllowedMethod("DELETE"); - source.registerCorsConfiguration("/**", config); - return new CorsFilter(source); - } - - - } - - +/* + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.akraino.bpm.config; + + +import java.io.IOException; + + +import javax.sql.DataSource; + +import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; +import org.camunda.bpm.engine.impl.jobexecutor.CallerRunsRejectedJobsHandler; +import org.camunda.bpm.engine.impl.jobexecutor.JobExecutor; +import org.camunda.bpm.engine.spring.SpringProcessEngineConfiguration; +import org.camunda.bpm.engine.spring.components.jobexecutor.SpringJobExecutor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.web.client.RestTemplateBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.core.io.support.PathMatchingResourcePatternResolver; +import org.springframework.core.task.TaskExecutor; +import org.springframework.jdbc.datasource.DataSourceTransactionManager; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.cors.UrlBasedCorsConfigurationSource; +import org.springframework.web.filter.CorsFilter; + + + +@Configuration + + public class CamundaCorsFilter { + + + @Value("${camunda.bpm.buildresponseurl}") + private String buildresponseurl; + + @Value("${camunda.bpm.tokenId}") + private String tokenId; + + @Autowired + private DataSource dataSource; + + @Autowired + private PlatformTransactionManager transactionManager; + + @Autowired + private JobExecutor jobExecutor; + + public String getBuildresponseurl() { + return buildresponseurl; + } + + public void setBuildresponseurl(String buildresponseurl) { + this.buildresponseurl = buildresponseurl; + } + + public String getTokenId() { + return tokenId; + } + + public void setTokenId(String tokenId) { + this.tokenId = tokenId; + } + + @Bean + public RestTemplate restTemplate(RestTemplateBuilder builder) { + // Do any additional configuration here + return builder.build(); + } + + + + + /*@Bean + public JobExecutor jobExecutor() { + final JobExecutor jobExecutor = new RuntimeContainerJobExecutor(); + jobExecutor.setWaitTimeInMillis(5000); + jobExecutor.setLockTimeInMillis(18000000); + return jobExecutor; + } + @Bean + + public ProcessEngineConfiguration SpringProcessEngineConfiguration () { + + ProcessEngineConfiguration ProcessEngineConfiguration=new SpringProcessEngineConfiguration().setJobExecutor(jobexecutor).setProcessEngineName("default"); + return ProcessEngineConfiguration; + }*/ + + @Bean + @Primary + public static JobExecutor jobExecutor(@Qualifier("camundaTaskExecutor") final TaskExecutor taskExecutor) { + final SpringJobExecutor springJobExecutor = new SpringJobExecutor(); + springJobExecutor.setTaskExecutor(taskExecutor); + springJobExecutor.setRejectedJobsHandler(new CallerRunsRejectedJobsHandler()); + springJobExecutor.setWaitTimeInMillis(5000); + springJobExecutor.setLockTimeInMillis(36000000); + return springJobExecutor; + } + + @Bean + @Primary + public ProcessEngineConfigurationImpl processEngineConfiguration() throws IOException { + SpringProcessEngineConfiguration config = (SpringProcessEngineConfiguration) new SpringProcessEngineConfiguration().setJobExecutor(jobExecutor); + config.setDataSource(dataSource); + config.setTransactionManager(transactionManager); + config.setDatabaseSchemaUpdate("true"); + config.setJobExecutorActivate(true); + config.setAuthorizationEnabled(true); + config.setDefaultSerializationFormat("application/json"); + PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); + config.setDeploymentResources(resolver.getResources("classpath:*.bpmn")); + //config.setProcessEnginePlugins(); + return config; + } + + @Bean + public PlatformTransactionManager getTransactionManager() { + PlatformTransactionManager ptm=new DataSourceTransactionManager(dataSource); + return ptm; + } + + + @Bean + public CorsFilter corsFilter() { + UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); + CorsConfiguration config = new CorsConfiguration(); + config.setAllowCredentials(true); + config.addAllowedOrigin("*"); + config.addAllowedHeader("*"); + config.addAllowedMethod("OPTIONS"); + config.addAllowedMethod("GET"); + config.addAllowedMethod("POST"); + config.addAllowedMethod("PATCH"); + config.addAllowedMethod("PUT"); + config.addAllowedMethod("DELETE"); + source.registerCorsConfiguration("/**", config); + return new CorsFilter(source); + } + + @Bean(name="akrainoprocessExecutor") + public TaskExecutor workExecutor() { + ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor(); + threadPoolTaskExecutor.setThreadNamePrefix("Async-"); + threadPoolTaskExecutor.setCorePoolSize(10); + threadPoolTaskExecutor.setMaxPoolSize(50); + threadPoolTaskExecutor.setQueueCapacity(600); + threadPoolTaskExecutor.afterPropertiesSet(); + return threadPoolTaskExecutor; + } + } + + diff --git a/akraino/src/main/java/com/akraino/bpm/controller/CamundaRestController.java b/akraino/src/main/java/com/akraino/bpm/controller/CamundaRestController.java index 1c5b599..798f513 100644 --- a/akraino/src/main/java/com/akraino/bpm/controller/CamundaRestController.java +++ b/akraino/src/main/java/com/akraino/bpm/controller/CamundaRestController.java @@ -1,221 +1,107 @@ -/* - * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.akraino.bpm.controller; - -import org.camunda.bpm.engine.ProcessEngine; -import org.camunda.bpm.engine.runtime.ProcessInstance; -import org.camunda.bpm.engine.variable.Variables; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; - -import com.akraino.bpm.Exception.TaskExecutorException; -import com.akraino.bpm.model.Airship; -import com.akraino.bpm.model.Apache; -import com.akraino.bpm.model.Build; -import com.akraino.bpm.model.Deploy; -import com.akraino.bpm.model.Onap; -import com.akraino.bpm.model.Tempest; -import com.akraino.bpm.model.WorkflowResponse; - -@RestController -public class CamundaRestController { - - @Autowired - private ProcessEngine camunda; - - private static Logger logger = LoggerFactory.getLogger(CamundaRestController.class); - - @PostMapping("/build/") - public ResponseEntity build(@RequestBody Build build) { - logger.debug("Request received for Build ",build.toString()); - - try { - executeBuildProcess(build); - }catch(TaskExecutorException ex) { - return new ResponseEntity(new WorkflowResponse(500,"Problem while executing Build . exception : "+ex.getMessage()),HttpStatus.OK); - } - return new ResponseEntity(new WorkflowResponse(200,"Build successfully completed."),HttpStatus.OK); - } - - private ProcessInstance executeBuildProcess(Build build) { - - String filepath=build.getFilepath()+" "+(build.getFileparams()!=null?build.getFileparams().replaceAll(",", " "):" "); - return camunda.getRuntimeService().startProcessInstanceByKey("build", - Variables.putValue("filepath", filepath).putValue("targetfolder", build.getTargetfolder())); - } - - - @PostMapping("/deploy/") - public ResponseEntity deploy(@RequestBody Deploy deploy) { - logger.debug("Request received for executing {} and targetDirectory {} ",deploy.toString()); - try { - executeDeployProcess(deploy); - }catch(TaskExecutorException ex) { - return new ResponseEntity(new WorkflowResponse(500,"Problem while executing genesis build. exception : "+ex.getMessage()),HttpStatus.OK); - } - return new ResponseEntity(new WorkflowResponse(200,"Genesis build completed ."),HttpStatus.OK); - } - - private ProcessInstance executeDeployProcess(Deploy deploy) { - - String filepath1=deploy.getFilepath()+" "+(deploy.getFileparams()!=null?deploy.getFileparams().replaceAll(",", " "):" "); - String filepath2=deploy.getWinscpfilepath()+" "+(deploy.getWinscpfileparams()!=null?deploy.getWinscpfileparams().replaceAll(",", " "):" "); - return camunda.getRuntimeService().startProcessInstanceByKey("deploy", - Variables.putValue("filepath", filepath1).putValue("ScpScriptFilepath", filepath2).putValue("remotserver", deploy.getRemotserver()) - .putValue("username", deploy.getUsername()) - .putValue("password", deploy.getPassword()) - .putValue("port", deploy.getPort()).putValue("destdir",deploy.getDestdir()).putValue("remotefilename", deploy.getRemotefilename()) - .putValue("fileparams", deploy.getFileparams()). - putValue("verifier", deploy.getDeploymentverifier()).putValue("verifierfileparams", - deploy.getDeploymentverifierfileparams()).putValue("waittime", deploy.getWaittime()). - putValue("iterations", deploy.getNoofiterations()).putValue("postverificationscript", deploy.getPostverificationscript()).putValue("postverificationScriptparams", deploy.getDeploymentverifierfileparams())); - - } - - - @PostMapping("/airship/") - public ResponseEntity deploy(@RequestBody Airship airship) { - logger.debug("Request received for airship {} and targetDirectory {} ",airship.toString()); - try { - executeAirshipProcess(airship); - }catch(TaskExecutorException ex) { - return new ResponseEntity(new WorkflowResponse(500,"Problem while executing genesis airship. exception : "+ex.getMessage()),HttpStatus.OK); - } - return new ResponseEntity(new WorkflowResponse(200,"Airship is completed ."),HttpStatus.OK); - } - - private ProcessInstance executeAirshipProcess(Airship airship) { - - String filepath1=airship.getFilepath()+" "+(airship.getFileparams()!=null?airship.getFileparams().replaceAll(",", " "):" "); - String filepath2=airship.getWinscpfilepath()+" "+(airship.getWinscpfileparams()!=null?airship.getWinscpfileparams().replaceAll(",", " "):" "); - return camunda.getRuntimeService().startProcessInstanceByKey("airship", - Variables.putValue("filepath", filepath1).putValue("scpdir", airship.getWinscpdir()).putValue("ScpScriptFilepath", filepath2).putValue("remotserver", airship.getRemotserver()) - .putValue("username", airship.getUsername()) - .putValue("password", airship.getPassword()) - .putValue("port", airship.getPort()).putValue("destdir",airship.getDestdir()).putValue("remotefilename", airship.getRemotefilename()) - .putValue("remotefileparams", airship.getRemotefileparams())); - - } - - - @PostMapping("/tempest/") - public ResponseEntity tempest(@RequestBody Tempest tempest) { - logger.debug("Request received for onap ",tempest.toString()); - try { - executeTempestProcess(tempest); - }catch(TaskExecutorException ex) { - return new ResponseEntity(new WorkflowResponse(500,"Problem while executing Tempset API. exception : "+ex.getMessage()),HttpStatus.OK); - } - return new ResponseEntity(new WorkflowResponse(200,"tempeset is completed successfully."),HttpStatus.OK); - } - - private ProcessInstance executeTempestProcess(Tempest tempest) { - - String transferfile= tempest.getFiletrasferscript()+" "+(tempest.getFiletransferparams()!=null?tempest.getFiletransferparams().replaceAll(",", " "):" "); - - return camunda.getRuntimeService().startProcessInstanceByKey("tempest", - Variables.putValue("filename", tempest.getFilename()).putValue("fileparams", tempest.getFileparams()). - putValue("verifier", tempest.getDeploymentverifier()).putValue("verifierfileparams", tempest.getVerifierparams()).putValue("waittime", tempest.getWaittime()). - putValue("iterations", tempest.getNoofiterations()).putValue("remotserver", tempest.getRemoteserver()) - .putValue("username", tempest.getUsername()) - .putValue("password", tempest.getPassword()) - .putValue("port", tempest.getPortnumber()).putValue("srcdir", tempest.getSrcdir()).putValue("destdir",tempest.getDestdir()).putValue("filepath", transferfile) - ); - - } - - - @PostMapping("/apache/") - public ResponseEntity apache(@RequestBody Apache apache) { - logger.debug("Request received for onap ",apache.toString()); - try { - executeapacheProcess(apache); - }catch(TaskExecutorException ex) { - return new ResponseEntity(new WorkflowResponse(500,"Problem while executing Apache API. exception : "+ex.getMessage()),HttpStatus.OK); - } - return new ResponseEntity(new WorkflowResponse(200,"apache is completed successfully."),HttpStatus.OK); - } - - private ProcessInstance executeapacheProcess(Apache apache) { - - String transferfile= apache.getFiletrasferscript()+" "+(apache.getFiletransferparams()!=null?apache.getFiletransferparams().replaceAll(",", " "):" "); - - return camunda.getRuntimeService().startProcessInstanceByKey("apache", - Variables.putValue("filename", apache.getFilename()).putValue("fileparams", apache.getFileparams()). - putValue("verifier", apache.getDeploymentverifier()).putValue("verifierfileparams", apache.getVerifierparams()).putValue("waittime", apache.getWaittime()). - putValue("iterations", apache.getNoofiterations()).putValue("remotserver", apache.getRemoteserver()) - .putValue("username", apache.getUsername()) - .putValue("password", apache.getPassword()) - .putValue("port", apache.getPortnumber()).putValue("srcdir", apache.getSrcdir()).putValue("destdir",apache.getDestdir()).putValue("filepath", transferfile) - ); - - } - - - @PostMapping("/onap/") - public ResponseEntity onap(@RequestBody Onap onap) { - logger.debug("Request received for onap ",onap.toString()); - try { - executeOnapProcess(onap); - }catch(TaskExecutorException ex) { - return new ResponseEntity(new WorkflowResponse(500,"Problem while executing onap build. exception : "+ex.getMessage()),HttpStatus.OK); - } - return new ResponseEntity(new WorkflowResponse(200,"Onap build completed ."),HttpStatus.OK); - } - - private ProcessInstance executeOnapProcess(Onap onap) { - - String transferfile= onap.getFiletrasferscript()+" "+(onap.getFiletransferparams()!=null?onap.getFiletransferparams().replaceAll(",", " "):" "); - return camunda.getRuntimeService().startProcessInstanceByKey("onap", - Variables.putValue("filename", onap.getFilename()).putValue("fileparams", onap.getFileparams()). - putValue("verifier", onap.getDeploymentverifier()).putValue("verifierfileparams", onap.getVerifierparams()).putValue("waittime", onap.getWaittime()). - putValue("iterations", onap.getNoofiterations()).putValue("remotserver", onap.getRemoteserver()) - .putValue("username", onap.getUsername()) - .putValue("password", onap.getPassword()) - .putValue("port", onap.getPortnumber()).putValue("srcdir", onap.getSrcdir()).putValue("destdir",onap.getDestdir()).putValue("filepath", transferfile) - ); - - } - - - - - /*@PostMapping("/singlestepdeploy/") - public ResponseEntity singelStepDeploy(@RequestBody Deploy deploy) { - logger.debug("Request received for onap ",deploy.toString()); - try { - executeOnapProcess(deploy); - }catch(TaskExecutorException ex) { - return new ResponseEntity(new WorkflowResponse(500,"Problem while executing single step deploymewnt. exception : "+ex.getMessage()),HttpStatus.OK); - } - return new ResponseEntity(new WorkflowResponse(200," single step deployment completed ."),HttpStatus.OK); - } - - private ProcessInstance executeOnapProcess(Deploy deploy) { - - String filepath1="bash " + deploy.getFilepath1()+" "+(deploy.getFile1params()!=null?deploy.getFile1params().replaceAll(",", " "):" "); - return camunda.getRuntimeService().startProcessInstanceByKey("singlestepdeploy",Variables.putValue("filepath", filepath1)); - - }*/ - -} +/* + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.akraino.bpm.controller; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + + +import com.akraino.bpm.model.Airship; +import com.akraino.bpm.model.Apache; +import com.akraino.bpm.model.Build; +import com.akraino.bpm.model.BuildResponse; +import com.akraino.bpm.model.Deploy; +import com.akraino.bpm.model.Onap; +import com.akraino.bpm.model.Tempest; +import com.akraino.bpm.service.AsyncProcessExecutorService; + +import io.swagger.annotations.Api; + +@Api +@RestController +public class CamundaRestController { + + + + @Autowired + private AsyncProcessExecutorService asyncProcessExecutorService; + + private static Logger logger = LoggerFactory.getLogger(CamundaRestController.class); + + @PostMapping("/build/") + public ResponseEntity build(@RequestBody Build build) { + logger.debug("Request received for Build ",build.toString()); + asyncProcessExecutorService.executeBuildProcess(build); + return new ResponseEntity(new BuildResponse("in progress",null,null,null,null,build.getSitename(),null,null,null),HttpStatus.OK); + + } + + + + + @PostMapping("/deploy/") + public ResponseEntity deploy(@RequestBody Deploy deploy) { + logger.debug("Request received for executing {} and targetDirectory {} ",deploy.toString()); + asyncProcessExecutorService.executeDeployProcess(deploy); + return new ResponseEntity(new BuildResponse(null,"in progress","not started","not started","not started",deploy.getSitename(),null,null,null),HttpStatus.OK); + } + + + + + @PostMapping("/airship/") + public ResponseEntity airship(@RequestBody Airship airship) { + logger.debug("Request received for airship {} ",airship.toString()); + asyncProcessExecutorService.executeAirshipProcess(airship); + return new ResponseEntity(new BuildResponse(null,null,null,null,"in progress",airship.getSitename(),null,null,null),HttpStatus.OK); + } + + + + @PostMapping("/tempest/") + public ResponseEntity tempest(@RequestBody Tempest tempest) { + logger.debug("Request received for onap ",tempest.toString()); + asyncProcessExecutorService.executeTempestProcess(tempest); + return new ResponseEntity(new BuildResponse(null,null,null,null,null,tempest.getSitename(),null,null,"in progress"),HttpStatus.OK); + } + + + + + @PostMapping("/apache/") + public ResponseEntity apache(@RequestBody Apache apache) { + logger.debug("Request received for onap ",apache.toString()); + asyncProcessExecutorService.executeApacheProcess(apache); + return new ResponseEntity(new BuildResponse(null,null,null,null,null,apache.getSitename(),null,"in progress",null),HttpStatus.OK); + } + + + + + @PostMapping("/onap/") + public ResponseEntity onap(@RequestBody Onap onap) { + logger.debug("Request received for onap ",onap.toString()); + asyncProcessExecutorService.executeOnapProcess(onap); + return new ResponseEntity(new BuildResponse(null,null,null,null,null,onap.getSitename(),"in progress",null,null),HttpStatus.OK); + } +} 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 0d64278..895938a 100644 --- a/akraino/src/main/java/com/akraino/bpm/delegate/DeployPostVerficationRemoteScriptExecutor.java +++ b/akraino/src/main/java/com/akraino/bpm/delegate/DeployPostVerficationRemoteScriptExecutor.java @@ -1,66 +1,67 @@ -/* - * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.akraino.bpm.delegate; - -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.camunda.bpm.engine.delegate.JavaDelegate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -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"); - - deployResponseSenderService.sendResponse(new BuildResponse("completed", "completed", "completed", "completed","inprogress","Boston")); - 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(",", " "):" "); - logger.debug("Execution command {}",command); - remoteScriptExecutionService.executeRemoteScript(remotserver,username,password,portnumner,filename,fileparams,srcdir,destdir,command); - - deployResponseSenderService.sendResponse(new BuildResponse("completed", "completed", "completed", "completed","completed","Boston")); - } - -} +/* + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.akraino.bpm.delegate; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +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="sh " +destdir+"/"+filename+" "+(fileparams!=null?fileparams.replaceAll(",", " "):" "); + logger.debug("Execution command {}",command); + remoteScriptExecutionService.executeRemoteScript(remotserver,username,password,portnumner,filename,fileparams,srcdir,destdir,command); + + + } + +} 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 328f0dd..df9e36c 100644 --- a/akraino/src/main/java/com/akraino/bpm/delegate/DeployRemoteDeploymentVerificationDelegate.java +++ b/akraino/src/main/java/com/akraino/bpm/delegate/DeployRemoteDeploymentVerificationDelegate.java @@ -1,76 +1,77 @@ -/* - * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.akraino.bpm.delegate; - - -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.camunda.bpm.engine.delegate.JavaDelegate; -import org.slf4j.Logger; -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.RemoteDeploymentVerificationService; - - - -@Component -public class DeployRemoteDeploymentVerificationDelegate implements JavaDelegate { - - private static Logger logger = LoggerFactory.getLogger(DeployRemoteDeploymentVerificationDelegate.class); - - @Autowired - RemoteDeploymentVerificationService remotedeploymentVerificationService; - - @Autowired - DeployResponseSenderService deployResponseSenderService; - - - 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"); - - deployResponseSenderService.sendResponse(new BuildResponse("completed", "completed", "completed", "inprogress","not started", "Boston")); - - 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(",", " "):" "); - logger.debug("Execution command {}",command); - remotedeploymentVerificationService.executeScript(remotserver,username,password,portnumner,verifierFilename,filepparams,srcdir,destdir,waittime,iterations,command); - }catch(TaskExecutorException ex) { - throw ex; - } - - - } - -} - +/* + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.akraino.bpm.delegate; + + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.slf4j.Logger; +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.RemoteDeploymentVerificationService; + + + +@Component +public class DeployRemoteDeploymentVerificationDelegate implements JavaDelegate { + + private static Logger logger = LoggerFactory.getLogger(DeployRemoteDeploymentVerificationDelegate.class); + + @Autowired + RemoteDeploymentVerificationService remotedeploymentVerificationService; + + @Autowired + DeployResponseSenderService deployResponseSenderService; + + + 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="sh " +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; + } + + + } + +} + diff --git a/akraino/src/main/java/com/akraino/bpm/delegate/DeployRemoteScriptExecutorTaskDelegate.java b/akraino/src/main/java/com/akraino/bpm/delegate/DeployRemoteScriptExecutorTaskDelegate.java index c6cf733..96f4b4a 100644 --- a/akraino/src/main/java/com/akraino/bpm/delegate/DeployRemoteScriptExecutorTaskDelegate.java +++ b/akraino/src/main/java/com/akraino/bpm/delegate/DeployRemoteScriptExecutorTaskDelegate.java @@ -1,64 +1,65 @@ -/* - * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.akraino.bpm.delegate; - -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.camunda.bpm.engine.delegate.JavaDelegate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -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); - - @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("filename"); - String fileparams=(String)ctx.getVariable("fileparams"); - String srcdir=(String)ctx.getVariable("srcdir"); - String destdir=(String)ctx.getVariable("destdir"); - - deployResponseSenderService.sendResponse(new BuildResponse("completed", "completed", "inprogress", "not started","not started", "Boston")); - 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(",", " "):" "); - logger.debug("Execution command {}",command); - remoteScriptExecutionService.executeRemoteScript(remotserver,username,password,portnumner,filename,fileparams,srcdir,destdir,command); - } - -} +/* + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.akraino.bpm.delegate; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +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); + + @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("filename"); + String fileparams=(String)ctx.getVariable("fileparams"); + String srcdir=(String)ctx.getVariable("srcdir"); + String destdir=(String)ctx.getVariable("destdir"); + String sitename=(String)ctx.getVariable("sitename"); + + deployResponseSenderService.sendResponse(new BuildResponse("completed", "completed", "inprogress", "not started","not started", 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="sh " +destdir+"/"+filename+" "+(fileparams!=null?fileparams.replaceAll(",", " "):" "); + logger.debug("Execution command {}",command); + remoteScriptExecutionService.executeRemoteScript(remotserver,username,password,portnumner,filename,fileparams,srcdir,destdir,command); + } + +} diff --git a/akraino/src/main/java/com/akraino/bpm/delegate/DeployScriptExecutorTaskDelegate.java b/akraino/src/main/java/com/akraino/bpm/delegate/DeployScriptExecutorTaskDelegate.java index 32654d1..a708b8a 100644 --- a/akraino/src/main/java/com/akraino/bpm/delegate/DeployScriptExecutorTaskDelegate.java +++ b/akraino/src/main/java/com/akraino/bpm/delegate/DeployScriptExecutorTaskDelegate.java @@ -1,51 +1,50 @@ -/* - * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.akraino.bpm.delegate; - - -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.camunda.bpm.engine.delegate.JavaDelegate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import com.akraino.bpm.model.BuildResponse; -import com.akraino.bpm.service.DeployResponseSenderService; -import com.akraino.bpm.service.ScriptExecutionService; - - -@Component -public class DeployScriptExecutorTaskDelegate implements JavaDelegate { - - private static Logger logger = LoggerFactory.getLogger(DeployScriptExecutorTaskDelegate.class); - - @Autowired - ScriptExecutionService scriptExecutionService; - - @Autowired - DeployResponseSenderService deployResponseSenderService; - - public void execute(DelegateExecution ctx) throws Exception { - deployResponseSenderService.sendResponse(new BuildResponse("completed", "inprogress", "not started", "not started","not started","Boston")); - String filepath=(String)ctx.getVariable("filepath"); - logger.debug("task execution started :"+filepath); - scriptExecutionService.executeScript(filepath); - - } - -} +/* + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.akraino.bpm.delegate; + + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.akraino.bpm.service.DeployResponseSenderService; +import com.akraino.bpm.service.ScriptExecutionService; + + +@Component +public class DeployScriptExecutorTaskDelegate implements JavaDelegate { + + private static Logger logger = LoggerFactory.getLogger(DeployScriptExecutorTaskDelegate.class); + + @Autowired + ScriptExecutionService scriptExecutionService; + + @Autowired + DeployResponseSenderService deployResponseSenderService; + + public void execute(DelegateExecution ctx) throws Exception { + + String filepath=(String)ctx.getVariable("filepath"); + logger.debug("task execution started :"+filepath); + scriptExecutionService.executeScript(filepath); + + } + +} diff --git a/akraino/src/main/java/com/akraino/bpm/delegate/DeploymentVerificationDelegate.java b/akraino/src/main/java/com/akraino/bpm/delegate/DeploymentVerificationDelegate.java index 4d5dc22..dda3d73 100644 --- a/akraino/src/main/java/com/akraino/bpm/delegate/DeploymentVerificationDelegate.java +++ b/akraino/src/main/java/com/akraino/bpm/delegate/DeploymentVerificationDelegate.java @@ -1,62 +1,66 @@ -/* - * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.akraino.bpm.delegate; - - -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.camunda.bpm.engine.delegate.JavaDelegate; -import org.slf4j.Logger; -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.DeploymentVerificationService; - - - -@Component -public class DeploymentVerificationDelegate implements JavaDelegate { - - private static Logger logger = LoggerFactory.getLogger(DeploymentVerificationDelegate.class); - - @Autowired - DeploymentVerificationService deploymentVerificationService; - - @Autowired - DeployResponseSenderService deployResponseSenderService; - - public void execute(DelegateExecution ctx) throws Exception { - - deployResponseSenderService.sendResponse(new BuildResponse("completed", "completed", "completed", "inprogress","not started", "Boston")); - try { - String verifierFilepath=(String)ctx.getVariable("verifier"); - int waittime=(Integer)ctx.getVariable("waittime"); - int iterations=(Integer)ctx.getVariable("iterations"); - logger.debug("task execution started filename : {} , waittime : {},No of iterations :{}",verifierFilepath,waittime,iterations); - deploymentVerificationService.executeScript(verifierFilepath,waittime,iterations); - }catch(TaskExecutorException ex) { - throw ex; - } - - deployResponseSenderService.sendResponse(new BuildResponse("completed", "completed", "completed", "completed","not started","Boston")); - } - -} - +/* + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.akraino.bpm.delegate; + + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.slf4j.Logger; +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.DeploymentVerificationService; + + + +@Component +public class DeploymentVerificationDelegate implements JavaDelegate { + + private static Logger logger = LoggerFactory.getLogger(DeploymentVerificationDelegate.class); + + @Autowired + DeploymentVerificationService deploymentVerificationService; + + @Autowired + DeployResponseSenderService deployResponseSenderService; + + public void execute(DelegateExecution ctx) throws Exception { + + String sitename=(String)ctx.getVariable("sitename"); + deployResponseSenderService.sendResponse(new BuildResponse("completed", "completed", "completed", "inprogress","not started",sitename,null,null,null)); + + try { + String verifierFilepath=(String)ctx.getVariable("verifier"); + int waittime=(Integer)ctx.getVariable("waittime"); + int iterations=(Integer)ctx.getVariable("iterations"); + + + logger.debug("task execution started filename : {} , waittime : {},No of iterations :{}",verifierFilepath,waittime,iterations); + deploymentVerificationService.executeScript(verifierFilepath,waittime,iterations); + }catch(TaskExecutorException ex) { + throw ex; + } + + deployResponseSenderService.sendResponse(new BuildResponse("completed", "completed", "completed", "completed","not started",sitename,null,null,null)); + } + +} + diff --git a/akraino/src/main/java/com/akraino/bpm/delegate/WinScpScriptDelegate.java b/akraino/src/main/java/com/akraino/bpm/delegate/WinScpScriptDelegate.java index e4ffcc0..8145f66 100644 --- a/akraino/src/main/java/com/akraino/bpm/delegate/WinScpScriptDelegate.java +++ b/akraino/src/main/java/com/akraino/bpm/delegate/WinScpScriptDelegate.java @@ -1,53 +1,54 @@ -/* - * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.akraino.bpm.delegate; - - -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.camunda.bpm.engine.delegate.JavaDelegate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import com.akraino.bpm.model.BuildResponse; -import com.akraino.bpm.service.DeployResponseSenderService; -import com.akraino.bpm.service.ScriptExecutionService; - - -@Component -public class WinScpScriptDelegate implements JavaDelegate { - - private static Logger logger = LoggerFactory.getLogger(WinScpScriptDelegate.class); - - @Autowired - DeployResponseSenderService deployResponseSenderService; - - @Autowired - ScriptExecutionService scriptExecutionService; - - public void execute(DelegateExecution ctx) throws Exception { - - deployResponseSenderService.sendResponse(new BuildResponse("completed", "completed", "inprogress", "not started","not started","Boston")); - String filepath=(String)ctx.getVariable("ScpScriptFilepath"); - logger.debug("Win SCP task execution started :"+filepath); - scriptExecutionService.executeScript(filepath); - - - } - -} +/* + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.akraino.bpm.delegate; + + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.akraino.bpm.model.BuildResponse; +import com.akraino.bpm.service.DeployResponseSenderService; +import com.akraino.bpm.service.ScriptExecutionService; + + +@Component +public class WinScpScriptDelegate implements JavaDelegate { + + private static Logger logger = LoggerFactory.getLogger(WinScpScriptDelegate.class); + + @Autowired + DeployResponseSenderService deployResponseSenderService; + + @Autowired + ScriptExecutionService scriptExecutionService; + + public void execute(DelegateExecution ctx) throws Exception { + + String sitename=(String)ctx.getVariable("sitename"); + deployResponseSenderService.sendResponse(new BuildResponse("completed", "completed", "inprogress", "not started","not started",sitename,null,null,null)); + String filepath=(String)ctx.getVariable("ScpScriptFilepath"); + logger.debug("Win SCP task execution started :"+filepath); + scriptExecutionService.executeScript(filepath); + + + } + +} diff --git a/akraino/src/main/java/com/akraino/bpm/model/Airship.java b/akraino/src/main/java/com/akraino/bpm/model/Airship.java index 9a59e2c..158d635 100644 --- a/akraino/src/main/java/com/akraino/bpm/model/Airship.java +++ b/akraino/src/main/java/com/akraino/bpm/model/Airship.java @@ -1,120 +1,128 @@ -/* - * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.akraino.bpm.model; - -public class Airship { - - private String filepath; - private String fileparams; - private String winscpdir; - private String winscpfilepath; - private String winscpfileparams; - private String remotserver; - private int port; - private String username; - private String password; - private String destdir; - private String remotefilename; - private String remotefileparams; - - - public String getFilepath() { - return filepath; - } - public void setFilepath(String filepath) { - this.filepath = filepath; - } - public String getFileparams() { - return fileparams; - } - public void setFileparams(String fileparams) { - this.fileparams = fileparams; - } - public String getWinscpfilepath() { - return winscpfilepath; - } - public void setWinscpfilepath(String winscpfilepath) { - this.winscpfilepath = winscpfilepath; - } - public String getWinscpfileparams() { - return winscpfileparams; - } - public void setWinscpfileparams(String winscpfileparams) { - this.winscpfileparams = winscpfileparams; - } - public String getDestdir() { - return destdir; - } - public void setDestdir(String destdir) { - this.destdir = destdir; - } - - public String getRemotserver() { - return remotserver; - } - public void setRemotserver(String remotserver) { - this.remotserver = remotserver; - } - public int getPort() { - return port; - } - public void setPort(int port) { - this.port = port; - } - public String getUsername() { - return username; - } - public void setUsername(String username) { - this.username = username; - } - public String getPassword() { - return password; - } - public void setPassword(String password) { - this.password = password; - } - public String getRemotefilename() { - return remotefilename; - } - public void setRemotefilename(String remotefilename) { - this.remotefilename = remotefilename; - } - public String getRemotefileparams() { - return remotefileparams; - } - public void setRemotefileparams(String remotefileparams) { - this.remotefileparams = remotefileparams; - } - public String getWinscpdir() { - return winscpdir; - } - public void setWinscpdir(String winscpdir) { - this.winscpdir = winscpdir; - } - @Override - public String toString() { - return "Airship [filepath=" + filepath + ", fileparams=" + fileparams + ", winscpdir=" + winscpdir - + ", winscpfilepath=" + winscpfilepath + ", winscpfileparams=" + winscpfileparams + ", remotserver=" - + remotserver + ", port=" + port + ", username=" + username + ", password=" + password + ", destdir=" - + destdir + ", remotefilename=" + remotefilename + ", remotefileparams=" + remotefileparams + "]"; - } - - - - - - } +/* + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.akraino.bpm.model; + +public class Airship { + + private String sitename; + private String filepath; + private String fileparams; + private String winscpdir; + private String winscpfilepath; + private String winscpfileparams; + private String remotserver; + private int port; + private String username; + private String password; + private String destdir; + private String remotefilename; + private String remotefileparams; + + + public String getFilepath() { + return filepath; + } + public void setFilepath(String filepath) { + this.filepath = filepath; + } + public String getFileparams() { + return fileparams; + } + public void setFileparams(String fileparams) { + this.fileparams = fileparams; + } + public String getWinscpfilepath() { + return winscpfilepath; + } + public void setWinscpfilepath(String winscpfilepath) { + this.winscpfilepath = winscpfilepath; + } + public String getWinscpfileparams() { + return winscpfileparams; + } + public void setWinscpfileparams(String winscpfileparams) { + this.winscpfileparams = winscpfileparams; + } + public String getDestdir() { + return destdir; + } + public void setDestdir(String destdir) { + this.destdir = destdir; + } + + public String getRemotserver() { + return remotserver; + } + public void setRemotserver(String remotserver) { + this.remotserver = remotserver; + } + public int getPort() { + return port; + } + public void setPort(int port) { + this.port = port; + } + public String getUsername() { + return username; + } + public void setUsername(String username) { + this.username = username; + } + public String getPassword() { + return password; + } + public void setPassword(String password) { + this.password = password; + } + public String getRemotefilename() { + return remotefilename; + } + public void setRemotefilename(String remotefilename) { + this.remotefilename = remotefilename; + } + public String getRemotefileparams() { + return remotefileparams; + } + public void setRemotefileparams(String remotefileparams) { + this.remotefileparams = remotefileparams; + } + public String getWinscpdir() { + return winscpdir; + } + public void setWinscpdir(String winscpdir) { + this.winscpdir = winscpdir; + } + public String getSitename() { + return sitename; + } + public void setSitename(String sitename) { + this.sitename = sitename; + } + @Override + public String toString() { + return "Airship [sitename=" + sitename + ", filepath=" + filepath + ", fileparams=" + fileparams + + ", winscpdir=" + winscpdir + ", winscpfilepath=" + winscpfilepath + ", winscpfileparams=" + + winscpfileparams + ", remotserver=" + remotserver + ", port=" + port + ", username=" + username + + ", password=" + password + ", destdir=" + destdir + ", remotefilename=" + remotefilename + + ", remotefileparams=" + remotefileparams + "]"; + } + + + + + + } diff --git a/akraino/src/main/java/com/akraino/bpm/model/Apache.java b/akraino/src/main/java/com/akraino/bpm/model/Apache.java index eef8f96..78ed8dc 100644 --- a/akraino/src/main/java/com/akraino/bpm/model/Apache.java +++ b/akraino/src/main/java/com/akraino/bpm/model/Apache.java @@ -1,194 +1,208 @@ -/* - * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.akraino.bpm.model; - -public class Apache { - - private String remoteserver; - private String username; - private String password; - private int portnumber; - private String srcdir; - private String destdir; - private String filename; - private String fileparams; - private String deploymentverifier; - private String verifierparams; - int noofiterations; - int waittime; - String filetrasferscript; - String filetransferparams; - - - public String getSrcdir() { - return srcdir; - } - - - public void setSrcdir(String srcdir) { - this.srcdir = srcdir; - } - - - public String getDestdir() { - return destdir; - } - - - public void setDestdir(String destdir) { - this.destdir = destdir; - } - - - public String getRemoteserver() { - return remoteserver; - } - - - public void setRemoteserver(String remoteserver) { - this.remoteserver = remoteserver; - } - - - public String getUsername() { - return username; - } - - - public void setUsername(String username) { - this.username = username; - } - - - public String getPassword() { - return password; - } - - - public void setPassword(String password) { - this.password = password; - } - - - public int getPortnumber() { - return portnumber; - } - - - public void setPortnumber(int portnumber) { - this.portnumber = portnumber; - } - - - - - - public String getFilename() { - return filename; - } - - - public void setFilename(String filename) { - this.filename = filename; - } - - - public String getFileparams() { - return fileparams; - } - - - public void setFileparams(String fileparams) { - this.fileparams = fileparams; - } - - - public String getDeploymentverifier() { - return deploymentverifier; - } - - - public void setDeploymentverifier(String deploymentverifier) { - this.deploymentverifier = deploymentverifier; - } - - - public int getNoofiterations() { - return noofiterations; - } - - - public void setNoofiterations(int noofiterations) { - this.noofiterations = noofiterations; - } - - - public int getWaittime() { - return waittime; - } - - - public void setWaittime(int waittime) { - this.waittime = waittime; - } - - - - - public String getVerifierparams() { - return verifierparams; - } - - - public void setVerifierparams(String verifierparams) { - this.verifierparams = verifierparams; - } - - - public String getFiletrasferscript() { - return filetrasferscript; - } - - - public void setFiletrasferscript(String filetrasferscript) { - this.filetrasferscript = filetrasferscript; - } - - - public String getFiletransferparams() { - return filetransferparams; - } - - - public void setFiletransferparams(String filetransferparams) { - this.filetransferparams = filetransferparams; - } - - - @Override - public String toString() { - return "Apache [remoteserver=" + remoteserver + ", username=" + username + ", password=" + password - + ", portnumber=" + portnumber + ", srcdir=" + srcdir + ", destdir=" + destdir + ", filename=" - + filename + ", fileparams=" + fileparams + ", deploymentverifier=" + deploymentverifier - + ", verifierparams=" + verifierparams + ", noofiterations=" + noofiterations + ", waittime=" + waittime - + ", filetrasferscript=" + filetrasferscript + ", filetransferparams=" + filetransferparams + "]"; - } - - - - - } +/* + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.akraino.bpm.model; + +public class Apache { + + private String sitename; + private String remoteserver; + private String username; + private String password; + private int portnumber; + private String srcdir; + private String destdir; + private String filename; + private String fileparams; + private String deploymentverifier; + private String verifierparams; + int noofiterations; + int waittime; + String filetrasferscript; + String filetransferparams; + + + public String getSrcdir() { + return srcdir; + } + + + public void setSrcdir(String srcdir) { + this.srcdir = srcdir; + } + + + public String getDestdir() { + return destdir; + } + + + public void setDestdir(String destdir) { + this.destdir = destdir; + } + + + public String getRemoteserver() { + return remoteserver; + } + + + public void setRemoteserver(String remoteserver) { + this.remoteserver = remoteserver; + } + + + public String getUsername() { + return username; + } + + + public void setUsername(String username) { + this.username = username; + } + + + public String getPassword() { + return password; + } + + + public void setPassword(String password) { + this.password = password; + } + + + public int getPortnumber() { + return portnumber; + } + + + public void setPortnumber(int portnumber) { + this.portnumber = portnumber; + } + + + + + + public String getFilename() { + return filename; + } + + + public void setFilename(String filename) { + this.filename = filename; + } + + + public String getFileparams() { + return fileparams; + } + + + public void setFileparams(String fileparams) { + this.fileparams = fileparams; + } + + + public String getDeploymentverifier() { + return deploymentverifier; + } + + + public void setDeploymentverifier(String deploymentverifier) { + this.deploymentverifier = deploymentverifier; + } + + + public int getNoofiterations() { + return noofiterations; + } + + + public void setNoofiterations(int noofiterations) { + this.noofiterations = noofiterations; + } + + + public int getWaittime() { + return waittime; + } + + + public void setWaittime(int waittime) { + this.waittime = waittime; + } + + + + + public String getVerifierparams() { + return verifierparams; + } + + + public void setVerifierparams(String verifierparams) { + this.verifierparams = verifierparams; + } + + + public String getFiletrasferscript() { + return filetrasferscript; + } + + + public void setFiletrasferscript(String filetrasferscript) { + this.filetrasferscript = filetrasferscript; + } + + + public String getFiletransferparams() { + return filetransferparams; + } + + + public void setFiletransferparams(String filetransferparams) { + this.filetransferparams = filetransferparams; + } + + + public String getSitename() { + return sitename; + } + + + public void setSitename(String sitename) { + this.sitename = sitename; + } + + + @Override + public String toString() { + return "Apache [sitename=" + sitename + ", remoteserver=" + remoteserver + ", username=" + username + + ", password=" + password + ", portnumber=" + portnumber + ", srcdir=" + srcdir + ", destdir=" + + destdir + ", filename=" + filename + ", fileparams=" + fileparams + ", deploymentverifier=" + + deploymentverifier + ", verifierparams=" + verifierparams + ", noofiterations=" + noofiterations + + ", waittime=" + waittime + ", filetrasferscript=" + filetrasferscript + ", filetransferparams=" + + filetransferparams + "]"; + } + + + + + + + } diff --git a/akraino/src/main/java/com/akraino/bpm/model/Build.java b/akraino/src/main/java/com/akraino/bpm/model/Build.java index d8a0cd6..6c2c58b 100644 --- a/akraino/src/main/java/com/akraino/bpm/model/Build.java +++ b/akraino/src/main/java/com/akraino/bpm/model/Build.java @@ -1,52 +1,63 @@ -/* - * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.akraino.bpm.model; - -public class Build { - - private String filepath; - private String fileparams; - private String targetfolder; - - - public String getFilepath() { - return filepath; - } - public void setFilepath(String filepath) { - this.filepath = filepath; - } - public String getFileparams() { - return fileparams; - } - public void setFileparams(String fileparams) { - this.fileparams = fileparams; - } - public String getTargetfolder() { - return targetfolder; - } - public void setTargetfolder(String targetfolder) { - this.targetfolder = targetfolder; - } - @Override - public String toString() { - return "Build [filepath=" + filepath + ", fileparams=" + fileparams + ", targetfolder=" + targetfolder + "]"; - } - - - - -} +/* + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.akraino.bpm.model; + +public class Build { + + private String sitename; + private String filepath; + private String fileparams; + private String targetfolder; + + + + + public String getSitename() { + return sitename; + } + public void setSitename(String sitename) { + this.sitename = sitename; + } + public String getFilepath() { + return filepath; + } + public void setFilepath(String filepath) { + this.filepath = filepath; + } + public String getFileparams() { + return fileparams; + } + public void setFileparams(String fileparams) { + this.fileparams = fileparams; + } + public String getTargetfolder() { + return targetfolder; + } + public void setTargetfolder(String targetfolder) { + this.targetfolder = targetfolder; + } + + @Override + public String toString() { + return "Build [sitename=" + sitename + ", filepath=" + filepath + ", fileparams=" + fileparams + + ", targetfolder=" + targetfolder + "]"; + } + + + + +} diff --git a/akraino/src/main/java/com/akraino/bpm/model/BuildResponse.java b/akraino/src/main/java/com/akraino/bpm/model/BuildResponse.java index a365156..c81596a 100644 --- a/akraino/src/main/java/com/akraino/bpm/model/BuildResponse.java +++ b/akraino/src/main/java/com/akraino/bpm/model/BuildResponse.java @@ -1,113 +1,135 @@ -/* - * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.akraino.bpm.model; - -public class BuildResponse { - - private String buildStatus; - private String createTarStatus; - private String genesisNodeStatus; - private String deployToolsStatus; - private String deployStatus; - private String siteName; - - - public BuildResponse(String buildStatus, String createTarStatus, String genesisNodeStatus, String deployToolsStatus,String deployStatus, - String siteName) { - super(); - this.buildStatus = buildStatus; - this.createTarStatus = createTarStatus; - this.genesisNodeStatus = genesisNodeStatus; - this.deployToolsStatus = deployToolsStatus; - this.deployStatus=deployStatus; - this.siteName = "siteName"; - } - - - public String getBuildStatus() { - return buildStatus; - } - - - public void setBuildStatus(String buildStatus) { - this.buildStatus = buildStatus; - } - - public String getCreateTarStatus() { - return createTarStatus; - } - - public void setCreateTarStatus(String createTarStatus) { - this.createTarStatus = createTarStatus; - } - - - public String getGenesisNodeStatus() { - return genesisNodeStatus; - } - - - public void setGenesisNodeStatus(String genesisNodeStatus) { - this.genesisNodeStatus = genesisNodeStatus; - } - - - public String getDeployToolsStatus() { - return deployToolsStatus; - } - - - public void setDeployToolsStatus(String deployToolsStatus) { - this.deployToolsStatus = deployToolsStatus; - } - - - public String getSiteName() { - return siteName; - } - - public void setSiteName(String siteName) { - this.siteName = siteName; - } - - - - - public String getDeployStatus() { - return deployStatus; - } - - - public void setDeployStatus(String deployStatus) { - this.deployStatus = deployStatus; - } - - - @Override - public String toString() { - return "BuildResponse [buildStatus=" + buildStatus + ", createTarStatus=" + createTarStatus - + ", genesisNodeStatus=" + genesisNodeStatus + ", deployToolsStatus=" + deployToolsStatus - + ", deployStatus=" + deployStatus + ", siteName=" + siteName + "]"; - } - - - - - - - -} +/* + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.akraino.bpm.model; + +public class BuildResponse { + + private String siteName; + private String buildStatus; + private String createTarStatus; + private String genesisNodeStatus; + private String deployToolsStatus; + private String deployStatus; + private String onapStatus; + private String vCDNStatus; + private String tempestStatus; + + public BuildResponse(String buildStatus, String createTarStatus, String genesisNodeStatus, String deployToolsStatus,String deployStatus, + String siteName,String onapStatus,String vCDNStatus,String tempestStatus) { + super(); + this.buildStatus = buildStatus; + this.createTarStatus = createTarStatus; + this.genesisNodeStatus = genesisNodeStatus; + this.deployToolsStatus = deployToolsStatus; + this.deployStatus=deployStatus; + this.siteName = siteName; + this.onapStatus=onapStatus; + this.vCDNStatus=vCDNStatus; + this.tempestStatus=tempestStatus; + } + + + public String getBuildStatus() { + return buildStatus; + } + + + public void setBuildStatus(String buildStatus) { + this.buildStatus = buildStatus; + } + + public String getCreateTarStatus() { + return createTarStatus; + } + + public void setCreateTarStatus(String createTarStatus) { + this.createTarStatus = createTarStatus; + } + + + public String getGenesisNodeStatus() { + return genesisNodeStatus; + } + + + public void setGenesisNodeStatus(String genesisNodeStatus) { + this.genesisNodeStatus = genesisNodeStatus; + } + + + public String getDeployToolsStatus() { + return deployToolsStatus; + } + + + public void setDeployToolsStatus(String deployToolsStatus) { + this.deployToolsStatus = deployToolsStatus; + } + + + public String getSiteName() { + return siteName; + } + + public void setSiteName(String siteName) { + this.siteName = siteName; + } + + + + + public String getDeployStatus() { + return deployStatus; + } + + + public void setDeployStatus(String deployStatus) { + this.deployStatus = deployStatus; + } + + + public String getOnapStatus() { + return onapStatus; + } + + + public void setOnapStatus(String onapStatus) { + this.onapStatus = onapStatus; + } + + + public String getvCDNStatus() { + return vCDNStatus; + } + + + public void setvCDNStatus(String vCDNStatus) { + this.vCDNStatus = vCDNStatus; + } + + + public String getTempestStatus() { + return tempestStatus; + } + + + public void setTempestStatus(String tempestStatus) { + this.tempestStatus = tempestStatus; + } + + +} diff --git a/akraino/src/main/java/com/akraino/bpm/model/Deploy.java b/akraino/src/main/java/com/akraino/bpm/model/Deploy.java index 221a981..fc0b7ff 100644 --- a/akraino/src/main/java/com/akraino/bpm/model/Deploy.java +++ b/akraino/src/main/java/com/akraino/bpm/model/Deploy.java @@ -1,162 +1,178 @@ -/* - * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.akraino.bpm.model; - -public class Deploy { - - private String filepath; - private String fileparams; - private String winscpfilepath; - private String winscpfileparams; - private String remotserver; - private int port; - private String username; - private String password; - private String destdir; - private String remotefilename; - private String remotefileparams; - private String deploymentverifier; - private String deploymentverifierfileparams; - int noofiterations; - int waittime; - String postverificationscript; - String postverificationScriptparams; - - public String getFilepath() { - return filepath; - } - public void setFilepath(String filepath) { - this.filepath = filepath; - } - public String getFileparams() { - return fileparams; - } - public void setFileparams(String fileparams) { - this.fileparams = fileparams; - } - public String getWinscpfilepath() { - return winscpfilepath; - } - public void setWinscpfilepath(String winscpfilepath) { - this.winscpfilepath = winscpfilepath; - } - public String getWinscpfileparams() { - return winscpfileparams; - } - public void setWinscpfileparams(String winscpfileparams) { - this.winscpfileparams = winscpfileparams; - } - public String getDestdir() { - return destdir; - } - public void setDestdir(String destdir) { - this.destdir = destdir; - } - - - - public String getRemotserver() { - return remotserver; - } - public void setRemotserver(String remotserver) { - this.remotserver = remotserver; - } - public int getPort() { - return port; - } - public void setPort(int port) { - this.port = port; - } - public String getUsername() { - return username; - } - public void setUsername(String username) { - this.username = username; - } - public String getPassword() { - return password; - } - public void setPassword(String password) { - this.password = password; - } - public String getRemotefilename() { - return remotefilename; - } - public void setRemotefilename(String remotefilename) { - this.remotefilename = remotefilename; - } - public String getRemotefileparams() { - return remotefileparams; - } - public void setRemotefileparams(String remotefileparams) { - this.remotefileparams = remotefileparams; - } - public String getDeploymentverifier() { - return deploymentverifier; - } - public void setDeploymentverifier(String deploymentverifier) { - this.deploymentverifier = deploymentverifier; - } - public int getNoofiterations() { - return noofiterations; - } - public void setNoofiterations(int noofiterations) { - this.noofiterations = noofiterations; - } - public int getWaittime() { - return waittime; - } - public void setWaittime(int waittime) { - this.waittime = waittime; - } - - public String getDeploymentverifierfileparams() { - return deploymentverifierfileparams; - } - - public void setDeploymentverifierfileparams(String deploymentverifierfileparams) { - this.deploymentverifierfileparams = deploymentverifierfileparams; - } - - public String getPostverificationscript() { - return postverificationscript; - } - - public void setPostverificationscript(String postverificationscript) { - this.postverificationscript = postverificationscript; - } - - public String getPostverificationScriptparams() { - return postverificationScriptparams; - } - - - public void setPostverificationScriptparams(String postverificationScriptparams) { - this.postverificationScriptparams = postverificationScriptparams; - } - @Override - public String toString() { - return "Deploy [filepath=" + filepath + ", fileparams=" + fileparams + ", winscpfilepath=" + winscpfilepath - + ", winscpfileparams=" + winscpfileparams + ", remotserver=" + remotserver + ", port=" + port - + ", username=" + username + ", password=" + password + ", destdir=" + destdir + ", remotefilename=" - + remotefilename + ", remotefileparams=" + remotefileparams + ", deploymentverifier=" - + deploymentverifier + ", deploymentverifierfileparams=" + deploymentverifierfileparams - + ", noofiterations=" + noofiterations + ", waittime=" + waittime + ", postverificationscript=" - + postverificationscript + ", postverificationScriptparams=" + postverificationScriptparams + "]"; - } - - } +/* + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.akraino.bpm.model; + +public class Deploy { + + private String sitename; + private String filepath; + private String fileparams; + private String winscpfilepath; + private String winscpfileparams; + private String remotserver; + private int port; + private String username; + private String password; + private String destdir; + private String remotefilename; + private String remotefileparams; + private String deploymentverifier; + private String deploymentverifierfileparams; + int noofiterations; + int waittime; + String postverificationscript; + String postverificationScriptparams; + + + + + public String getSitename() { + return sitename; + } + public void setSitename(String sitename) { + this.sitename = sitename; + } + public String getFilepath() { + return filepath; + } + public void setFilepath(String filepath) { + this.filepath = filepath; + } + public String getFileparams() { + return fileparams; + } + public void setFileparams(String fileparams) { + this.fileparams = fileparams; + } + public String getWinscpfilepath() { + return winscpfilepath; + } + public void setWinscpfilepath(String winscpfilepath) { + this.winscpfilepath = winscpfilepath; + } + public String getWinscpfileparams() { + return winscpfileparams; + } + public void setWinscpfileparams(String winscpfileparams) { + this.winscpfileparams = winscpfileparams; + } + public String getDestdir() { + return destdir; + } + public void setDestdir(String destdir) { + this.destdir = destdir; + } + + + + public String getRemotserver() { + return remotserver; + } + public void setRemotserver(String remotserver) { + this.remotserver = remotserver; + } + public int getPort() { + return port; + } + public void setPort(int port) { + this.port = port; + } + public String getUsername() { + return username; + } + public void setUsername(String username) { + this.username = username; + } + public String getPassword() { + return password; + } + public void setPassword(String password) { + this.password = password; + } + public String getRemotefilename() { + return remotefilename; + } + public void setRemotefilename(String remotefilename) { + this.remotefilename = remotefilename; + } + public String getRemotefileparams() { + return remotefileparams; + } + public void setRemotefileparams(String remotefileparams) { + this.remotefileparams = remotefileparams; + } + public String getDeploymentverifier() { + return deploymentverifier; + } + public void setDeploymentverifier(String deploymentverifier) { + this.deploymentverifier = deploymentverifier; + } + public int getNoofiterations() { + return noofiterations; + } + public void setNoofiterations(int noofiterations) { + this.noofiterations = noofiterations; + } + public int getWaittime() { + return waittime; + } + public void setWaittime(int waittime) { + this.waittime = waittime; + } + + public String getDeploymentverifierfileparams() { + return deploymentverifierfileparams; + } + + public void setDeploymentverifierfileparams(String deploymentverifierfileparams) { + this.deploymentverifierfileparams = deploymentverifierfileparams; + } + + public String getPostverificationscript() { + return postverificationscript; + } + + public void setPostverificationscript(String postverificationscript) { + this.postverificationscript = postverificationscript; + } + + public String getPostverificationScriptparams() { + return postverificationScriptparams; + } + + + public void setPostverificationScriptparams(String postverificationScriptparams) { + this.postverificationScriptparams = postverificationScriptparams; + } + + + @Override + public String toString() { + return "Deploy [sitename=" + sitename + ", filepath=" + filepath + ", fileparams=" + fileparams + + ", winscpfilepath=" + winscpfilepath + ", winscpfileparams=" + winscpfileparams + ", remotserver=" + + remotserver + ", port=" + port + ", username=" + username + ", password=" + password + ", destdir=" + + destdir + ", remotefilename=" + remotefilename + ", remotefileparams=" + remotefileparams + + ", deploymentverifier=" + deploymentverifier + ", deploymentverifierfileparams=" + + deploymentverifierfileparams + ", noofiterations=" + noofiterations + ", waittime=" + waittime + + ", postverificationscript=" + postverificationscript + ", postverificationScriptparams=" + + postverificationScriptparams + "]"; + } + + + + + } diff --git a/akraino/src/main/java/com/akraino/bpm/model/Onap.java b/akraino/src/main/java/com/akraino/bpm/model/Onap.java index e30e527..9a4b246 100644 --- a/akraino/src/main/java/com/akraino/bpm/model/Onap.java +++ b/akraino/src/main/java/com/akraino/bpm/model/Onap.java @@ -1,193 +1,210 @@ -/* - * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.akraino.bpm.model; - -public class Onap { - - private String remoteserver; - private String username; - private String password; - private int portnumber; - private String srcdir; - private String destdir; - private String filename; - private String fileparams; - private String deploymentverifier; - private String verifierparams; - int noofiterations; - int waittime; - String filetrasferscript; - String filetransferparams; - - - public String getSrcdir() { - return srcdir; - } - - - public void setSrcdir(String srcdir) { - this.srcdir = srcdir; - } - - - public String getDestdir() { - return destdir; - } - - - public void setDestdir(String destdir) { - this.destdir = destdir; - } - - - public String getRemoteserver() { - return remoteserver; - } - - - public void setRemoteserver(String remoteserver) { - this.remoteserver = remoteserver; - } - - - public String getUsername() { - return username; - } - - - public void setUsername(String username) { - this.username = username; - } - - - public String getPassword() { - return password; - } - - - public void setPassword(String password) { - this.password = password; - } - - - public int getPortnumber() { - return portnumber; - } - - - public void setPortnumber(int portnumber) { - this.portnumber = portnumber; - } - - - - - - public String getFilename() { - return filename; - } - - - public void setFilename(String filename) { - this.filename = filename; - } - - - public String getFileparams() { - return fileparams; - } - - - public void setFileparams(String fileparams) { - this.fileparams = fileparams; - } - - - public String getDeploymentverifier() { - return deploymentverifier; - } - - - public void setDeploymentverifier(String deploymentverifier) { - this.deploymentverifier = deploymentverifier; - } - - - public int getNoofiterations() { - return noofiterations; - } - - - public void setNoofiterations(int noofiterations) { - this.noofiterations = noofiterations; - } - - - public int getWaittime() { - return waittime; - } - - - public void setWaittime(int waittime) { - this.waittime = waittime; - } - - - - - public String getVerifierparams() { - return verifierparams; - } - - - public void setVerifierparams(String verifierparams) { - this.verifierparams = verifierparams; - } - - - public String getFiletrasferscript() { - return filetrasferscript; - } - - - public void setFiletrasferscript(String filetrasferscript) { - this.filetrasferscript = filetrasferscript; - } - - - - public String getFiletransferparams() { - return filetransferparams; - } - - - public void setFiletransferparams(String filetransferparams) { - this.filetransferparams = filetransferparams; - } - - - @Override - public String toString() { - return "Onap [remoteserver=" + remoteserver + ", username=" + username + ", password=" + password - + ", portnumber=" + portnumber + ", srcdir=" + srcdir + ", destdir=" + destdir + ", filename=" - + filename + ", fileparams=" + fileparams + ", deploymentverifier=" + deploymentverifier - + ", verifierparams=" + verifierparams + ", noofiterations=" + noofiterations + ", waittime=" + waittime - + ", filetrasferscript=" + filetrasferscript + ", filetransferparams=" + filetransferparams + "]"; - } - - - } +/* + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.akraino.bpm.model; + +public class Onap { + + private String sitename; + private String remoteserver; + private String username; + private String password; + private int portnumber; + private String srcdir; + private String destdir; + private String filename; + private String fileparams; + private String deploymentverifier; + private String verifierparams; + int noofiterations; + int waittime; + String filetrasferscript; + String filetransferparams; + + + + + + + public String getSitename() { + return sitename; + } + + + public void setSitename(String sitename) { + this.sitename = sitename; + } + + + public String getSrcdir() { + return srcdir; + } + + + public void setSrcdir(String srcdir) { + this.srcdir = srcdir; + } + + + public String getDestdir() { + return destdir; + } + + + public void setDestdir(String destdir) { + this.destdir = destdir; + } + + + public String getRemoteserver() { + return remoteserver; + } + + + public void setRemoteserver(String remoteserver) { + this.remoteserver = remoteserver; + } + + + public String getUsername() { + return username; + } + + + public void setUsername(String username) { + this.username = username; + } + + + public String getPassword() { + return password; + } + + + public void setPassword(String password) { + this.password = password; + } + + + public int getPortnumber() { + return portnumber; + } + + + public void setPortnumber(int portnumber) { + this.portnumber = portnumber; + } + + + + + + public String getFilename() { + return filename; + } + + + public void setFilename(String filename) { + this.filename = filename; + } + + + public String getFileparams() { + return fileparams; + } + + + public void setFileparams(String fileparams) { + this.fileparams = fileparams; + } + + + public String getDeploymentverifier() { + return deploymentverifier; + } + + + public void setDeploymentverifier(String deploymentverifier) { + this.deploymentverifier = deploymentverifier; + } + + + public int getNoofiterations() { + return noofiterations; + } + + + public void setNoofiterations(int noofiterations) { + this.noofiterations = noofiterations; + } + + + public int getWaittime() { + return waittime; + } + + + public void setWaittime(int waittime) { + this.waittime = waittime; + } + + + + + public String getVerifierparams() { + return verifierparams; + } + + + public void setVerifierparams(String verifierparams) { + this.verifierparams = verifierparams; + } + + + public String getFiletrasferscript() { + return filetrasferscript; + } + + + public void setFiletrasferscript(String filetrasferscript) { + this.filetrasferscript = filetrasferscript; + } + + + + public String getFiletransferparams() { + return filetransferparams; + } + + + public void setFiletransferparams(String filetransferparams) { + this.filetransferparams = filetransferparams; + } + + + @Override + public String toString() { + return "Onap [sitename=" + sitename + ", remoteserver=" + remoteserver + ", username=" + username + + ", password=" + password + ", portnumber=" + portnumber + ", srcdir=" + srcdir + ", destdir=" + + destdir + ", filename=" + filename + ", fileparams=" + fileparams + ", deploymentverifier=" + + deploymentverifier + ", verifierparams=" + verifierparams + ", noofiterations=" + noofiterations + + ", waittime=" + waittime + ", filetrasferscript=" + filetrasferscript + ", filetransferparams=" + + filetransferparams + "]"; + } + + + + } diff --git a/akraino/src/main/java/com/akraino/bpm/model/Tempest.java b/akraino/src/main/java/com/akraino/bpm/model/Tempest.java index 2010cd3..7f180c2 100644 --- a/akraino/src/main/java/com/akraino/bpm/model/Tempest.java +++ b/akraino/src/main/java/com/akraino/bpm/model/Tempest.java @@ -1,195 +1,211 @@ -/* - * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.akraino.bpm.model; - -public class Tempest { - - private String remoteserver; - private String username; - private String password; - private int portnumber; - private String srcdir; - private String destdir; - private String filename; - private String fileparams; - private String deploymentverifier; - private String verifierparams; - int noofiterations; - int waittime; - String filetrasferscript; - String filetransferparams; - - - public String getSrcdir() { - return srcdir; - } - - - public void setSrcdir(String srcdir) { - this.srcdir = srcdir; - } - - - public String getDestdir() { - return destdir; - } - - - public void setDestdir(String destdir) { - this.destdir = destdir; - } - - - public String getRemoteserver() { - return remoteserver; - } - - - public void setRemoteserver(String remoteserver) { - this.remoteserver = remoteserver; - } - - - public String getUsername() { - return username; - } - - - public void setUsername(String username) { - this.username = username; - } - - - public String getPassword() { - return password; - } - - - public void setPassword(String password) { - this.password = password; - } - - - public int getPortnumber() { - return portnumber; - } - - - public void setPortnumber(int portnumber) { - this.portnumber = portnumber; - } - - - - - - public String getFilename() { - return filename; - } - - - public void setFilename(String filename) { - this.filename = filename; - } - - - public String getFileparams() { - return fileparams; - } - - - public void setFileparams(String fileparams) { - this.fileparams = fileparams; - } - - - public String getDeploymentverifier() { - return deploymentverifier; - } - - - public void setDeploymentverifier(String deploymentverifier) { - this.deploymentverifier = deploymentverifier; - } - - - public int getNoofiterations() { - return noofiterations; - } - - - public void setNoofiterations(int noofiterations) { - this.noofiterations = noofiterations; - } - - - public int getWaittime() { - return waittime; - } - - - public void setWaittime(int waittime) { - this.waittime = waittime; - } - - - - - public String getVerifierparams() { - return verifierparams; - } - - - public void setVerifierparams(String verifierparams) { - this.verifierparams = verifierparams; - } - - - public String getFiletrasferscript() { - return filetrasferscript; - } - - - public void setFiletrasferscript(String filetrasferscript) { - this.filetrasferscript = filetrasferscript; - } - - - - - public String getFiletransferparams() { - return filetransferparams; - } - - - public void setFiletransferparams(String filetransferparams) { - this.filetransferparams = filetransferparams; - } - - - @Override - public String toString() { - return "Tempest [remoteserver=" + remoteserver + ", username=" + username + ", password=" + password - + ", portnumber=" + portnumber + ", srcdir=" + srcdir + ", destdir=" + destdir + ", filename=" - + filename + ", fileparams=" + fileparams + ", deploymentverifier=" + deploymentverifier - + ", verifierparams=" + verifierparams + ", noofiterations=" + noofiterations + ", waittime=" + waittime - + ", filetrasferscript=" + filetrasferscript + ", filetransferparams=" + filetransferparams + "]"; - } - - - - } +/* + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.akraino.bpm.model; + +public class Tempest { + + private String sitename; + private String remoteserver; + private String username; + private String password; + private int portnumber; + private String srcdir; + private String destdir; + private String filename; + private String fileparams; + private String deploymentverifier; + private String verifierparams; + int noofiterations; + int waittime; + String filetrasferscript; + String filetransferparams; + + + + + + public String getSitename() { + return sitename; + } + + + public void setSitename(String sitename) { + this.sitename = sitename; + } + + + public String getSrcdir() { + return srcdir; + } + + + public void setSrcdir(String srcdir) { + this.srcdir = srcdir; + } + + + public String getDestdir() { + return destdir; + } + + + public void setDestdir(String destdir) { + this.destdir = destdir; + } + + + public String getRemoteserver() { + return remoteserver; + } + + + public void setRemoteserver(String remoteserver) { + this.remoteserver = remoteserver; + } + + + public String getUsername() { + return username; + } + + + public void setUsername(String username) { + this.username = username; + } + + + public String getPassword() { + return password; + } + + + public void setPassword(String password) { + this.password = password; + } + + + public int getPortnumber() { + return portnumber; + } + + + public void setPortnumber(int portnumber) { + this.portnumber = portnumber; + } + + + + + + public String getFilename() { + return filename; + } + + + public void setFilename(String filename) { + this.filename = filename; + } + + + public String getFileparams() { + return fileparams; + } + + + public void setFileparams(String fileparams) { + this.fileparams = fileparams; + } + + + public String getDeploymentverifier() { + return deploymentverifier; + } + + + public void setDeploymentverifier(String deploymentverifier) { + this.deploymentverifier = deploymentverifier; + } + + + public int getNoofiterations() { + return noofiterations; + } + + + public void setNoofiterations(int noofiterations) { + this.noofiterations = noofiterations; + } + + + public int getWaittime() { + return waittime; + } + + + public void setWaittime(int waittime) { + this.waittime = waittime; + } + + + + + public String getVerifierparams() { + return verifierparams; + } + + + public void setVerifierparams(String verifierparams) { + this.verifierparams = verifierparams; + } + + + public String getFiletrasferscript() { + return filetrasferscript; + } + + + public void setFiletrasferscript(String filetrasferscript) { + this.filetrasferscript = filetrasferscript; + } + + + + + public String getFiletransferparams() { + return filetransferparams; + } + + + public void setFiletransferparams(String filetransferparams) { + this.filetransferparams = filetransferparams; + } + + + @Override + public String toString() { + return "Tempest [sitename=" + sitename + ", remoteserver=" + remoteserver + ", username=" + username + + ", password=" + password + ", portnumber=" + portnumber + ", srcdir=" + srcdir + ", destdir=" + + destdir + ", filename=" + filename + ", fileparams=" + fileparams + ", deploymentverifier=" + + deploymentverifier + ", verifierparams=" + verifierparams + ", noofiterations=" + noofiterations + + ", waittime=" + waittime + ", filetrasferscript=" + filetrasferscript + ", filetransferparams=" + + filetransferparams + "]"; + } + + + + + } diff --git a/akraino/src/main/java/com/akraino/bpm/service/AsyncProcessExecutorService.java b/akraino/src/main/java/com/akraino/bpm/service/AsyncProcessExecutorService.java new file mode 100644 index 0000000..bee88d9 --- /dev/null +++ b/akraino/src/main/java/com/akraino/bpm/service/AsyncProcessExecutorService.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.akraino.bpm.service; + +import com.akraino.bpm.model.Airship; +import com.akraino.bpm.model.Apache; +import com.akraino.bpm.model.Build; +import com.akraino.bpm.model.Deploy; +import com.akraino.bpm.model.Onap; +import com.akraino.bpm.model.Tempest; + +public interface AsyncProcessExecutorService { + + public void executeAirshipProcess(Airship airship); + + public void executeBuildProcess(Build build); + + public void executeDeployProcess(Deploy deploy); + + public void executeOnapProcess(Onap onap); + + public void executeTempestProcess(Tempest tempest); + + public void executeApacheProcess(Apache apache); +} diff --git a/akraino/src/main/java/com/akraino/bpm/service/impl/AsyncProcessExecutorServiceImpl.java b/akraino/src/main/java/com/akraino/bpm/service/impl/AsyncProcessExecutorServiceImpl.java new file mode 100644 index 0000000..73dd05b --- /dev/null +++ b/akraino/src/main/java/com/akraino/bpm/service/impl/AsyncProcessExecutorServiceImpl.java @@ -0,0 +1,228 @@ +/* + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.akraino.bpm.service.impl; + +import org.camunda.bpm.engine.ProcessEngine; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.camunda.bpm.engine.variable.Variables; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Service; + +import com.akraino.bpm.Exception.TaskExecutorException; +import com.akraino.bpm.model.Airship; +import com.akraino.bpm.model.Apache; +import com.akraino.bpm.model.Build; +import com.akraino.bpm.model.BuildResponse; +import com.akraino.bpm.model.Deploy; +import com.akraino.bpm.model.Onap; +import com.akraino.bpm.model.Tempest; +import com.akraino.bpm.service.AsyncProcessExecutorService; +import com.akraino.bpm.service.DeployResponseSenderService; + +@Service("asyncProcessExecutorService") +public class AsyncProcessExecutorServiceImpl implements AsyncProcessExecutorService{ + + @Autowired + private ProcessEngine camunda; + + @Autowired + private DeployResponseSenderService deployResponseSenderService; + + private static Logger logger = LoggerFactory.getLogger(AsyncProcessExecutorServiceImpl.class); + + @Async + public void executeAirshipProcess(Airship airship) { + + try { + executeAirshipservice(airship); + }catch(TaskExecutorException ex) { + logger.error("Airship execution failed ",ex); + deployResponseSenderService.sendResponse(new BuildResponse(null,null,null,null,"exception: "+ex.getMessage(),airship.getSitename(),null,null,null)); + } + logger.error("Airship execution sucess "); + deployResponseSenderService.sendResponse(new BuildResponse(null,null,null,null,"success",airship.getSitename(),null,null,null)); + + + + } + + private ProcessInstance executeAirshipservice(Airship airship) { + + String filepath1=airship.getFilepath()+" "+(airship.getFileparams()!=null?airship.getFileparams().replaceAll(",", " "):" "); + String filepath2=airship.getWinscpfilepath()+" "+(airship.getWinscpfileparams()!=null?airship.getWinscpfileparams().replaceAll(",", " "):" "); + return camunda.getRuntimeService().startProcessInstanceByKey("airship", + Variables.putValue("filepath", filepath1).putValue("scpdir", airship.getWinscpdir()).putValue("ScpScriptFilepath", filepath2).putValue("remotserver", airship.getRemotserver()) + .putValue("username", airship.getUsername()) + .putValue("password", airship.getPassword()) + .putValue("port", airship.getPort()).putValue("destdir",airship.getDestdir()).putValue("remotefilename", airship.getRemotefilename()) + .putValue("remotefileparams", airship.getRemotefileparams()).putValue("sitename", airship.getSitename())); + + } + + @Async + public void executeBuildProcess(Build build) { + + try { + executeBuildService(build); + }catch(TaskExecutorException ex) { + logger.error("Build execution failed ",ex); + deployResponseSenderService.sendResponse(new BuildResponse("exception: "+ex.getMessage(),null,null,null,null,build.getSitename(),null,null,null)); + } + logger.error("Build execution sucess "); + deployResponseSenderService.sendResponse(new BuildResponse("success",null,null,null,null,build.getSitename(),null,null,null)); + } + + + private ProcessInstance executeBuildService(Build build) { + + String filepath=build.getFilepath()+" "+(build.getFileparams()!=null?build.getFileparams().replaceAll(",", " "):" "); + return camunda.getRuntimeService().startProcessInstanceByKey("build", + Variables.putValue("filepath", filepath).putValue("targetfolder", build.getTargetfolder())); + } + + @Async + public void executeDeployProcess(Deploy deploy) { + + try { + executeDeployService(deploy); + }catch(TaskExecutorException ex) { + logger.error("deploy execution failed ",ex); + deployResponseSenderService.sendResponse(new BuildResponse(null,null,null,null,"exception: "+ex.getMessage(),deploy.getSitename(),null,null,null)); + } + logger.debug("deploy execution sucess "); + deployResponseSenderService.sendResponse(new BuildResponse("success","success","success","success","success",deploy.getSitename(),null,null,null)); + } + + + private ProcessInstance executeDeployService(Deploy deploy) { + + String filepath1=deploy.getFilepath()+" "+(deploy.getFileparams()!=null?deploy.getFileparams().replaceAll(",", " "):" "); + String filepath2=deploy.getWinscpfilepath()+" "+(deploy.getWinscpfileparams()!=null?deploy.getWinscpfileparams().replaceAll(",", " "):" "); + return camunda.getRuntimeService().startProcessInstanceByKey("deploy", + Variables.putValue("filepath", filepath1).putValue("ScpScriptFilepath", filepath2).putValue("remotserver", deploy.getRemotserver()) + .putValue("username", deploy.getUsername()) + .putValue("password", deploy.getPassword()) + .putValue("port", deploy.getPort()).putValue("destdir",deploy.getDestdir()).putValue("remotefilename", deploy.getRemotefilename()) + .putValue("fileparams", deploy.getFileparams()). + putValue("verifier", deploy.getDeploymentverifier()).putValue("verifierfileparams", + deploy.getDeploymentverifierfileparams()).putValue("waittime", deploy.getWaittime()). + putValue("iterations", deploy.getNoofiterations()).putValue("postverificationscript", deploy.getPostverificationscript()). + putValue("postverificationScriptparams", deploy.getDeploymentverifierfileparams()).putValue("sitename", deploy.getSitename())); + + } + + @Async + public void executeOnapProcess(Onap onap) { + + try { + executeOnapService(onap); + }catch(TaskExecutorException ex) { + logger.error("Onap execution failed ",ex); + deployResponseSenderService.sendResponse(new BuildResponse(null,null,null,null,null,onap.getSitename(),"exception: "+ex.getMessage(),null,null)); + } + logger.error("Onap execution sucess "); + deployResponseSenderService.sendResponse(new BuildResponse(null,null,null,null,null,onap.getSitename(),"succes",null,null)); + + + } + + + private ProcessInstance executeOnapService(Onap onap) { + + String transferfile= onap.getFiletrasferscript()+" "+(onap.getFiletransferparams()!=null?onap.getFiletransferparams().replaceAll(",", " "):" "); + return camunda.getRuntimeService().startProcessInstanceByKey("onap", + Variables.putValue("filename", onap.getFilename()).putValue("fileparams", onap.getFileparams()). + putValue("verifier", onap.getDeploymentverifier()).putValue("verifierfileparams", onap.getVerifierparams()).putValue("waittime", onap.getWaittime()). + putValue("iterations", onap.getNoofiterations()).putValue("remotserver", onap.getRemoteserver()) + .putValue("username", onap.getUsername()) + .putValue("password", onap.getPassword()) + .putValue("port", onap.getPortnumber()).putValue("srcdir", onap.getSrcdir()).putValue("destdir",onap.getDestdir()).putValue("filepath", transferfile) + ); + + } + + + @Async + public void executeTempestProcess(Tempest tempest) { + try { + executeTempestService(tempest); + }catch(TaskExecutorException ex) { + logger.error("Tempest execution failed ",ex); + deployResponseSenderService.sendResponse(new BuildResponse(null,null,null,null,null,tempest.getSitename(),null,null,"exception: "+ex.getMessage())); + } + logger.error("Tempest execution sucess "); + deployResponseSenderService.sendResponse(new BuildResponse(null,null,null,null,null,tempest.getSitename(),null,null,"success")); + + } + + private ProcessInstance executeTempestService(Tempest tempest) { + + + String transferfile= tempest.getFiletrasferscript()+" "+(tempest.getFiletransferparams()!=null?tempest.getFiletransferparams().replaceAll(",", " "):" "); + + return camunda.getRuntimeService().startProcessInstanceByKey("tempest", + Variables.putValue("filename", tempest.getFilename()).putValue("fileparams", tempest.getFileparams()). + putValue("verifier", tempest.getDeploymentverifier()).putValue("verifierfileparams", tempest.getVerifierparams()).putValue("waittime", tempest.getWaittime()). + putValue("iterations", tempest.getNoofiterations()).putValue("remotserver", tempest.getRemoteserver()) + .putValue("username", tempest.getUsername()) + .putValue("password", tempest.getPassword()) + .putValue("port", tempest.getPortnumber()).putValue("srcdir", tempest.getSrcdir()).putValue("destdir",tempest.getDestdir()).putValue("filepath", transferfile) + ); + + } + + + @Async + public void executeApacheProcess(Apache apache) { + try { + executeApacheService(apache); + }catch(TaskExecutorException ex) { + logger.error("Apache execution failed ",ex); + deployResponseSenderService.sendResponse(new BuildResponse(null,null,null,null,null,apache.getSitename(),null,"exception: "+ex.getMessage(),null)); + } + logger.error("Apache execution sucess "); + deployResponseSenderService.sendResponse(new BuildResponse(null,null,null,null,null,apache.getSitename(),null,"success",null)); + + + } + + + private ProcessInstance executeApacheService(Apache apache) { + + String transferfile= apache.getFiletrasferscript()+" "+(apache.getFiletransferparams()!=null?apache.getFiletransferparams().replaceAll(",", " "):" "); + + return camunda.getRuntimeService().startProcessInstanceByKey("apache", + Variables.putValue("filename", apache.getFilename()).putValue("fileparams", apache.getFileparams()). + putValue("verifier", apache.getDeploymentverifier()).putValue("verifierfileparams", apache.getVerifierparams()).putValue("waittime", apache.getWaittime()). + putValue("iterations", apache.getNoofiterations()).putValue("remotserver", apache.getRemoteserver()) + .putValue("username", apache.getUsername()) + .putValue("password", apache.getPassword()) + .putValue("port", apache.getPortnumber()).putValue("srcdir", apache.getSrcdir()).putValue("destdir",apache.getDestdir()).putValue("filepath", transferfile) + ); + + } + + + + + + + +} diff --git a/akraino/src/main/java/com/akraino/bpm/service/impl/DeployResponseSenderServiceImpl.java b/akraino/src/main/java/com/akraino/bpm/service/impl/DeployResponseSenderServiceImpl.java index 842274b..939331a 100644 --- a/akraino/src/main/java/com/akraino/bpm/service/impl/DeployResponseSenderServiceImpl.java +++ b/akraino/src/main/java/com/akraino/bpm/service/impl/DeployResponseSenderServiceImpl.java @@ -1,60 +1,63 @@ -/* - * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.akraino.bpm.service.impl; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Service; -import org.springframework.web.client.RestTemplate; - -import com.akraino.bpm.Exception.TaskExecutorException; -import com.akraino.bpm.config.CamundaCorsFilter; -import com.akraino.bpm.model.BuildResponse; -import com.akraino.bpm.service.DeployResponseSenderService; - -@Service("deployResponseSenderService") -public class DeployResponseSenderServiceImpl implements DeployResponseSenderService { - - private static Logger logger = LoggerFactory.getLogger(DeployResponseSenderServiceImpl.class); - - @Autowired - private RestTemplate restTemplate; - - @Autowired - private CamundaCorsFilter camundaCorsFilter; - - public void sendResponse(BuildResponse response) { - try { - logger.debug(response.toString()); - HttpEntity request = new HttpEntity(response); - ResponseEntity httpresposne =restTemplate - .exchange(camundaCorsFilter.getBuildresponseurl(), HttpMethod.POST, request, Void.class); - - logger.debug("Build response HttpResponseStatus :"+httpresposne.getStatusCodeValue()); - }catch (Exception e ) { - logger.error("problem while sending deploy response :"+e.getMessage()); - - throw new TaskExecutorException("problem while sending deploy response :"+e.getMessage()); - - } - } - - } +/* + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.akraino.bpm.service.impl; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestTemplate; + +import com.akraino.bpm.Exception.TaskExecutorException; +import com.akraino.bpm.config.CamundaCorsFilter; +import com.akraino.bpm.model.BuildResponse; +import com.akraino.bpm.service.DeployResponseSenderService; + +@Service("deployResponseSenderService") +public class DeployResponseSenderServiceImpl implements DeployResponseSenderService { + + private static Logger logger = LoggerFactory.getLogger(DeployResponseSenderServiceImpl.class); + + @Autowired + private RestTemplate restTemplate; + + @Autowired + private CamundaCorsFilter camundaCorsFilter; + + public void sendResponse(BuildResponse response) { + try { + logger.debug(response.toString()); + HttpHeaders header = new HttpHeaders(); + header.add("tokenId", camundaCorsFilter.getTokenId()); + HttpEntity request = new HttpEntity(response,header); + ResponseEntity httpresposne =restTemplate + .exchange(camundaCorsFilter.getBuildresponseurl(), HttpMethod.POST, request, Void.class); + + logger.debug("Build response HttpResponseStatus :"+httpresposne.getStatusCodeValue()); + }catch (Exception e ) { + logger.error("problem while sending response :"+e.getMessage()); + + throw new TaskExecutorException("problem while sending response :"+e.getMessage()); + + } + } + +} diff --git a/akraino/src/main/java/com/akraino/bpm/service/impl/FileTransferServiceImpl.java b/akraino/src/main/java/com/akraino/bpm/service/impl/FileTransferServiceImpl.java index d8b158c..2754af2 100644 --- a/akraino/src/main/java/com/akraino/bpm/service/impl/FileTransferServiceImpl.java +++ b/akraino/src/main/java/com/akraino/bpm/service/impl/FileTransferServiceImpl.java @@ -1,93 +1,93 @@ -/* - * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.akraino.bpm.service.impl; - -import java.io.File; -import java.io.FileInputStream; -import java.util.ArrayList; -import java.util.List; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Service; - -import com.akraino.bpm.Exception.TaskExecutorException; -import com.akraino.bpm.service.FileTransferService; -import com.jcraft.jsch.ChannelSftp; -import com.jcraft.jsch.JSch; -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(); - } - } - - - public void transferFile(String srcdir, String destdir,String servername,String username,String password,int port) { - - List files=getAllfiles(new File(srcdir)); - for(File file: files) { - transferFile(srcdir,destdir,file.getName(),servername,username,password,port); - } - - - } - - private List getAllfiles(File rootDirectory){ - List results = new ArrayList(); - - 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); - } - } - return results; - } - - -} +/* + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.akraino.bpm.service.impl; + +import java.io.File; +import java.io.FileInputStream; +import java.util.ArrayList; +import java.util.List; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +import com.akraino.bpm.Exception.TaskExecutorException; +import com.akraino.bpm.service.FileTransferService; +import com.jcraft.jsch.ChannelSftp; +import com.jcraft.jsch.JSch; +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(); + } + } + + + public void transferFile(String srcdir, String destdir,String servername,String username,String password,int port) { + + List files=getAllfiles(new File(srcdir)); + for(File file: files) { + transferFile(srcdir,destdir,file.getName(),servername,username,password,port); + } + + + } + + private List getAllfiles(File rootDirectory){ + List results = new ArrayList(); + + 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); + } + } + return results; + } + + +} diff --git a/akraino/src/main/java/com/akraino/bpm/service/impl/RemoteDeploymentverificationServiceImpl.java b/akraino/src/main/java/com/akraino/bpm/service/impl/RemoteDeploymentverificationServiceImpl.java index b3335e7..865e768 100644 --- a/akraino/src/main/java/com/akraino/bpm/service/impl/RemoteDeploymentverificationServiceImpl.java +++ b/akraino/src/main/java/com/akraino/bpm/service/impl/RemoteDeploymentverificationServiceImpl.java @@ -1,110 +1,110 @@ -/* - * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.akraino.bpm.service.impl; - -import java.io.BufferedReader; -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; - -import com.akraino.bpm.Exception.TaskExecutorException; -import com.akraino.bpm.service.RemoteDeploymentVerificationService; -import com.jcraft.jsch.ChannelExec; -import com.jcraft.jsch.JSch; -import com.jcraft.jsch.Session; - - -@Service("remoteDeploymentVerificationService") -public class RemoteDeploymentverificationServiceImpl implements RemoteDeploymentVerificationService{ - - private static Logger logger = LoggerFactory.getLogger(RemoteDeploymentverificationServiceImpl.class); - - public void executeScript(String remoteserver,String username,String password,int portnumber, - String filename,String fileparams,String srcdir,String destdir,int waitttime,int iterations,String command) { - - boolean issuccess=false; - //String filepath=destdir+"/"+filename+" "+(fileparams!=null?fileparams.replaceAll(",", " "):" "); - ChannelExec channelExec=null; - BufferedReader reader =null; - Session session=null; - for( int i=0;i<=iterations;i++) { - try { - logger.debug("Executing the deployment verification script.............iteration : {}",i); - Thread.sleep(waitttime*1000); - JSch jsch = new JSch(); - session = jsch.getSession(username, remoteserver, portnumber); - session.setConfig("StrictHostKeyChecking", "no"); - session.setPassword(password); - session.connect(); - channelExec = (ChannelExec)session.openChannel("exec"); - InputStream in = channelExec.getInputStream(); - channelExec.setPty(true); - channelExec.setCommand(command); - channelExec.connect(); - reader = new BufferedReader(new InputStreamReader(in)); - String line; - logger.debug("Script output......................"); - while ((line = reader.readLine()) != null){ - logger.debug(line); - } - channelExec.disconnect(); - while (!channelExec.isClosed()) { - - } - int exitStatus = channelExec.getExitStatus(); - logger.debug("Script exit code :"+exitStatus); - if(exitStatus==0) { - issuccess=true; - } - } - catch (IOException e) { - throw new TaskExecutorException(filename + " not found."); - } catch (Exception e) { - throw new TaskExecutorException("problem while executing the script "+command); - }finally{ - if(reader!=null) { - try { - reader.close(); - }catch(Exception e) { - throw new TaskExecutorException("onap build failed"); - } - } - if(session!=null) { - session.disconnect(); - } - } - - if(issuccess) { - break; - } - - } - - if(!issuccess) { - logger.debug("verification script returned 1 "); - throw new TaskExecutorException(" verification script exit code : 1"); - } - } - - - -} +/* + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.akraino.bpm.service.impl; + +import java.io.BufferedReader; +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; + +import com.akraino.bpm.Exception.TaskExecutorException; +import com.akraino.bpm.service.RemoteDeploymentVerificationService; +import com.jcraft.jsch.ChannelExec; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.Session; + + +@Service("remoteDeploymentVerificationService") +public class RemoteDeploymentverificationServiceImpl implements RemoteDeploymentVerificationService{ + + private static Logger logger = LoggerFactory.getLogger(RemoteDeploymentverificationServiceImpl.class); + + public void executeScript(String remoteserver,String username,String password,int portnumber, + String filename,String fileparams,String srcdir,String destdir,int waitttime,int iterations,String command) { + + boolean issuccess=false; + //String filepath=destdir+"/"+filename+" "+(fileparams!=null?fileparams.replaceAll(",", " "):" "); + ChannelExec channelExec=null; + BufferedReader reader =null; + Session session=null; + for( int i=0;i<=iterations;i++) { + try { + logger.debug("Executing the deployment verification script.............iteration : {}",i); + Thread.sleep(waitttime*1000); + JSch jsch = new JSch(); + session = jsch.getSession(username, remoteserver, portnumber); + session.setConfig("StrictHostKeyChecking", "no"); + session.setPassword(password); + session.connect(); + channelExec = (ChannelExec)session.openChannel("exec"); + InputStream in = channelExec.getInputStream(); + channelExec.setPty(true); + channelExec.setCommand(command); + channelExec.connect(); + reader = new BufferedReader(new InputStreamReader(in)); + String line; + logger.debug("Script output......................"); + while ((line = reader.readLine()) != null){ + logger.debug(line); + } + channelExec.disconnect(); + while (!channelExec.isClosed()) { + + } + int exitStatus = channelExec.getExitStatus(); + logger.debug("Script exit code :"+exitStatus); + if(exitStatus==0) { + issuccess=true; + } + } + catch (IOException e) { + throw new TaskExecutorException(filename + " not found."); + } catch (Exception e) { + throw new TaskExecutorException("problem while executing the script "+command); + }finally{ + if(reader!=null) { + try { + reader.close(); + }catch(Exception e) { + throw new TaskExecutorException("onap build failed"); + } + } + if(session!=null) { + session.disconnect(); + } + } + + if(issuccess) { + break; + } + + } + + if(!issuccess) { + logger.debug("verification script returned 1 "); + throw new TaskExecutorException(" verification script exit code : 1"); + } + } + + + +} diff --git a/akraino/src/main/java/com/akraino/bpm/service/impl/RemoteScriptExecutionServiceImpl.java b/akraino/src/main/java/com/akraino/bpm/service/impl/RemoteScriptExecutionServiceImpl.java index 0a05f9f..b25e12e 100644 --- a/akraino/src/main/java/com/akraino/bpm/service/impl/RemoteScriptExecutionServiceImpl.java +++ b/akraino/src/main/java/com/akraino/bpm/service/impl/RemoteScriptExecutionServiceImpl.java @@ -1,106 +1,108 @@ -/* - * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.akraino.bpm.service.impl; - -import java.io.BufferedReader; -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; - -import com.akraino.bpm.Exception.TaskExecutorException; -import com.akraino.bpm.service.RemoteScriptExecutionService; -import com.jcraft.jsch.ChannelExec; -import com.jcraft.jsch.JSch; -import com.jcraft.jsch.Session; - -@Service("remoteScriptExecutionService") -public class RemoteScriptExecutionServiceImpl implements RemoteScriptExecutionService{ - - private static Logger logger = LoggerFactory.getLogger(RemoteScriptExecutionServiceImpl.class); - - public void executeRemoteScript(String remoteserver,String username,String password,int portnumber,String filename, - String fileparams,String srcdir,String destdir,String command) { - - //String filepath=destdir+"/"+filename+" "+(fileparams!=null?fileparams.replaceAll(",", " "):" "); - ChannelExec channelExec=null; - Session session=null; - BufferedReader reader =null; - try { - //tranferFile(remoteserver,portnumber,username,password,filename,srcdir,destdir); - logger.debug("executing the script "+command); - JSch jsch = new JSch(); - session = jsch.getSession(username, remoteserver, portnumber); - session.setConfig("StrictHostKeyChecking", "no"); - session.setPassword(password); - session.connect(); - channelExec = (ChannelExec)session.openChannel("exec"); - InputStream in = channelExec.getInputStream(); - channelExec.setCommand(command); - channelExec.setPty(true); - channelExec.connect(); - reader = new BufferedReader(new InputStreamReader(in)); - String line; - logger.debug("Script output......................"); - while ((line = reader.readLine()) != null){ - logger.debug(line); - } - - channelExec.disconnect(); - while (!channelExec.isClosed()) { - - } - - int exitStatus = channelExec.getExitStatus(); - - logger.debug("Script exit code :"+exitStatus); - if(exitStatus!=0) { - throw new TaskExecutorException("problem while executing the script . exist code :"+exitStatus); - } - - - } catch (IOException e) { - throw new TaskExecutorException(filename + " not found."); - } catch (Exception e) { - throw new TaskExecutorException("Problem while executing script"+e.getMessage()); - }finally{ - if(reader!=null) { - try { - reader.close(); - }catch(Exception e) { - throw new TaskExecutorException("onap build failed"); - } - } - if(session!=null) { - session.disconnect(); - } - } - - - - } - - - - -} - - +/* + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.akraino.bpm.service.impl; + +import java.io.BufferedReader; +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; + +import com.akraino.bpm.Exception.TaskExecutorException; +import com.akraino.bpm.service.RemoteScriptExecutionService; +import com.jcraft.jsch.ChannelExec; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.Session; + +@Service("remoteScriptExecutionService") +public class RemoteScriptExecutionServiceImpl implements RemoteScriptExecutionService{ + + private static Logger logger = LoggerFactory.getLogger(RemoteScriptExecutionServiceImpl.class); + + public void executeRemoteScript(String remoteserver,String username,String password,int portnumber,String filename, + String fileparams,String srcdir,String destdir,String command) { + + //String filepath=destdir+"/"+filename+" "+(fileparams!=null?fileparams.replaceAll(",", " "):" "); + ChannelExec channelExec=null; + Session session=null; + BufferedReader reader =null; + try { + //tranferFile(remoteserver,portnumber,username,password,filename,srcdir,destdir); + logger.debug("executing the script "+command); + JSch jsch = new JSch(); + session = jsch.getSession(username, remoteserver, portnumber); + session.setConfig("StrictHostKeyChecking", "no"); + session.setPassword(password); + session.connect(); + session.setTimeout(36000000); + channelExec = (ChannelExec)session.openChannel("exec"); + InputStream in = channelExec.getInputStream(); + channelExec.setCommand(command); + channelExec.setPty(true); + + channelExec.connect(36000000); + reader = new BufferedReader(new InputStreamReader(in)); + String line; + logger.debug("Script output......................"); + while ((line = reader.readLine()) != null){ + logger.debug(line); + } + + channelExec.disconnect(); + while (!channelExec.isClosed()) { + + } + + int exitStatus = channelExec.getExitStatus(); + + logger.debug("Script exit code :"+exitStatus); + if(exitStatus!=0) { + throw new TaskExecutorException("problem while executing the script . exist code :"+exitStatus); + } + + + } catch (IOException e) { + throw new TaskExecutorException(filename + " not found."); + } catch (Exception e) { + throw new TaskExecutorException("Problem while executing script"+e.getMessage()); + }finally{ + if(reader!=null) { + try { + reader.close(); + }catch(Exception e) { + throw new TaskExecutorException("onap build failed"); + } + } + if(session!=null) { + session.disconnect(); + } + } + + + + } + + + + +} + + diff --git a/akraino/src/main/java/com/akraino/bpm/service/impl/ScriptExecutionServiceImpl.java b/akraino/src/main/java/com/akraino/bpm/service/impl/ScriptExecutionServiceImpl.java index ee02934..a8b4106 100644 --- a/akraino/src/main/java/com/akraino/bpm/service/impl/ScriptExecutionServiceImpl.java +++ b/akraino/src/main/java/com/akraino/bpm/service/impl/ScriptExecutionServiceImpl.java @@ -1,115 +1,115 @@ -/* - * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.akraino.bpm.service.impl; - -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStreamReader; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Service; - -import com.akraino.bpm.Exception.TaskExecutorException; -import com.akraino.bpm.service.ScriptExecutionService; - -@Service("scriptExecutionService") -public class ScriptExecutionServiceImpl implements ScriptExecutionService{ - - private static Logger logger = LoggerFactory.getLogger(ScriptExecutionServiceImpl.class); - - public void executeScript(String filepatch) { - - try { - logger.debug("Executing the script............."); - Process p = Runtime.getRuntime().exec(filepatch); - 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(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); - } - - } - - - /*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); - } - - }*/ - -} +/* + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.akraino.bpm.service.impl; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStreamReader; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +import com.akraino.bpm.Exception.TaskExecutorException; +import com.akraino.bpm.service.ScriptExecutionService; + +@Service("scriptExecutionService") +public class ScriptExecutionServiceImpl implements ScriptExecutionService{ + + private static Logger logger = LoggerFactory.getLogger(ScriptExecutionServiceImpl.class); + + public void executeScript(String filepatch) { + + try { + logger.debug("Executing the script............."); + Process p = Runtime.getRuntime().exec(filepatch); + BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream())); + String line = ""; + while ((line = input.readLine()) != null) { + logger.debug(line); + } + p.waitFor(); + 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."); + } 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); + } + + } + + + /*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); + } + + }*/ + +} diff --git a/akraino/src/main/resources/application.yaml b/akraino/src/main/resources/application.yaml index 3063508..80ddc8d 100644 --- a/akraino/src/main/resources/application.yaml +++ b/akraino/src/main/resources/application.yaml @@ -1,14 +1,15 @@ -camunda.bpm: - admin-user: - id: admin - password: admin - firstName: administrator - filter: - create: All tasks - buildresponseurl: http://localhost:8069/AECPortalMgmt/install/status/ -logging: - file: C:/tmp/scriptexecutor.log - level: - com.camunda.bpm: debug - org.camunda.bpm: warn +camunda.bpm: + admin-user: + id: admin + password: admin + firstName: administrator + filter: + create: All tasks + buildresponseurl: http://localhost:8069/AECPortalMgmt/install/status/ + tokenId: YWthZG1pbg==:9FCBA840BD274292F4DCC995BECE3D09 +logging: + file: C:/tmp/scriptexecutor.log + level: + com.akraino.bpm: debug + org.camunda.bpm: warn org.springframework: warn \ No newline at end of file diff --git a/config/application.yaml b/config/application.yaml index 111c60b..8a879f4 100644 --- a/config/application.yaml +++ b/config/application.yaml @@ -5,7 +5,8 @@ camunda.bpm: firstName: administrator filter: create: All tasks - buildresponseurl: http://135.16.101.85:8069/AECPortalMgmt/edgeSites/status + buildresponseurl: http://192.168.2.44:8080/AECPortalMgmt/edgeSites/status + tokenId: YWthZG1pbg==:9FCBA840BD274292F4DCC995BECE3D09 logging: file: /var/log/scriptexecutor.log level: diff --git a/config/deploy.bpmn b/config/deploy.bpmn index 29c2330..1776b85 100644 --- a/config/deploy.bpmn +++ b/config/deploy.bpmn @@ -1,5 +1,5 @@ - + @@ -17,17 +17,12 @@ SequenceFlow_064ccvc - SequenceFlow_0e9qo9c SequenceFlow_1jh4nm3 SequenceFlow_064ccvc - - - SequenceFlow_0e9qo9c - Rest @@ -48,16 +43,12 @@ Remote Script Executor - - Post verification  - - - - + + @@ -66,28 +57,28 @@ - - + + - - + + - + - + - + - - + + @@ -96,59 +87,45 @@ - - + + - + - + - - + + - - + + - + - - + + - + - + - - - - - - - - - - - - - - - - + + diff --git a/config/singledeploy.bpmn b/config/singledeploy.bpmn new file mode 100644 index 0000000..b20b067 --- /dev/null +++ b/config/singledeploy.bpmn @@ -0,0 +1,54 @@ + + + + + + SequenceFlow_125l5l0 + + + SequenceFlow_125l5l0 + + + Rest + + + + Script execution Task + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.16.6