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.openecomp.sdnc.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+")");
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 BufferedReader rdr = null;
93 rdr = new BufferedReader(new FileReader(mapFile));
95 for (String ln ; (ln = rdr.readLine()) != null ; ) {
96 String[] lnFields = ln.split(",");
97 if (lnFields.length == 3) {
98 SdncArtifactType entry = new SdncArtifactType(lnFields[0], lnFields[1], lnFields[2]);
99 mapItems.put(entry.getTag(), entry);
100 if (entry.getPass() + 1 > NumPasses ) {
101 NumPasses = entry.getPass() + 1;
107 } catch (Exception e) {
108 LOG.error("Caught exception reading artifact map", e);
114 } catch (IOException e) {
122 public SdncArtifactType getMapping(String tag) {
123 if (mapItems.containsKey(tag)) {
124 return(mapItems.get(tag));
130 public static SdncArtifactMap getInstance() {
131 return new SdncArtifactMap();