c9c0f810f04305304c7ff0afb3390d56ccb0d0f0
[sdc/sdc-workflow-designer.git] /
1 /**
2  * Copyright 2017-2018 ZTE Corporation.
3  *
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 package org.onap.sdc.workflowdesigner.externalservice.sdc;
17
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;
24
25 import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
26
27 /**
28  * 
29  */
30 public class SDCServiceProxy {
31   private static final Logger LOGGER = LoggerFactory.getLogger(SDCService.class);
32
33   /**
34    * @return
35    */
36   private SDCService getSDCServiceProxy() {
37     ClientConfig config = new ClientConfig();
38     SDCService sdcServiceProxy =
39         ConsumerFactory.createConsumer(AppConfig.getSDCAddr(), config, SDCService.class);
40     return sdcServiceProxy;
41   }
42
43   /**
44    * 
45    * @param uuid
46    * @param operationId
47    * @param workflowId
48    * @param workflowArtifactInfo
49    * @throws WorkflowDesignerException
50    */
51   public void saveWorkflowArtifact(String uuid, String operationId, String workflowId,
52       WorkflowArtifactInfo workflowArtifactInfo) throws WorkflowDesignerException {
53     SDCService sdcServiceProxy = getSDCServiceProxy();
54     try {
55       sdcServiceProxy.saveWorkflowArtifact(uuid, operationId, workflowId,
56           AppConfig.getSdcServiceProxy().getxEcompInstanceId(),
57           AppConfig.getSdcServiceProxy().getAuthorization(), workflowArtifactInfo);
58     } catch (Exception e) {
59       LOGGER.error("Save WorkflowArtifact Failed.", e);
60       throw new WorkflowDesignerException("Save WorkflowArtifact Failed.", e);
61     }
62   }
63
64   /**
65    * 
66    * @param uuid
67    * @param operationId
68    * @param workflowId
69    * @return
70    * @throws WorkflowDesignerException
71    */
72   public WorkflowArtifactInfo getWorkflowArtifact(String uuid, String operationId,
73       String workflowId) throws WorkflowDesignerException {
74     SDCService sdcServiceProxy = getSDCServiceProxy();
75     try {
76       return sdcServiceProxy.getWorkflowArtifact(uuid, operationId, workflowId,
77           AppConfig.getSdcServiceProxy().getxEcompInstanceId(),
78           AppConfig.getSdcServiceProxy().getAuthorization());
79     } catch (Exception e) {
80       LOGGER.error("Get WorkflowArtifact Failed.", e);
81       throw new WorkflowDesignerException("Save WorkflowArtifact Failed.", e);
82     }
83   }
84
85
86 }