aboutsummaryrefslogtreecommitdiffstats
path: root/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyEngine.java
diff options
context:
space:
mode:
Diffstat (limited to 'PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyEngine.java')
-rw-r--r--PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyEngine.java39
1 files changed, 27 insertions, 12 deletions
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyEngine.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyEngine.java
index 3d3eceead..2349c2e2f 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyEngine.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyEngine.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* PolicyEngineAPI
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -175,6 +175,13 @@ public class StdPolicyEngine {
public StdPolicyEngine(final String propertyFilePath, final String clientKey) throws PolicyEngineException {
setProperty(propertyFilePath, clientKey);
}
+
+ /*
+ * Taking the Property structure even if it null.
+ */
+ public StdPolicyEngine(final Properties properties, final String clientKey) throws PolicyEngineException {
+ setProperty(properties, clientKey);
+ }
/*
* Taking the Notification Constructor.
@@ -840,14 +847,22 @@ public class StdPolicyEngine {
throw new PolicyEngineException(
XACMLErrorConstants.ERROR_DATA_ISSUE + "Error NO PropertyFile Path provided");
}
-
final Properties prop = getProperties(propertyFilePath);
+ setProperty(prop,clientKey);
+ }
+
+ private void setProperty(final Properties properties, String clientKey) throws PolicyEngineException {
+ if (properties == null) {
+ throw new PolicyEngineException(
+ XACMLErrorConstants.ERROR_DATA_ISSUE + "NO properties provided, the value is NULL");
+ }
+
// UEB and DMAAP Settings
- final String notificationTypeValue = prop.getProperty(NOTIFICATION_TYPE_PROP_NAME);
- final String serverList = prop.getProperty(NOTIFICATION_SERVERS_PROP_NAME);
- topic = prop.getProperty(NOTIFICATION_TOPIC_PROP_NAME);
- apiKey = prop.getProperty(UEB_API_KEY_PROP_NAME);
- apiSecret = prop.getProperty(UEB_API_SECRET_PROP_NAME);
+ final String notificationTypeValue = properties.getProperty(NOTIFICATION_TYPE_PROP_NAME);
+ final String serverList = properties.getProperty(NOTIFICATION_SERVERS_PROP_NAME);
+ topic = properties.getProperty(NOTIFICATION_TOPIC_PROP_NAME);
+ apiKey = properties.getProperty(UEB_API_KEY_PROP_NAME);
+ apiSecret = properties.getProperty(UEB_API_SECRET_PROP_NAME);
setNotificationType(notificationTypeValue, DEFAULT_NOTIFICATION);
@@ -867,9 +882,9 @@ public class StdPolicyEngine {
}
// Client ID Authorization Settings.
- final String clientID = prop.getProperty(CLIENT_ID_PROP_NAME);
+ final String clientID = properties.getProperty(CLIENT_ID_PROP_NAME);
if (clientKey == null) {
- clientKey = getClientKeyFromProperties(prop);
+ clientKey = getClientKeyFromProperties(properties);
}
if (clientID == null || clientKey == null || clientID.isEmpty() || clientKey.isEmpty()) {
LOGGER.error(XACMLErrorConstants.ERROR_PERMISSIONS
@@ -880,12 +895,12 @@ public class StdPolicyEngine {
setClientId(clientID.trim());
setClientKey(clientKey.trim());
}
- setEnvironment(prop);
+ setEnvironment(properties);
// Initializing the values.
init();
- readPdpProperites(prop);
+ readPdpProperites(properties);
// Get JUNIT property from properties file when running tests
- checkJunit(prop);
+ checkJunit(properties);
}
private void readPdpProperites(final Properties prop) throws PolicyEngineException {