Merge "Added informing dmaap client in pnf-ready workflow"
[so.git] / bpmn / MSOInfrastructureBPMN / src / main / java / org / openecomp / mso / bpmn / infrastructure / properties / BPMNProperties.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2018 Huawei 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.openecomp.mso.bpmn.infrastructure.properties;
21
22 import org.openecomp.mso.logger.MessageEnum;
23 import org.openecomp.mso.logger.MsoLogger;
24 import org.openecomp.mso.properties.MsoPropertiesException;
25 import org.openecomp.mso.properties.MsoPropertiesFactory;
26
27 import java.util.Arrays;
28 import java.util.List;
29
30 public class BPMNProperties {
31
32     public static String MSO_PROP_BPMN = "MSO_PROP_BPMN";
33
34     private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA);
35
36     public static String getProperty(String key, String defaultValue) {
37         String value;
38         try {
39             value =  new MsoPropertiesFactory().getMsoJavaProperties(MSO_PROP_BPMN).getProperty(key, defaultValue);
40         } catch (MsoPropertiesException e) {
41              msoLogger.error (MessageEnum.NO_PROPERTIES, "Unknown. Mso Properties ID not found in cache: "
42                      + MSO_PROP_BPMN, "BPMN", "", MsoLogger.ErrorCode.DataError,
43                      "Exception - Mso Properties ID not found in cache", e);
44             return null;
45         }
46         msoLogger.debug("Config read for " + MSO_PROP_BPMN + " - key:" + key + " value:" + value);
47         return value;
48     }
49
50     public static List<String> getResourceSequenceProp() {
51         String resource_sequence = getProperty("resource_sequence", null);
52         if (resource_sequence != null) {
53             String[] resourceSequence = resource_sequence.split(",");
54             return Arrays.asList(resource_sequence);
55         }
56         return Arrays.asList(ResourceSequence.RESOURCE_EPC,
57                 ResourceSequence.RESOURCE_IMS,
58                 ResourceSequence.RESOUCE_OVERLAY,
59                 ResourceSequence.RESOURCE_UNDERLAY);
60     }
61 }