CorrelationId cleanup
[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
28 import org.camunda.bpm.engine.delegate.DelegateExecution;
29 import org.camunda.bpm.engine.delegate.JavaDelegate;
30 import org.onap.aai.domain.yang.Pnf;
31 import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement;
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 /**
38  * Implementation of "Create Pnf entry in AAI" task in CreateAndActivatePnfResource.bpmn
39  *
40  * Inputs:
41  *  - pnfCorrelationId - String
42  *  - pnfUuid - String
43  */
44 @Component
45 public class CreatePnfEntryInAaiDelegate implements JavaDelegate {
46
47     private static final Logger logger = LoggerFactory.getLogger(CreatePnfEntryInAaiDelegate.class);
48     private PnfManagement pnfManagement;
49
50     @Autowired
51     public void setPnfManagement(PnfManagement pnfManagement) {
52         this.pnfManagement = pnfManagement;
53     }
54
55     @Override
56     public void execute(DelegateExecution execution) throws Exception {
57         String pnfCorrelationId = (String) execution.getVariable(PNF_CORRELATION_ID);
58         String pnfUuid = (String) execution.getVariable(PNF_UUID);
59         Pnf pnf = new Pnf();
60         pnf.setPnfId(pnfUuid);
61         pnf.setPnfName(pnfCorrelationId);
62         pnfManagement.createEntry(pnfCorrelationId, pnf);
63         logger.debug("AAI entry is created for pnf correlation id: {}, pnf uuid: {}", pnfCorrelationId, pnfUuid);
64     }
65 }