Service Proxy for Activity Spec. 71/37371/1
authorYuanHu <yuan.hu1@zte.com.cn>
Wed, 21 Mar 2018 08:11:27 +0000 (16:11 +0800)
committerYuanHu <yuan.hu1@zte.com.cn>
Wed, 21 Mar 2018 08:11:27 +0000 (16:11 +0800)
Call rest api to retrive activity specs.

Issue-ID: SDC-1129

Change-Id: Iae2144c01bffe39cf2691d12b7916afcb77f8090
Signed-off-by: YuanHu <yuan.hu1@zte.com.cn>
sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/ActivitySpecService.java [new file with mode: 0644]
sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/ActivitySpecServiceProxy.java [new file with mode: 0644]
sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/SDCServiceProxy.java

diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/ActivitySpecService.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/ActivitySpecService.java
new file mode 100644 (file)
index 0000000..c1878c0
--- /dev/null
@@ -0,0 +1,37 @@
+/**
+ * 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.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.onap.sdc.workflowdesigner.externalservice.sdc.entity.ActivitySpec;
+
+@Path("")
+public interface ActivitySpecService {
+  @GET
+  @Path("/activity-spec?Filter=Certified")
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
+  public ActivitySpec[] getActivitySpecs(
+      @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/ActivitySpecServiceProxy.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/ActivitySpecServiceProxy.java
new file mode 100644 (file)
index 0000000..fa1987e
--- /dev/null
@@ -0,0 +1,70 @@
+/**
+ * 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 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.ActivitySpec;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
+
+/**
+ * 
+ */
+public class ActivitySpecServiceProxy {
+  private static final Logger LOGGER = LoggerFactory.getLogger(SDCService.class);
+
+  private static final String AUTHORIZATION = AppConfig.getSdcServiceProxy().getAuthorization();
+
+  private static final String X_ECOMP_INSTANCE_ID =
+      AppConfig.getSdcServiceProxy().getxEcompInstanceId();
+  /** */
+  private static final String Activity_ROOT_PATH = "/activityspec-api/v1.0";
+
+
+  private static String getActivityRootPath() {
+    return AppConfig.getSdcServiceProxy().getServiceAddr() + Activity_ROOT_PATH;
+  }
+
+  /**
+   * @return
+   */
+  private ActivitySpecService getActivityServiceProxy() {
+    ClientConfig config = new ClientConfig();
+    return ConsumerFactory.createConsumer(getActivityRootPath(), config, ActivitySpecService.class);
+  }
+
+
+  /**
+   * 
+   * @return
+   * @throws WorkflowDesignerException
+   */
+  public ActivitySpec[] getActivitySpecs() throws WorkflowDesignerException {
+    ActivitySpecService serviceProxy = getActivityServiceProxy();
+    try {
+      return serviceProxy.getActivitySpecs(X_ECOMP_INSTANCE_ID, AUTHORIZATION);
+    } catch (Exception e) {
+      LOGGER.error("Get Activity Specifications Failed.", e);
+      throw new WorkflowDesignerException("Get Activity Specifications Failed.", e);
+    }
+  }
+
+
+}
index 6319cbf..b925c03 100644 (file)
@@ -32,23 +32,22 @@ public class SDCServiceProxy {
 
   private static final String AUTHORIZATION = AppConfig.getSdcServiceProxy().getAuthorization();
 
-  private static final String X_ECOMP_INSTANCE_ID = AppConfig.getSdcServiceProxy().getxEcompInstanceId();
+  private static final String X_ECOMP_INSTANCE_ID =
+      AppConfig.getSdcServiceProxy().getxEcompInstanceId();
   /** */
   private static final String SDC_ROOT_PATH = "/sdc/v1";
-  
+
 
   private static String getSDCRootPath() {
     return AppConfig.getSdcServiceProxy().getServiceAddr() + SDC_ROOT_PATH;
   }
-  
+
   /**
    * @return
    */
   private SDCService getSDCServiceProxy() {
     ClientConfig config = new ClientConfig();
-    SDCService sdcServiceProxy =
-        ConsumerFactory.createConsumer(getSDCRootPath(), config, SDCService.class);
-    return sdcServiceProxy;
+    return ConsumerFactory.createConsumer(getSDCRootPath(), config, SDCService.class);
   }
 
   /**
@@ -61,10 +60,9 @@ public class SDCServiceProxy {
    */
   public void saveWorkflowArtifact(String uuid, String operationId, String workflowId,
       WorkflowArtifactInfo workflowArtifactInfo) throws WorkflowDesignerException {
-    SDCService sdcServiceProxy = getSDCServiceProxy();
+    SDCService serviceProxy = getSDCServiceProxy();
     try {
-      sdcServiceProxy.saveWorkflowArtifact(uuid, operationId, workflowId,
-          X_ECOMP_INSTANCE_ID,
+      serviceProxy.saveWorkflowArtifact(uuid, operationId, workflowId, X_ECOMP_INSTANCE_ID,
           AUTHORIZATION, workflowArtifactInfo);
     } catch (Exception e) {
       LOGGER.error("Save WorkflowArtifact Failed.", e);
@@ -82,14 +80,13 @@ public class SDCServiceProxy {
    */
   public WorkflowArtifactInfo getWorkflowArtifact(String uuid, String operationId,
       String workflowId) throws WorkflowDesignerException {
-    SDCService sdcServiceProxy = getSDCServiceProxy();
+    SDCService serviceProxy = getSDCServiceProxy();
     try {
-      return sdcServiceProxy.getWorkflowArtifact(uuid, operationId, workflowId,
-          X_ECOMP_INSTANCE_ID,
+      return serviceProxy.getWorkflowArtifact(uuid, operationId, workflowId, X_ECOMP_INSTANCE_ID,
           AUTHORIZATION);
     } catch (Exception e) {
       LOGGER.error("Get WorkflowArtifact Failed.", e);
-      throw new WorkflowDesignerException("Save WorkflowArtifact Failed.", e);
+      throw new WorkflowDesignerException("Get WorkflowArtifact Failed.", e);
     }
   }