diff options
author | YuanHu <yuan.hu1@zte.com.cn> | 2018-03-19 16:41:15 +0800 |
---|---|---|
committer | YuanHu <yuan.hu1@zte.com.cn> | 2018-03-19 17:30:28 +0800 |
commit | 43bed0e28512332aecc3b70f9e24840682c59e92 (patch) | |
tree | 509c6c9f8912e39bcaa59e97ae427e357730b001 /sdc-workflow-designer-server | |
parent | 4e1d1d797e185a0ae259e8251d292418232cff67 (diff) |
Save Workflow Artifact to SDC.
Get SDC Serive Proxy Information from conf file.
Call rest api to save workflow artifact to SDC
Issue-ID: SDC-1004
Change-Id: I620674def79bdfb9fd71aebc96d0774bc7dfddd8
Signed-off-by: YuanHu <yuan.hu1@zte.com.cn>
Diffstat (limited to 'sdc-workflow-designer-server')
9 files changed, 394 insertions, 2 deletions
diff --git a/sdc-workflow-designer-server/pom.xml b/sdc-workflow-designer-server/pom.xml index 98733c90..b47f8453 100644 --- a/sdc-workflow-designer-server/pom.xml +++ b/sdc-workflow-designer-server/pom.xml @@ -27,6 +27,8 @@ <properties> <jackson.version>2.9.1</jackson.version> + <gson.version>2.2.4</gson.version> + <jaxrs.consumer.version>5.0</jaxrs.consumer.version> <velocity.version>1.7</velocity.version> <junit.version>4.10</junit.version> <dropwizard.version>1.2.4</dropwizard.version> @@ -157,6 +159,26 @@ <version>${jackson.version}</version> </dependency> + <!-- gson --> + <dependency> + <groupId>com.google.code.gson</groupId> + <artifactId>gson</artifactId> + <version>${gson.version}</version> + </dependency> + + <!-- consumer --> + <dependency> + <groupId>com.eclipsesource.jaxrs</groupId> + <artifactId>consumer</artifactId> + <exclusions> + <exclusion> + <groupId>com.eclipsesource.jaxrs</groupId> + <artifactId>jersey-all</artifactId> + </exclusion> + </exclusions> + <version>${jaxrs.consumer.version}</version> + </dependency> + <dependency> <groupId>org.apache.velocity</groupId> <artifactId>velocity</artifactId> diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/SDCServiceProxyInfo.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/SDCServiceProxyInfo.java new file mode 100644 index 00000000..5d8b8eaa --- /dev/null +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/SDCServiceProxyInfo.java @@ -0,0 +1,50 @@ +/**
+ * Copyright (c) 2018 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the Apache License, Version 2.0
+ * and the Eclipse Public License v1.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * ZTE - initial API and implementation and/or initial documentation
+ */
+package org.onap.sdc.workflowdesigner;
+
+/**
+ *
+ */
+public class SDCServiceProxyInfo {
+ private String xEcompInstanceId;
+
+ private String authorization;
+
+ /**
+ * @return the xEcompInstanceId
+ */
+ public String getxEcompInstanceId() {
+ return xEcompInstanceId;
+ }
+
+ /**
+ * @param xEcompInstanceId the xEcompInstanceId to set
+ */
+ public void setxEcompInstanceId(String xEcompInstanceId) {
+ this.xEcompInstanceId = xEcompInstanceId;
+ }
+
+ /**
+ * @return the authorization
+ */
+ public String getAuthorization() {
+ return authorization;
+ }
+
+ /**
+ * @param authorization the authorization to set
+ */
+ public void setAuthorization(String authorization) {
+ this.authorization = authorization;
+ }
+
+}
diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerApp.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerApp.java index e2ec2711..ba0fcd72 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerApp.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerApp.java @@ -30,7 +30,6 @@ import io.swagger.jaxrs.config.BeanConfig; import io.swagger.jaxrs.listing.ApiListingResource; public class WorkflowDesignerApp extends Application<WorkflowDesignerConfiguration> { - private static final Logger LOGGER = LoggerFactory.getLogger(WorkflowDesignerApp.class); public static void main(String[] args) throws Exception { @@ -55,6 +54,7 @@ public class WorkflowDesignerApp extends Application<WorkflowDesignerConfigurati LOGGER.info("Start to initialize Workflow Designer."); AppConfig.setMsbServerAddr(configuration.getMsbServerAddr()); + AppConfig.setSdcServiceProxy(configuration.getSdcServiceProxy()); environment.jersey().register(new WorkflowModelerResource()); environment.jersey().register(new ExtendActivityResource()); diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerConfiguration.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerConfiguration.java index b4ed3d10..dfdffcf9 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerConfiguration.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerConfiguration.java @@ -27,6 +27,9 @@ public class WorkflowDesignerConfiguration extends Configuration { @NotEmpty private String msbServerAddr; + + @NotEmpty + private SDCServiceProxyInfo sdcServiceProxy; @JsonProperty public String getTemplate() { @@ -58,4 +61,20 @@ public class WorkflowDesignerConfiguration extends Configuration { this.msbServerAddr = msbServerAddr; } + /** + * @return the sdcServiceProxy + */ + @JsonProperty + public SDCServiceProxyInfo getSdcServiceProxy() { + return sdcServiceProxy; + } + + /** + * @param sdcServiceProxy the sdcServiceProxy to set + */ + @JsonProperty + public void setSdcServiceProxy(SDCServiceProxyInfo sdcServiceProxy) { + this.sdcServiceProxy = sdcServiceProxy; + } + } diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/common/WorkflowDesignerException.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/common/WorkflowDesignerException.java new file mode 100644 index 00000000..343df014 --- /dev/null +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/common/WorkflowDesignerException.java @@ -0,0 +1,33 @@ +/** + * Copyright 2018 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.sdc.workflowdesigner.common; + +public class WorkflowDesignerException extends Exception { + + private static final long serialVersionUID = 1L; + + public WorkflowDesignerException() { + super(); + } + + public WorkflowDesignerException(String msg, Exception e) { + super(msg, e); + } + + public WorkflowDesignerException(String msg) { + super(msg); + } +} diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/config/AppConfig.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/config/AppConfig.java index a3cae9ca..f9aa060c 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/config/AppConfig.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/config/AppConfig.java @@ -15,15 +15,17 @@ */ package org.onap.sdc.workflowdesigner.config; +import org.onap.sdc.workflowdesigner.SDCServiceProxyInfo; + /** * */ public class AppConfig { private static String msbServerAddr; + private static SDCServiceProxyInfo sdcServiceProxy; private AppConfig() {} - public static String getMsbServerAddr() { return msbServerAddr; } @@ -31,4 +33,23 @@ public class AppConfig { public static void setMsbServerAddr(String msbServerAddr) { AppConfig.msbServerAddr = msbServerAddr; } + + public static String getSDCAddr() { + return msbServerAddr + "/api/sdc/v1"; + } + + /** + * @param sdcServiceProxy + */ + public static void setSdcServiceProxy(SDCServiceProxyInfo sdcServiceProxy) { + AppConfig.sdcServiceProxy = sdcServiceProxy; + } + + /** + * @return the sdcServiceProxy + */ + public static SDCServiceProxyInfo getSdcServiceProxy() { + return sdcServiceProxy; + } + } diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/SDCService.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/SDCService.java new file mode 100644 index 00000000..d5a55669 --- /dev/null +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/SDCService.java @@ -0,0 +1,51 @@ +/** + * Copyright 2018 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.sdc.workflowdesigner.externalservice.sdc; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +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 org.onap.sdc.workflowdesigner.externalservice.sdc.entity.WorkflowArtifactInfo; + +@Path("/catalog") +public interface SDCService { + @POST + @Path("/resource/{uuid}/interfaces/{operationID}/artifacts/{id}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public void saveWorkflowArtifact(@PathParam("uuid") String uuid, + @PathParam("operationID") String operationId, @PathParam("id") String workflowId, + @HeaderParam("X-ECOMP-InstanceID") String xEcompInstanceId, + @HeaderParam("Authorization") String authorization, + WorkflowArtifactInfo workflowArtifactInfo) throws Exception; + + + @GET + @Path("/resource/{uuid}/interfaces/{operationID}/artifacts/{id}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public WorkflowArtifactInfo getWorkflowArtifact(@PathParam("uuid") String uuid, + @PathParam("operationID") String operationId, @PathParam("id") String workflowId, + @HeaderParam("X-ECOMP-InstanceID") String xEcompInstanceId, + @HeaderParam("Authorization") String authorization) throws Exception; + +} diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/SDCServiceProxy.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/SDCServiceProxy.java new file mode 100644 index 00000000..c9c0f810 --- /dev/null +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/SDCServiceProxy.java @@ -0,0 +1,86 @@ +/** + * Copyright 2017-2018 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.sdc.workflowdesigner.externalservice.sdc; + +import org.glassfish.jersey.client.ClientConfig; +import org.onap.sdc.workflowdesigner.common.WorkflowDesignerException; +import org.onap.sdc.workflowdesigner.config.AppConfig; +import org.onap.sdc.workflowdesigner.externalservice.sdc.entity.WorkflowArtifactInfo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.eclipsesource.jaxrs.consumer.ConsumerFactory; + +/** + * + */ +public class SDCServiceProxy { + private static final Logger LOGGER = LoggerFactory.getLogger(SDCService.class); + + /** + * @return + */ + private SDCService getSDCServiceProxy() { + ClientConfig config = new ClientConfig(); + SDCService sdcServiceProxy = + ConsumerFactory.createConsumer(AppConfig.getSDCAddr(), config, SDCService.class); + return sdcServiceProxy; + } + + /** + * + * @param uuid + * @param operationId + * @param workflowId + * @param workflowArtifactInfo + * @throws WorkflowDesignerException + */ + public void saveWorkflowArtifact(String uuid, String operationId, String workflowId, + WorkflowArtifactInfo workflowArtifactInfo) throws WorkflowDesignerException { + SDCService sdcServiceProxy = getSDCServiceProxy(); + try { + sdcServiceProxy.saveWorkflowArtifact(uuid, operationId, workflowId, + AppConfig.getSdcServiceProxy().getxEcompInstanceId(), + AppConfig.getSdcServiceProxy().getAuthorization(), workflowArtifactInfo); + } catch (Exception e) { + LOGGER.error("Save WorkflowArtifact Failed.", e); + throw new WorkflowDesignerException("Save WorkflowArtifact Failed.", e); + } + } + + /** + * + * @param uuid + * @param operationId + * @param workflowId + * @return + * @throws WorkflowDesignerException + */ + public WorkflowArtifactInfo getWorkflowArtifact(String uuid, String operationId, + String workflowId) throws WorkflowDesignerException { + SDCService sdcServiceProxy = getSDCServiceProxy(); + try { + return sdcServiceProxy.getWorkflowArtifact(uuid, operationId, workflowId, + AppConfig.getSdcServiceProxy().getxEcompInstanceId(), + AppConfig.getSdcServiceProxy().getAuthorization()); + } catch (Exception e) { + LOGGER.error("Get WorkflowArtifact Failed.", e); + throw new WorkflowDesignerException("Save WorkflowArtifact Failed.", e); + } + } + + +} diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/WorkflowArtifactInfo.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/WorkflowArtifactInfo.java new file mode 100644 index 00000000..23c8f860 --- /dev/null +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/WorkflowArtifactInfo.java @@ -0,0 +1,110 @@ +/** + * Copyright 2018 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.sdc.workflowdesigner.externalservice.sdc.entity; + +import java.io.Serializable; + +public class WorkflowArtifactInfo implements Serializable { + public static final long serialVersionUID = 1L; + + private String artifactName; + + private String description; + + private String artifactType = "WORKFLOW"; + + private String payloadData; + + + /** + * @param artifactName + * @param description + * @param artifactType + * @param payloadData + */ + public WorkflowArtifactInfo(String artifactName, String description, String artifactType, + String payloadData) { + super(); + this.artifactName = artifactName; + this.description = description; + this.artifactType = artifactType; + this.payloadData = payloadData; + } + + /** + * @return the artifactName + */ + public String getArtifactName() { + return artifactName; + } + + /** + * @param artifactName the artifactName to set + */ + public void setArtifactName(String artifactName) { + this.artifactName = artifactName; + } + + /** + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * @param description the description to set + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * @return the artifactType + */ + public String getArtifactType() { + return artifactType; + } + + /** + * @param artifactType the artifactType to set + */ + public void setArtifactType(String artifactType) { + this.artifactType = artifactType; + } + + /** + * @return the payloadData + */ + public String getPayloadData() { + return payloadData; + } + + /** + * @param payloadData the payloadData to set + */ + public void setPayloadData(String payloadData) { + this.payloadData = payloadData; + } + + /** + * @return the serialversionuid + */ + public static long getSerialversionuid() { + return serialVersionUID; + } + +} |