summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/clamp/clds/Application.java2
-rw-r--r--src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java11
-rw-r--r--src/main/java/org/onap/clamp/clds/config/PolicyConfiguration.java128
-rw-r--r--src/main/resources/application.properties17
-rw-r--r--src/main/resources/clds/clds-policy-config.properties37
5 files changed, 150 insertions, 45 deletions
diff --git a/src/main/java/org/onap/clamp/clds/Application.java b/src/main/java/org/onap/clamp/clds/Application.java
index 9d057b583..ae8b6d82b 100644
--- a/src/main/java/org/onap/clamp/clds/Application.java
+++ b/src/main/java/org/onap/clamp/clds/Application.java
@@ -42,6 +42,7 @@ import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
@@ -56,6 +57,7 @@ import org.springframework.scheduling.annotation.EnableAsync;
DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class, JpaRepositoriesAutoConfiguration.class,
SecurityAutoConfiguration.class, ManagementWebSecurityAutoConfiguration.class
})
+@EnableConfigurationProperties
@EnableAsync
public class Application extends SpringBootServletInitializer {
diff --git a/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java b/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java
index 8caac0c7d..5c68f00b9 100644
--- a/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java
+++ b/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java
@@ -26,7 +26,6 @@ package org.onap.clamp.clds.client.req.policy;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -38,6 +37,7 @@ import java.util.UUID;
import javax.ws.rs.BadRequestException;
import org.onap.clamp.clds.config.ClampProperties;
+import org.onap.clamp.clds.config.PolicyConfiguration;
import org.onap.clamp.clds.exception.policy.PolicyClientException;
import org.onap.clamp.clds.model.properties.ModelProperties;
import org.onap.clamp.clds.util.LoggingUtils;
@@ -55,7 +55,6 @@ import org.onap.policy.api.PolicyParameters;
import org.onap.policy.api.PolicyType;
import org.onap.policy.api.PushPolicyParameters;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
@@ -71,12 +70,12 @@ public class PolicyClient {
protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
protected static final String POLICY_MSTYPE_PROPERTY_NAME = "policy.ms.type";
protected static final String POLICY_ONAPNAME_PROPERTY_NAME = "policy.onap.name";
- @Value("${clamp.config.files.cldsPolicyConfig:'classpath:/clds/clds-policy-config.properties'}")
- protected String cldsPolicyConfigFile;
@Autowired
protected ApplicationContext appContext;
@Autowired
protected ClampProperties refProp;
+ @Autowired
+ private PolicyConfiguration policyConfiguration;
/**
* Perform BRMS policy type.
@@ -353,9 +352,7 @@ public class PolicyClient {
private PolicyEngine getPolicyEngine() {
PolicyEngine policyEngine;
try {
- policyEngine = new PolicyEngine(appContext.getResource(cldsPolicyConfigFile).getFile().getAbsolutePath());
- } catch (IOException e1) {
- throw new PolicyClientException("Exception when opening policy config file", e1);
+ policyEngine = new PolicyEngine(policyConfiguration.getProperties());
} catch (PolicyEngineException e) {
throw new PolicyClientException("Exception when creating a new policy engine", e);
}
diff --git a/src/main/java/org/onap/clamp/clds/config/PolicyConfiguration.java b/src/main/java/org/onap/clamp/clds/config/PolicyConfiguration.java
new file mode 100644
index 000000000..53899d5e5
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/config/PolicyConfiguration.java
@@ -0,0 +1,128 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2018 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============================================
+ * ===================================================================
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.clamp.clds.config;
+
+import java.util.Properties;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+@Component
+@ConfigurationProperties(prefix = "clamp.config.policy")
+public class PolicyConfiguration {
+
+ public static final String PDP_URL1 = "PDP_URL1";
+ public static final String PDP_URL2 = "PDP_URL2";
+ public static final String PAP_URL = "PAP_URL";
+ public static final String NOTIFICATION_TYPE = "NOTIFICATION_TYPE";
+ public static final String NOTIFICATION_UEB_SERVERS = "NOTIFICATION_UEB_SERVERS";
+ public static final String CLIENT_ID = "CLIENT_ID";
+ public static final String CLIENT_KEY = "CLIENT_KEY";
+ public static final String ENVIRONMENT = "ENVIRONMENT";
+ private String pdpUrl1;
+ private String pdpUrl2;
+ private String papUrl;
+ private String notificationType;
+ private String notificationUebServers;
+ private String clientId;
+ private String clientKey;
+ private String policyEnvironment;
+
+ public String getPdpUrl1() {
+ return pdpUrl1;
+ }
+
+ public void setPdpUrl1(String pdpUrl1) {
+ this.pdpUrl1 = pdpUrl1;
+ }
+
+ public String getPdpUrl2() {
+ return pdpUrl2;
+ }
+
+ public void setPdpUrl2(String pdpUrl2) {
+ this.pdpUrl2 = pdpUrl2;
+ }
+
+ public String getPapUrl() {
+ return papUrl;
+ }
+
+ public void setPapUrl(String papUrl) {
+ this.papUrl = papUrl;
+ }
+
+ public String getNotificationType() {
+ return notificationType;
+ }
+
+ public void setNotificationType(String notificationType) {
+ this.notificationType = notificationType;
+ }
+
+ public String getNotificationUebServers() {
+ return notificationUebServers;
+ }
+
+ public void setNotificationUebServers(String notificationUebServers) {
+ this.notificationUebServers = notificationUebServers;
+ }
+
+ public String getClientId() {
+ return clientId;
+ }
+
+ public void setClientId(String clientId) {
+ this.clientId = clientId;
+ }
+
+ public String getClientKey() {
+ return clientKey;
+ }
+
+ public void setClientKey(String clientKey) {
+ this.clientKey = clientKey;
+ }
+
+ public String getPolicyEnvironment() {
+ return policyEnvironment;
+ }
+
+ public void setPolicyEnvironment(String environment) {
+ this.policyEnvironment = environment;
+ }
+
+ public Properties getProperties() {
+ Properties prop = new Properties();
+ prop.put(PDP_URL1, pdpUrl1);
+ prop.put(PDP_URL2, pdpUrl2);
+ prop.put(PAP_URL, papUrl);
+ prop.put(NOTIFICATION_TYPE, notificationType);
+ prop.put(NOTIFICATION_UEB_SERVERS, notificationUebServers);
+ prop.put(CLIENT_ID, clientId);
+ prop.put(CLIENT_KEY, clientKey);
+ prop.put(ENVIRONMENT, policyEnvironment);
+ return prop;
+ }
+}
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 5f6a0d659..1411b8b2b 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -124,6 +124,21 @@ clamp.config.sdc.template=classpath:/clds/templates/sdc-template.json
clamp.config.sdc.decode.service_ids=classpath:/clds/templates/sdc-decode-service_ids.json
#
#
+# Configuration Settings for Policy Engine Components
+clamp.config.policy.pdpUrl1=http://vm1.policy.simpledemo.onap.org:8081/pdp/ , testpdp, alpha123
+clamp.config.policy.pdpUrl2=http://vm1.policy.simpledemo.onap.org:8081/pdp/ , testpdp, alpha123
+clamp.config.policy.papUrl=http://vm1.policy.simpledemo.onap.org:8081/pap/ , testpap, alpha123
+clamp.config.policy.notificationType=websocket
+clamp.config.policy.notificationUebServers=localhost
+clamp.config.policy.notificationTopic=
+clamp.config.policy.clientId=myclientid
+# base64 encoding
+
+clamp.config.policy.clientKey=5CE79532B3A2CB4D132FC0C04BF916A7
+#DEVL for development
+#TEST for Test environments
+#PROD for prod environments
+clamp.config.policy.policyEnvironment=TEST
# General Policy request properties
#
clamp.config.policy.onap.name=DCAE
@@ -203,4 +218,4 @@ clamp.config.security.permission.type.cl.event=permission-type-cl-event
clamp.config.security.permission.type.filter.vf=permission-type-filter-vf
clamp.config.security.permission.type.template=permission-type-template
#This one indicates the type of instances (dev|prod|perf...), this must be set accordingly in clds-users.properties
-clamp.config.security.permission.instance=dev \ No newline at end of file
+clamp.config.security.permission.instance=dev
diff --git a/src/main/resources/clds/clds-policy-config.properties b/src/main/resources/clds/clds-policy-config.properties
deleted file mode 100644
index 54b927727..000000000
--- a/src/main/resources/clds/clds-policy-config.properties
+++ /dev/null
@@ -1,37 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# ONAP CLAMP
-# ================================================================================
-# Copyright (C) 2017 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============================================
-# ===================================================================
-# ECOMP is a trademark and service mark of AT&T Intellectual Property.
-###
-
-# Configuration Settings for Policy Engine Components
-PDP_URL1=http://vm1.policy.simpledemo.onap.org:8081/pdp/ , testpdp, alpha123
-PDP_URL2=http://vm1.policy.simpledemo.onap.org:8081/pdp/ , testpdp, alpha123
-NOTIFICATION_TYPE=websocket
-NOTIFICATION_UEB_SERVERS=localhost
-NOTIFICATION_TOPIC=
-CLIENT_ID=myclientid
-# base64 encoding
-#CLIENT_KEY=ChlakDuk
-CLIENT_KEY=5CE79532B3A2CB4D132FC0C04BF916A7
-#DEVL for development
-#TEST for Test environments
-#PROD for prod environments
-ENVIRONMENT=TEST \ No newline at end of file