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