summaryrefslogtreecommitdiffstats
path: root/mod2/catalog-service
diff options
context:
space:
mode:
authorMantena, Ravi (rx908f) <rx908f@att.com>2020-12-29 13:46:37 -0500
committerRavi Mantena <rx908f@att.com>2020-12-30 09:22:37 -0500
commit3681b0c5b9ecf13e1d3decb14c4dce0b3140377c (patch)
tree61c02c5e3f03211b6ac08486b02c5f1380f29af3 /mod2/catalog-service
parent2f551ba584dbb70568a69144b39e6da7c55c517f (diff)
Update to Policy Model to use sigle map to wrap object Issue-ID: DCAEGEN2-1867
Change-Id: I71d1bc8f0a3ace22a1713c6d74f7fb1c9b27d0c1 Issue-ID: DCAEGEN2-1867 Signed-off-by: Ravi Mantena <rx908f@att.com>
Diffstat (limited to 'mod2/catalog-service')
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/policymodel/EnvInfo.java43
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/util/PolicyModelUtils.java38
2 files changed, 56 insertions, 25 deletions
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/policymodel/EnvInfo.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/policymodel/EnvInfo.java
new file mode 100644
index 0000000..cf676d5
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/policymodel/EnvInfo.java
@@ -0,0 +1,43 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.policymodel;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * A model class which represents Distribution Info of a Policy Model entity
+ */
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class EnvInfo {
+
+ private String url;
+ private String username;
+ private String password;
+
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/util/PolicyModelUtils.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/util/PolicyModelUtils.java
index 8d7b643..30e13ea 100644
--- a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/util/PolicyModelUtils.java
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/util/PolicyModelUtils.java
@@ -24,6 +24,7 @@ import io.netty.handler.ssl.SslContext;
import io.netty.handler.ssl.SslContextBuilder;
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
import org.onap.dcaegen2.platform.mod.model.exceptions.policymodel.PolicyModelDistributionEnvNotFoundException;
+import org.onap.dcaegen2.platform.mod.model.policymodel.EnvInfo;
import org.onap.dcaegen2.platform.mod.model.policymodel.PolicyModelDistributionEnv;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
@@ -96,31 +97,18 @@ public class PolicyModelUtils {
@Value("${prod.password}")
private String prodServerUserPassword;
- Map<String, String> envToUrlMap,envToUserNameMap,envToPasswordMap;
+ Map<String, EnvInfo> envMap;
/**
* Creates a Policy Model Distribution Engine URL for the Environment requested
*/
@PostConstruct
public void init() {
- envToUrlMap = new HashMap<>();
- envToUserNameMap = new HashMap();
- envToPasswordMap = new HashMap();
-
- envToUrlMap.put(PolicyModelDistributionEnv.DEV.name(), "https://"+ devServer + ":" + devServerPort + urlpath);
- envToUrlMap.put(PolicyModelDistributionEnv.PST.name(), "https://"+ pstServer + ":" + pstServerPort + urlpath);
- envToUrlMap.put(PolicyModelDistributionEnv.ETE.name(), "https://"+ eteServer + ":" + eteServerPort + urlpath);
- envToUrlMap.put(PolicyModelDistributionEnv.PROD.name(), "https://"+ prodServer + ":" + prodServerPort + urlpath);
-
- envToUserNameMap.put(PolicyModelDistributionEnv.DEV.name(), devServerUser);
- envToUserNameMap.put(PolicyModelDistributionEnv.PST.name(), pstServerUser);
- envToUserNameMap.put(PolicyModelDistributionEnv.ETE.name(), eteServerUser);
- envToUserNameMap.put(PolicyModelDistributionEnv.PROD.name(), prodServerUser);
-
- envToPasswordMap.put(PolicyModelDistributionEnv.DEV.name(), devServerUserPassword);
- envToPasswordMap.put(PolicyModelDistributionEnv.PST.name(), pstServerUserPassword);
- envToPasswordMap.put(PolicyModelDistributionEnv.ETE.name(), eteServerUserPassword);
- envToPasswordMap.put(PolicyModelDistributionEnv.PROD.name(), prodServerUserPassword);
+ envMap = new HashMap<>();
+ envMap.put(PolicyModelDistributionEnv.DEV.name(), EnvInfo.builder().url("https://"+ devServer + ":" + devServerPort + urlpath).username(devServerUser).password(devServerUserPassword).build());
+ envMap.put(PolicyModelDistributionEnv.PST.name(), EnvInfo.builder().url("https://"+ pstServer + ":" + pstServerPort + urlpath).username(pstServerUser).password(pstServerUserPassword).build());
+ envMap.put(PolicyModelDistributionEnv.ETE.name(), EnvInfo.builder().url("https://"+ eteServer + ":" + eteServerPort + urlpath).username(eteServerUser).password(eteServerUserPassword).build());
+ envMap.put(PolicyModelDistributionEnv.PROD.name(), EnvInfo.builder().url("https://"+ prodServer + ":" + prodServerPort + urlpath).username(prodServerUser).password(prodServerUserPassword).build());
}
/**
@@ -130,8 +118,8 @@ public class PolicyModelUtils {
* @return
*/
public String getPolicyEngineURL(String env) {
- if(!envToUrlMap.containsKey(env)) throw new PolicyModelDistributionEnvNotFoundException(String.format("Policy Model Environment with env %s invalid", env));
- return envToUrlMap.get(env);
+ if(!envMap.containsKey(env)) throw new PolicyModelDistributionEnvNotFoundException(String.format("Policy Model Environment with env %s invalid", env));
+ return envMap.get(env).getUrl();
}
@@ -144,8 +132,8 @@ public class PolicyModelUtils {
*/
public String getUserName(String env) {
- if(!envToUserNameMap.containsKey(env)) throw new PolicyModelDistributionEnvNotFoundException(String.format("Policy Model Environment with env %s invalid", env));
- return envToUserNameMap.get(env);
+ if(!envMap.containsKey(env)) throw new PolicyModelDistributionEnvNotFoundException(String.format("Policy Model Environment with env %s invalid", env));
+ return envMap.get(env).getUsername();
}
@@ -157,8 +145,8 @@ public class PolicyModelUtils {
*/
public String getPassword(String env) {
- if(!envToPasswordMap.containsKey(env)) throw new PolicyModelDistributionEnvNotFoundException(String.format("Policy Model Environment with env %s invalid", env));
- return envToPasswordMap.get(env);
+ if(!envMap.containsKey(env)) throw new PolicyModelDistributionEnvNotFoundException(String.format("Policy Model Environment with env %s invalid", env));
+ return envMap.get(env).getPassword();
}
/**