Adding preload capability using userParams
[so.git] / bpmn / so-bpmn-tasks / src / main / java / org / onap / so / bpmn / infrastructure / adapter / vnfm / tasks / utils / UserParamInputParametersProvider.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2019 Nordix Foundation.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  * 
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  * 
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  * 
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20 package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils;
21
22 import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.ADDITIONAL_PARAMS;
23 import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.EXT_VIRTUAL_LINKS;
24 import java.util.Map;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
27 import org.springframework.stereotype.Service;
28
29 /**
30  * @author Waqas Ikram (waqas.ikram@ericsson.com)
31  *
32  */
33 @Service
34 public class UserParamInputParametersProvider extends AbstractInputParametersProvider<Map<String, Object>> {
35     private static final Logger LOGGER = LoggerFactory.getLogger(UserParamInputParametersProvider.class);
36
37     @Override
38     public InputParameter getInputParameter(final Map<String, Object> userParams) {
39         if (userParams != null) {
40             final InputParameter inputParameter = new InputParameter();
41             final Object additionalParams = userParams.get(ADDITIONAL_PARAMS);
42
43             if (additionalParams != null && additionalParams instanceof String) {
44                 inputParameter.setAdditionalParams(parseAdditionalParameters(additionalParams.toString()));
45             }
46
47             final Object extVirtualLinks = userParams.get(EXT_VIRTUAL_LINKS);
48             if (extVirtualLinks != null && extVirtualLinks instanceof String) {
49                 inputParameter.setExtVirtualLinks(parseExternalVirtualLinks(extVirtualLinks.toString()));
50             }
51             LOGGER.info("InputParameter found in userParams : {}", inputParameter);
52             return inputParameter;
53         }
54         LOGGER.warn("No input parameters found ...");
55         return NullInputParameter.NULL_INSTANCE;
56     }
57
58 }