2 * Copyright 2017-2018 ZTE Corporation.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.onap.sdc.workflowdesigner.externalservice.sdc;
18 import org.glassfish.jersey.client.ClientConfig;
19 import org.onap.sdc.workflowdesigner.common.WorkflowDesignerException;
20 import org.onap.sdc.workflowdesigner.config.AppConfig;
21 import org.onap.sdc.workflowdesigner.externalservice.sdc.entity.WorkflowArtifactInfo;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
25 import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
30 public class SDCServiceProxy {
31 private static final Logger LOGGER = LoggerFactory.getLogger(SDCService.class);
33 private static final String AUTHORIZATION = AppConfig.getSdcServiceProxy().getAuthorization();
35 private static final String X_ECOMP_INSTANCE_ID =
36 AppConfig.getSdcServiceProxy().getxEcompInstanceId();
38 private static final String SDC_ROOT_PATH = "/sdc/v1";
41 private static String getSDCRootPath() {
42 return AppConfig.getSdcServiceProxy().getServiceAddr() + SDC_ROOT_PATH;
48 private SDCService getSDCServiceProxy() {
49 ClientConfig config = new ClientConfig();
50 return ConsumerFactory.createConsumer(getSDCRootPath(), config, SDCService.class);
58 * @param workflowArtifactInfo
59 * @throws WorkflowDesignerException
61 public void saveWorkflowArtifact(String uuid, String operationId, String workflowId,
62 WorkflowArtifactInfo workflowArtifactInfo) throws WorkflowDesignerException {
63 SDCService serviceProxy = getSDCServiceProxy();
65 serviceProxy.saveWorkflowArtifact(uuid, operationId, workflowId, X_ECOMP_INSTANCE_ID,
66 AUTHORIZATION, workflowArtifactInfo);
67 } catch (Exception e) {
68 LOGGER.error("Save WorkflowArtifact Failed.", e);
69 throw new WorkflowDesignerException("Save WorkflowArtifact Failed.", e);
79 * @throws WorkflowDesignerException
81 public WorkflowArtifactInfo getWorkflowArtifact(String uuid, String operationId,
82 String workflowId) throws WorkflowDesignerException {
83 SDCService serviceProxy = getSDCServiceProxy();
85 return serviceProxy.getWorkflowArtifact(uuid, operationId, workflowId, X_ECOMP_INSTANCE_ID,
87 } catch (Exception e) {
88 LOGGER.error("Get WorkflowArtifact Failed.", e);
89 throw new WorkflowDesignerException("Get WorkflowArtifact Failed.", e);