Replaced all tabs with spaces in java and pom.xml
[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      * 
53      * @param execution
54      * @return
55      */
56     public boolean networkFoundByName(BuildingBlockExecution execution) throws Exception {
57         boolean found = false;
58         // TODO - populate logic after iTrack MSO-2143 implemented
59         return found;
60     }
61
62     /**
63      * BPMN access method to extract Cloud Region data
64      * 
65      * @param execution
66      * @throws Exception
67      */
68     public void getCloudRegion(BuildingBlockExecution execution) {
69         try {
70             GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
71             CloudRegion cloudRegion = gBBInput.getCloudRegion();
72             String cloudRegionSdnc;
73             String cloudRegionPo = cloudRegion.getLcpCloudRegionId();
74             if (cloudRegion.getCloudRegionVersion().equalsIgnoreCase("2.5")) {
75                 cloudRegionSdnc = "AAIAIC25";
76             } else {
77                 cloudRegionSdnc = cloudRegionPo;
78             }
79             execution.setVariable("cloudRegionPo", cloudRegionPo);
80             execution.setVariable("cloudRegionSdnc", cloudRegionSdnc);
81         } catch (Exception ex) {
82             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
83         }
84     }
85
86     /**
87      * BPMN access method. Process silent success scenario
88      * 
89      * @param execution
90      */
91     public void processSilentSuccess(BuildingBlockExecution execution) {
92         String msg = "Silent success processing network assign";
93         logger.info(msg);
94     }
95
96     /**
97      * BPMN access method. Process silent success scenario
98      * 
99      * @param execution
100      */
101     public void failOrchestrationStatus(BuildingBlockExecution execution) {
102         BpmnError error = new BpmnError("Failed orchestration status verificaiton");
103         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, error);
104     }
105 }