--- /dev/null
+### JAVA
+# Compiled class file
+*.class
+
+# Log file
+*.log
+
+# BlueJ files
+*.ctxt
+
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+
+# Package Files #
+*.jar
+*.war
+*.ear
+*.zip
+*.tar.gz
+*.rar
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+
+### MAVEN
+target/
+pom.xml.tag
+pom.xml.releaseBackup
+pom.xml.versionsBackup
+pom.xml.next
+release.properties
+dependency-reduced-pom.xml
+buildNumber.properties
+.mvn/timing.properties
+
+# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
+!/.mvn/wrapper/maven-wrapper.jar
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>\r
+<!-- Copyright 2016 ZTE Corporation. Licensed under the Apache License, Version \r
+ 2.0 (the "License"); you may not use this file except in compliance with \r
+ the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 \r
+ Unless required by applicable law or agreed to in writing, software distributed \r
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES \r
+ OR CONDITIONS OF ANY KIND, either express or implied. See the License for \r
+ the specific language governing permissions and limitations under the License. -->\r
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
+ <parent>\r
+ <groupId>org.onap.oparent</groupId>\r
+ <artifactId>oparent</artifactId>\r
+ <version>1.0.0-SNAPSHOT</version>\r
+ </parent>\r
+\r
+ <modelVersion>4.0.0</modelVersion>\r
+ <artifactId>activiti-extension</artifactId>\r
+ <name>workflow/activiti-extension</name>\r
+ <packaging>jar</packaging>\r
+\r
+ <properties>\r
+ <ant.version>1.9.6</ant.version>\r
+ <apache-velocity.version>1.6.2</apache-velocity.version>\r
+ <jgrapht.version>0.9.1</jgrapht.version>\r
+ </properties>\r
+\r
+ <build>\r
+ <plugins>\r
+ <plugin>\r
+ <groupId>org.eclipse.m2e</groupId>\r
+ <artifactId>lifecycle-mapping</artifactId>\r
+ <version>1.0.0</version>\r
+ <configuration>\r
+ <lifecycleMappingMetadata>\r
+ <pluginExecutions>\r
+ <pluginExecution>\r
+ <pluginExecutionFilter>\r
+ <groupId>org.apache.maven.plugins</groupId>\r
+ <artifactId>maven-dependency-plugin</artifactId>\r
+ <version>2.8</version>\r
+ <goals>\r
+ <goal>copy-dependencies</goal>\r
+ </goals>\r
+ </pluginExecutionFilter>\r
+ <action>\r
+ <ignore />\r
+ </action>\r
+ </pluginExecution>\r
+ </pluginExecutions>\r
+ </lifecycleMappingMetadata>\r
+ </configuration>\r
+ </plugin>\r
+ <plugin>\r
+ <groupId>org.apache.maven.plugins</groupId>\r
+ <artifactId>maven-jar-plugin</artifactId>\r
+ <version>2.6</version>\r
+ <configuration>\r
+ <archive>\r
+ <manifest>\r
+ <addDefaultImplementationEntries>true</addDefaultImplementationEntries>\r
+ </manifest>\r
+ </archive>\r
+ </configuration>\r
+ </plugin>\r
+ <plugin>\r
+ <groupId>org.apache.maven.plugins</groupId>\r
+ <artifactId>maven-compiler-plugin</artifactId>\r
+ <version>3.5.1</version>\r
+ <configuration>\r
+ <source>1.8</source>\r
+ <target>1.8</target>\r
+ </configuration>\r
+ </plugin>\r
+ <plugin>\r
+ <groupId>org.apache.maven.plugins</groupId>\r
+ <artifactId>maven-shade-plugin</artifactId>\r
+ <version>2.4</version>\r
+ <configuration>\r
+ <createDependencyReducedPom>false</createDependencyReducedPom>\r
+ <filters>\r
+ <filter>\r
+ <artifact>*:*</artifact>\r
+ <excludes>\r
+ <exclude>META-INF/*.SF</exclude>\r
+ <exclude>META-INF/*.DSA</exclude>\r
+ <exclude>META-INF/*.RSA</exclude>\r
+ </excludes>\r
+ </filter>\r
+ </filters>\r
+ </configuration>\r
+ <executions>\r
+ <execution>\r
+ <phase>package</phase>\r
+ <goals>\r
+ <goal>shade</goal>\r
+ </goals>\r
+ <configuration>\r
+ <transformers>\r
+ <transformer\r
+ implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />\r
+ <transformer\r
+ implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">\r
+ <mainClass>org.onap.workflow.activitiext.activitiExtApp</mainClass>\r
+ </transformer>\r
+ </transformers>\r
+ </configuration>\r
+ </execution>\r
+ </executions>\r
+ </plugin>\r
+ <plugin>\r
+ <groupId>org.apache.maven.plugins</groupId>\r
+ <artifactId>maven-dependency-plugin</artifactId>\r
+ <version>2.10</version>\r
+ <executions>\r
+ <execution>\r
+ <id>copy-dependencies</id>\r
+ <phase>package</phase>\r
+ <goals>\r
+ <goal>copy-dependencies</goal>\r
+ </goals>\r
+ <configuration>\r
+ <artifactItems>\r
+ <artifactItem>\r
+ <groupId>io.dropwizard</groupId>\r
+ <artifactId>dropwizard-core</artifactId>\r
+ <version>0.8.0</version>\r
+ <overWrite>true</overWrite>\r
+ </artifactItem>\r
+ </artifactItems>\r
+ </configuration>\r
+ </execution>\r
+ </executions>\r
+ </plugin>\r
+ </plugins>\r
+ <pluginManagement>\r
+ <plugins>\r
+ <!--This plugin's configuration is used to store Eclipse m2e settings \r
+ only. It has no influence on the Maven build itself. -->\r
+ <plugin>\r
+ <groupId>org.eclipse.m2e</groupId>\r
+ <artifactId>lifecycle-mapping</artifactId>\r
+ <version>1.0.0</version>\r
+ <configuration>\r
+ <lifecycleMappingMetadata>\r
+ <pluginExecutions>\r
+ <pluginExecution>\r
+ <pluginExecutionFilter>\r
+ <groupId>\r
+ org.apache.maven.plugins\r
+ </groupId>\r
+ <artifactId>\r
+ maven-checkstyle-plugin\r
+ </artifactId>\r
+ <versionRange>\r
+ [2.17,)\r
+ </versionRange>\r
+ <goals>\r
+ <goal>check</goal>\r
+ </goals>\r
+ </pluginExecutionFilter>\r
+ <action>\r
+ <ignore></ignore>\r
+ </action>\r
+ </pluginExecution>\r
+ </pluginExecutions>\r
+ </lifecycleMappingMetadata>\r
+ </configuration>\r
+ </plugin>\r
+ </plugins>\r
+ </pluginManagement>\r
+ </build>\r
+ <dependencies>\r
+ <dependency>\r
+ <groupId>io.dropwizard</groupId>\r
+ <artifactId>dropwizard-core</artifactId>\r
+ <version>0.8.0</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>io.dropwizard</groupId>\r
+ <artifactId>dropwizard-assets</artifactId>\r
+ <version>0.8.0</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>io.dropwizard</groupId>\r
+ <artifactId>dropwizard-hibernate</artifactId>\r
+ <version>0.8.0</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>io.dropwizard</groupId>\r
+ <artifactId>dropwizard-migrations</artifactId>\r
+ <version>0.8.0</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>io.swagger</groupId>\r
+ <artifactId>swagger-jersey2-jaxrs</artifactId>\r
+ <version>1.5.3</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.projectlombok</groupId>\r
+ <artifactId>lombok</artifactId>\r
+ <version>1.16.4</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.glassfish.jersey.core</groupId>\r
+ <artifactId>jersey-server</artifactId>\r
+ <version>2.16</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.glassfish.jersey.media</groupId>\r
+ <artifactId>jersey-media-multipart</artifactId>\r
+ <version>2.16</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.glassfish.jersey.containers</groupId>\r
+ <artifactId>jersey-container-servlet-core</artifactId>\r
+ <version>2.16</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>com.eclipsesource.jaxrs</groupId>\r
+ <artifactId>consumer</artifactId>\r
+ <version>5.0</version>\r
+ <exclusions>\r
+ <exclusion>\r
+ <groupId>com.eclipsesource.jaxrs</groupId>\r
+ <artifactId>jersey-all</artifactId>\r
+ </exclusion>\r
+ </exclusions>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>com.jcraft</groupId>\r
+ <artifactId>jsch</artifactId>\r
+ <version>0.1.53</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>io.dropwizard</groupId>\r
+ <artifactId>dropwizard-jdbi</artifactId>\r
+ <version>0.8.0</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>commons-io</groupId>\r
+ <artifactId>commons-io</artifactId>\r
+ <version>2.4</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>junit</groupId>\r
+ <artifactId>junit</artifactId>\r
+ <version>4.12</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.powermock</groupId>\r
+ <artifactId>powermock-module-junit4</artifactId>\r
+ <version>1.6.1</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.powermock</groupId>\r
+ <artifactId>powermock-api-mockito</artifactId>\r
+ <version>1.6.1</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.mockito</groupId>\r
+ <artifactId>mockito-all</artifactId>\r
+ <version>1.9.5</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.apache.ant</groupId>\r
+ <artifactId>ant</artifactId>\r
+ <version>${ant.version}</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>com.alibaba</groupId>\r
+ <artifactId>fastjson</artifactId>\r
+ <version>1.2.23</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.activiti</groupId>\r
+ <artifactId>activiti-engine</artifactId>\r
+ <version>5.21.0</version>\r
+ <scope>provided</scope>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>commons-httpclient</groupId>\r
+ <artifactId>commons-httpclient</artifactId>\r
+ <version>3.1</version>\r
+ </dependency>\r
+ </dependencies>\r
+</project>\r
--- /dev/null
+/**
+ * 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;
+
+import org.glassfish.jersey.media.multipart.MultiPartFeature;
+
+import io.dropwizard.Application;
+import io.dropwizard.setup.Environment;
+
+public class ActivitiExtApp extends Application<ActivitiExtAppConfig> {
+
+ public static void main(String[] args) throws Exception {
+ new ActivitiExtApp().run(args);
+ }
+
+ @Override
+ public String getName() {
+ return " Activiti Ext APP ";
+ }
+
+ @Override
+ public void run(ActivitiExtAppConfig configuration, Environment environment) throws Exception {
+
+ environment.jersey().register(MultiPartFeature.class);
+ }
+}
+
--- /dev/null
+/**
+ * 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;
+
+import io.dropwizard.Configuration;
+
+import javax.validation.Valid;
+
+import org.hibernate.validator.constraints.NotEmpty;
+import org.onap.workflow.activitiext.common.MsbClientConfig;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class ActivitiExtAppConfig 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;
+ }
+}
--- /dev/null
+/**
+ * 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;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+
+import org.jvnet.hk2.annotations.Service;
+import org.onap.workflow.activitiext.common.Config;
+
+
+@Service
+public class ActivitiExtAppInit {
+ @Inject
+ private ActivitiExtAppConfig appconfig;
+
+ @PostConstruct
+ private void run() {
+ runConfigComponent();
+ }
+
+ private void runConfigComponent() {
+ Config.getInstance().setAppconfig(appconfig);
+ }
+}
--- /dev/null
+/**\r
+ * Copyright 2017 ZTE Corporation.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.workflow.activitiext.common;\r
+\r
+import org.onap.workflow.activitiext.ActivitiExtAppConfig;\r
+\r
+public class Config {\r
+\r
+ private static Config instance = new Config();\r
+ \r
+ private ActivitiExtAppConfig appconfig;\r
+\r
+ public static Config getInstance(){\r
+ return instance;\r
+ }\r
+ \r
+ public ActivitiExtAppConfig getAppconfig() {\r
+ return appconfig;\r
+ }\r
+\r
+ public void setAppconfig(ActivitiExtAppConfig config) {\r
+ this.appconfig = config;\r
+ }\r
+ \r
+}\r
--- /dev/null
+/**\r
+ * Copyright 2017 ZTE Corporation.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.workflow.activitiext.common;\r
+\r
+import lombok.Data;\r
+\r
+@Data\r
+public class MsbClientConfig {\r
+\r
+ private String msbSvrIp;\r
+ private Integer msbSvrPort;\r
+}\r
--- /dev/null
+/**\r
+ * Copyright 2016-2017 ZTE Corporation.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package org.onap.workflow.activitiext.restservicetask;\r
+\r
+/**\r
+ * \r
+ * @author 10222158\r
+ *\r
+ */\r
+public class ConstString {\r
+\r
+ /**\r
+ * http method type : get\r
+ */\r
+ public static final String HTTP_GET = "GET";\r
+ \r
+ /**\r
+ * http method type : post\r
+ */\r
+ public static final String HTTP_POST = "POST";\r
+ \r
+ /**\r
+ * http method type : delete\r
+ */\r
+ public static final String HTTP_DELETE = "DELETE";\r
+ \r
+ /**\r
+ * http method type : put\r
+ */\r
+ public static final String HTTP_PUT = "PUT";\r
+ \r
+ /**\r
+ * parameter position : in the uri path\r
+ */\r
+ public static final String PARAMETER_POSITION_PATH = "path";\r
+ \r
+ /**\r
+ * parameter positoin : after the uri\r
+ */\r
+ public static final String PARAMETER_POSITION_QUERY = "query";\r
+ \r
+ /**\r
+ * parameter positoin : in the request body\r
+ */\r
+ public static final String PARAMETER_POSITION_BODY = "body";\r
+ \r
+ /**\r
+ * parameter type : string\r
+ */\r
+ public static final String PARAMETER_TYPE_STRING = "string";\r
+ \r
+ /**\r
+ * parameter type : acitviti expression\r
+ */\r
+ public static final String PARAMETER_TYPE_EXPRESSION = "expression";\r
+ \r
+}\r
--- /dev/null
+/**
+ * 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.restservicetask;
+
+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;
+}
--- /dev/null
+/**
+ * Copyright 2016-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.restservicetask;
+
+import org.activiti.engine.ActivitiException;
+import org.apache.commons.httpclient.HttpMethodBase;
+import org.apache.commons.httpclient.NameValuePair;
+import org.apache.commons.httpclient.methods.DeleteMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author 10222158
+ *
+ */
+public class HighLevelRestApi {
+
+ private static final Logger logger = LoggerFactory.getLogger(HighLevelRestApi.class);
+
+ /**
+ * invoke http service
+ *
+ * @param methodValue
+ * @param uri
+ * @param requestPayload
+ * @param acceptValue
+ * @param contentTypeValue
+ * @return
+ */
+ public static HttpResponseMessage invoke(String methodValue, String uri, String requestPayload, String acceptValue,
+ String contentTypeValue) throws ActivitiException {
+
+ // complete uri
+ uri = completeUri(uri);
+
+ logger.info("uri: " + uri);
+ logger.info("method: " + methodValue);
+ logger.info("requestbody: " + requestPayload);
+ logger.info("accept: " + acceptValue);
+ logger.info("content-type: " + contentTypeValue);
+
+ HttpResponseMessage msg = new HttpResponseMessage();
+ switch (methodValue.toUpperCase()) {
+ case ConstString.HTTP_GET:
+ msg = HighLevelRestApi.Get(uri, acceptValue, contentTypeValue);
+ break;
+ case ConstString.HTTP_POST:
+ msg = HighLevelRestApi.Post(uri, requestPayload, acceptValue, contentTypeValue);
+ break;
+ case ConstString.HTTP_DELETE:
+ msg = HighLevelRestApi.Delete(uri, acceptValue, contentTypeValue);
+ break;
+ case ConstString.HTTP_PUT:
+ msg = HighLevelRestApi.Put(uri, requestPayload, acceptValue, contentTypeValue);
+ break;
+ default:
+ throw new ActivitiException("can not find the http method type '" + methodValue + "'!");
+ }
+ return msg;
+ }
+
+ /**
+ * This method implements the HTTP Put Method
+ *
+ * @param uri
+ * Resource URI
+ * @param requestPayload
+ * Content which has to be put into the Resource
+ * @return ResponseCode of HTTP Interaction
+ */
+ @SuppressWarnings("deprecation")
+ public static HttpResponseMessage Put(String uri, String requestPayload, String acceptValue,
+ String contentTypeValue) {
+
+ PutMethod method = new PutMethod(uri);
+
+ HighLevelRestApi.setAcceptHeader(method, acceptValue);
+ HighLevelRestApi.setContentTypeHeader(method, contentTypeValue);
+ method.setRequestBody(requestPayload);
+
+ HttpResponseMessage responseMessage = LowLevelRestApi.executeHttpMethod(method);
+
+ return responseMessage;
+ }
+
+ /**
+ * This method implements the HTTP Post Method
+ *
+ * @param uri
+ * Resource URI
+ * @param requestPayload
+ * Content which has to be posted into the Resource
+ * @return ResponseCode of HTTP Interaction
+ */
+ @SuppressWarnings("deprecation")
+ public static HttpResponseMessage Post(String uri, String requestPayload, String acceptValue,
+ String contentTypeValue) {
+
+ PostMethod method = null;
+ if (uri.contains("?")) {
+ String[] split = uri.split("\\?");
+ method = new PostMethod(split[0]);
+ method.setQueryString(HighLevelRestApi.createNameValuePairArrayFromQuery(split[1]));
+ } else {
+ method = new PostMethod(uri);
+ }
+ method.setRequestBody(requestPayload);
+ HighLevelRestApi.setAcceptHeader(method, acceptValue);
+ HighLevelRestApi.setContentTypeHeader(method, contentTypeValue);
+ HttpResponseMessage responseMessage = LowLevelRestApi.executeHttpMethod(method);
+ return responseMessage;
+ }
+
+ /**
+ * This method implements the HTTP Get Method
+ *
+ * @param uri
+ * Resource URI
+ * @return Content represented by the Resource URI
+ */
+ public static HttpResponseMessage Get(String uri, String acceptValue, String contentTypeValue) {
+ GetMethod method = null;
+ if (uri.contains("?")) {
+ String[] split = uri.split("\\?");
+ method = new GetMethod(split[0]);
+ method.setQueryString(HighLevelRestApi.createNameValuePairArrayFromQuery(split[1]));
+ } else {
+ method = new GetMethod(uri);
+ }
+
+ HighLevelRestApi.setAcceptHeader(method, acceptValue);
+ HighLevelRestApi.setContentTypeHeader(method, contentTypeValue);
+ HttpResponseMessage responseMessage = LowLevelRestApi.executeHttpMethod(method);
+ return responseMessage;
+ }
+
+ private static NameValuePair[] createNameValuePairArrayFromQuery(String query) {
+ String[] pairs = query.trim().split("&");
+ NameValuePair[] nameValuePairArray = new NameValuePair[pairs.length];
+ int count = 0;
+ for (String pair : pairs) {
+ String[] keyValue = pair.split("=");
+ NameValuePair nameValuePair = new NameValuePair();
+ nameValuePair.setName(keyValue[0]);
+ nameValuePair.setValue(keyValue[1]);
+ nameValuePairArray[count] = nameValuePair;
+ count++;
+ }
+ return nameValuePairArray;
+ }
+
+ /**
+ * This method implements the HTTP Delete Method
+ *
+ * @param uri
+ * Resource URI
+ * @return ResponseCode of HTTP Interaction
+ */
+ public static HttpResponseMessage Delete(String uri, String acceptValue, String contentTypeValue) {
+
+ DeleteMethod method = new DeleteMethod(uri);
+ HighLevelRestApi.setAcceptHeader(method, acceptValue);
+ HighLevelRestApi.setContentTypeHeader(method, contentTypeValue);
+ HttpResponseMessage responseMessage = LowLevelRestApi.executeHttpMethod(method);
+ return responseMessage;
+ }
+
+ private static void setAcceptHeader(HttpMethodBase method, String value) {
+ if (!StringUtils.isEmpty(value)) {
+ method.setRequestHeader("Accept", value);
+ } else {
+ method.setRequestHeader("Accept", "application/xml");
+ }
+ }
+
+ private static void setContentTypeHeader(HttpMethodBase method, String value) {
+ if (!StringUtils.isEmpty(value)) {
+ method.setRequestHeader("content-type", value);
+ } else {
+ method.setRequestHeader("content-type", "application/json");
+ }
+ }
+
+ private static String completeUri(String uri) {
+
+ String urlReg = "^http[\\s\\S]*";
+ if (uri != null && !uri.matches(urlReg)) {
+ uri = PropertyUtil.getBasePath() + uri;
+ }
+
+ return uri;
+ }
+}
--- /dev/null
+/**
+ * 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.restservicetask;
+
+import java.io.Serializable;
+
+/**
+ */
+public class HttpResponseMessage implements Serializable {
+
+ private int statusCode;
+ private String responseBody;
+
+
+ /**
+ * @return the statusCode
+ */
+ public int getStatusCode() {
+ return this.statusCode;
+ }
+
+ /**
+ * @param statusCode the statusCode to set
+ */
+ protected void setStatusCode(int statusCode) {
+ this.statusCode = statusCode;
+ }
+
+ /**
+ * @return the responseBody
+ */
+ public String getResponseBody() {
+ return this.responseBody;
+ }
+
+ /**
+ * @param responseBody the responseBody to set
+ */
+ protected void setResponseBody(String responseBody) {
+ this.responseBody = responseBody;
+ }
+
+}
--- /dev/null
+/**\r
+ * Copyright 2016-2017 ZTE Corporation.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package org.onap.workflow.activitiext.restservicetask;\r
+\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.activiti.engine.ActivitiException;\r
+import org.activiti.engine.delegate.BpmnError;\r
+import org.activiti.engine.delegate.DelegateExecution;\r
+import org.activiti.engine.delegate.Expression;\r
+import org.activiti.engine.delegate.JavaDelegate;\r
+import org.activiti.engine.impl.context.Context;\r
+import org.apache.commons.lang3.StringUtils;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+import com.alibaba.fastjson.JSON;\r
+import com.alibaba.fastjson.JSONArray;\r
+\r
+/**\r
+ * rest service\r
+ * \r
+ * @author 10222158\r
+ *\r
+ */\r
+public class HttpUtil implements JavaDelegate {\r
+\r
+ private static final Logger logger = LoggerFactory.getLogger(HttpUtil.class);\r
+\r
+ private Expression uri;\r
+ private Expression method;\r
+ private Expression accept;\r
+ private Expression contentType;\r
+ private Expression parameters;\r
+\r
+ @Override\r
+ public void execute(DelegateExecution execution) throws ActivitiException {\r
+\r
+ try {\r
+ this.executeMethod(execution);\r
+ } catch (Exception e) {\r
+\r
+ logger.error("Invoke rest service failed!", e);\r
+ throw new BpmnError(e.getMessage());\r
+ }\r
+ }\r
+\r
+ /**\r
+ * invoke rest service\r
+ * \r
+ * @param execution\r
+ */\r
+ public boolean executeMethod(DelegateExecution execution) throws Exception {\r
+\r
+ String uriValue = getValue(uri, execution);\r
+ String methodValue = getValue(method, execution);\r
+ String acceptValue = getValue(accept, execution);\r
+ String contentTypeValue = getValue(contentType, execution);\r
+ String parametersValue = getValue(parameters, execution);\r
+\r
+ Map<String, String> requestBody = new HashMap<String, String>();\r
+\r
+ if (!StringUtils.isEmpty(parametersValue)) {\r
+\r
+ // Parse the parameter into Object List\r
+ List<Parameter> parameters = JSONArray.parseArray(parametersValue, Parameter.class);\r
+\r
+ for (Parameter param : parameters) {\r
+\r
+ handleParam(execution, param, requestBody, uriValue);\r
+ }\r
+ }\r
+\r
+ String requestPayload = JSON.toJSONString(requestBody);\r
+\r
+ // invoke http service\r
+ HttpResponseMessage msg = HighLevelRestApi.invoke(methodValue, uriValue, requestPayload, acceptValue,\r
+ contentTypeValue);\r
+\r
+ // inject the result to variable\r
+ execution.setVariable(execution.getCurrentActivityId(), msg);\r
+\r
+ logger.info("statusCode: " + msg.getStatusCode());\r
+ logger.info("responseBody: " + msg.getResponseBody());\r
+ \r
+ return true;\r
+ }\r
+\r
+ /**\r
+ * \r
+ * @param execution\r
+ * @param param\r
+ * @param requestBody\r
+ * @param uriValue\r
+ */\r
+ public void handleParam(DelegateExecution execution, Parameter param, Map<String, String> requestBody,\r
+ String uriValue) throws ActivitiException {\r
+\r
+ if (ConstString.PARAMETER_TYPE_EXPRESSION.equals(param.getType())) {\r
+ handleExpression(execution, param);\r
+ }\r
+\r
+ switch (param.getPosition()) {\r
+ case ConstString.PARAMETER_POSITION_PATH:\r
+\r
+ // replace the path parameter\r
+ uriValue = uriValue.replaceAll("\\{+" + param.getName() + "+\\}", param.getValue());\r
+ break;\r
+ case ConstString.PARAMETER_POSITION_QUERY:\r
+\r
+ // add the query parameter\r
+ if (!uriValue.contains("?")) {\r
+ uriValue = uriValue + "?" + param.getName() + "=" + param.getValue();\r
+ } else {\r
+ uriValue = uriValue + "&" + param.getName() + "=" + param.getValue();\r
+ }\r
+ break;\r
+ case ConstString.PARAMETER_POSITION_BODY:\r
+\r
+ // add parameter to request body\r
+ requestBody.put(param.getName(), param.getValue());\r
+ break;\r
+ default:\r
+ throw new ActivitiException(\r
+ "The position '" + param.getPosition() + "' is illegal, please check your input!");\r
+ }\r
+ }\r
+\r
+ /**\r
+ * get value from VariableScope\r
+ * \r
+ * @param expression\r
+ * @param execution\r
+ * @return\r
+ */\r
+ public String getValue(Expression expression, DelegateExecution execution) {\r
+\r
+ String value = new String();\r
+ if (expression != null) {\r
+ value = (String) expression.getValue(execution);\r
+ }\r
+\r
+ return value;\r
+ }\r
+\r
+ /**\r
+ * parse expression in the parameter\r
+ * \r
+ * @param execution\r
+ * @param param\r
+ */\r
+ public void handleExpression(DelegateExecution execution, Parameter param) {\r
+\r
+ Expression expression = Context.getProcessEngineConfiguration().getExpressionManager()\r
+ .createExpression(param.getValue());\r
+\r
+ String value = String.valueOf(expression.getValue(execution));\r
+\r
+ param.setValue(value);\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/**
+ * 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.restservicetask;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpMethod;
+
+/**
+ * This static-class eases HTTP-method execution by self-managed fault-handling and automated
+ * Response-information processing
+ */
+public class LowLevelRestApi {
+
+ // Local HttpClient used for every communication (Singleton implementation)
+ private static HttpClient httpClient = new HttpClient();
+
+
+ /**
+ * Executes a passed HttpMethod (Method type is either PUT, POST, GET or DELETE) and returns a
+ * HttpResponseMessage
+ *
+ * @param method Method to execute
+ * @return HttpResponseMessage which contains all information about the execution
+ */
+ public static HttpResponseMessage executeHttpMethod(HttpMethod method) {
+
+ HttpResponseMessage responseMessage = null;
+
+ try {
+
+ // Execute Request
+ LowLevelRestApi.httpClient.executeMethod(method);
+ responseMessage = LowLevelRestApi.extractResponseInformation(method);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+
+ // Release Connection anyway
+ method.releaseConnection();
+ }
+
+ // Extract response information and return
+ return responseMessage;
+ }
+
+ /**
+ * Extracts the response information from an executed HttpMethod
+ *
+ * @param method Executed Method
+ * @return Packaged response information
+ */
+ private static HttpResponseMessage extractResponseInformation(HttpMethod method) {
+ // Create and return HttpResponseMethod
+ HttpResponseMessage responseMessage = new HttpResponseMessage();
+ responseMessage.setStatusCode(method.getStatusCode());
+ try {
+ responseMessage.setResponseBody(method.getResponseBodyAsString());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return responseMessage;
+
+ }
+
+}
--- /dev/null
+/**\r
+ * Copyright 2017 ZTE Corporation.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package org.onap.workflow.activitiext.restservicetask;\r
+\r
+public class Parameter {\r
+\r
+ private String position;\r
+ private String type;\r
+ private String name;\r
+ private String value;\r
+\r
+ public String getPosition() {\r
+ return position;\r
+ }\r
+\r
+ public void setPosition(String position) {\r
+ this.position = position;\r
+ }\r
+\r
+ public String getType() {\r
+ return type;\r
+ }\r
+\r
+ public void setType(String type) {\r
+ this.type = type;\r
+ }\r
+\r
+ public String getName() {\r
+ return name;\r
+ }\r
+\r
+ public void setName(String name) {\r
+ this.name = name;\r
+ }\r
+\r
+ public String getValue() {\r
+ return value;\r
+ }\r
+\r
+ public void setValue(String value) {\r
+ this.value = value;\r
+ }\r
+}\r
--- /dev/null
+/**\r
+ * Copyright 2017 ZTE Corporation.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.workflow.activitiext.restservicetask;\r
+\r
+import java.util.ResourceBundle;\r
+\r
+public class PropertyUtil {\r
+ \r
+ public static final String REST_PROPERTY_LOCATION = "config";\r
+ \r
+ public static final String BASE_URL = "baseurl";\r
+ \r
+ private static ResourceBundle resource;\r
+ \r
+ static{\r
+ resource = ResourceBundle.getBundle(REST_PROPERTY_LOCATION);\r
+ }\r
+\r
+ public static String findByKey(String key){\r
+ \r
+ String value = resource.getString(key);\r
+ \r
+ return value;\r
+ }\r
+ \r
+ public static String getBasePath(){\r
+ \r
+ String basepath = findByKey(BASE_URL);\r
+ \r
+ return basepath;\r
+ }\r
+}\r
--- /dev/null
+/**
+ * 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.restservicetask;
+
+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 processId;
+ private Map<String, String> params;
+}
--- /dev/null
+<!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/activitiext/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"> </div>
+<div id="swagger-ui-container" class="swagger-ui-wrap"></div>
+</body>
+</html>
--- /dev/null
+ _ ____ _____ ___ __ __ ___ _____ ___ _____ __ __ _____ \r
+ / \ / ___| |_ _| |_ _| \ \ / / |_ _| |_ _| |_ _| | ____| \ \/ / |_ _|\r
+ / _ \ | | | | | | \ \ / / | | | | | | _____ | _| \ / | | \r
+ / ___ \ | |___ | | | | \ V / | | | | | | |_____| | |___ / \ | | \r
+ /_/ \_\ \____| |_| |___| \_/ |___| |_| |___| |_____| /_/\_\ |_| \r
+
\ No newline at end of file