2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (c) 2021 AT&T 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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.dcaegen2.platform.mod.util;
23 import java.util.HashMap;
25 import javax.annotation.PostConstruct;
26 import org.onap.dcaegen2.platform.mod.model.exceptions.policymodel.PolicyModelDistributionEnvNotFoundException;
27 import org.onap.dcaegen2.platform.mod.model.policymodel.EnvInfo;
28 import org.onap.dcaegen2.platform.mod.model.policymodel.PolicyModelDistributionEnv;
29 import org.springframework.beans.factory.annotation.Value;
30 import org.springframework.stereotype.Component;
33 * Policy Model Service Utils to get URL, Username, Password, Webclient
37 public class BlueprintDistributionUtils {
39 @Value("${dcae.platform.url.path}")
40 private String urlpath;
42 @Value("${dcae.platform.dev.server}")
43 private String devServer;
45 @Value("${dcae.platform.dev.port}")
46 private String devServerPort;
48 @Value("${dcae.platform.dev.user}")
49 private String devServerUser;
51 @Value("${dcae.platform.dev.password}")
52 private String devServerUserPassword;
54 @Value("${dcae.platform.pst.server}")
55 private String pstServer;
57 @Value("${dcae.platform.pst.port}")
58 private String pstServerPort;
60 @Value("${dcae.platform.pst.user}")
61 private String pstServerUser;
63 @Value("${dcae.platform.pst.password}")
64 private String pstServerUserPassword;
66 @Value("${dcae.platform.ete.server}")
67 private String eteServer;
69 @Value("${dcae.platform.ete.port}")
70 private String eteServerPort;
72 @Value("${dcae.platform.ete.user}")
73 private String eteServerUser;
75 @Value("${dcae.platform.ete.password}")
76 private String eteServerUserPassword;
78 @Value("${dcae.platform.prod.server}")
79 private String prodServer;
81 @Value("${dcae.platform.prod.port}")
82 private String prodServerPort;
84 @Value("${dcae.platform.prod.user}")
85 private String prodServerUser;
87 @Value("${dcae.platform.prod.password}")
88 private String prodServerUserPassword;
90 Map<String, EnvInfo> envMap;
93 * Creates a Blueprint Distribution Dashboard URL for the Environment requested
97 envMap = new HashMap<>();
98 envMap.put(PolicyModelDistributionEnv.DEV.name(), EnvInfo.builder().url("https://"+ devServer + ":" + devServerPort + urlpath).username(devServerUser).password(devServerUserPassword).build());
99 envMap.put(PolicyModelDistributionEnv.PST.name(), EnvInfo.builder().url("https://"+ pstServer + ":" + pstServerPort + urlpath).username(pstServerUser).password(pstServerUserPassword).build());
100 envMap.put(PolicyModelDistributionEnv.ETE.name(), EnvInfo.builder().url("https://"+ eteServer + ":" + eteServerPort + urlpath).username(eteServerUser).password(eteServerUserPassword).build());
101 envMap.put(PolicyModelDistributionEnv.PROD.name(), EnvInfo.builder().url("https://"+ prodServer + ":" + prodServerPort + urlpath).username(prodServerUser).password(prodServerUserPassword).build());
105 * Generates a Blueprint Distribution Dashboard URL for the Environment
110 public String getBlueprintDashboardURL(String env) {
111 if(!envMap.containsKey(env)) throw new PolicyModelDistributionEnvNotFoundException(String.format("Blueprint Dashboard Environment with env %s invalid", env));
112 return envMap.get(env).getUrl();
116 * Generates a Blueprint Distribution Dashboard UserName for the Environment
122 public String getBlueprintDashboardUserName(String env) {
123 if(!envMap.containsKey(env)) throw new PolicyModelDistributionEnvNotFoundException(String.format("Blueprint Dashboard Environment with env %s invalid", env));
124 return envMap.get(env).getUsername();
129 * Generates a Blueprint Distribution Dashboard Password for the Environment
135 public String getBlueprintDashboardPassword(String env) {
136 if(!envMap.containsKey(env)) throw new PolicyModelDistributionEnvNotFoundException(String.format("Blueprint Dashboard Environment with env %s invalid", env));
137 return envMap.get(env).getPassword();