df3f5465e670c50dcc3edce49a866b0cf0879abd
[so.git] / bpmn / so-bpmn-tasks / src / main / java / org / onap / so / bpmn / infrastructure / flowspecific / tasks / AssignNetworkBBUtils.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Modifications Copyright (c) 2019 Samsung
8  * ================================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=========================================================
21  */
22 package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
23
24 import org.camunda.bpm.engine.delegate.BpmnError;
25 import org.onap.so.bpmn.common.BuildingBlockExecution;
26 import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
27 import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
28 import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
29 import org.onap.so.client.exception.ExceptionBuilder;
30 import org.onap.so.client.orchestration.AAINetworkResources;
31 import org.onap.so.client.orchestration.SDNCNetworkResources;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
34 import org.springframework.beans.factory.annotation.Autowired;
35 import org.springframework.stereotype.Component;
36
37 @Component
38 public class AssignNetworkBBUtils {
39
40         private static final Logger logger = LoggerFactory.getLogger(AssignNetworkBBUtils.class);
41         @Autowired
42         private ExceptionBuilder exceptionUtil;
43         @Autowired
44         private AAINetworkResources aaiNetworkResources;
45         @Autowired
46         private SDNCNetworkResources sdncNetworkResources;
47         @Autowired
48         private ExtractPojosForBB extractPojosForBB;
49
50         /**
51          * BPMN access method. Verify if network name was provided as input to BB
52          * @param execution
53          * @return
54          */
55         public boolean networkFoundByName(BuildingBlockExecution execution) throws Exception {
56                 boolean found = false;
57                 //TODO - populate logic after iTrack MSO-2143 implemented
58                 return found;
59         }
60         
61         /**
62          * BPMN access method to extract Cloud Region data
63          * @param execution
64          * @throws Exception
65          */
66         public void getCloudRegion(BuildingBlockExecution execution) {
67                 try{
68                         GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
69                         CloudRegion cloudRegion = gBBInput.getCloudRegion();
70                         String cloudRegionSdnc;
71                         String cloudRegionPo = cloudRegion.getLcpCloudRegionId();
72                         if (cloudRegion.getCloudRegionVersion().equalsIgnoreCase("2.5")){
73                                 cloudRegionSdnc = "AAIAIC25";
74                         } else {
75                                 cloudRegionSdnc = cloudRegionPo;
76                         }
77                         execution.setVariable("cloudRegionPo", cloudRegionPo);
78                         execution.setVariable("cloudRegionSdnc", cloudRegionSdnc);
79                 }catch (Exception ex) {
80                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
81                 }
82         }
83         
84         /**
85          * BPMN access method. Process silent success scenario
86          * @param execution
87          */
88         public void processSilentSuccess(BuildingBlockExecution execution) {
89                         String msg = "Silent success processing network assign";
90                 logger.info(msg);
91         }
92         
93         /**
94          * BPMN access method. Process silent success scenario
95          * @param execution
96          */
97         public void failOrchestrationStatus(BuildingBlockExecution execution) {
98                 BpmnError error = new BpmnError("Failed orchestration status verificaiton");
99                 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, error);
100         }
101 }