Call rest api to retrive activity specs.
Issue-ID: SDC-1129
Change-Id: Iae2144c01bffe39cf2691d12b7916afcb77f8090
Signed-off-by: YuanHu <yuan.hu1@zte.com.cn>
--- /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.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;
+
+}
--- /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 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);
+ }
+ }
+
+
+}
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);
}
/**
*/
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);
*/
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);
}
}