2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.ccsdk.sli.northbound.uebclient;
24 import java.io.BufferedReader;
26 import java.io.FileReader;
27 import java.io.IOException;
28 import java.util.HashMap;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
34 public class SdncArtifactMap {
36 private static final Logger LOG = LoggerFactory
37 .getLogger(SdncArtifactMap.class);
39 public class SdncArtifactType {
41 private String artifactType;
45 public String getTag() {
48 public String getArtifactType() {
51 public String getRpc() {
55 public int getPass() {
59 public String getRpcUrl(String base) {
63 private SdncArtifactType(String tag, String rpc, String pass) {
67 this.pass = Integer.parseInt(pass);
68 } catch (Exception e) {
69 LOG.error("Invalid pass value for artifact map entry ({} {} {})", tag, rpc, pass, e);
76 private Map<String, SdncArtifactType> mapItems = new HashMap<String, SdncArtifactType>();
78 private int NumPasses = 1;
80 public int getNumPasses() {
84 public void load(String fileName) {
86 File mapFile = new File(fileName);
88 if (mapFile.exists() && mapFile.canRead()) {
90 try (BufferedReader rdr = new BufferedReader(new FileReader(mapFile))) {
92 for (String ln ; (ln = rdr.readLine()) != null ; ) {
93 String[] lnFields = ln.split(",");
94 if (lnFields.length == 3) {
95 SdncArtifactType entry = new SdncArtifactType(lnFields[0], lnFields[1], lnFields[2]);
96 mapItems.put(entry.getTag(), entry);
97 if (entry.getPass() + 1 > NumPasses ) {
98 NumPasses = entry.getPass() + 1;
104 } catch (Exception e) {
105 LOG.error("Caught exception reading artifact map", e);
111 public SdncArtifactType getMapping(String tag) {
112 if (mapItems.containsKey(tag)) {
113 return(mapItems.get(tag));
119 public static SdncArtifactMap getInstance() {
120 return new SdncArtifactMap();