Replaced all tabs with spaces in java and pom.xml
[so.git] / bpmn / so-bpmn-infrastructure-common / src / main / java / org / onap / so / bpmn / infrastructure / pnf / delegate / CreatePnfEntryInAaiDelegate.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Modifications Copyright 2018 Nokia
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
23 package org.onap.so.bpmn.infrastructure.pnf.delegate;
24
25 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID;
26 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID;
27 import org.camunda.bpm.engine.delegate.DelegateExecution;
28 import org.camunda.bpm.engine.delegate.JavaDelegate;
29 import org.onap.aai.domain.yang.Pnf;
30 import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
33 import org.springframework.beans.factory.annotation.Autowired;
34 import org.springframework.stereotype.Component;
35
36 /**
37  * Implementation of "Create Pnf entry in AAI" task in CreateAndActivatePnfResource.bpmn
38  *
39  * Inputs: - pnfCorrelationId - String - pnfUuid - String
40  */
41 @Component
42 public class CreatePnfEntryInAaiDelegate implements JavaDelegate {
43
44     private static final Logger logger = LoggerFactory.getLogger(CreatePnfEntryInAaiDelegate.class);
45     private PnfManagement pnfManagement;
46
47     @Autowired
48     public void setPnfManagement(PnfManagement pnfManagement) {
49         this.pnfManagement = pnfManagement;
50     }
51
52     @Override
53     public void execute(DelegateExecution execution) throws Exception {
54         String pnfCorrelationId = (String) execution.getVariable(PNF_CORRELATION_ID);
55         String pnfUuid = (String) execution.getVariable(PNF_UUID);
56         Pnf pnf = new Pnf();
57         pnf.setPnfId(pnfUuid);
58         pnf.setPnfName(pnfCorrelationId);
59         pnfManagement.createEntry(pnfCorrelationId, pnf);
60         logger.debug("AAI entry is created for pnf correlation id: {}, pnf uuid: {}", pnfCorrelationId, pnfUuid);
61     }
62 }