summaryrefslogtreecommitdiffstats
path: root/wfenginemgrservice
diff options
context:
space:
mode:
Diffstat (limited to 'wfenginemgrservice')
-rw-r--r--wfenginemgrservice/pom.xml310
-rw-r--r--wfenginemgrservice/src/main/java/org/onap/workflow/WorkflowApp.java42
-rw-r--r--wfenginemgrservice/src/main/java/org/onap/workflow/WorkflowAppConfig.java43
-rw-r--r--wfenginemgrservice/src/main/java/org/onap/workflow/activitiext/common/ToolUtil.java52
-rw-r--r--wfenginemgrservice/src/main/java/org/onap/workflow/activitiext/common/package-info.java16
-rw-r--r--wfenginemgrservice/src/main/java/org/onap/workflow/common/Config.java31
-rw-r--r--wfenginemgrservice/src/main/java/org/onap/workflow/common/EnumModuleUrl.java33
-rw-r--r--wfenginemgrservice/src/main/java/org/onap/workflow/common/EnumStatus.java21
-rw-r--r--wfenginemgrservice/src/main/java/org/onap/workflow/common/RestClient.java310
-rw-r--r--wfenginemgrservice/src/main/java/org/onap/workflow/common/RestClientUtils.java42
-rw-r--r--wfenginemgrservice/src/main/java/org/onap/workflow/common/RestResponse.java37
-rw-r--r--wfenginemgrservice/src/main/java/org/onap/workflow/common/ToolUtil.java67
-rw-r--r--wfenginemgrservice/src/main/java/org/onap/workflow/common/package-info.java16
-rw-r--r--wfenginemgrservice/src/main/java/org/onap/workflow/entity/DeployBpmnFileResponse.java31
-rw-r--r--wfenginemgrservice/src/main/java/org/onap/workflow/entity/MsbClientConfig.java26
-rw-r--r--wfenginemgrservice/src/main/java/org/onap/workflow/entity/StartProcessRequest.java33
-rw-r--r--wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/entity/activitientitiy/ActivitiDeployResponse.java25
-rw-r--r--wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/entity/activitientitiy/ActivitiStartProcessRequest.java25
-rw-r--r--wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/entity/activitientitiy/ActivitiStartProcessRequestParam.java27
-rw-r--r--wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/entity/activitientitiy/package-info.java19
-rw-r--r--wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/service/activitiservice/ActivitiServiceConsumer.java142
-rw-r--r--wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/service/activitiservice/IActivitiRestService.java44
-rw-r--r--wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/service/activitiservice/package-info.java17
-rw-r--r--wfenginemgrservice/src/main/java/org/onap/workflow/resources/WorkflowResource.java101
-rw-r--r--wfenginemgrservice/src/main/java/org/onap/workflow/tools/Constants.java29
-rw-r--r--wfenginemgrservice/src/main/java/org/onap/workflow/tools/HttpDeleteWithBody.java37
-rw-r--r--wfenginemgrservice/src/main/java/org/onap/workflow/tools/RequestParameters.java35
-rw-r--r--wfenginemgrservice/src/main/java/org/onap/workflow/tools/package-info.java17
-rw-r--r--wfenginemgrservice/src/main/java/org/onap/workflow/wrapper/WorkflowInstanceWrapper.java98
-rw-r--r--wfenginemgrservice/src/main/resources/api-doc/index.html99
-rw-r--r--wfenginemgrservice/src/main/resources/banner.txt6
31 files changed, 1831 insertions, 0 deletions
diff --git a/wfenginemgrservice/pom.xml b/wfenginemgrservice/pom.xml
new file mode 100644
index 0000000..b60df33
--- /dev/null
+++ b/wfenginemgrservice/pom.xml
@@ -0,0 +1,310 @@
+<?xml version="1.0"?>
+<!-- Copyright 2016 ZTE Corporation. 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. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <groupId>org.onap.oparent</groupId>
+ <artifactId>oparent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>workflow-engine-mgr-service</artifactId>
+ <name>vfc/nfvo/wfengine/wfenginemgrservice</name>
+ <packaging>jar</packaging>
+
+ <properties>
+ <ant.version>1.9.6</ant.version>
+ <apache-velocity.version>1.6.2</apache-velocity.version>
+ <jgrapht.version>0.9.1</jgrapht.version>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>lifecycle-mapping</artifactId>
+ <version>1.0.0</version>
+ <configuration>
+ <lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <versionRange>[2.0,)</versionRange>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore />
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ </lifecycleMappingMetadata>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.6</version>
+ <configuration>
+ <archive>
+ <manifest>
+ <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.5.1</version>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>2.4</version>
+ <configuration>
+ <createDependencyReducedPom>false</createDependencyReducedPom>
+ <filters>
+ <filter>
+ <artifact>*:*</artifact>
+ <excludes>
+ <exclude>META-INF/*.SF</exclude>
+ <exclude>META-INF/*.DSA</exclude>
+ <exclude>META-INF/*.RSA</exclude>
+ </excludes>
+ </filter>
+ </filters>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <transformers>
+ <transformer
+ implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
+ <transformer
+ implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+ <mainClass>com.onap.workflow.WorkflowApp</mainClass>
+ </transformer>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>io.dropwizard</groupId>
+ <artifactId>dropwizard-core</artifactId>
+ <version>${dropwizard.version}</version>
+ <overWrite>true</overWrite>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <version>2.8</version>
+ </plugin>
+ </plugins>
+ <pluginManagement>
+ <plugins>
+ <!--This plugin's configuration is used to store Eclipse m2e settings
+ only. It has no influence on the Maven build itself. -->
+ <plugin>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>lifecycle-mapping</artifactId>
+ <version>1.0.0</version>
+ <configuration>
+ <lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>
+ org.apache.maven.plugins
+ </groupId>
+ <artifactId>
+ maven-checkstyle-plugin
+ </artifactId>
+ <versionRange>
+ [2.17,)
+ </versionRange>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore></ignore>
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ </lifecycleMappingMetadata>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>io.dropwizard</groupId>
+ <artifactId>dropwizard-core</artifactId>
+ <version>0.8.0</version>
+ </dependency>
+ <dependency>
+ <groupId>io.dropwizard</groupId>
+ <artifactId>dropwizard-assets</artifactId>
+ <version>0.8.0</version>
+ </dependency>
+ <dependency>
+ <groupId>io.dropwizard</groupId>
+ <artifactId>dropwizard-hibernate</artifactId>
+ <version>0.8.0</version>
+ </dependency>
+ <dependency>
+ <groupId>io.dropwizard</groupId>
+ <artifactId>dropwizard-migrations</artifactId>
+ <version>0.8.0</version>
+ </dependency>
+ <dependency>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-jersey2-jaxrs</artifactId>
+ <version>1.5.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <version>1.16.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.core</groupId>
+ <artifactId>jersey-server</artifactId>
+ <version>2.16</version>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.media</groupId>
+ <artifactId>jersey-media-multipart</artifactId>
+ <version>2.16</version>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.containers</groupId>
+ <artifactId>jersey-container-servlet-core</artifactId>
+ <version>2.16</version>
+ </dependency>
+ <dependency>
+ <groupId>com.eclipsesource.jaxrs</groupId>
+ <artifactId>consumer</artifactId>
+ <version>5.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.jcraft</groupId>
+ <artifactId>jsch</artifactId>
+ <version>0.1.53</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.dataformat</groupId>
+ <artifactId>jackson-dataformat-xml</artifactId>
+ <version>2.5.1</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-annotations</artifactId>
+ <version>2.8.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>2.2.4</version>
+ </dependency>
+ <dependency>
+ <groupId>dom4j</groupId>
+ <artifactId>dom4j</artifactId>
+ <version>1.6.1</version>
+ </dependency>
+ <dependency>
+ <groupId>io.dropwizard</groupId>
+ <artifactId>dropwizard-jdbi</artifactId>
+ <version>0.8.0</version>
+ </dependency>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.40</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore</artifactId>
+ <version>4.4.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpmime</artifactId>
+ <version>4.4.1</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ <version>1.6.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito</artifactId>
+ <version>1.6.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.9.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.9.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.7.12</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/wfenginemgrservice/src/main/java/org/onap/workflow/WorkflowApp.java b/wfenginemgrservice/src/main/java/org/onap/workflow/WorkflowApp.java
new file mode 100644
index 0000000..23f6ac6
--- /dev/null
+++ b/wfenginemgrservice/src/main/java/org/onap/workflow/WorkflowApp.java
@@ -0,0 +1,42 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * 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 org.onap.workflow;
+
+import org.glassfish.jersey.media.multipart.MultiPartFeature;
+import org.onap.workflow.common.Config;
+
+import io.dropwizard.Application;
+import io.dropwizard.setup.Environment;
+
+public class WorkflowApp extends Application<WorkflowAppConfig> {
+
+ public static void main(String[] args) throws Exception {
+ new WorkflowApp().run(args);
+ }
+
+ public String getName() {
+ return " Workflow APP ";
+ }
+
+ @Override
+ public void run(WorkflowAppConfig configuration, Environment environment) throws Exception {
+ // TODO Auto-generated method stub
+ environment.jersey().register(MultiPartFeature.class);
+
+ Config.setWorkflowAppConfig(configuration);
+ }
+}
diff --git a/wfenginemgrservice/src/main/java/org/onap/workflow/WorkflowAppConfig.java b/wfenginemgrservice/src/main/java/org/onap/workflow/WorkflowAppConfig.java
new file mode 100644
index 0000000..71985cc
--- /dev/null
+++ b/wfenginemgrservice/src/main/java/org/onap/workflow/WorkflowAppConfig.java
@@ -0,0 +1,43 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * 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 org.onap.workflow;
+
+import javax.validation.Valid;
+
+import org.hibernate.validator.constraints.NotEmpty;
+import org.onap.workflow.entity.MsbClientConfig;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import io.dropwizard.Configuration;
+
+public class WorkflowAppConfig extends Configuration {
+
+ @NotEmpty
+ private String defaultName = "WORKFLOW-ACTIVITI-EXT";
+ @NotEmpty
+ @JsonProperty
+ private String apidescription = "ZTE workflow-activiti-ext rest API";
+
+ @JsonProperty
+ @Valid
+ private MsbClientConfig msbClientConfig;
+
+ public MsbClientConfig getMsbClientConfig() {
+ return msbClientConfig;
+ }
+}
diff --git a/wfenginemgrservice/src/main/java/org/onap/workflow/activitiext/common/ToolUtil.java b/wfenginemgrservice/src/main/java/org/onap/workflow/activitiext/common/ToolUtil.java
new file mode 100644
index 0000000..fe573e2
--- /dev/null
+++ b/wfenginemgrservice/src/main/java/org/onap/workflow/activitiext/common/ToolUtil.java
@@ -0,0 +1,52 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * 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 org.onap.workflow.activitiext.common;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+
+public class ToolUtil {
+ private static final Logger logger = LoggerFactory.getLogger(ToolUtil.class);
+ public static boolean isEmptyString(String val) {
+ return ((val == null || "".equals(val)) ? true : false);
+ }
+
+ public static boolean isTrimedEmptyString(String val) {
+ return ((val == null || "".equals(val.trim())) ? true : false);
+ }
+
+ public static boolean isTrimedEmptyArray(String[] val) {
+ return ((val == null || val.length == 0) ? true : false);
+ }
+
+ /**
+ * @param ins
+ */
+ public static void closeInputStream(InputStream ins) {
+ if (ins != null) {
+ try {
+ ins.close();
+ } catch (IOException e) {
+ logger.info("Close InputStream failed.", e);
+ }
+ }
+ }
+}
diff --git a/wfenginemgrservice/src/main/java/org/onap/workflow/activitiext/common/package-info.java b/wfenginemgrservice/src/main/java/org/onap/workflow/activitiext/common/package-info.java
new file mode 100644
index 0000000..d64450f
--- /dev/null
+++ b/wfenginemgrservice/src/main/java/org/onap/workflow/activitiext/common/package-info.java
@@ -0,0 +1,16 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * 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 org.onap.workflow.activitiext.common; \ No newline at end of file
diff --git a/wfenginemgrservice/src/main/java/org/onap/workflow/common/Config.java b/wfenginemgrservice/src/main/java/org/onap/workflow/common/Config.java
new file mode 100644
index 0000000..49dc227
--- /dev/null
+++ b/wfenginemgrservice/src/main/java/org/onap/workflow/common/Config.java
@@ -0,0 +1,31 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * 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 org.onap.workflow.common;
+
+import org.onap.workflow.WorkflowAppConfig;
+
+public class Config {
+ private static WorkflowAppConfig workflowAppConfig;
+
+ public static WorkflowAppConfig getWorkflowAppConfig() {
+ return workflowAppConfig;
+ }
+
+ public static void setWorkflowAppConfig(WorkflowAppConfig config) {
+ workflowAppConfig = config;
+ }
+} \ No newline at end of file
diff --git a/wfenginemgrservice/src/main/java/org/onap/workflow/common/EnumModuleUrl.java b/wfenginemgrservice/src/main/java/org/onap/workflow/common/EnumModuleUrl.java
new file mode 100644
index 0000000..00f10d8
--- /dev/null
+++ b/wfenginemgrservice/src/main/java/org/onap/workflow/common/EnumModuleUrl.java
@@ -0,0 +1,33 @@
+/**
+ * Copyright 2017 [ZTE] and others.
+ *
+ * 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 org.onap.workflow.common;
+
+public enum EnumModuleUrl {
+ ACTIVITI {
+ @Override
+ public String getApiRootDomain() {
+ return "/activiti-rest/service";
+ }
+ };
+
+ public abstract String getApiRootDomain();
+
+ public static String getBaseUrl(EnumModuleUrl enumUrl) {
+ String msbHost = Config.getWorkflowAppConfig().getMsbClientConfig().getMsbSvrIp();
+ return "http://" + msbHost + ":" + "80" + enumUrl.getApiRootDomain();
+ }
+
+}
diff --git a/wfenginemgrservice/src/main/java/org/onap/workflow/common/EnumStatus.java b/wfenginemgrservice/src/main/java/org/onap/workflow/common/EnumStatus.java
new file mode 100644
index 0000000..e2d1c5c
--- /dev/null
+++ b/wfenginemgrservice/src/main/java/org/onap/workflow/common/EnumStatus.java
@@ -0,0 +1,21 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * 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 org.onap.workflow.common;
+
+public enum EnumStatus {
+ SUCCESS, FAIL
+}
diff --git a/wfenginemgrservice/src/main/java/org/onap/workflow/common/RestClient.java b/wfenginemgrservice/src/main/java/org/onap/workflow/common/RestClient.java
new file mode 100644
index 0000000..f037757
--- /dev/null
+++ b/wfenginemgrservice/src/main/java/org/onap/workflow/common/RestClient.java
@@ -0,0 +1,310 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * 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 org.onap.workflow.common;
+
+import java.io.IOException;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpHost;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.ResponseHandler;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.BasicResponseHandler;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+import org.onap.workflow.externalservice.entity.activitientitiy.ActivitiStartProcessRequest;
+import org.onap.workflow.tools.Constants;
+import org.onap.workflow.tools.HttpDeleteWithBody;
+import org.onap.workflow.tools.RequestParameters;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.gson.Gson;
+
+public class RestClient {
+ private static final String HTTP = "http";
+ private static final Logger logger = LoggerFactory.getLogger(RestClient.class);
+
+ enum HttpMethod {
+ GET, POST, PUT, DELETE
+ }
+
+ /**
+ *
+ * @param method
+ * @param ip
+ * @param port
+ * @param url
+ * @param body
+ * @return
+ * @throws ClientProtocolException
+ * @throws IOException
+ */
+ public static RestResponse executeHttp(HttpMethod method, String ip, Integer port, String url,
+ HttpEntity body) throws ClientProtocolException, IOException {
+ logger.info("deployfile method send");
+ CloseableHttpClient httpclient = HttpClients.createDefault();
+ HttpResponse httpResponse = null;
+ RestResponse result = new RestResponse();
+ try {
+ if (ip == null) {
+ ip = Config.getWorkflowAppConfig().getMsbClientConfig().getMsbSvrIp();
+ }
+ if (port == null) {
+ port = Config.getWorkflowAppConfig().getMsbClientConfig().getMsbSvrPort();
+ }
+ HttpHost target = new HttpHost(ip, port, HTTP);
+ HttpRequest request = getRequest(method, url, body);
+ logger.info("deployfile method send ip"+ip);
+ request.addHeader(Constants.AUTHORIZATION, ToolUtil.getHeader());
+
+ httpResponse = httpclient.execute(target, request);
+ HttpEntity entity = httpResponse.getEntity();
+ logger.info("deployfile method send");
+ if (entity != null) {
+ result.setStatusCode(httpResponse.getStatusLine().getStatusCode());
+ logger.info("reply status code deploy"+httpResponse.getStatusLine().getStatusCode());
+ result.setResult(EntityUtils.toString(entity));
+ }
+ } catch (IOException e) {
+ logger.warn("Close httpclient failed.", e);
+ } finally {
+ if (httpclient != null) {
+ try {
+ httpclient.close();
+ } catch (IOException e) {
+ logger.warn("Close httpclient failed.", e);
+ }
+ }
+ }
+ return result;
+ }
+
+ private static HttpRequest getRequest(HttpMethod method, String url, HttpEntity body) {
+ HttpRequest request = null;
+ switch (method) {
+ case GET:
+ request = new HttpGet(url);
+ break;
+ case POST:
+ request = new HttpPost(url);
+ ((HttpPost) request).setEntity(body);
+ break;
+ case PUT:
+ request = new HttpPut(url);
+ ((HttpPut) request).setEntity(body);
+ break;
+ case DELETE:
+ request = new HttpDelete(url);
+ break;
+ default:
+ break;
+ }
+ return request;
+ }
+
+ /**
+ *
+ * @param ip
+ * @param port
+ * @param url
+ * @return
+ * @throws ClientProtocolException
+ * @throws IOException
+ */
+ public static String get(String ip, int port, String url)
+ throws ClientProtocolException, IOException {
+ return executeHttp(HttpMethod.GET, ip, port, url, null).getResult();
+ }
+
+ /**
+ *
+ * @param ip
+ * @param port
+ * @param url
+ * @return
+ * @throws ClientProtocolException
+ * @throws IOException
+ */
+ public static RestResponse delete(String ip, int port, String url)
+ throws ClientProtocolException, IOException {
+ return executeHttp(HttpMethod.GET, ip, port, url, null);
+ }
+
+ /**
+ *
+ * @param ip
+ * @param port
+ * @param url
+ * @param requestBody
+ * @return
+ * @throws ClientProtocolException
+ * @throws IOException
+ */
+ public static RestResponse post(String ip, int port, String url, HttpEntity requestBody)
+ throws ClientProtocolException, IOException {
+ return executeHttp(HttpMethod.POST, ip, port, url, requestBody);
+ }
+
+
+
+ /**
+ *
+ * @param method
+ * @param ip
+ * @param port
+ * @param url
+ * @param body
+ * @return
+ * @throws ClientProtocolException
+ * @throws IOException
+ */
+ public static RestResponse executeHttpDeleteDeploy(HttpMethod method, String ip, Integer port,
+ String url) throws ClientProtocolException, IOException {
+ if (ip == null) {
+ ip = Config.getWorkflowAppConfig().getMsbClientConfig().getMsbSvrIp();
+ }
+ port = Config.getWorkflowAppConfig().getMsbClientConfig().getMsbSvrPort();
+ RestResponse result = new RestResponse();
+ CloseableHttpClient httpClient = HttpClients.createDefault();
+ try {
+ httpClient = HttpClients.createDefault();
+ // "http://localhost:8080/activiti-rest/service/repository/deployments/167501"
+ String deleteUrl = Constants.HTTP_HEADER + ip + Constants.COLON + port + url;
+ HttpDeleteWithBody httpDeteTest = new HttpDeleteWithBody(deleteUrl);
+ Gson gson = new Gson();
+ RequestParameters reqPa = new RequestParameters();
+ reqPa.setCasCade(true);
+ String jsonStr = gson.toJson(reqPa, RequestParameters.class);
+ StringEntity requestEntity = new StringEntity(jsonStr, "UTF-8");
+ requestEntity.setContentEncoding("UTF-8");
+ httpDeteTest.setHeader("Content-type", "application/json");
+ httpDeteTest.setHeader(Constants.AUTHORIZATION, ToolUtil.getHeader());
+ httpDeteTest.setEntity(new StringEntity(jsonStr));
+ // returnValue = httpClient.execute(httpDeteTest, responseHandler); // 调接口获取返回值时,必须用此方法
+ CloseableHttpResponse httpResonse = httpClient.execute(httpDeteTest);
+ int statusCode = httpResonse.getStatusLine().getStatusCode();
+ result.setStatusCode(statusCode);
+ // result.setResult(EntityUtils.toString(httpResonse.getEntity()));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ finally {
+ try {
+ httpClient.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * @param method
+ * @param ip
+ * @param port
+ * @param url
+ * @param body
+ * @return
+ * @throws ClientProtocolException
+ * @throws IOException
+ */
+ public static RestResponse executeHttpStartIntance(HttpMethod method, String ip, Integer port,
+ String url, ActivitiStartProcessRequest object) throws ClientProtocolException, IOException {
+ String returnValue = "";
+ RestResponse result = new RestResponse();
+ CloseableHttpClient httpClient = HttpClients.createDefault();
+ ResponseHandler<String> responseHandler = new BasicResponseHandler();
+ try {
+ httpClient = HttpClients.createDefault();
+ if (ip == null) {
+ ip = Config.getWorkflowAppConfig().getMsbClientConfig().getMsbSvrIp();
+ }
+ port = Config.getWorkflowAppConfig().getMsbClientConfig().getMsbSvrPort();
+
+ HttpPost httpPost = new HttpPost(Constants.HTTP_HEADER + ip + ":" + port + url);
+ Gson gson = new Gson();
+ String jsonStr = gson.toJson(object, ActivitiStartProcessRequest.class);
+ StringEntity requestEntity = new StringEntity(jsonStr, "utf-8");
+ requestEntity.setContentEncoding("UTF-8");
+ httpPost.setHeader("Content-type", "application/json");
+ httpPost.setHeader(Constants.AUTHORIZATION, ToolUtil.getHeader());
+ httpPost.setEntity(requestEntity);
+ returnValue = httpClient.execute(httpPost, responseHandler); // 调接口获取返回值时,必须用此方法
+ CloseableHttpResponse httpResonse = httpClient.execute(httpPost);
+ int statusCode = httpResonse.getStatusLine().getStatusCode();
+ returnValue = EntityUtils.toString(httpResonse.getEntity(),"UTF-8");
+ result.setStatusCode(statusCode);
+ result.setResult(returnValue);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ finally {
+ try {
+ httpClient.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * @param ip
+ * @param port
+ * @param url
+ * @param requestBody
+ * @return
+ * @throws ClientProtocolException
+ * @throws IOException
+ */
+ public static RestResponse post(String ip, Integer port, String url,
+ ActivitiStartProcessRequest requestBody) throws ClientProtocolException, IOException {
+ return executeHttpStartIntance(HttpMethod.POST, ip, port, url, requestBody);
+ }
+
+ /**
+ *
+ * @param ip
+ * @param port
+ * @param url
+ * @param requestBody
+ * @return
+ * @throws ClientProtocolException
+ * @throws IOException
+ */
+ public static RestResponse post(String ip, Integer port, String url)
+ throws ClientProtocolException, IOException {
+ return executeHttpDeleteDeploy(HttpMethod.DELETE, ip, port, url);
+ }
+
+}
diff --git a/wfenginemgrservice/src/main/java/org/onap/workflow/common/RestClientUtils.java b/wfenginemgrservice/src/main/java/org/onap/workflow/common/RestClientUtils.java
new file mode 100644
index 0000000..d90077c
--- /dev/null
+++ b/wfenginemgrservice/src/main/java/org/onap/workflow/common/RestClientUtils.java
@@ -0,0 +1,42 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * 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 org.onap.workflow.common;
+
+import java.io.InputStream;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.mime.MultipartEntityBuilder;
+
+/**
+ *
+ * @author 10090474
+ *
+ */
+public class RestClientUtils {
+ /**
+ *
+ * @param ins
+ * @param fileName
+ * @return
+ */
+ public static HttpEntity buildMultipartRequest(InputStream ins, String fileName) {
+ MultipartEntityBuilder builder = MultipartEntityBuilder.create();
+ builder.seContentType(ContentType.MULTIPART_FORM_DATA);
+ builder.addBinaryBody("file", ins, ContentType.APPLICATION_OCTET_STREAM, fileName);
+ return builder.build();
+ }
+}
diff --git a/wfenginemgrservice/src/main/java/org/onap/workflow/common/RestResponse.java b/wfenginemgrservice/src/main/java/org/onap/workflow/common/RestResponse.java
new file mode 100644
index 0000000..21467bf
--- /dev/null
+++ b/wfenginemgrservice/src/main/java/org/onap/workflow/common/RestResponse.java
@@ -0,0 +1,37 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * 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 org.onap.workflow.common;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class RestResponse {
+ private int statusCode;
+ private String result;
+
+ @Override
+ public String toString() {
+ return "RestResponse [statusCode=" + statusCode + ", result=" + result + "]";
+ }
+
+}
diff --git a/wfenginemgrservice/src/main/java/org/onap/workflow/common/ToolUtil.java b/wfenginemgrservice/src/main/java/org/onap/workflow/common/ToolUtil.java
new file mode 100644
index 0000000..c148eb3
--- /dev/null
+++ b/wfenginemgrservice/src/main/java/org/onap/workflow/common/ToolUtil.java
@@ -0,0 +1,67 @@
+/**
+ * Copyright (C) 2017 ZTE, Inc. and others. All rights reserved. (ZTE)
+ *
+ * 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 org.onap.workflow.common;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+
+import org.apache.commons.codec.binary.Base64;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+
+public class ToolUtil {
+ private static final Logger logger = LoggerFactory.getLogger(ToolUtil.class);
+
+ /**
+ * 构造Basic Auth认证头信息
+ *
+ * @return
+ */
+ public static String getHeader() {
+ String auth = "kermit" + ":" +"kermit";
+ byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(Charset.forName("US-ASCII")));
+ String authHeader = "Basic " + new String(encodedAuth);
+ return authHeader;
+ }
+
+ public static boolean isEmptyString(String val) {
+ return ((val == null || "".equals(val)) ? true : false);
+ }
+
+ public static boolean isTrimedEmptyString(String val) {
+ return ((val == null || "".equals(val.trim())) ? true : false);
+ }
+
+ public static boolean isTrimedEmptyArray(String[] val) {
+ return ((val == null || val.length == 0) ? true : false);
+ }
+
+ /**
+ * @param ins
+ */
+ public static void closeInputStream(InputStream ins) {
+ if (ins != null) {
+ try {
+ ins.close();
+ } catch (IOException e) {
+ logger.info("Close InputStream failed.", e);
+ }
+ }
+ }
+}
diff --git a/wfenginemgrservice/src/main/java/org/onap/workflow/common/package-info.java b/wfenginemgrservice/src/main/java/org/onap/workflow/common/package-info.java
new file mode 100644
index 0000000..e47fcb8
--- /dev/null
+++ b/wfenginemgrservice/src/main/java/org/onap/workflow/common/package-info.java
@@ -0,0 +1,16 @@
+/**
+ * Copyright 2017 [ZTE] and others.
+ *
+ * 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 org.onap.workflow.common; \ No newline at end of file
diff --git a/wfenginemgrservice/src/main/java/org/onap/workflow/entity/DeployBpmnFileResponse.java b/wfenginemgrservice/src/main/java/org/onap/workflow/entity/DeployBpmnFileResponse.java
new file mode 100644
index 0000000..6a1920e
--- /dev/null
+++ b/wfenginemgrservice/src/main/java/org/onap/workflow/entity/DeployBpmnFileResponse.java
@@ -0,0 +1,31 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * 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 org.onap.workflow.entity;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class DeployBpmnFileResponse {
+ private int status;
+ private String message;
+ private String deployedId;
+ private String processId;
+}
diff --git a/wfenginemgrservice/src/main/java/org/onap/workflow/entity/MsbClientConfig.java b/wfenginemgrservice/src/main/java/org/onap/workflow/entity/MsbClientConfig.java
new file mode 100644
index 0000000..e73c4f2
--- /dev/null
+++ b/wfenginemgrservice/src/main/java/org/onap/workflow/entity/MsbClientConfig.java
@@ -0,0 +1,26 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * 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 org.onap.workflow.entity;
+
+import lombok.Data;
+
+@Data
+public class MsbClientConfig {
+
+ private String msbSvrIp;
+ private Integer msbSvrPort;
+}
diff --git a/wfenginemgrservice/src/main/java/org/onap/workflow/entity/StartProcessRequest.java b/wfenginemgrservice/src/main/java/org/onap/workflow/entity/StartProcessRequest.java
new file mode 100644
index 0000000..cddaa09
--- /dev/null
+++ b/wfenginemgrservice/src/main/java/org/onap/workflow/entity/StartProcessRequest.java
@@ -0,0 +1,33 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * 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 org.onap.workflow.entity;
+
+import java.util.Map;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class StartProcessRequest {
+ private String processDefinitionKey;
+ private Map<String, String> params;
+}
diff --git a/wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/entity/activitientitiy/ActivitiDeployResponse.java b/wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/entity/activitientitiy/ActivitiDeployResponse.java
new file mode 100644
index 0000000..5ad3d12
--- /dev/null
+++ b/wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/entity/activitientitiy/ActivitiDeployResponse.java
@@ -0,0 +1,25 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * 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 org.onap.workflow.externalservice.entity.activitientitiy;
+
+import lombok.Data;
+
+@Data
+public class ActivitiDeployResponse {
+ private String id;
+ private String deploymentTime;
+ private String url;
+}
diff --git a/wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/entity/activitientitiy/ActivitiStartProcessRequest.java b/wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/entity/activitientitiy/ActivitiStartProcessRequest.java
new file mode 100644
index 0000000..ae7edf1
--- /dev/null
+++ b/wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/entity/activitientitiy/ActivitiStartProcessRequest.java
@@ -0,0 +1,25 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * 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 org.onap.workflow.externalservice.entity.activitientitiy;
+
+import lombok.Data;
+
+@Data
+public class ActivitiStartProcessRequest {
+ private String processDefinitionKey;
+ private ActivitiStartProcessRequestParam[] variables;
+}
diff --git a/wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/entity/activitientitiy/ActivitiStartProcessRequestParam.java b/wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/entity/activitientitiy/ActivitiStartProcessRequestParam.java
new file mode 100644
index 0000000..35dc487
--- /dev/null
+++ b/wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/entity/activitientitiy/ActivitiStartProcessRequestParam.java
@@ -0,0 +1,27 @@
+/**
+ * Copyright 2017 [ZTE] and others.
+ *
+ * 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 org.onap.workflow.externalservice.entity.activitientitiy;
+
+import lombok.Data;
+
+/**
+ *
+ */
+@Data
+public class ActivitiStartProcessRequestParam {
+ private String name;
+ private String value;
+}
diff --git a/wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/entity/activitientitiy/package-info.java b/wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/entity/activitientitiy/package-info.java
new file mode 100644
index 0000000..102c36f
--- /dev/null
+++ b/wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/entity/activitientitiy/package-info.java
@@ -0,0 +1,19 @@
+/**
+ * Copyright 2017 [ZTE] and others.
+ *
+ * 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 org.onap.workflow.externalservice.entity.activitientitiy; \ No newline at end of file
diff --git a/wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/service/activitiservice/ActivitiServiceConsumer.java b/wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/service/activitiservice/ActivitiServiceConsumer.java
new file mode 100644
index 0000000..017cf35
--- /dev/null
+++ b/wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/service/activitiservice/ActivitiServiceConsumer.java
@@ -0,0 +1,142 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * 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 org.onap.workflow.externalservice.service.activitiservice;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.ws.rs.core.Response;
+
+import org.apache.http.client.ClientProtocolException;
+import org.glassfish.jersey.client.ClientConfig;
+import org.onap.workflow.common.Config;
+import org.onap.workflow.common.EnumModuleUrl;
+import org.onap.workflow.common.RestClient;
+import org.onap.workflow.common.RestClientUtils;
+import org.onap.workflow.common.RestResponse;
+import org.onap.workflow.common.ToolUtil;
+import org.onap.workflow.externalservice.entity.activitientitiy.ActivitiDeployResponse;
+import org.onap.workflow.externalservice.entity.activitientitiy.ActivitiStartProcessRequest;
+import org.onap.workflow.tools.Constants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
+import com.google.gson.Gson;
+
+/**
+ *
+ * @author 10090474
+ *
+ */
+public class ActivitiServiceConsumer {
+ private static final Logger logger = LoggerFactory.getLogger(ActivitiServiceConsumer.class);
+ private static final String DEPLOY_BPMNFILE_URL =
+ EnumModuleUrl.ACTIVITI.getApiRootDomain() + "/repository/deployments";
+
+ private static IActivitiRestService activitiServiceProxy = null;
+
+ private static IActivitiRestService getActivitiService() {
+ if (activitiServiceProxy == null) {
+ ClientConfig config = new ClientConfig();
+ activitiServiceProxy = ConsumerFactory.createConsumer(
+ EnumModuleUrl.getBaseUrl(EnumModuleUrl.ACTIVITI), config, IActivitiRestService.class);
+
+ }
+ return activitiServiceProxy;
+ }
+
+ public static RestResponse undeploybpmnfile(String deploymentId) {
+ /*
+ * IActivitiRestService activitiProxy = getActivitiService();
+ * activitiProxy.undeployBpmnFile(deploymentId);
+ */
+ RestResponse res = deleteDeployProcess(deploymentId);
+ // activitiProxy.startProcess(request);
+
+ return res;
+ }
+
+ public static RestResponse startBpmnProcess(ActivitiStartProcessRequest request) {
+ // IActivitiRestService activitiProxy = getActivitiService();
+ // startProcess( request);
+ // activitiProxy.startProcess(request);
+ return startProcess(request);
+ }
+
+ public static RestResponse deleteDeployProcess(String deploymentId) {
+ // TODO Auto-generated method stub
+ RestResponse res = null;
+ try {
+ res = RestClient.post(null, null, Constants.DEPLOY_BPMNFILE_URL + "/" + deploymentId);
+ } catch (ClientProtocolException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return res;
+ }
+
+ public static RestResponse startProcess(ActivitiStartProcessRequest request) {
+ // TODO Auto-generated method stub
+ RestResponse res = null;
+ try {
+ res = RestClient.post(null, null, Constants.ACITIVI_START_INSTANCE_URL, request);
+ } catch (ClientProtocolException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ // if (Response.Status.OK.getStatusCode() == res.getStatusCode()
+ // || Response.Status.CREATED.getStatusCode() == res.getStatusCode()) {
+ // Response response = new Gson().fromJson(res.getResult(), Response.class);
+ // return response;
+ // }
+ return res;
+ }
+
+ public static ActivitiDeployResponse deploybpmnfile(InputStream ins, String filename)
+ throws ClientProtocolException, IOException {
+ try {
+ return deployPackage2Activiti(ins, filename);
+ } finally {
+ ToolUtil.closeInputStream(ins);
+ }
+ }
+
+ private static ActivitiDeployResponse deployPackage2Activiti(InputStream ins, String filename)
+ throws ClientProtocolException, IOException {
+ String ip = Config.getWorkflowAppConfig().getMsbClientConfig().getMsbSvrIp();
+ int port = Config.getWorkflowAppConfig().getMsbClientConfig().getMsbSvrPort();
+ RestResponse res = RestClient.post(ip, port, DEPLOY_BPMNFILE_URL,
+ RestClientUtils.buildMultipartRequest(ins, filename));
+ logger.info("deployfile to activiti return. {}", res);
+
+ if (Response.Status.OK.getStatusCode() == res.getStatusCode()
+ || Response.Status.CREATED.getStatusCode() == res.getStatusCode()) {
+ ActivitiDeployResponse response =
+ new Gson().fromJson(res.getResult(), ActivitiDeployResponse.class);
+ return response;
+ }
+ return null;
+ }
+}
diff --git a/wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/service/activitiservice/IActivitiRestService.java b/wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/service/activitiservice/IActivitiRestService.java
new file mode 100644
index 0000000..b2a8366
--- /dev/null
+++ b/wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/service/activitiservice/IActivitiRestService.java
@@ -0,0 +1,44 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * 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 org.onap.workflow.externalservice.service.activitiservice;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.onap.workflow.externalservice.entity.activitientitiy.ActivitiStartProcessRequest;
+
+@Path("/")
+public interface IActivitiRestService {
+ @Path("/repository/deployments/{deploymentId}")
+ @DELETE
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ Response undeployBpmnFile(@PathParam("deploymentId") String deploymentId);
+
+
+ @Path("/runtime/process-instances")
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ Response startProcess(ActivitiStartProcessRequest request);
+}
diff --git a/wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/service/activitiservice/package-info.java b/wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/service/activitiservice/package-info.java
new file mode 100644
index 0000000..a32e966
--- /dev/null
+++ b/wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/service/activitiservice/package-info.java
@@ -0,0 +1,17 @@
+/**
+ * Copyright 2017 [ZTE] and others.
+ *
+ * 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 org.onap.workflow.externalservice.service.activitiservice; \ No newline at end of file
diff --git a/wfenginemgrservice/src/main/java/org/onap/workflow/resources/WorkflowResource.java b/wfenginemgrservice/src/main/java/org/onap/workflow/resources/WorkflowResource.java
new file mode 100644
index 0000000..5450d75
--- /dev/null
+++ b/wfenginemgrservice/src/main/java/org/onap/workflow/resources/WorkflowResource.java
@@ -0,0 +1,101 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * 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 org.onap.workflow.resources;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+
+import java.io.InputStream;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.eclipse.jetty.http.HttpStatus;
+import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
+import org.glassfish.jersey.media.multipart.FormDataParam;
+import org.jvnet.hk2.annotations.Service;
+import org.onap.workflow.common.RestResponse;
+import org.onap.workflow.entity.DeployBpmnFileResponse;
+import org.onap.workflow.entity.StartProcessRequest;
+import org.onap.workflow.wrapper.WorkflowInstanceWrapper;
+
+@Path("/")
+@Api(tags = {"Workflow Resource"})
+@Produces(MediaType.APPLICATION_JSON)
+@Service
+public class WorkflowResource {
+ @POST
+ @Path("/package")
+ @Consumes({"multipart/form-data"})
+ @Produces({"application/json"})
+ @ApiOperation(value = "deploy bpmn file")
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
+ response = DeployBpmnFileResponse.class),
+ @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
+ message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
+ @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "error")})
+ public Response deployBpmnFile(
+ @ApiParam(value = "file inputstream",
+ required = true) @FormDataParam("file") InputStream fileInputStream,
+ @ApiParam(value = "file detail",
+ required = false) @FormDataParam("file") FormDataContentDisposition fileDetail) {
+ return WorkflowInstanceWrapper.getInstance().deployBpmnFile(fileDetail.getFileName(),
+ fileInputStream, null);
+ }
+
+ @Path("/package/{deployId}")
+ @DELETE
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "undeploy bpmn file")
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
+ response = DeployBpmnFileResponse.class),
+ @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
+ message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
+ @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "error")})
+ public RestResponse undeployBpmnFile(
+ @ApiParam("deployId") @PathParam("deployId") String deployId) {
+ return WorkflowInstanceWrapper.getInstance().undeployBpmnFile(deployId);
+ }
+
+ @Path("process/instance")
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "package process")
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
+ response = DeployBpmnFileResponse.class),
+ @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
+ message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
+ @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "error")})
+ public Response startProcess(
+ @ApiParam(value = "request", required = false) StartProcessRequest request) {
+ return WorkflowInstanceWrapper.getInstance().startProcess(request);
+ }
+}
diff --git a/wfenginemgrservice/src/main/java/org/onap/workflow/tools/Constants.java b/wfenginemgrservice/src/main/java/org/onap/workflow/tools/Constants.java
new file mode 100644
index 0000000..15aac35
--- /dev/null
+++ b/wfenginemgrservice/src/main/java/org/onap/workflow/tools/Constants.java
@@ -0,0 +1,29 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * 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 org.onap.workflow.tools;
+
+import org.onap.workflow.common.EnumModuleUrl;
+
+public class Constants {
+ public final static String AUTHORIZATION ="Authorization";
+ public final static String HTTP_HEADER ="http://";
+ public final static String HTTP ="HTTP";
+ public final static String COLON =":";
+ public static final String ACITIVI_START_INSTANCE_URL =
+ EnumModuleUrl.ACTIVITI.getApiRootDomain() + "/runtime/process-instances";
+ public static final String DEPLOY_BPMNFILE_URL = EnumModuleUrl.ACTIVITI.getApiRootDomain() + "/repository/deployments";
+}
diff --git a/wfenginemgrservice/src/main/java/org/onap/workflow/tools/HttpDeleteWithBody.java b/wfenginemgrservice/src/main/java/org/onap/workflow/tools/HttpDeleteWithBody.java
new file mode 100644
index 0000000..8fcc7a0
--- /dev/null
+++ b/wfenginemgrservice/src/main/java/org/onap/workflow/tools/HttpDeleteWithBody.java
@@ -0,0 +1,37 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * 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 org.onap.workflow.tools;
+
+import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
+import java.net.URI;
+import org.apache.http.annotation.NotThreadSafe;
+
+@NotThreadSafe
+public class HttpDeleteWithBody extends HttpEntityEnclosingRequestBase {
+ public static final String METHOD_NAME = "DELETE";
+ public String getMethod() { return METHOD_NAME; }
+
+ public HttpDeleteWithBody(final String uri) {
+ super();
+ setURI(URI.create(uri));
+ }
+ public HttpDeleteWithBody(final URI uri) {
+ super();
+ setURI(uri);
+ }
+ public HttpDeleteWithBody() { super(); }
+} \ No newline at end of file
diff --git a/wfenginemgrservice/src/main/java/org/onap/workflow/tools/RequestParameters.java b/wfenginemgrservice/src/main/java/org/onap/workflow/tools/RequestParameters.java
new file mode 100644
index 0000000..b8e76d8
--- /dev/null
+++ b/wfenginemgrservice/src/main/java/org/onap/workflow/tools/RequestParameters.java
@@ -0,0 +1,35 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * 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 org.onap.workflow.tools;
+
+import lombok.Data;
+
+/**
+ * @author 10175158
+ *
+ */
+@Data
+public class RequestParameters {
+
+ protected boolean casCade;
+ @Override
+ public String toString() {
+ return "casCade [casCade=" + casCade + "]";
+ }
+}
+
+
diff --git a/wfenginemgrservice/src/main/java/org/onap/workflow/tools/package-info.java b/wfenginemgrservice/src/main/java/org/onap/workflow/tools/package-info.java
new file mode 100644
index 0000000..afd5cfc
--- /dev/null
+++ b/wfenginemgrservice/src/main/java/org/onap/workflow/tools/package-info.java
@@ -0,0 +1,17 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * 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 org.onap.workflow.tools;
diff --git a/wfenginemgrservice/src/main/java/org/onap/workflow/wrapper/WorkflowInstanceWrapper.java b/wfenginemgrservice/src/main/java/org/onap/workflow/wrapper/WorkflowInstanceWrapper.java
new file mode 100644
index 0000000..5bc734d
--- /dev/null
+++ b/wfenginemgrservice/src/main/java/org/onap/workflow/wrapper/WorkflowInstanceWrapper.java
@@ -0,0 +1,98 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * 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 org.onap.workflow.wrapper;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ws.rs.core.Response;
+
+import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
+import org.onap.workflow.common.EnumStatus;
+import org.onap.workflow.common.RestResponse;
+import org.onap.workflow.entity.DeployBpmnFileResponse;
+import org.onap.workflow.entity.StartProcessRequest;
+import org.onap.workflow.externalservice.entity.activitientitiy.ActivitiDeployResponse;
+import org.onap.workflow.externalservice.entity.activitientitiy.ActivitiStartProcessRequest;
+import org.onap.workflow.externalservice.entity.activitientitiy.ActivitiStartProcessRequestParam;
+import org.onap.workflow.externalservice.service.activitiservice.ActivitiServiceConsumer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class WorkflowInstanceWrapper {
+ private static final Logger logger = LoggerFactory.getLogger(WorkflowInstanceWrapper.class);
+
+ private static WorkflowInstanceWrapper wrapper = new WorkflowInstanceWrapper();
+
+ public static WorkflowInstanceWrapper getInstance() {
+ return wrapper;
+ }
+
+ public Response deployBpmnFile(String filename, InputStream fileInputStream,
+ FormDataContentDisposition fileDetail) {
+ try {
+ ActivitiDeployResponse deployresult =
+ ActivitiServiceConsumer.deploybpmnfile(fileInputStream, filename);
+ if (deployresult != null) {
+ DeployBpmnFileResponse result = new DeployBpmnFileResponse();
+ result.setStatus(EnumStatus.SUCCESS.ordinal());
+ result.setMessage(EnumStatus.SUCCESS.toString());
+ result.setDeployedId(deployresult.getId());
+ result.setProcessId(filename);
+ return Response.ok(result).build();
+ }
+ } catch (Exception e) {
+ logger.error("deployBpmnFile fail.", e);
+ }
+ return Response.serverError().build();
+ }
+
+ public RestResponse undeployBpmnFile(String deployId) {
+ return ActivitiServiceConsumer.undeploybpmnfile(deployId);
+ }
+
+ public Response startProcess(StartProcessRequest request) {
+ try {
+ ActivitiStartProcessRequest bpmnrequest = new ActivitiStartProcessRequest();
+ bpmnrequest.setProcessDefinitionKey(request.getProcessDefinitionKey());
+ if (request.getParams() != null) {
+ List<ActivitiStartProcessRequestParam> paramlist = convertProcessRequest(request);
+ bpmnrequest.setVariables(paramlist.toArray(new ActivitiStartProcessRequestParam[0]));
+ }
+ RestResponse result = ActivitiServiceConsumer.startBpmnProcess(bpmnrequest);
+ return Response.ok(result.getResult()).build();
+ } catch (Exception e) {
+ logger.error("startProcess fail.", e);
+ }
+ return Response.serverError().build();
+ }
+
+ private List<ActivitiStartProcessRequestParam> convertProcessRequest(
+ StartProcessRequest request) {
+ List<ActivitiStartProcessRequestParam> paramlist =
+ new ArrayList<ActivitiStartProcessRequestParam>();
+ while (request.getParams().keySet().iterator().hasNext()) {
+ String key = request.getParams().keySet().iterator().next();
+ ActivitiStartProcessRequestParam param = new ActivitiStartProcessRequestParam();
+ param.setName(key);
+ param.setValue(request.getParams().get(key));
+ paramlist.add(param);
+ }
+ return paramlist;
+ }
+}
diff --git a/wfenginemgrservice/src/main/resources/api-doc/index.html b/wfenginemgrservice/src/main/resources/api-doc/index.html
new file mode 100644
index 0000000..092c1c8
--- /dev/null
+++ b/wfenginemgrservice/src/main/resources/api-doc/index.html
@@ -0,0 +1,99 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Swagger UI</title>
+ <link href='css/typography.css' media='screen' rel='stylesheet' type='text/css'/>
+ <link href='css/reset.css' media='screen' rel='stylesheet' type='text/css'/>
+ <link href='css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
+ <link href='css/reset.css' media='print' rel='stylesheet' type='text/css'/>
+ <link href='css/screen.css' media='print' rel='stylesheet' type='text/css'/>
+ <script type="text/javascript" src="lib/shred.bundle.js"></script>
+ <script src='lib/jquery-1.8.0.min.js' type='text/javascript'></script>
+ <script src='lib/jquery.slideto.min.js' type='text/javascript'></script>
+ <script src='lib/jquery.wiggle.min.js' type='text/javascript'></script>
+ <script src='lib/jquery.ba-bbq.min.js' type='text/javascript'></script>
+ <script src='lib/handlebars-2.0.0.js' type='text/javascript'></script>
+ <script src='lib/underscore-min.js' type='text/javascript'></script>
+ <script src='lib/backbone-min.js' type='text/javascript'></script>
+ <script src='lib/swagger-client.js' type='text/javascript'></script>
+ <script src='swagger-ui.js' type='text/javascript'></script>
+ <script src='lib/highlight.7.3.pack.js' type='text/javascript'></script>
+ <script src='lib/marked.js' type='text/javascript'></script>
+
+ <!-- enabling this will enable oauth2 implicit scope support -->
+ <script src='lib/swagger-oauth.js' type='text/javascript'></script>
+ <script type="text/javascript">
+ $(function () {
+ var url = window.location.search.match(/url=([^&]+)/);
+ if (url && url.length > 1) {
+ url = decodeURIComponent(url[1]);
+ } else {
+ url = "/api/workflow/v1/swagger.json";
+ }
+ window.swaggerUi = new SwaggerUi({
+ url: url,
+ dom_id: "swagger-ui-container",
+ supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
+ onComplete: function(swaggerApi, swaggerUi){
+
+ if(typeof initOAuth == "function") {
+ /*
+ initOAuth({
+ clientId: "your-client-id",
+ realm: "your-realms",
+ appName: "your-app-name"
+ });
+ */
+ }
+ $('pre code').each(function(i, e) {
+ hljs.highlightBlock(e)
+ });
+ },
+ onFailure: function(data) {
+ log("Unable to Load SwaggerUI");
+ },
+ docExpansion: "none",
+ sorter : "alpha"
+ });
+
+ function addApiKeyAuthorization() {
+ var key = $('#input_apiKey')[0].value;
+ log("key: " + key);
+ if(key && key.trim() != "") {
+ log("added key " + key);
+ window.authorizations.add("api_key", new ApiKeyAuthorization("api_key", key, "query"));
+ }
+ }
+
+ $('#input_apiKey').change(function() {
+ addApiKeyAuthorization();
+ });
+
+ // if you have an apiKey you would like to pre-populate on the page for demonstration purposes...
+ /*
+ var apiKey = "myApiKeyXXXX123456789";
+ $('#input_apiKey').val(apiKey);
+ addApiKeyAuthorization();
+ */
+
+ window.swaggerUi.load();
+ });
+ </script>
+</head>
+
+<body class="swagger-section">
+<div id='header' style="display:none">
+ <div class="swagger-ui-wrap" >
+ <a id="logo" >zte conductor</a>
+ <form id='api_selector'>
+ <div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text"/></div>
+ <div class='input'><input placeholder="api_key" id="input_apiKey" name="apiKey" type="text"/></div>
+ <div class='input'><a id="explore" href="#">Explore</a></div>
+ </form>
+ </div>
+</div>
+
+<div id="message-bar" class="swagger-ui-wrap">&nbsp;</div>
+<div id="swagger-ui-container" class="swagger-ui-wrap"></div>
+</body>
+</html>
diff --git a/wfenginemgrservice/src/main/resources/banner.txt b/wfenginemgrservice/src/main/resources/banner.txt
new file mode 100644
index 0000000..ec90bd7
--- /dev/null
+++ b/wfenginemgrservice/src/main/resources/banner.txt
@@ -0,0 +1,6 @@
+ _ ____ _____ ___ __ __ ___ _____ ___ _____ __ __ _____
+ / \ / ___| |_ _| |_ _| \ \ / / |_ _| |_ _| |_ _| | ____| \ \/ / |_ _|
+ / _ \ | | | | | | \ \ / / | | | | | | _____ | _| \ / | |
+ / ___ \ | |___ | | | | \ V / | | | | | | |_____| | |___ / \ | |
+ /_/ \_\ \____| |_| |___| \_/ |___| |_| |___| |_____| /_/\_\ |_|
+ \ No newline at end of file