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>
msbServerAddr: http://127.0.0.1:80
+sdcServiceProxy:
+ xEcompInstanceId: workflow
+ authorization: Basic YWFpOktwOGJKNFNYc3pNMFdYbGhhazNlSGxjc2UyZ0F3ODR2YW9HR21KdlV5MlU=
+
# use the simple server factory if you only want to run on a single port
server:
type: simple
<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>
<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>
--- /dev/null
+/**\r
+ * Copyright (c) 2018 ZTE Corporation.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the Apache License, Version 2.0\r
+ * and the Eclipse Public License v1.0 which both accompany this distribution,\r
+ * and are available at http://www.eclipse.org/legal/epl-v10.html\r
+ * and http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Contributors:\r
+ * ZTE - initial API and implementation and/or initial documentation\r
+ */\r
+package org.onap.sdc.workflowdesigner;\r
+\r
+/**\r
+ *\r
+ */\r
+public class SDCServiceProxyInfo {\r
+ private String xEcompInstanceId;\r
+ \r
+ private String authorization;\r
+\r
+ /**\r
+ * @return the xEcompInstanceId\r
+ */\r
+ public String getxEcompInstanceId() {\r
+ return xEcompInstanceId;\r
+ }\r
+\r
+ /**\r
+ * @param xEcompInstanceId the xEcompInstanceId to set\r
+ */\r
+ public void setxEcompInstanceId(String xEcompInstanceId) {\r
+ this.xEcompInstanceId = xEcompInstanceId;\r
+ }\r
+\r
+ /**\r
+ * @return the authorization\r
+ */\r
+ public String getAuthorization() {\r
+ return authorization;\r
+ }\r
+\r
+ /**\r
+ * @param authorization the authorization to set\r
+ */\r
+ public void setAuthorization(String authorization) {\r
+ this.authorization = authorization;\r
+ }\r
+\r
+}\r
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 {
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());
@NotEmpty
private String msbServerAddr;
+
+ @NotEmpty
+ private SDCServiceProxyInfo sdcServiceProxy;
@JsonProperty
public String getTemplate() {
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;
+ }
+
}
--- /dev/null
+/**
+ * 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);
+ }
+}
*/
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;
}
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;
+ }
+
}
--- /dev/null
+/**
+ * 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;
+
+}
--- /dev/null
+/**
+ * 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);
+ }
+ }
+
+
+}
--- /dev/null
+/**
+ * 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;
+ }
+
+}