aboutsummaryrefslogtreecommitdiffstats
path: root/PolicyEngineAPI/src/main/java/org/openecomp/policy/std
diff options
context:
space:
mode:
authorGuo Ruijing <ruijing.guo@intel.com>2017-07-31 08:47:35 +0000
committerPamela Dragosh <pdragosh@research.att.com>2017-07-31 15:51:10 -0400
commit073cc188efe9abb4c010cf674e34e2cf46ef1c52 (patch)
tree155c23fbdf3a838ecb5f4183fc3bb6b09aac41eb /PolicyEngineAPI/src/main/java/org/openecomp/policy/std
parent4ca818fdfb9b807562166800a086b413593d6894 (diff)
[POLICY-73] replace openecomp for policy-engine
Change-Id: I54072f6bcd388c0e05562614ee89b4ae7ad67004 Signed-off-by: Guo Ruijing <ruijing.guo@intel.com> Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'PolicyEngineAPI/src/main/java/org/openecomp/policy/std')
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientDMAAP.java132
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientEnd.java248
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientUEB.java178
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEnd.java138
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEndDMAAP.java107
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEndUEB.java160
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/std/MatchStore.java246
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/std/Matches.java48
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/std/NotificationUnMarshal.java69
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdDecisionResponse.java55
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdDictionaryResponse.java73
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdMetricsResponse.java78
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyChangeResponse.java47
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyConfig.java168
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyEngine.java1254
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyResponse.java98
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdStatus.java235
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/std/package-info.java27
18 files changed, 0 insertions, 3361 deletions
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientDMAAP.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientDMAAP.java
deleted file mode 100644
index 563cd85ca..000000000
--- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientDMAAP.java
+++ /dev/null
@@ -1,132 +0,0 @@
-package org.openecomp.policy.std;
-
-import java.util.List;
-import java.util.UUID;
-
-import org.openecomp.policy.api.NotificationHandler;
-import org.openecomp.policy.api.NotificationScheme;
-import org.openecomp.policy.api.NotificationType;
-import org.openecomp.policy.api.PDPNotification;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.flexlogger.Logger;
-import org.openecomp.policy.utils.BusConsumer;
-import org.openecomp.policy.xacml.api.XACMLErrorConstants;
-
-public class AutoClientDMAAP implements Runnable {
- private static StdPDPNotification notification = null;
- private static NotificationScheme scheme = null;
- private static NotificationHandler handler = null;
- private static String topic = null;
- private static boolean status = false;
- private static Logger logger = FlexLogger.getLogger(AutoClientDMAAP.class.getName());
- private static String notficatioinType = null;
- private static BusConsumer dmaapConsumer = null;
- private static List<String> dmaapList = null;
- private static String aafLogin = null;
- private static String aafPassword = null;
- public volatile boolean isRunning = false;
-
-
- public AutoClientDMAAP(List<String> dmaapList, String topic, String aafLogin, String aafPassword) {
- AutoClientDMAAP.topic = topic;
- AutoClientDMAAP.dmaapList = dmaapList;
- AutoClientDMAAP.aafLogin = aafLogin;
- AutoClientDMAAP.aafPassword = aafPassword;
- }
-
- public void setAuto(NotificationScheme scheme,
- NotificationHandler handler) {
- AutoClientDMAAP.scheme = scheme;
- AutoClientDMAAP.handler = handler;
- }
-
- public static void setScheme(NotificationScheme scheme) {
- AutoClientDMAAP.scheme = scheme;
- }
-
- public static boolean getStatus(){
- return AutoClientDMAAP.status;
- }
-
- public static String getTopic() {
- return AutoClientDMAAP.topic;
- }
-
- public static String getNotficationType(){
- return AutoClientDMAAP.notficatioinType;
- }
-
- public synchronized boolean isRunning() {
- return this.isRunning;
- }
-
- public synchronized void terminate() {
- this.isRunning = false;
- }
-
- @Override
- public void run() {
- synchronized(this) {
- this.isRunning = true;
- }
- String group = UUID.randomUUID ().toString ();
- String id = "0";
-
- // Stop and Start needs to be done.
- if (scheme != null && handler!=null) {
- if (scheme.equals(NotificationScheme.AUTO_ALL_NOTIFICATIONS) || scheme.equals(NotificationScheme.AUTO_NOTIFICATIONS)) {
-
- // create a loop to listen for messages from DMaaP server
- try {
- dmaapConsumer = new BusConsumer.DmaapConsumerWrapper(dmaapList, topic, aafLogin, aafPassword, group, id, 15*1000, 1000 );
- } catch (Exception e) {
- logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Unable to create DMaaP Consumer: ", e);
- }
-
- while (this.isRunning() )
- {
- try {
- for ( String msg : dmaapConsumer.fetch () )
- {
- logger.debug("Auto Notification Recieved Message " + msg + " from DMAAP server : " + dmaapList.toString());
- notification = NotificationUnMarshal.notificationJSON(msg);
- callHandler();
- }
- } catch (Exception e) {
- logger.debug("Error in processing DMAAP message");
- }
-
- }
- logger.debug("Stopping DMAAP Consumer loop will no longer fetch messages from the servers");
- }
- }
- }
-
- private static void callHandler() {
- if (handler != null && scheme != null) {
- if (scheme.equals(NotificationScheme.AUTO_ALL_NOTIFICATIONS)) {
- boolean removed = false, updated = false;
- if (notification.getRemovedPolicies() != null && !notification.getRemovedPolicies().isEmpty()) {
- removed = true;
- }
- if (notification.getLoadedPolicies() != null && !notification.getLoadedPolicies().isEmpty()) {
- updated = true;
- }
- if (removed && updated) {
- notification.setNotificationType(NotificationType.BOTH);
- } else if (removed) {
- notification.setNotificationType(NotificationType.REMOVE);
- } else if (updated) {
- notification.setNotificationType(NotificationType.UPDATE);
- }
- handler.notificationReceived(notification);
- } else if (scheme.equals(NotificationScheme.AUTO_NOTIFICATIONS)) {
- PDPNotification newNotification = MatchStore.checkMatch(notification);
- if (newNotification.getNotificationType() != null) {
- handler.notificationReceived(newNotification);
- }
- }
- }
- }
-
-}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientEnd.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientEnd.java
deleted file mode 100644
index 06a2e471e..000000000
--- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientEnd.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * PolicyEngineAPI
- * ================================================================================
- * 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=========================================================
- */
-
-package org.openecomp.policy.std;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import javax.websocket.ClientEndpoint;
-import javax.websocket.DeploymentException;
-import javax.websocket.OnClose;
-import javax.websocket.OnError;
-import javax.websocket.OnMessage;
-import javax.websocket.OnOpen;
-import javax.websocket.Session;
-
-//import org.apache.log4j.Logger;
-import org.glassfish.tyrus.client.ClientManager;
-import org.openecomp.policy.api.NotificationHandler;
-import org.openecomp.policy.api.NotificationScheme;
-import org.openecomp.policy.api.NotificationType;
-import org.openecomp.policy.api.PDPNotification;
-import org.openecomp.policy.std.NotificationStore;
-import org.openecomp.policy.std.StdPDPNotification;
-
-import org.openecomp.policy.xacml.api.XACMLErrorConstants;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import org.openecomp.policy.common.logging.flexlogger.*;
-
-@ClientEndpoint
-public class AutoClientEnd {
- private static StdPDPNotification notification = null;
- private static StdPDPNotification oldNotification = null;
- private static ClientManager client = null;
- private static NotificationScheme scheme = null;
- private static NotificationHandler handler = null;
- private static String url = null;
- private static Session session = null;
- private static boolean status = false;
- private static boolean stop = false;
- private static boolean message = false;
- private static boolean error = false;
- private static Logger logger = FlexLogger.getLogger(AutoClientEnd.class.getName());
-
- public static void setAuto(NotificationScheme scheme,
- NotificationHandler handler) {
- AutoClientEnd.scheme = scheme;
- AutoClientEnd.handler = handler;
- }
-
- public static void setScheme(NotificationScheme scheme) {
- AutoClientEnd.scheme = scheme;
- }
-
- public static boolean getStatus(){
- return AutoClientEnd.status;
- }
-
- public static String getURL() {
- return AutoClientEnd.url;
- }
-
- public static void start(String url) {
- AutoClientEnd.url = url;
- // Stop and Start needs to be done.
- if (scheme != null && handler!=null) {
- if (scheme.equals(NotificationScheme.AUTO_ALL_NOTIFICATIONS) || scheme.equals(NotificationScheme.AUTO_NOTIFICATIONS)) {
- if (AutoClientEnd.client == null) {
- client = ClientManager.createClient();
- if(url.contains("https")){
- url = url.replaceAll("https", "wss");
- }else {
- url = url.replaceAll("http", "ws");
- }
- try {
- logger.info("Starting Auto Notification with the PDP server : " + url);
- client.connectToServer(AutoClientEnd.class, new URI(url + "notifications"));
- status = true;
- if(error){
- // The URL's will be in Sync according to design Spec.
- ManualClientEnd.start(AutoClientEnd.url);
- StdPDPNotification notification = NotificationStore.getDeltaNotification((StdPDPNotification)ManualClientEnd.result(NotificationScheme.MANUAL_ALL_NOTIFICATIONS));
- if(notification.getNotificationType()!=null){
- if(oldNotification!=notification){
- oldNotification= notification;
- AutoClientEnd.notification = notification;
- callHandler();
- }
- }
- error = false;
- }
- //
- } catch (DeploymentException | IOException | URISyntaxException e) {
- logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e);
- client = null;
- status = false;
- changeURL();
- }
- }
- }
- }
- }
-
- private static void changeURL(){
- // Change the PDP if it is not Up.
- StdPolicyEngine.rotatePDPList();
- start(StdPolicyEngine.getPDPURL());
- }
-
- public static void stop() {
- if (client != null) {
- client.shutdown();
- if(session!=null){
- try {
- stop = true;
- logger.info("\n Closing Auto Notification WebSocket Connection.. ");
- session.close();
- session = null;
- } catch (IOException e) {
- //
- }
- }
- client = null;
- status = false;
- stop = false;
- }
- }
-
- private static void callHandler() {
- if (handler != null && scheme != null) {
- if (scheme.equals(NotificationScheme.AUTO_ALL_NOTIFICATIONS)) {
- boolean removed = false, updated = false;
- if (notification.getRemovedPolicies() != null && !notification.getRemovedPolicies().isEmpty()) {
- removed = true;
- }
- if (notification.getLoadedPolicies() != null && !notification.getLoadedPolicies().isEmpty()) {
- updated = true;
- }
- if (removed && updated) {
- notification.setNotificationType(NotificationType.BOTH);
- } else if (removed) {
- notification.setNotificationType(NotificationType.REMOVE);
- } else if (updated) {
- notification.setNotificationType(NotificationType.UPDATE);
- }
- try{
- handler.notificationReceived(notification);
- }catch (Exception e){
- logger.error("Error in Clients Handler Object : ", e);
- }
- } else if (scheme.equals(NotificationScheme.AUTO_NOTIFICATIONS)) {
- PDPNotification newNotification = MatchStore.checkMatch(notification);
- if (newNotification.getNotificationType() != null) {
- try{
- handler.notificationReceived(newNotification);
- }catch (Exception e){
- logger.error("Error in Clients Handler Object : ", e);
- }
- }
- }
- }
- }
-
- // WebSockets Code..
- @OnOpen
- public void onOpen(Session session) throws IOException {
- // session.getBasicRemote().sendText("Connected to Client with Session: "
- // + session.getId());
- logger.debug("Auto Notification Session Started... " + session.getId());
- if(AutoClientEnd.session == null){
- AutoClientEnd.session = session;
- }
- }
-
- @OnError
- public void onError(Session session, Throwable e) {
- // trying to Restart by self.
- logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Session Error.. "+ session.getId() + "\n Error is : " + e );
- // logger.error("Exception Occured"+e);
- stop();
- if (url != null) {
- client = null;
- status = false;
- error= true;
- start(url);
- }
- }
-
- @OnClose
- public void onClose(Session session) {
- logger.info("Session ended with "+ session.getId());
- if(!stop && !message){
- // This Block of code is executed if there is any Network Failure or if the Notification is Down.
- logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Disconnected from Notification Server");
- client = null;
- status = false;
- AutoClientEnd.session=null;
- // Try to connect Back to available PDP.
- error = true;
- start(url);
- }
- AutoClientEnd.message=false;
- }
-
- @OnMessage
- public void onMessage(String message, Session session) throws JsonParseException, JsonMappingException, IOException {
- AutoClientEnd.message = true;
- logger.debug("Auto Notification Recieved Message " + message + " Session info is : " + session.getId());
- try {
- notification = NotificationUnMarshal.notificationJSON(message);
- } catch (Exception e) {
- logger.error("PE500 " + e);
- }
- if(AutoClientEnd.session == session){
- try{
- NotificationStore.recordNotification(notification);
- }catch(Exception e){
- logger.error(e);
- }
- if(oldNotification!=notification){
- oldNotification= notification;
- callHandler();
- }
- }else{
- session.close();
- }
- AutoClientEnd.message = false;
- }
-}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientUEB.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientUEB.java
deleted file mode 100644
index 782187720..000000000
--- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientUEB.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * PolicyEngineAPI
- * ================================================================================
- * 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=========================================================
- */
-
-package org.openecomp.policy.std;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.List;
-import java.util.UUID;
-
-import org.openecomp.policy.api.NotificationHandler;
-import org.openecomp.policy.api.NotificationScheme;
-import org.openecomp.policy.api.NotificationType;
-import org.openecomp.policy.api.PDPNotification;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.flexlogger.Logger;
-import org.openecomp.policy.xacml.api.XACMLErrorConstants;
-
-import com.att.nsa.cambria.client.CambriaClientBuilders;
-import com.att.nsa.cambria.client.CambriaClientBuilders.ConsumerBuilder;
-import com.att.nsa.cambria.client.CambriaConsumer;
-/**
- * Create a UEB Consumer to receive policy update notification.
- *
- *
- *
- */
-public class AutoClientUEB implements Runnable {
- private static StdPDPNotification notification = null;
- private static NotificationScheme scheme = null;
- private static NotificationHandler handler = null;
- private static String topic = null;
- private static String url = null;
- private static boolean status = false;
- private static Logger logger = FlexLogger.getLogger(AutoClientUEB.class.getName());
- private static String notficatioinType = null;
- private static CambriaConsumer CConsumer = null;
- private static String apiKey = null;
- private static String apiSecret = null;
- private static List<String> uebURLList = null;
- public volatile boolean isRunning = false;
-
-
- public AutoClientUEB(String url, List<String> uebURLList, String apiKey, String apiSecret) {
- AutoClientUEB.url = url;
- AutoClientUEB.uebURLList = uebURLList;
- AutoClientUEB.apiKey = apiKey;
- AutoClientUEB.apiKey = apiKey;
- }
-
- public void setAuto(NotificationScheme scheme,
- NotificationHandler handler) {
- AutoClientUEB.scheme = scheme;
- AutoClientUEB.handler = handler;
- }
-
- public static void setScheme(NotificationScheme scheme) {
- AutoClientUEB.scheme = scheme;
- }
-
- public static boolean getStatus(){
- return AutoClientUEB.status;
- }
-
- public static String getURL() {
- return AutoClientUEB.url;
- }
-
- public static String getNotficationType(){
- return AutoClientUEB.notficatioinType;
- }
-
- public synchronized boolean isRunning() {
- return this.isRunning;
- }
-
- public synchronized void terminate() {
- this.isRunning = false;
- }
-
- @Override
- public void run() {
- synchronized(this) {
- this.isRunning = true;
- }
- String group = UUID.randomUUID ().toString ();
- String id = "0";
- //String topic = null;
- // Stop and Start needs to be done.
- if (scheme != null && handler!=null) {
- if (scheme.equals(NotificationScheme.AUTO_ALL_NOTIFICATIONS) || scheme.equals(NotificationScheme.AUTO_NOTIFICATIONS)) {
- URL aURL;
- try {
- aURL = new URL(AutoClientUEB.topic);
- topic = aURL.getHost() + aURL.getPort();
- } catch (MalformedURLException e) {
- topic = AutoClientUEB.url.replace("[:/]", "");
- }
-
- try {
- //CConsumer = CambriaClientFactory.createConsumer ( null, uebURLList, topic, group, id, 15*1000, 1000 );
- ConsumerBuilder builder = new CambriaClientBuilders.ConsumerBuilder();
- builder.knownAs(group, id)
- .usingHosts(uebURLList)
- .onTopic(topic)
- .waitAtServer(15*1000)
- .receivingAtMost(1000)
- .authenticatedBy(apiKey, apiSecret);
-
- CConsumer = builder.build();
-
- } catch (Exception e1) {
- logger.error("Exception Occured" + e1);
- }
- while (this.isRunning() )
- {
- try {
- for ( String msg : CConsumer.fetch () )
- {
- logger.debug("Auto Notification Recieved Message " + msg + " from UEB cluster : " + uebURLList.toString());
- notification = NotificationUnMarshal.notificationJSON(msg);
- callHandler();
- }
- } catch (Exception e) {
- logger.debug(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Error in processing UEB message" + e.getMessage());
- }
-
- }
- logger.debug("Stopping UEB Consumer loop will not logger fetch messages from the cluster");
- }
- }
- }
-
- private static void callHandler() {
- if (handler != null && scheme != null) {
- if (scheme.equals(NotificationScheme.AUTO_ALL_NOTIFICATIONS)) {
- boolean removed = false, updated = false;
- if (notification.getRemovedPolicies() != null && !notification.getRemovedPolicies().isEmpty()) {
- removed = true;
- }
- if (notification.getLoadedPolicies() != null && !notification.getLoadedPolicies().isEmpty()) {
- updated = true;
- }
- if (removed && updated) {
- notification.setNotificationType(NotificationType.BOTH);
- } else if (removed) {
- notification.setNotificationType(NotificationType.REMOVE);
- } else if (updated) {
- notification.setNotificationType(NotificationType.UPDATE);
- }
- handler.notificationReceived(notification);
- } else if (scheme.equals(NotificationScheme.AUTO_NOTIFICATIONS)) {
- PDPNotification newNotification = MatchStore.checkMatch(notification);
- if (newNotification.getNotificationType() != null) {
- handler.notificationReceived(newNotification);
- }
- }
- }
- }
-
-}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEnd.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEnd.java
deleted file mode 100644
index c006b057b..000000000
--- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEnd.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * PolicyEngineAPI
- * ================================================================================
- * 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=========================================================
- */
-
-package org.openecomp.policy.std;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.concurrent.CountDownLatch;
-
-import javax.websocket.ClientEndpoint;
-import javax.websocket.DeploymentException;
-import javax.websocket.OnClose;
-import javax.websocket.OnError;
-import javax.websocket.OnMessage;
-import javax.websocket.OnOpen;
-import javax.websocket.Session;
-
-//import org.apache.log4j.Logger;
-import org.glassfish.tyrus.client.ClientManager;
-import org.openecomp.policy.api.NotificationScheme;
-import org.openecomp.policy.api.NotificationType;
-import org.openecomp.policy.api.PDPNotification;
-import org.openecomp.policy.std.StdPDPNotification;
-
-import org.openecomp.policy.xacml.api.XACMLErrorConstants;
-
-import org.openecomp.policy.common.logging.flexlogger.*;
-
-@ClientEndpoint
-public class ManualClientEnd {
- private static CountDownLatch latch;
- private static StdPDPNotification notification = null;
- private static String resultJson = null;
- private static Logger logger = FlexLogger.getLogger(ManualClientEnd.class.getName());
-
- public static void start(String url) {
- latch = new CountDownLatch(1);
- ClientManager client = ClientManager.createClient();
- if(url.contains("https")){
- url = url.replaceAll("https", "wss");
- }else {
- url = url.replaceAll("http", "ws");
- }
- try {
- client.connectToServer(ManualClientEnd.class, new URI(url+"notifications"));
- latch.await();
- } catch (DeploymentException | URISyntaxException | InterruptedException e) {
- logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e);
- } catch (IOException e) {
- logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e);
- }
- }
-
- public static PDPNotification result(NotificationScheme scheme) {
- if (resultJson == null || notification == null) {
- logger.debug("No Result" );
- return null;
- } else {
- if(scheme.equals(NotificationScheme.MANUAL_ALL_NOTIFICATIONS)) {
- boolean removed = false, updated = false;
- if(notification.getRemovedPolicies()!=null && !notification.getRemovedPolicies().isEmpty()){
- removed = true;
- }
- if(notification.getLoadedPolicies()!=null && !notification.getLoadedPolicies().isEmpty()){
- updated = true;
- }
- if(removed && updated) {
- notification.setNotificationType(NotificationType.BOTH);
- }else if(removed){
- notification.setNotificationType(NotificationType.REMOVE);
- }else if(updated){
- notification.setNotificationType(NotificationType.UPDATE);
- }
- return notification;
- }else if(scheme.equals(NotificationScheme.MANUAL_NOTIFICATIONS)) {
- return MatchStore.checkMatch(notification);
- }else {
- return null;
- }
- }
- }
-
- // WebSockets Code..
- @OnOpen
- public void onOpen(Session session) throws IOException {
- logger.info("Session Started with : " + session.getId());
- session.getBasicRemote().sendText("Manual");
- }
-
- @OnError
- public void onError(Session session, Throwable e) {
- logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error in: "+ session.getId());
- latch.countDown();
- }
-
- @OnClose
- public void onClose(Session session) {
- logger.info("Session ended with "+ session.getId());
- latch.countDown();
- }
-
- @OnMessage
- public void onMessage(String message, Session session){
- logger.debug(" Manual Notification Recieved Message : " + message +" Session info is : "+ session.getId());
- resultJson = message;
- try {
- notification = NotificationUnMarshal.notificationJSON(message);
- } catch (Exception e) {
- logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e);
- latch.countDown();
- }
- try {
- session.close();
- } catch (IOException e) {
- logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- latch.countDown();
- } // For Manual Client..
- latch.countDown();
- }
-}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEndDMAAP.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEndDMAAP.java
deleted file mode 100644
index f4a218d66..000000000
--- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEndDMAAP.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package org.openecomp.policy.std;
-
-import java.util.List;
-
-import org.json.JSONObject;
-import org.openecomp.policy.api.NotificationScheme;
-import org.openecomp.policy.api.NotificationType;
-import org.openecomp.policy.api.PDPNotification;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.flexlogger.Logger;
-import org.openecomp.policy.utils.BusConsumer;
-import org.openecomp.policy.utils.BusPublisher;
-import org.openecomp.policy.xacml.api.XACMLErrorConstants;
-
-public class ManualClientEndDMAAP {
- private static StdPDPNotification notification = null;
- private static String resultJson = null;
- private static Logger logger = FlexLogger.getLogger(ManualClientEndDMAAP.class.getName());
- private static BusConsumer dmaapConsumer = null;
- private static String uniquID = null;
- private static String topic = null;
-
-
- public static PDPNotification result(NotificationScheme scheme) {
- if (resultJson == null || notification == null) {
- logger.debug("No Result" );
- return null;
- } else {
- if(scheme.equals(NotificationScheme.MANUAL_ALL_NOTIFICATIONS)) {
- boolean removed = false, updated = false;
- if(notification.getRemovedPolicies()!=null && !notification.getRemovedPolicies().isEmpty()){
- removed = true;
- }
- if(notification.getLoadedPolicies()!=null && !notification.getLoadedPolicies().isEmpty()){
- updated = true;
- }
- if(removed && updated) {
- notification.setNotificationType(NotificationType.BOTH);
- }else if(removed){
- notification.setNotificationType(NotificationType.REMOVE);
- }else if(updated){
- notification.setNotificationType(NotificationType.UPDATE);
- }
- return notification;
- }else if(scheme.equals(NotificationScheme.MANUAL_NOTIFICATIONS)) {
- return MatchStore.checkMatch(notification);
- }else {
- return null;
- }
- }
- }
-
- private static void publishMessage(String pubTopic, String uniqueID, List<String> dmaapList, String aafLogin, String aafPassword) {
- BusPublisher pub = null;
- try {
- pub = new BusPublisher.DmaapPublisherWrapper(dmaapList, topic, aafLogin, aafPassword);
- final JSONObject msg1 = new JSONObject ();
- msg1.put ( "JSON", "DMaaP Update Request UID=" + uniqueID);
- pub.send ( "MyPartitionKey", msg1.toString () );
- } catch (Exception e) {
- logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Unable to create DMaaP Publisher: ", e);
- }
- if(pub != null){
- pub.close ();
- }
- }
-
- //NOTE: should be able to remove this for DMAAP since we will not be creating topics dynamically
- public static void createTopic (String topic, String uniquID, List<String> dmaapList, String aafLogin, String aafPassword){
- ManualClientEndDMAAP.topic = topic;
- publishMessage(topic, uniquID, dmaapList, aafLogin, aafPassword);
- }
-
-
- public static void start(List<String> dmaapList, String topic, String aafLogin, String aafPassword, String uniqueID) {
-
- ManualClientEndDMAAP.uniquID = uniqueID;
- ManualClientEndDMAAP.topic = topic;
-
- String id = "0";
-
- try {
- dmaapConsumer = new BusConsumer.DmaapConsumerWrapper(dmaapList, topic, aafLogin, aafPassword, "clientGroup", id, 15*1000, 1000);
- } catch (Exception e) {
- logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Unable to create DMaaP Consumer: ", e);
- }
-
- int count = 1;
- while (count < 4) {
- publishMessage(topic, uniquID, dmaapList, aafLogin, aafPassword);
- try {
- for ( String msg : dmaapConsumer.fetch () )
- {
- logger.debug("Manual Notification Recieved Message " + msg + " from DMaaP server : " + dmaapList.toString());
- resultJson = msg;
- if (!msg.contains("DMaaP Update")){
- notification = NotificationUnMarshal.notificationJSON(msg);
- count = 4;
- }
- }
- }catch (Exception e) {
- logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Unable to fetch messages from DMaaP servers: ", e);
- }
- count++;
- }
- }
-}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEndUEB.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEndUEB.java
deleted file mode 100644
index 85d5659e8..000000000
--- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEndUEB.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * PolicyEngineAPI
- * ================================================================================
- * 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=========================================================
- */
-
-package org.openecomp.policy.std;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.List;
-
-import org.json.JSONObject;
-import org.openecomp.policy.api.NotificationScheme;
-import org.openecomp.policy.api.NotificationType;
-import org.openecomp.policy.api.PDPNotification;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.flexlogger.Logger;
-
-import com.att.nsa.cambria.client.CambriaClientFactory;
-import com.att.nsa.cambria.client.CambriaConsumer;
-import com.att.nsa.cambria.client.CambriaPublisher;
-
-
-@SuppressWarnings("deprecation")
-public class ManualClientEndUEB {
- private static StdPDPNotification notification = null;
- private static String resultJson = null;
- private static Logger logger = FlexLogger.getLogger(ManualClientEndUEB.class.getName());
- private static CambriaConsumer CConsumer = null;
- @SuppressWarnings("unused")
- private static List<String> uebURLList = null;
- @SuppressWarnings("unused")
- private static boolean messageNotReceived = false;
- @SuppressWarnings("unused")
- private static String url = null;
- private static String uniquID = null;
- private static String topic = null;
-
-
- public static PDPNotification result(NotificationScheme scheme) {
- if (resultJson == null || notification == null) {
- logger.debug("No Result" );
- return null;
- } else {
- if(scheme.equals(NotificationScheme.MANUAL_ALL_NOTIFICATIONS)) {
- boolean removed = false, updated = false;
- if(notification.getRemovedPolicies()!=null && !notification.getRemovedPolicies().isEmpty()){
- removed = true;
- }
- if(notification.getLoadedPolicies()!=null && !notification.getLoadedPolicies().isEmpty()){
- updated = true;
- }
- if(removed && updated) {
- notification.setNotificationType(NotificationType.BOTH);
- }else if(removed){
- notification.setNotificationType(NotificationType.REMOVE);
- }else if(updated){
- notification.setNotificationType(NotificationType.UPDATE);
- }
- return notification;
- }else if(scheme.equals(NotificationScheme.MANUAL_NOTIFICATIONS)) {
- return MatchStore.checkMatch(notification);
- }else {
- return null;
- }
- }
- }
-
- private static void publishMessage(String pubTopic, String uniqueID , List<String> uebURLList) {
-
- String UEBlist = uebURLList.toString();
- UEBlist = UEBlist.substring(1,UEBlist.length()-1);
- CambriaPublisher pub = null;
- try {
- pub = CambriaClientFactory.createSimplePublisher(null, UEBlist, pubTopic);
- } catch (Exception e1) {
- logger.error("Exception Occured"+e1);
- }
- final JSONObject msg1 = new JSONObject ();
-
- msg1.put ( "JSON", "UEB Update Ruest UID=" + uniqueID);
- if(pub != null){
- try {
- pub.send ( "MyPartitionKey", msg1.toString () );
- pub.close ();
- } catch (IOException e) {
- logger.error("Exception Occured"+e);
- }
- }
- }
-
- public static void createTopic (String url, String uniquID, List<String> uebURLList){
- URL aURL;
- try {
- aURL = new URL(url);
- topic = aURL.getHost() + aURL.getPort();
- } catch (MalformedURLException e) {
- topic = url.replace("[:/]", "");
- }
-
- publishMessage(topic+ uniquID , uniquID, uebURLList);
-
- }
- public static void start(String url, List<String> uebURLList,
- String uniqueID) {
- ManualClientEndUEB.uebURLList = uebURLList;
- ManualClientEndUEB.url = url;
- ManualClientEndUEB.uniquID = uniqueID;
- URL aURL;
- try {
- aURL = new URL(url);
- ManualClientEndUEB.topic = aURL.getHost() + aURL.getPort();
- } catch (MalformedURLException e) {
- ManualClientEndUEB.topic = url.replace("[:/]", "");
- }
- String id = "0";
- try {
- CConsumer = CambriaClientFactory.createConsumer ( null, uebURLList, topic + uniquID, "clientGroup", id, 15*1000, 1000 );
- } catch (Exception e1) {
- logger.error("Exception Occured"+e1);
- }
- int count = 1;
- while (count < 4) {
- publishMessage(topic + "UpdateRequest", uniquID, uebURLList);
- try {
- for ( String msg : CConsumer.fetch () )
- {
-
- logger.debug("Manual Notification Recieved Message " + msg + " from UEB cluster : " + uebURLList.toString());
- resultJson = msg;
- if (!msg.contains("UEB Update")){
-// System.out.println("Manual Notification Recieved Message " + msg + " from UEB cluster : " + uebURLList.toString());
- notification = NotificationUnMarshal.notificationJSON(msg);
- count = 4;
- }
- }
- }catch (Exception e) {
-
- }
- count++;
- }
- }
-
-}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/MatchStore.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/MatchStore.java
deleted file mode 100644
index 1459dd9d9..000000000
--- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/MatchStore.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * PolicyEngineAPI
- * ================================================================================
- * 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=========================================================
- */
-
-package org.openecomp.policy.std;
-
-import java.util.Collection;
-import java.util.HashSet;
-
-import org.openecomp.policy.api.LoadedPolicy;
-import org.openecomp.policy.api.NotificationType;
-import org.openecomp.policy.api.PDPNotification;
-import org.openecomp.policy.api.RemovedPolicy;
-import org.openecomp.policy.std.StdLoadedPolicy;
-import org.openecomp.policy.std.StdPDPNotification;
-import org.openecomp.policy.std.StdRemovedPolicy;
-
-import org.openecomp.policy.common.logging.flexlogger.*;
-
-public class MatchStore {
- private static HashSet<Matches> matchStore = new HashSet<>();
- private static Logger logger = FlexLogger.getLogger(MatchStore.class.getName());
-
- public static HashSet<Matches> getMatchStore() {
- return matchStore;
- }
-
- public static void storeMatch(Matches newMatch){
- // Initialization..
- if(newMatch!=null){
- if(matchStore.isEmpty()){
- matchStore.add(newMatch);
- }else{
- // Check if it is a new Match
- Boolean match = false;
- for(Matches oldMatch: matchStore){
- // Compare ECOMPName
- if(oldMatch.getEcompName().equals(newMatch.getEcompName())){
- // Compare ConfigName if it exists.
- if(newMatch.getConfigName()!=null && oldMatch.getConfigName()!=null){
- if(oldMatch.getConfigName().equals(newMatch.getConfigName())){
- // Compare the Config Attributes if they exist.
- if(newMatch.getConfigAttributes()!= null && oldMatch.getConfigAttributes()!=null) {
- //Simple thing would be comparing their size.
- if(newMatch.getConfigAttributes().size()==oldMatch.getConfigAttributes().size()){
- // Now need to compare each of them..
- int count= 0;
- for(String oldkey: oldMatch.getConfigAttributes().keySet()){
- boolean check = false;
- for(String newKey: newMatch.getConfigAttributes().keySet()){
- if(oldkey.equals(newKey)){
- if(oldMatch.getConfigAttributes().get(oldkey).equals(newMatch.getConfigAttributes().get(newKey))){
- check = true;
- }
- }
- }
- if(check){
- count++;
- }else{
- break;
- }
- }
- if(count==oldMatch.getConfigAttributes().size()){
- match = true;
- break;
- }
- }
- }else if(newMatch.getConfigAttributes()== null && oldMatch.getConfigAttributes()==null){
- match = true;
- break;
- }
- }
- }else if(newMatch.getConfigName()==null && oldMatch.getConfigName()==null){
- match = true;
- break;
- }
- }
-
- }
- // IF not a match then add it to the MatchStore
- if(match==false){
- matchStore.add(newMatch);
- }
- }
- }
- }
-
- //Logic changes for Requested Policies notifications..
- public static PDPNotification checkMatch(PDPNotification oldNotification) {
- boolean removed = false, updated = false;
- if(oldNotification==null){
- return null;
- }
- StdPDPNotification newNotification = new StdPDPNotification();
- if(matchStore.isEmpty()) {
- logger.debug("No Success Config Calls made yet.. ");
- System.out.println("No success Config calls made yet. ");
- return null;
- }
- if(oldNotification.getRemovedPolicies()!=null && !oldNotification.getRemovedPolicies().isEmpty()){
- // send all removed policies to client.
- Collection<StdRemovedPolicy> removedPolicies = new HashSet<>();
- StdRemovedPolicy newRemovedPolicy;
- for(RemovedPolicy removedPolicy: oldNotification.getRemovedPolicies()){
- newRemovedPolicy = new StdRemovedPolicy();
- newRemovedPolicy.setPolicyName(removedPolicy.getPolicyName());
- newRemovedPolicy.setVersionNo(removedPolicy.getVersionNo());
- removedPolicies.add(newRemovedPolicy);
- }
- newNotification.setRemovedPolicies(removedPolicies);
- removed = true;
- }
- if(oldNotification.getLoadedPolicies()!=null && !oldNotification.getLoadedPolicies().isEmpty()){
- Collection<StdLoadedPolicy> updatedPolicies = new HashSet<>();
- StdLoadedPolicy newUpdatedPolicy;
- for(LoadedPolicy updatedPolicy: oldNotification.getLoadedPolicies()){
- // if it is config policies check their matches..
- if(updatedPolicy.getMatches()!=null && !updatedPolicy.getMatches().isEmpty()){
- boolean matched = false;
- for(Matches match : matchStore){
- matched = false;
- // Again Better way would be comparing sizes first.
- // Matches are different need to check if has configAttributes
- if(match.getConfigAttributes()!=null && !match.getConfigAttributes().isEmpty()){
- // adding ecomp and config to config-attributes.
- int compValues = match.getConfigAttributes().size() + 2;
- if(updatedPolicy.getMatches().size()== compValues){
- // Comparing both the values..
- boolean matchAttributes = false;
- for(String newKey: updatedPolicy.getMatches().keySet()){
- if(newKey.equals("ECOMPName")){
- if(updatedPolicy.getMatches().get(newKey).equals(match.getEcompName())){
- matchAttributes = true;
- }else {
- matchAttributes = false;
- break;
- }
- }else if(newKey.equals("ConfigName")) {
- if(updatedPolicy.getMatches().get(newKey).equals(match.getConfigName())){
- matchAttributes = true;
- }else{
- matchAttributes = false;
- break;
- }
- }else {
- if(match.getConfigAttributes().containsKey(newKey)){
- if(updatedPolicy.getMatches().get(newKey).equals(match.getConfigAttributes().get(newKey))){
- matchAttributes = true;
- }else{
- matchAttributes = false;
- break;
- }
- }else{
- matchAttributes = false;
- break;
- }
- }
- }
- if(matchAttributes){
- // Match..
- matched = true;
- }else{
- break;
- }
- }else {
- break;
- }
- }else if(match.getConfigName()!=null){
- // If there are no config Attributes then check if it has Config Name
- if(updatedPolicy.getMatches().size()== 2){
- if(updatedPolicy.getMatches().get("ECOMPName").equals(match.getEcompName())){
- if(updatedPolicy.getMatches().get("ConfigName").equals(match.getConfigName())){
- // Match..
- matched = true;
- }else{
- break;
- }
- }else {
- break;
- }
- }else{
- break;
- }
- }else {
- // If non exist then assuming the ECOMP Name to be there.
- if(updatedPolicy.getMatches().size()== 1){
- if(updatedPolicy.getMatches().get("ECOMPName").equals(match.getEcompName())){
- // Match..
- matched = true;
- }else {
- break;
- }
- }else{
- break;
- }
- }
- // Add logic to add the policy.
- if(matched){
- newUpdatedPolicy = new StdLoadedPolicy();
- newUpdatedPolicy.setPolicyName(updatedPolicy.getPolicyName());
- newUpdatedPolicy.setVersionNo(updatedPolicy.getVersionNo());
- newUpdatedPolicy.setMatches(updatedPolicy.getMatches());
- updatedPolicies.add(newUpdatedPolicy);
- updated = true;
- }
- }
-
- }else {
- //send all non config notifications to client.
- newUpdatedPolicy = new StdLoadedPolicy();
- newUpdatedPolicy.setPolicyName(updatedPolicy.getPolicyName());
- newUpdatedPolicy.setVersionNo(updatedPolicy.getVersionNo());
- updatedPolicies.add(newUpdatedPolicy);
- updated = true;
- }
- }
- newNotification.setLoadedPolicies(updatedPolicies);
- }
- // Need to set the type of Update..
- if(removed && updated) {
- newNotification.setNotificationType(NotificationType.BOTH);
- }else if(removed){
- newNotification.setNotificationType(NotificationType.REMOVE);
- }else if(updated){
- newNotification.setNotificationType(NotificationType.UPDATE);
- }
- return newNotification;
- }
-
-}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/Matches.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/Matches.java
deleted file mode 100644
index 8e6a8ee97..000000000
--- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/Matches.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * PolicyEngineAPI
- * ================================================================================
- * 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=========================================================
- */
-
-package org.openecomp.policy.std;
-
-import java.util.Map;
-
-public class Matches {
- private String ecompName = null;
- private String configName = null;
- private Map<String,String> configAttributes = null;
- public String getEcompName() {
- return ecompName;
- }
- public void setEcompName(String ecompName) {
- this.ecompName = ecompName;
- }
- public String getConfigName() {
- return configName;
- }
- public void setConfigName(String configName) {
- this.configName = configName;
- }
- public Map<String,String> getConfigAttributes() {
- return configAttributes;
- }
- public void setConfigAttributes(Map<String,String> configAttributes) {
- this.configAttributes = configAttributes;
- }
-
-}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/NotificationUnMarshal.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/NotificationUnMarshal.java
deleted file mode 100644
index 196f89b3d..000000000
--- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/NotificationUnMarshal.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * PolicyEngineAPI
- * ================================================================================
- * 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=========================================================
- */
-
-package org.openecomp.policy.std;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.openecomp.policy.api.LoadedPolicy;
-import org.openecomp.policy.api.RemovedPolicy;
-import org.openecomp.policy.api.UpdateType;
-import org.openecomp.policy.std.StdLoadedPolicy;
-import org.openecomp.policy.std.StdPDPNotification;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-public class NotificationUnMarshal {
- private static StdPDPNotification notification;
-
- public static StdPDPNotification notificationJSON(String json) throws Exception{
- ObjectMapper mapper = new ObjectMapper();
- notification = mapper.readValue(json, StdPDPNotification.class);
- if(notification!=null){
- if(notification.getLoadedPolicies()!=null){
- Collection<StdLoadedPolicy> stdLoadedPolicies = new ArrayList<>();
- for(LoadedPolicy loadedPolicy: notification.getLoadedPolicies()){
- StdLoadedPolicy stdLoadedPolicy = (StdLoadedPolicy) loadedPolicy;
- if(notification.getRemovedPolicies()!=null){
- Boolean updated = false;
- for(RemovedPolicy removedPolicy: notification.getRemovedPolicies()){
- String regex = ".(\\d)*.xml";
- if(removedPolicy.getPolicyName().replaceAll(regex, "").equals(stdLoadedPolicy.getPolicyName().replaceAll(regex, ""))){
- updated = true;
- break;
- }
- }
- if(updated){
- stdLoadedPolicy.setUpdateType(UpdateType.UPDATE);
- }else{
- stdLoadedPolicy.setUpdateType(UpdateType.NEW);
- }
- }else{
- stdLoadedPolicy.setUpdateType(UpdateType.NEW);
- }
- stdLoadedPolicies.add(stdLoadedPolicy);
- }
- notification.setLoadedPolicies(stdLoadedPolicies);
- }
- }
- return notification;
- }
-}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdDecisionResponse.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdDecisionResponse.java
deleted file mode 100644
index 1f4cf65d0..000000000
--- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdDecisionResponse.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * PolicyEngineAPI
- * ================================================================================
- * 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=========================================================
- */
-
-
-package org.openecomp.policy.std;
-
-import org.openecomp.policy.api.DecisionResponse;
-import org.openecomp.policy.api.PolicyDecision;
-
-/**
- * Decision Response Implementation Class.
- *
- * @version 0.1
- */
-public class StdDecisionResponse implements DecisionResponse {
-
- private PolicyDecision decision = PolicyDecision.DENY;
- private String details;
-
- @Override
- public PolicyDecision getDecision() {
- return decision;
- }
-
- @Override
- public String getDetails() {
- return details;
- }
-
- public void setDecision(PolicyDecision decision){
- this.decision = decision;
- }
-
- public void setDetails(String details) {
- this.details = details;
- }
-
-}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdDictionaryResponse.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdDictionaryResponse.java
deleted file mode 100644
index 74eebc354..000000000
--- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdDictionaryResponse.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * PolicyEngineAPI
- * ================================================================================
- * 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=========================================================
- */
-
-package org.openecomp.policy.std;
-
-import java.util.Map;
-
-import javax.json.JsonObject;
-
-import org.openecomp.policy.api.DictionaryResponse;
-
-public class StdDictionaryResponse implements DictionaryResponse {
- private String dictionaryMessage;
- private JsonObject dictionaryJson;
- private Map<String,String> dictionaryData;
- private int responseCode;
-
- @Override
- public String getResponseMessage() {
- return dictionaryMessage;
- }
-
- @Override
- public JsonObject getDictionaryJson() {
- return dictionaryJson;
- }
-
- @Override
- public Map<String, String> getDictionaryData() {
- return dictionaryData;
- }
-
- @Override
- public int getResponseCode() {
- return responseCode;
- }
-
- public void setResponseMessage(String dictionaryMessage) {
- this.dictionaryMessage = dictionaryMessage;
- }
-
- public void setDictionaryJson(JsonObject dictionaryJson) {
- this.dictionaryJson = dictionaryJson;
- }
-
- public void setDictionaryData(Map<String, String> dictionaryData) {
- this.dictionaryData = dictionaryData;
- }
-
- public void setResponseCode(int responseCode) {
- this.responseCode = responseCode;
- }
-
-
-
-}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdMetricsResponse.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdMetricsResponse.java
deleted file mode 100644
index 8c89e4a9d..000000000
--- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdMetricsResponse.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * PolicyEngineAPI
- * ================================================================================
- * 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=========================================================
- */
-
-package org.openecomp.policy.std;
-
-import org.openecomp.policy.api.MetricsResponse;
-
-public class StdMetricsResponse implements MetricsResponse {
- private String responseMessage;
- private int pdpMetrics;
- private int papMetrics;
- private int metricsTotal;
- private int responseCode;
-
- @Override
- public String getResponseMessage() {
- return responseMessage;
- }
-
- @Override
- public int getResponseCode() {
- return responseCode;
- }
-
- @Override
- public int getPapMetrics() {
- return papMetrics;
- }
-
- @Override
- public int getPdpMetrics() {
- return pdpMetrics;
- }
-
- @Override
- public int getMetricsTotal() {
- metricsTotal = papMetrics + pdpMetrics;
- return metricsTotal;
- }
-
- public void setResponseMessage(String responseMessage) {
- this.responseMessage = responseMessage;
- }
-
- public void setPdpMetrics(int pdpMetrics) {
- this.pdpMetrics = pdpMetrics;
- }
-
- public void setPapMetrics(int papMetrics) {
- this.papMetrics = papMetrics;
- }
-
- public void setMetricsTotal(int metricsTotal) {
- this.metricsTotal = metricsTotal;
- }
-
- public void setResponseCode(int responseCode) {
- this.responseCode = responseCode;
- }
-
-} \ No newline at end of file
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyChangeResponse.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyChangeResponse.java
deleted file mode 100644
index 2fec8605c..000000000
--- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyChangeResponse.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * PolicyEngineAPI
- * ================================================================================
- * 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=========================================================
- */
-
-package org.openecomp.policy.std;
-
-import org.openecomp.policy.api.PolicyChangeResponse;
-
-public class StdPolicyChangeResponse implements PolicyChangeResponse{
- private String responseMessage = null;
- private int responseCode;
-
- @Override
- public String getResponseMessage() {
- return responseMessage;
- }
-
- @Override
- public int getResponseCode() {
- return responseCode;
- }
-
- public void setResponseMessage(String responseMessage){
- this.responseMessage = responseMessage;
- }
-
- public void setResponseCode(int responseCode){
- this.responseCode = responseCode;
- }
-
-}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyConfig.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyConfig.java
deleted file mode 100644
index ec205dab2..000000000
--- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyConfig.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * PolicyEngineAPI
- * ================================================================================
- * 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=========================================================
- */
-
-
-package org.openecomp.policy.std;
-
-import java.util.Map;
-import java.util.Properties;
-
-import javax.json.JsonObject;
-
-import org.openecomp.policy.api.PolicyConfig;
-import org.openecomp.policy.api.PolicyConfigStatus;
-import org.openecomp.policy.api.PolicyType;
-import org.w3c.dom.Document;
-
-/**
- * PolicyConfig Implementation.
- *
- * @version 0.3
- *
- */
-
-public class StdPolicyConfig implements PolicyConfig{
- private PolicyType policyType;
- private Properties properties;
- private JsonObject jsonObject;
- private Document document;
- private String other;
- private PolicyConfigStatus policyConfigStatus;
- private String configStatus;
- private String policyName;
- private String policyVersion;
- private Map<String,String> matchingConditions;
- private Map<String,String> responseAttributes;
-
- @Override
- public PolicyType getType() {
- return policyType;
- }
-
- @Override
- public Properties toProperties() {
- return properties;
- }
-
- @Override
- public JsonObject toJSON() {
- return jsonObject;
- }
-
- @Override
- public Document toXML() {
- return document;
- }
-
- @Override
- public String toOther() {
- return other;
- }
-
- @Override
- public PolicyConfigStatus getPolicyConfigStatus() {
- return policyConfigStatus;
- }
-
- @Override
- public String getPolicyConfigMessage() {
- return configStatus;
- }
-
- @Override
- public String getPolicyName() {
- if(policyName!=null && policyName.contains(".xml")){
- return (policyName.substring(0, policyName.substring(0, policyName.lastIndexOf(".")).lastIndexOf(".")));
- }
- return policyName;
- }
-
- @Override
- public String getPolicyVersion() {
- return policyVersion;
- }
-
- @Override
- public Map<String,String> getMatchingConditions(){
- return matchingConditions;
- }
-
- @Override
- public Map<String,String> getResponseAttributes(){
- return responseAttributes;
- }
-
- public void setPolicyType(PolicyType policyType) {
- this.policyType = policyType;
- }
-
- public void setPolicyName(String policyName) {
- this.policyName = policyName;
- }
-
- public void setPolicyVersion(String policyVersion) {
- this.policyVersion = policyVersion;
- }
-
- public void setProperties(Properties properties) {
- this.properties = properties;
- }
-
- public void setJsonObject(JsonObject jsonObject) {
- this.jsonObject = jsonObject;
- }
-
- public void setDocument(Document document) {
- this.document = document;
- }
-
- public void setOther(String other) {
- this.other = other;
- }
-
- public void setConfigStatus(String configStatus) {
- this.configStatus = configStatus;
- }
-
- public void setPolicyConfigStatus(PolicyConfigStatus policyConfigStatus) {
- this.policyConfigStatus = policyConfigStatus;
- }
-
- public void setConfigStatus(String configStatus, PolicyConfigStatus policyConfigStatus) {
- this.configStatus = configStatus;
- this.policyConfigStatus = policyConfigStatus;
- }
-
- public void setMatchingConditions(Map<String,String> matchingConditions){
- this.matchingConditions = matchingConditions;
- }
-
- public void setResponseAttributes(Map<String,String> responseAttributes){
- this.responseAttributes = responseAttributes;
- }
-
- @Override
- public String toString() {
- return "PolicyConfig [ policyConfigStatus=" + policyConfigStatus + ", policyConfigMessage=" + configStatus + ", policyName=" + policyName +
- ""
- + "]";
- }
-
-}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyEngine.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyEngine.java
deleted file mode 100644
index 0732c3cf5..000000000
--- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyEngine.java
+++ /dev/null
@@ -1,1254 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * PolicyEngineAPI
- * ================================================================================
- * 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=========================================================
- */
-
-
-package org.openecomp.policy.std;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringReader;
-import java.io.UnsupportedEncodingException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Base64;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.UUID;
-
-import javax.json.Json;
-import javax.json.JsonObject;
-import javax.json.JsonReader;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.openecomp.policy.api.AttributeType;
-import org.openecomp.policy.api.ConfigRequestParameters;
-import org.openecomp.policy.api.DecisionRequestParameters;
-import org.openecomp.policy.api.DecisionResponse;
-import org.openecomp.policy.api.DeletePolicyParameters;
-import org.openecomp.policy.api.DictionaryParameters;
-import org.openecomp.policy.api.DictionaryResponse;
-import org.openecomp.policy.api.EventRequestParameters;
-import org.openecomp.policy.api.ImportParameters;
-import org.openecomp.policy.api.MetricsRequestParameters;
-import org.openecomp.policy.api.MetricsResponse;
-import org.openecomp.policy.api.NotificationHandler;
-import org.openecomp.policy.api.NotificationScheme;
-import org.openecomp.policy.api.PDPNotification;
-import org.openecomp.policy.api.PolicyChangeResponse;
-import org.openecomp.policy.api.PolicyClass;
-import org.openecomp.policy.api.PolicyConfig;
-import org.openecomp.policy.api.PolicyConfigException;
-import org.openecomp.policy.api.PolicyConfigType;
-import org.openecomp.policy.api.PolicyDecisionException;
-import org.openecomp.policy.api.PolicyEngineException;
-import org.openecomp.policy.api.PolicyEventException;
-import org.openecomp.policy.api.PolicyException;
-import org.openecomp.policy.api.PolicyParameters;
-import org.openecomp.policy.api.PolicyResponse;
-import org.openecomp.policy.api.PolicyType;
-import org.openecomp.policy.api.PushPolicyParameters;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.flexlogger.Logger;
-import org.openecomp.policy.models.APIDictionaryResponse;
-import org.openecomp.policy.models.APIPolicyConfigResponse;
-import org.openecomp.policy.utils.AAFEnvironment;
-import org.openecomp.policy.utils.PolicyUtils;
-import org.openecomp.policy.xacml.api.XACMLErrorConstants;
-import org.springframework.core.io.FileSystemResource;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
-import org.springframework.util.LinkedMultiValueMap;
-import org.springframework.web.client.HttpClientErrorException;
-import org.springframework.web.client.RestTemplate;
-import org.xml.sax.InputSource;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-
-/**
- * PolicyEngine Implementation class
- *
- * @version 1.0
- */
-public class StdPolicyEngine {
- private static final String ERROR_AUTH_GET_PERM = "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to: ";
- private static final String DEFAULT_NOTIFICATION = "websocket";
-
- private String propertyFilePath = null;
- private String clientEncoding = null;
- private String contentType = null;
- private static List<String> pdps = null;
- private static String environment= null;
- private static String userName = null;
- private static String pass = null;
- private static List<String> encoding = null;
- private static boolean junit = false;
- private List<String> pdpDefault = null;
- private List<String> typeDefault = null;
- private List<String> notificationType = new ArrayList<String>();
- private List<String> notificationURLList = new ArrayList<String>();
- private NotificationScheme scheme = null;
- private NotificationHandler handler = null;
- private AutoClientUEB uebClientThread = null;
- private Thread registerUEBThread = null;
- private boolean uebThread = false;
- private AutoClientDMAAP dmaapClientThread = null;
- private Thread registerDMAAPThread = null;
- private boolean dmaapThread = false;
- private String topic = null;
- private String apiKey = null;
- private String apiSecret = null;
-
- private static final String UNIQUEID = UUID.randomUUID ().toString ();
- private static final Logger LOGGER = FlexLogger.getLogger(StdPolicyConfig.class.getName());
-
- /*
- * Taking the Property file even if it null.
- */
- public StdPolicyEngine(String propertyFilePath, String clientKey) throws PolicyEngineException {
- setProperty(propertyFilePath, clientKey);
- }
-
- /*
- * Taking the Notification Constructor.
- */
- public StdPolicyEngine(String propertyFilePath,
- NotificationScheme scheme,
- NotificationHandler handler) throws PolicyEngineException {
- setProperty(propertyFilePath, null);
- this.scheme = scheme;
- this.handler = handler;
- if ((!"ueb".equals(notificationType.get(0)))||(!"dmaap".equals(notificationType.get(0)))){
- AutoClientEnd.setAuto(scheme, handler);
- }
- notification(scheme, handler);
- }
-
- /*
- * Taking the Notification Constructor.
- */
- public StdPolicyEngine(String propertyFilePath, NotificationScheme scheme) throws PolicyEngineException {
- setProperty(propertyFilePath, null);
- this.scheme = scheme;
- setScheme(scheme);
- }
-
- /*
- * sendEvent API Implementation
- */
- public Collection<PolicyResponse> sendEvent(Map<String, String> eventAttributes, UUID requestID) throws PolicyEventException {
- return sendEventImpl(eventAttributes, requestID);
- }
-
- /*
- * sendEvent API Implementation for eventRequestParameters
- */
- public Collection<PolicyResponse> sendEvent(EventRequestParameters eventRequestParameters) throws PolicyEventException{
- if(eventRequestParameters==null){
- String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No event Request Parameters Given. ";
- LOGGER.error(message);
- throw new PolicyEventException(message);
- }
- return sendEventImpl(eventRequestParameters.getEventAttributes(), eventRequestParameters.getRequestID());
- }
-
- /*
- * getConfig using configRequestParameters Implementation
- */
- public Collection<PolicyConfig> getConfig(ConfigRequestParameters configRequestParameters) throws PolicyConfigException{
- return getConfigImpl(configRequestParameters);
- }
-
- /*
- * listPolicies using configRequestParameters Implementation
- */
- public Collection<String> listConfig(ConfigRequestParameters listPolicyRequestParameters) throws PolicyConfigException{
- return listConfigImpl(listPolicyRequestParameters);
- }
-
- /*
- * getDecision using the decision Attributes.
- */
- public DecisionResponse getDecision(String eCOMPComponentName, Map<String, String> decisionAttributes, UUID requestID) throws PolicyDecisionException {
- return getDecisionImpl(eCOMPComponentName, decisionAttributes, requestID);
- }
-
- /*
- * getDecision Using decisionRequestParameters.
- */
- public DecisionResponse getDecision(DecisionRequestParameters decisionRequestParameters) throws PolicyDecisionException{
- if(decisionRequestParameters==null){
- String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Decision Request Parameters Given. ";
- LOGGER.error(message);
- throw new PolicyDecisionException(message);
- }
- return getDecisionImpl(decisionRequestParameters.getECOMPComponentName(), decisionRequestParameters.getDecisionAttributes(), decisionRequestParameters.getRequestID());
- }
-
- /*
- * getMetrics using metricsRequestParameters
- */
- public MetricsResponse getMetrics(MetricsRequestParameters parameters) throws PolicyException{
- return getMetricsImpl(parameters);
- }
-
- public MetricsResponse getMetricsImpl(MetricsRequestParameters parameters) throws PolicyException{
- StdMetricsResponse response = new StdMetricsResponse();
- String resource = "getMetrics";
- String body = new String();
-
- // Create the Request
- try {
- if (parameters!=null) {
- body = PolicyUtils.objectToJsonString(parameters);
- }
- } catch (JsonProcessingException e) {
- String message = XACMLErrorConstants.ERROR_SCHEMA_INVALID + e;
- LOGGER.error(message);
- throw new PolicyException(message, e);
- }
- // Get Response.
- try {
- ResponseEntity<String> result = callNewPDP(resource, HttpMethod.GET, body, String.class);
- // Process response
- response.setResponseMessage(result.getBody());
- response.setResponseCode(result.getStatusCode().value());
- } catch (PolicyException exception) {
- if(exception.getCause()!=null && exception.getCause() instanceof HttpClientErrorException){
- LOGGER.error(exception);
- HttpClientErrorException ex = (HttpClientErrorException) exception.getCause();
- response.setResponseCode(ex.getRawStatusCode());
- response.setResponseMessage(exception.getMessage());
- return response;
- }else{
- String message = XACMLErrorConstants.ERROR_SYSTEM_ERROR+ "Error while processing results. please check logs.";
- LOGGER.error(message, exception);
- throw new PolicyException(message, exception);
- }
- }
- return response;
- }
-
- /*
- * PushPolicy using pushPolicyParameters.
- */
- public PolicyChangeResponse pushPolicy(PushPolicyParameters pushPolicyParameters) throws PolicyException{
- return pushPolicyImpl(pushPolicyParameters);
- }
-
- public PolicyChangeResponse pushPolicyImpl(PushPolicyParameters pushPolicyParameters) throws PolicyException{
- StdPolicyChangeResponse response = new StdPolicyChangeResponse();
- String resource= "pushPolicy";
- String body = new String();
- // Create Request.
- try {
- body = PolicyUtils.objectToJsonString(pushPolicyParameters);
- } catch (JsonProcessingException e) {
- String message = XACMLErrorConstants.ERROR_SCHEMA_INVALID + e;
- LOGGER.error(message);
- throw new PolicyException(message, e);
- }
- // Get Response.
- try {
- ResponseEntity<String> result = callNewPDP(resource, HttpMethod.PUT, body, String.class);
- // Process response
- response.setResponseMessage(result.getBody());
- response.setResponseCode(result.getStatusCode().value());
- } catch (PolicyException exception) {
- return processException(exception);
- }
- return response;
- }
-
- /*
- * Delete a Policy using deletePolicyParameters
- */
- public PolicyChangeResponse deletePolicy(DeletePolicyParameters parameters) throws PolicyException {
- return deletePolicyImpl(parameters);
- }
-
- public PolicyChangeResponse deletePolicyImpl(DeletePolicyParameters parameters) throws PolicyException {
- StdPolicyChangeResponse response = new StdPolicyChangeResponse();
- String resource= "deletePolicy";
- String body = new String();
- // Create Request.
- try {
- body = PolicyUtils.objectToJsonString(parameters);
- } catch (JsonProcessingException e) {
- String message = XACMLErrorConstants.ERROR_SCHEMA_INVALID + e;
- LOGGER.error(message);
- throw new PolicyException(message, e);
- }
- // Get Response.
- try {
- ResponseEntity<String> result = callNewPDP(resource, HttpMethod.DELETE, body, String.class);
- // Process response
- response.setResponseMessage(result.getBody());
- response.setResponseCode(result.getStatusCode().value());
- } catch (PolicyException exception) {
- return processException(exception);
- }
- return response;
- }
-
- /*
- * getDictionaryItem Using dictionaryParameters
- */
- public DictionaryResponse getDictionaryItem(DictionaryParameters parameters) throws PolicyException {
- return getDictionaryItemImpl(parameters);
- }
-
- public DictionaryResponse getDictionaryItemImpl(DictionaryParameters parameters) throws PolicyException{
- StdDictionaryResponse response = new StdDictionaryResponse();
- String resource="getDictionaryItems";
- String body = "{}";
- // Create Request.
- try {
- body = PolicyUtils.objectToJsonString(parameters);
- } catch (JsonProcessingException e) {
- String message = XACMLErrorConstants.ERROR_SCHEMA_INVALID + e;
- LOGGER.error(message);
- throw new PolicyException(message, e);
- }
- // Get Response.
- try {
- ResponseEntity<APIDictionaryResponse> result = callNewPDP(resource, HttpMethod.POST, body, APIDictionaryResponse.class);
- // Process response
- response = dictionaryResult(result.getBody());
- } catch (Exception exception) {
- if(exception.getCause().getMessage().contains("401")){
- String message = XACMLErrorConstants.ERROR_PERMISSIONS + ERROR_AUTH_GET_PERM + resource;
- LOGGER.error(message);
- response.setResponseMessage(message);
- response.setResponseCode(401);
- return response;
- }if(exception.getCause().getMessage().contains("400")){
- String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Invalid Data is given.";
- response.setResponseMessage(message);
- response.setResponseCode(400);
- return response;
- }
- String message = XACMLErrorConstants.ERROR_PERMISSIONS+ "Unable to get valid Response from PDP(s) " + pdps;
- LOGGER.error(message, exception);
- response.setResponseMessage(message);
- response.setResponseCode(500);
- return response;
- }
- return response;
- }
-
- @SuppressWarnings("unchecked")
- private StdDictionaryResponse dictionaryResult(APIDictionaryResponse body) {
- StdDictionaryResponse response = new StdDictionaryResponse();
- response.setResponseCode(body.getResponseCode());
- response.setResponseMessage(body.getResponseMessage());
- response.setDictionaryData((Map<String, String>) body.getDictionaryData());
- if(body.getDictionaryJson()!=null){
- Gson objGson = new GsonBuilder().create();
- String mapToJson = objGson.toJson(body.getDictionaryJson());
- JsonReader jsonReader = Json.createReader(new StringReader(mapToJson));
- JsonObject object = jsonReader.readObject();
- jsonReader.close();
- response.setDictionaryJson(object);
- }
- return response;
- }
-
- /*
- * createDictinaryItem Using dictionaryParameters.
- */
- public PolicyChangeResponse createDictionaryItem(DictionaryParameters parameters) throws PolicyException{
- return createUpdateDictionaryItemImpl(parameters, false);
- }
-
- /*
- * updateDictinaryItem Using dictionaryParameters.
- */
- public PolicyChangeResponse updateDictionaryItem(DictionaryParameters parameters) throws PolicyException{
- return createUpdateDictionaryItemImpl(parameters, true);
- }
-
- public PolicyChangeResponse createUpdateDictionaryItemImpl(DictionaryParameters parameters, boolean updateFlag) throws PolicyException{
- StdPolicyChangeResponse response = new StdPolicyChangeResponse();
- String resource = "createDictionaryItem";
- if(updateFlag){
- resource = "updateDictionaryItem";
- }
- String body = new String();
- // Create Request.
- try {
- body = PolicyUtils.objectToJsonString(parameters);
- } catch (JsonProcessingException e) {
- String message = XACMLErrorConstants.ERROR_SCHEMA_INVALID + e;
- LOGGER.error(message);
- throw new PolicyException(message, e);
- }
- // Get Response.
- try {
- ResponseEntity<String> result = callNewPDP(resource, HttpMethod.PUT, body, String.class);
- // Process response
- response.setResponseMessage(result.getBody());
- response.setResponseCode(result.getStatusCode().value());
- } catch (PolicyException exception) {
- return processException(exception);
- }
- return response;
- }
-
- /*
- * PolicyEngine Import
- */
- public PolicyChangeResponse policyEngineImport(ImportParameters importParameters) throws PolicyException {
- return policyEngineImportImpl(importParameters);
- }
-
- public PolicyChangeResponse policyEngineImportImpl(ImportParameters importParameters) throws PolicyException {
- StdPolicyChangeResponse response = new StdPolicyChangeResponse();
- String resource= "policyEngineImport";
- LinkedMultiValueMap<String, Object> parameters = new LinkedMultiValueMap<String, Object>();
- // Create Request.
- try {
- String body = PolicyUtils.objectToJsonString(importParameters);
- parameters.set("importParametersJson", body);
- parameters.set("file", new FileSystemResource(importParameters.getFilePath()));
- } catch (Exception e) {
- String message = XACMLErrorConstants.ERROR_SCHEMA_INVALID + e;
- LOGGER.error(message);
- throw new PolicyException(message, e);
- }
- contentType = MediaType.MULTIPART_FORM_DATA_VALUE;
- // Get Response.
- try {
- ResponseEntity<String> result = callNewPDP(resource, HttpMethod.POST, parameters, String.class);
- // Process response
- response.setResponseMessage(result.getBody());
- response.setResponseCode(result.getStatusCode().value());
- } catch (PolicyException exception) {
- return processException(exception);
- } finally{
- contentType = null;
- }
- return response;
- }
-
- /*
- * createPolicy Using policyParameters.
- */
- public PolicyChangeResponse createPolicy(PolicyParameters policyParameters) throws PolicyException{
- return createUpdatePolicyImpl(policyParameters, false);
- }
-
- /*
- * updatePolicy using policyParameters.
- */
- public PolicyChangeResponse updatePolicy(PolicyParameters policyParameters) throws PolicyException{
- return createUpdatePolicyImpl(policyParameters, true);
- }
-
- public PolicyChangeResponse createUpdatePolicyImpl(PolicyParameters policyParameters, boolean updateFlag) throws PolicyException{
- StdPolicyChangeResponse response = new StdPolicyChangeResponse();
- String resource= "createPolicy";
- if(updateFlag){
- resource="updatePolicy";
- }
- String body = new String();
- // Create Request.
- try {
- body = PolicyUtils.objectToJsonString(policyParameters);
- } catch (JsonProcessingException e) {
- String message = XACMLErrorConstants.ERROR_SCHEMA_INVALID + e;
- LOGGER.error(message);
- throw new PolicyException(message, e);
- }
- // Get Response.
- try {
- ResponseEntity<String> result = callNewPDP(resource, HttpMethod.PUT, body, String.class);
- // Process response
- response.setResponseMessage(result.getBody());
- response.setResponseCode(result.getStatusCode().value());
- } catch (PolicyException exception) {
- return processException(exception);
- }
- return response;
- }
-
- private PolicyChangeResponse processException(PolicyException exception) throws PolicyException {
- StdPolicyChangeResponse response = new StdPolicyChangeResponse();
- if(exception.getCause()!=null && exception.getCause() instanceof HttpClientErrorException){
- LOGGER.error(exception);
- HttpClientErrorException ex = (HttpClientErrorException) exception.getCause();
- response.setResponseCode(ex.getRawStatusCode());
- response.setResponseMessage(exception.getMessage());
- return response;
- }else{
- String message = XACMLErrorConstants.ERROR_SYSTEM_ERROR+ "Error while processing results. please check logs.";
- LOGGER.error(message, exception);
- throw new PolicyException(message, exception);
- }
- }
-
- public DecisionResponse getDecisionImpl(String eCOMPComponentName,
- Map<String, String> decisionAttributes,
- UUID requestID) throws PolicyDecisionException {
- String resource= "getDecision";
- StdDecisionResponse response = new StdDecisionResponse();
- String body = new String();
- // Create Request.
- try {
- DecisionRequestParameters decisionRequestParameters = new DecisionRequestParameters();
- decisionRequestParameters.setDecisionAttributes(decisionAttributes);
- decisionRequestParameters.setECOMPComponentName(eCOMPComponentName);
- decisionRequestParameters.setRequestID(requestID);
- body = PolicyUtils.objectToJsonString(decisionRequestParameters);
- } catch (JsonProcessingException e) {
- String message = XACMLErrorConstants.ERROR_SCHEMA_INVALID + e;
- LOGGER.error(message);
- throw new PolicyDecisionException(message, e);
- }
- // Get Response.
- try {
- ResponseEntity<StdDecisionResponse> result = callNewPDP(resource, HttpMethod.POST, body, StdDecisionResponse.class);
- // Process response
- response = result.getBody();
- } catch (Exception exception) {
- if(exception.getCause().getMessage().contains("401")){
- String message = XACMLErrorConstants.ERROR_PERMISSIONS + ERROR_AUTH_GET_PERM + resource;
- LOGGER.error(message);
- throw new PolicyDecisionException(message, exception);
- }if(exception.getCause().getMessage().contains("400")){
- String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Invalid Data is given.";
- LOGGER.error(message);
- throw new PolicyDecisionException(message, exception);
- }
- String message = XACMLErrorConstants.ERROR_PERMISSIONS+ "Unable to get valid Response from PDP(s) " + pdps;
- LOGGER.error(message, exception);
- throw new PolicyDecisionException(message, exception);
- }
- return response;
- }
-
- public Collection<PolicyConfig> getConfigImpl(ConfigRequestParameters configRequestParameters) throws PolicyConfigException{
- String resource= "getConfig";
- ArrayList<PolicyConfig> response = new ArrayList<>();
- String body = new String();
- // Create Request.
- try {
- body = PolicyUtils.objectToJsonString(configRequestParameters);
- } catch (JsonProcessingException e) {
- String message = XACMLErrorConstants.ERROR_SCHEMA_INVALID + e;
- LOGGER.error(message);
- throw new PolicyConfigException(message, e);
- }
- // Get Response.
- try {
- ResponseEntity<APIPolicyConfigResponse[]> result = callNewPDP(resource, HttpMethod.POST, body, APIPolicyConfigResponse[].class);
- // Process Response
- response = configResult(result.getBody());
- } catch (Exception exception) {
- if(exception.getCause().getMessage().contains("401")){
- String message = XACMLErrorConstants.ERROR_PERMISSIONS + ERROR_AUTH_GET_PERM + resource;
- LOGGER.error(message);
- throw new PolicyConfigException(message, exception);
- }if(exception.getCause().getMessage().contains("400")){
- String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Invalid Data is given.";
- LOGGER.error(message);
- throw new PolicyConfigException(message, exception);
- }
- String message = XACMLErrorConstants.ERROR_PROCESS_FLOW+ "Unable to get valid Response from PDP(s) " + pdps;
- LOGGER.error(message, exception);
- throw new PolicyConfigException(message, exception);
- }
- return response;
- }
-
- private ArrayList<PolicyConfig> configResult(APIPolicyConfigResponse[] response) throws PolicyConfigException {
- ArrayList<PolicyConfig> result = new ArrayList<>();
- if(response!=null && response.length>0){
- for(APIPolicyConfigResponse policyConfigResponse: response){
- StdPolicyConfig policyConfig = new StdPolicyConfig();
- policyConfig.setConfigStatus(policyConfigResponse.getPolicyConfigMessage());
- policyConfig.setMatchingConditions(policyConfigResponse.getMatchingConditions());
- policyConfig.setPolicyConfigStatus(policyConfigResponse.getPolicyConfigStatus());
- policyConfig.setPolicyName(policyConfigResponse.getPolicyName());
- policyConfig.setPolicyType(policyConfigResponse.getType());
- policyConfig.setPolicyVersion(policyConfigResponse.getPolicyVersion());
- policyConfig.setResponseAttributes(policyConfigResponse.getResponseAttributes());
- setMatches(policyConfig.getMatchingConditions());
- if(policyConfigResponse.getType()!=null){
- try {
- switch (policyConfigResponse.getType()) {
- case JSON:
- JsonReader jsonReader = Json.createReader(new StringReader(policyConfigResponse.getConfig()));
- JsonObject object = jsonReader.readObject();
- jsonReader.close();
- policyConfig.setJsonObject(object);
- break;
- case OTHER:
- policyConfig.setOther(policyConfigResponse.getConfig());
- break;
- case PROPERTIES:
- Properties props = new Properties();
- props.putAll(policyConfigResponse.getProperty());
- policyConfig.setProperties(props);
- break;
- case XML:
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder builder;
- builder = factory.newDocumentBuilder();
- policyConfig.setDocument(builder.parse(new InputSource(new StringReader(policyConfigResponse.getConfig()))));
- break;
- }
- } catch (Exception e) {
- LOGGER.error(XACMLErrorConstants.ERROR_SCHEMA_INVALID+ e);
- throw new PolicyConfigException(XACMLErrorConstants.ERROR_SCHEMA_INVALID+ "Unable to parse the config", e);
- }
- }
- result.add(policyConfig);
- }
- }
- return result;
- }
-
- private void setMatches(Map<String, String> matchingConditions) {
- Matches match = new Matches();
- HashMap<String, String> configAttributes = new HashMap<>();
- try{
- for(String key: matchingConditions.keySet()){
- if(key.equalsIgnoreCase("ECOMPName")){
- match.setEcompName(matchingConditions.get(key));
- }else if(key.equalsIgnoreCase("ConfigName")){
- match.setConfigName(matchingConditions.get(key));
- }else{
- configAttributes.put(key, matchingConditions.get(key));
- }
- }
- if(!configAttributes.isEmpty()){
- match.setConfigAttributes(configAttributes);
- }
- MatchStore.storeMatch(match);
- }catch(Exception e){
- LOGGER.info("StoreMatch failed for Ecomp:"
- + match.getEcompName() + " Config: "
- + match.getConfigName());
- }
- }
-
- /*
- * Generic Rest Client to call PDP services.
- */
- private <T> ResponseEntity<T> callNewPDP(String resource,
- HttpMethod method, Object body, Class<T> responseType) throws PolicyException{
- RestTemplate restTemplate = new RestTemplate();
- HttpEntity<?> requestEntity = new HttpEntity<>(body, getHeaders());
- ResponseEntity<T> result = null;
- HttpClientErrorException exception = null;
- int pdpsCount = 0;
- while(pdpsCount < pdps.size()){
- try{
- result = restTemplate.exchange(pdps.get(0)+"/api/" + resource, method, requestEntity, responseType);
- }catch(HttpClientErrorException e){
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while connecting to " + pdps.get(0), e);
- exception = e;
- }catch(Exception e){
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while connecting to " + pdps.get(0), e);
- exception = new HttpClientErrorException(HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage());
- }
- if(result == null){
- Collections.rotate(pdps, -1);
- Collections.rotate(encoding, -1);
- pdpsCount++;
- }else{
- break;
- }
- }
- if(exception != null && exception.getStatusCode()!=null){
- if(exception.getStatusCode().equals(HttpStatus.UNAUTHORIZED)){
- String message = XACMLErrorConstants.ERROR_PERMISSIONS +":"+exception.getStatusCode()+":" +ERROR_AUTH_GET_PERM + resource;
- LOGGER.error(message);
- throw new PolicyException(message, exception);
- }
- if(exception.getStatusCode().equals(HttpStatus.BAD_REQUEST)){
- String message = XACMLErrorConstants.ERROR_DATA_ISSUE + ":"+exception.getStatusCode()+":" + exception.getResponseBodyAsString();
- LOGGER.error(message);
- throw new PolicyException(message, exception);
- }
- if(exception.getStatusCode().equals(HttpStatus.NOT_FOUND)){
- String message = XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while connecting to " + pdps + exception;
- LOGGER.error(message);
- throw new PolicyException(message, exception);
- }
- String message = XACMLErrorConstants.ERROR_PROCESS_FLOW + ":"+exception.getStatusCode()+":" + exception.getResponseBodyAsString();
- LOGGER.error(message);
- throw new PolicyException(message, exception);
- }
- return result;
- }
-
- private HttpHeaders getHeaders() {
- HttpHeaders headers = new HttpHeaders();
- headers.set("ClientAuth", "Basic " + clientEncoding);
- headers.set("Authorization", "Basic " + encoding.get(0));
- if(contentType!=null){
- headers.set("Content-Type", contentType.toString());
- }else{
- headers.set("Content-Type", MediaType.APPLICATION_JSON_VALUE);
- }
- headers.set("Environment", environment);
- return headers;
- }
-
- private void setClientEncoding() {
- Base64.Encoder encoder = Base64.getEncoder();
- clientEncoding = encoder.encodeToString((userName+":"+pass).getBytes(StandardCharsets.UTF_8));
- }
-
- public Collection<String> listConfigImpl(ConfigRequestParameters listRequestParameters) throws PolicyConfigException{
- Collection<String> policyList = new ArrayList<>();
- if (junit){
- policyList.add("Policy Name: listConfigTest");
- return policyList;
- }
- Collection<PolicyConfig> policyConfig = getConfigImpl(listRequestParameters);
- for(PolicyConfig policy : policyConfig){
- if(policy.getPolicyConfigMessage()!=null && policy.getPolicyConfigMessage().contains("PE300")){
- policyList.add(policy.getPolicyConfigMessage());
- } else {
- policyList.add("Policy Name: " + policy.getPolicyName());
- }
- }
- return policyList;
- }
-
- public Collection<PolicyResponse> sendEventImpl(Map<String, String> eventAttributes, UUID requestID) throws PolicyEventException {
- String resource= "sendEvent";
- ArrayList<PolicyResponse> response = new ArrayList<PolicyResponse>();
- String body = new String();
- // Create Request.
- try {
- // Long way here, can be shortened and will be done.
- EventRequestParameters eventRequestParameters = new EventRequestParameters();
- eventRequestParameters.setEventAttributes(eventAttributes);
- eventRequestParameters.setRequestID(requestID);
- body = PolicyUtils.objectToJsonString(eventRequestParameters);
- } catch (JsonProcessingException e) {
- String message = XACMLErrorConstants.ERROR_SCHEMA_INVALID + e;
- LOGGER.error(message);
- throw new PolicyEventException(message, e);
- }
- // Get Response.
- try {
- ResponseEntity<StdPolicyResponse[]> result = callNewPDP(resource, HttpMethod.POST, body, StdPolicyResponse[].class);
- // Process Response
- response = eventResult(result.getBody());
- } catch (Exception exception) {
- if(exception.getCause().getMessage().contains("401")){
- String message = XACMLErrorConstants.ERROR_PERMISSIONS + ERROR_AUTH_GET_PERM + resource;
- LOGGER.error(message);
- throw new PolicyEventException(message, exception);
- }if(exception.getCause().getMessage().contains("400")){
- String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Invalid Data is given.";
- LOGGER.error(message);
- throw new PolicyEventException(message, exception);
- }
- String message = XACMLErrorConstants.ERROR_PERMISSIONS+ "Unable to get valid Response from PDP(s) " + pdps;
- LOGGER.error(message, exception);
- throw new PolicyEventException(message, exception);
- }
- return response;
- }
-
- private ArrayList<PolicyResponse> eventResult(StdPolicyResponse[] response) throws PolicyEventException{
- ArrayList<PolicyResponse> eventResult = new ArrayList<>();
- if(response!=null && response.length>0){
- for(StdPolicyResponse policyConfigResponse: response){
- eventResult.add(policyConfigResponse);
- }
- }
- return eventResult;
- }
-
- private void setProperty(String propertyFilePath, String clientKey)
- throws PolicyEngineException {
- this.propertyFilePath = propertyFilePath;
- if (this.propertyFilePath == null) {
- throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "Error NO PropertyFile Path provided");
- } else {
- // Adding logic for remote Properties file.
- Properties prop = new Properties();
- if (propertyFilePath.startsWith("http")) {
- URL configURL;
- try {
- configURL = new URL(propertyFilePath);
- URLConnection connection = null;
- connection = configURL.openConnection();
- prop.load(connection.getInputStream());
- } catch (IOException e) {
- LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e);
- throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "Maformed property URL "+ e.getMessage());
- }
- } else {
- Path file = Paths.get(propertyFilePath);
- if (Files.notExists(file)) {
- throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "File doesn't exist in the specified Path " + file.toString());
- }
- if (file.toString().endsWith(".properties")) {
- InputStream in;
- prop = new Properties();
- try {
- in = new FileInputStream(file.toFile());
- prop.load(in);
- } catch (IOException e) {
- LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e);
- throw new PolicyEngineException(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Cannot Load the Properties file", e);
- }
- } else {
- LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Not a .properties file " + propertyFilePath);
- throw new PolicyEngineException(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Not a .properties file");
- }
- }
- // UEB and DMAAP Settings
- String check_type = prop.getProperty("NOTIFICATION_TYPE");
- String serverList = prop.getProperty("NOTIFICATION_SERVERS");
- topic = prop.getProperty("NOTIFICATION_TOPIC");
- apiKey = prop.getProperty("UEB_API_KEY");
- apiSecret = prop.getProperty("UEB_API_SECRET");
-
- if(check_type==null) {
- notificationType.add(DEFAULT_NOTIFICATION);
- LOGGER.info("Properties file doesn't have the NOTIFICATION_TYPE parameter system will use defualt websockets");
- }else{
- check_type = check_type.trim();
- if(check_type.contains(",")) {
- typeDefault = new ArrayList<String>(Arrays.asList(prop.getProperty("NOTIFICATION_TYPE").split(",")));
- notificationType = typeDefault;
- } else {
- notificationType = new ArrayList<>();
- notificationType.add(check_type);
- }
- }
- if(serverList==null) {
- notificationType.clear();
- notificationType.add(DEFAULT_NOTIFICATION);
- LOGGER.info("Properties file doesn't have the NOTIFICATION_SERVERS parameter system will use defualt websockets");
- }else{
- serverList = serverList.trim();
- if(serverList.contains(",")) {
- notificationURLList = new ArrayList<String>(Arrays.asList(serverList.split(",")));
- } else {
- notificationURLList = new ArrayList<>();
- notificationURLList.add(serverList);
- }
- }
-
- if(topic!=null) {
- topic = topic.trim();
- } else {
- LOGGER.error("Properties file doesn't have the NOTIFICATION_TOPIC parameter.");
- }
-
- // Client ID Authorization Settings.
- String clientID = prop.getProperty("CLIENT_ID");
- if(clientKey==null){
- clientKey = prop.getProperty("CLIENT_KEY");
- try {
- clientKey = PolicyUtils.decode(clientKey);
- } catch (UnsupportedEncodingException|IllegalArgumentException e) {
- LOGGER.error(XACMLErrorConstants.ERROR_PERMISSIONS+" Cannot Decode the given Password Proceeding with given Password!!");
- }
- }
- if(clientID ==null || clientKey == null || clientID.isEmpty() || clientKey.isEmpty()){
- LOGGER.error(XACMLErrorConstants.ERROR_PERMISSIONS+" Cannot proceed without the CLIENT_KEY and CLIENT_ID values !!");
- throw new PolicyEngineException(XACMLErrorConstants.ERROR_PERMISSIONS+ " Cannot proceed without the CLIENT_KEY and CLIENT_ID values !!");
- }else{
- userName = clientID.trim();
- pass = clientKey.trim();
- }
- setClientEncoding();
- environment = prop.getProperty("ENVIRONMENT", AAFEnvironment.DEVL.toString());
- if(environment.equalsIgnoreCase(AAFEnvironment.TEST.toString())){
- environment = AAFEnvironment.TEST.toString();
- }else if(environment.equalsIgnoreCase(AAFEnvironment.PROD.toString())){
- environment = AAFEnvironment.PROD.toString();
- }else{
- environment = AAFEnvironment.DEVL.toString();
- }
- // Initializing the values.
- pdps = new ArrayList<>();
- encoding = new ArrayList<>();
- // Check the Keys for PDP_URLs
- Collection<Object> unsorted = prop.keySet();
- @SuppressWarnings({ "rawtypes", "unchecked" })
- List<String> sorted = new ArrayList(unsorted);
- Collections.sort(sorted);
- for (String propKey : sorted) {
- if (propKey.startsWith("PDP_URL")) {
- String check_val = prop.getProperty(propKey);
- if (check_val == null) {
- throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "Properties file doesn't have the PDP_URL parameter");
- }
- if (check_val.contains(";")) {
- pdpDefault = new ArrayList<String>(Arrays.asList(check_val.split("\\s*;\\s*")));
- int pdpCount = 0;
- while (pdpCount < pdpDefault.size()) {
- String pdpVal = pdpDefault.get(pdpCount);
- readPDPParam(pdpVal);
- pdpCount++;
- }
- } else {
- readPDPParam(check_val);
- }
- }
- }
- if (pdps == null || pdps.isEmpty()) {
- LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Cannot Proceed without PDP_URLs");
- throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "Cannot Proceed without PDP_URLs");
- }
-
- // Get JUNIT property from properties file when running tests
- String junit = prop.getProperty("JUNIT");
- if(junit == null || junit.isEmpty()){
- LOGGER.info("No JUNIT property provided, this will not be executed as a test.");
- }else{
- if(junit.equalsIgnoreCase("test")){
- StdPolicyEngine.junit = true;
- } else {
- StdPolicyEngine.junit = false;
- }
- }
- }
- }
-
- /*
- * Read the PDP_URL parameter
- */
- private void readPDPParam(String pdpVal) throws PolicyEngineException{
- if(pdpVal.contains(",")){
- List<String> pdpValues = new ArrayList<String>(Arrays.asList(pdpVal.split("\\s*,\\s*")));
- if(pdpValues.size()==3){
- // 0 - PDPURL
- pdps.add(pdpValues.get(0));
- // 1:2 will be UserID:Password
- String userID = pdpValues.get(1);
- String pass = pdpValues.get(2);
- Base64.Encoder encoder = Base64.getEncoder();
- encoding.add(encoder.encodeToString((userID+":"+pass).getBytes(StandardCharsets.UTF_8)));
- }else{
- LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Credentials to send Request: " + pdpValues);
- throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "No enough Credentials to send Request. " + pdpValues);
- }
- }else{
- LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "PDP value is improper/missing required values: " + pdpVal);
- throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "PDP value is improper/missing required values.");
- }
- }
- /*
- * Allowing changes to the scheme and Handler.
- */
- public void notification(NotificationScheme scheme, NotificationHandler handler) {
- this.scheme = scheme;
- this.handler = handler;
- LOGGER.debug("Scheme is : " + scheme.toString());
- LOGGER.debug("Handler is : " + handler.getClass().getName());
-
- if (notificationType.get(0).equals("ueb")){
- if (this.uebThread) {
- uebClientThread.setAuto(scheme, handler);
- this.uebThread = registerUEBThread.isAlive();
- }
- } else if (notificationType.get(0).equals("dmaap")){
- if (this.dmaapThread) {
- dmaapClientThread.setAuto(scheme, handler);
- this.dmaapThread = registerDMAAPThread.isAlive();
- }
- } else {
- AutoClientEnd.setAuto(scheme, handler);
- }
-
- if(junit){
- return;
- }
-
- if(pdps!=null){
- if (notificationType.get(0).equals("ueb") && !this.uebThread){
- this.uebClientThread = new AutoClientUEB(pdps.get(0), notificationURLList, apiKey, apiSecret);
- this.uebClientThread.setAuto(scheme, handler);
- this.registerUEBThread = new Thread(this.uebClientThread);
- this.registerUEBThread.start();
- this.uebThread = true;
- }else if (notificationType.get(0).equals("dmaap") && !this.dmaapThread){
- this.dmaapClientThread = new AutoClientDMAAP(notificationURLList,topic,userName,pass);
- this.dmaapClientThread.setAuto(scheme, handler);
- this.registerDMAAPThread = new Thread(this.dmaapClientThread);
- this.registerDMAAPThread.start();
- this.dmaapThread = true;
- }else{
- if(pdps.get(0)!=null){
- if(AutoClientEnd.getURL()==null){
- AutoClientEnd.start(pdps.get(0));
- }else {
- AutoClientEnd.stop();
- AutoClientEnd.start(pdps.get(0));
- }
- }
- }
- }
- }
-
- /*
- * Gets the Notification if one exists. Used only for Manual Polling
- * purposes.
- */
- public PDPNotification getNotification(){
- //Check if there is proper scheme..
- PDPNotification notification = null;
- if(this.scheme.equals(NotificationScheme.MANUAL_ALL_NOTIFICATIONS) || this.scheme.equals(NotificationScheme.MANUAL_NOTIFICATIONS)) {
- if (notificationType.get(0).equals("ueb")){
- ManualClientEndUEB.start(pdps.get(0), notificationURLList, UNIQUEID);
- notification = ManualClientEndUEB.result(scheme);
- }else if (notificationType.get(0).equals("dmaap")){
- ManualClientEndDMAAP.start(notificationURLList, topic, UNIQUEID, userName, pass);
- notification = ManualClientEndDMAAP.result(scheme);
- }else{
- ManualClientEnd.start(pdps.get(0));
- LOGGER.debug("manual notification requested.. : " + scheme.toString());
- notification = ManualClientEnd.result(scheme);
- }
- if (notification == null){
- LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Notification yet..");
- return null;
- } else {
- return notification;
- }
- }else {
- return null;
- }
- }
-
- /*
- * Setting the Scheme.
- */
- public void setScheme(NotificationScheme scheme) {
- this.scheme = scheme;
- if (notificationType.get(0).equals("ueb")){
- AutoClientUEB.setScheme(this.scheme);
- if (this.scheme.equals(NotificationScheme.MANUAL_ALL_NOTIFICATIONS)){
- ManualClientEndUEB.createTopic(pdps.get(0), UNIQUEID, notificationURLList);
- }
- }else if (notificationType.get(0).equals("dmaap")){
- AutoClientDMAAP.setScheme(this.scheme);
- if (this.scheme.equals(NotificationScheme.MANUAL_ALL_NOTIFICATIONS)){
- ManualClientEndDMAAP.createTopic(topic, UNIQUEID, notificationURLList, userName, pass);
- }
- }else{
- AutoClientEnd.setScheme(this.scheme);
- }
- }
-
- /*
- * Returns the Scheme
- */
- public NotificationScheme getScheme() {
- return this.scheme;
- }
-
- /*
- * Returns the NotificationHandler
- */
- public NotificationHandler getNotificationHandler() {
- return this.handler;
- }
-
- /*
- * Stop the Notification Service if its running.
- */
- public void stopNotification() {
- if (this.scheme != null && this.handler != null) {
- if (this.scheme.equals(NotificationScheme.AUTO_ALL_NOTIFICATIONS)
- || this.scheme
- .equals(NotificationScheme.AUTO_NOTIFICATIONS)) {
- LOGGER.info("Clear Notification called.. ");
- if (notificationType.get(0).equals("ueb")){
- this.uebClientThread.terminate();
- this.uebThread = false;
- }else if (notificationType.get(0).equals("dmaap")){
- this.dmaapClientThread.terminate();
- this.dmaapThread = false;
- }else{
- AutoClientEnd.stop();
- }
- }
- }
- }
-
- /*
- * Push a policy to the PDP API implementation
- */
- public String pushPolicy(String policyScope, String policyName, String policyType, String pdpGroup, UUID requestID) throws PolicyException {
- PushPolicyParameters pushPolicyParameters = new PushPolicyParameters();
- if(policyScope==null|| policyScope.trim().isEmpty()){
- String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.";
- LOGGER.error(message);
- throw new PolicyException(message);
- }
- if(policyName==null|| policyName.trim().isEmpty()){
- String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.";
- LOGGER.error(message);
- throw new PolicyException(message);
- }
- pushPolicyParameters.setPolicyName(policyScope+"."+policyName);
- pushPolicyParameters.setPolicyType(policyType);
- pushPolicyParameters.setPdpGroup(pdpGroup);
- pushPolicyParameters.setRequestID(requestID);
- return pushPolicyImpl(pushPolicyParameters).getResponseMessage();
- }
-
- public String createUpdateConfigPolicy(String policyName, String policyDescription, String ecompName, String configName,
- Map<String, String> configAttributes, String configType, String body, String policyScope, UUID requestID,
- String riskLevel, String riskType, String guard, String ttlDate, boolean updateFlag) throws PolicyException {
- return createUpdateConfigPolicyImpl(policyName, policyDescription, ecompName, configName,
- configAttributes, configType, body, policyScope, requestID,
- riskLevel, riskType, guard, ttlDate, updateFlag);
- }
-
- /*
- * Create Config Policy API Implementation
- */
- public String createUpdateConfigPolicyImpl(String policyName, String policyDescription, String ecompName, String configName,
- Map<String, String> configAttributes, String configType, String body, String policyScope, UUID requestID,
- String riskLevel, String riskType, String guard, String ttlDate, boolean updateFlag) throws PolicyException {
- PolicyParameters policyParameters = new PolicyParameters();
- policyParameters.setPolicyClass(PolicyClass.Config);
- policyParameters.setPolicyConfigType(PolicyConfigType.Base);
- if(policyScope==null|| policyScope.trim().isEmpty()){
- String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.";
- LOGGER.error(message);
- throw new PolicyException(message);
- }
- if(policyName==null|| policyName.trim().isEmpty()){
- String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.";
- LOGGER.error(message);
- throw new PolicyException(message);
- }
- policyParameters.setPolicyName(policyScope+"."+policyName);
- policyParameters.setPolicyDescription(policyDescription);
- policyParameters.setEcompName(ecompName);
- policyParameters.setConfigName(configName);
- Map<AttributeType, Map<String, String>> attributes = new HashMap<AttributeType, Map<String, String>>();
- attributes.put(AttributeType.MATCHING, configAttributes);
- policyParameters.setAttributes(attributes);
- policyParameters.setConfigBodyType(PolicyType.valueOf(configType));
- policyParameters.setConfigBody(body);
- policyParameters.setRequestID(requestID);
- policyParameters.setRiskLevel(riskLevel);
- policyParameters.setRiskType(riskType);
- policyParameters.setGuard(Boolean.parseBoolean(guard));
- try {
- policyParameters.setTtlDate(new SimpleDateFormat("dd-MM-yyyy").parse(ttlDate));
- } catch (ParseException e) {
- LOGGER.warn("Error Parsing date given " + ttlDate);
- policyParameters.setTtlDate(null);
- }
- return createUpdatePolicyImpl(policyParameters, updateFlag).getResponseMessage();
- }
-
- public String createUpdateConfigFirewallPolicy(String policyName, JsonObject firewallJson, String policyScope, UUID requestID,
- String riskLevel, String riskType, String guard, String ttlDate, boolean updateFlag) throws PolicyException {
- return createUpdateConfigFirewallPolicyImpl(policyName, firewallJson, policyScope, requestID,
- riskLevel, riskType, guard, ttlDate, updateFlag);
- }
-
- /*
- * Create Update Config Firewall Policy API implementation
- */
- public String createUpdateConfigFirewallPolicyImpl(String policyName, JsonObject firewallJson, String policyScope, UUID requestID,
- String riskLevel, String riskType, String guard, String ttlDate, boolean updateFlag) throws PolicyException {
- PolicyParameters policyParameters = new PolicyParameters();
- policyParameters.setPolicyClass(PolicyClass.Config);
- policyParameters.setPolicyConfigType(PolicyConfigType.Firewall);
- if(policyScope==null|| policyScope.trim().isEmpty()){
- String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.";
- LOGGER.error(message);
- throw new PolicyException(message);
- }
- if(policyName==null|| policyName.trim().isEmpty()){
- String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.";
- LOGGER.error(message);
- throw new PolicyException(message);
- }
- policyParameters.setPolicyName(policyScope+"."+policyName);
- policyParameters.setConfigBody(firewallJson.toString());
- policyParameters.setRequestID(requestID);
- policyParameters.setRiskLevel(riskLevel);
- policyParameters.setRiskType(riskType);
- policyParameters.setGuard(Boolean.parseBoolean(guard));
- try {
- policyParameters.setTtlDate(new SimpleDateFormat("dd-MM-yyyy").parse(ttlDate));
- } catch (NullPointerException | ParseException e) {
- LOGGER.warn("Error Parsing date given " + ttlDate);
- policyParameters.setTtlDate(null);
- }
- return createUpdatePolicyImpl(policyParameters, updateFlag).getResponseMessage();
- }
-
- public void setClientKey(String clientKey){
- if(clientKey!=null && !clientKey.isEmpty()){
- StdPolicyEngine.pass = clientKey;
- setClientEncoding();
- }
- }
- /*
- * Get the Environment.
- */
- public static String getEnvironment() {
- return environment;
- }
- /*
- * Rotate the PDP list upon WEBsocket Failures
- */
- public static void rotatePDPList() {
- Collections.rotate(pdps, -1);
- Collections.rotate(encoding, -1);
- }
- /*
- * Get the latest PDP
- */
- public static String getPDPURL() {
- return pdps.get(0);
- }
-} \ No newline at end of file
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyResponse.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyResponse.java
deleted file mode 100644
index eed40ba2e..000000000
--- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyResponse.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * PolicyEngineAPI
- * ================================================================================
- * 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=========================================================
- */
-
-
-package org.openecomp.policy.std;
-
-import java.util.Map;
-
-import org.openecomp.policy.api.PolicyResponse;
-import org.openecomp.policy.api.PolicyResponseStatus;
-
-/**
- * PolicyResponse Implementation class.
- *
- * @version 0.1
- *
- */
-public class StdPolicyResponse implements PolicyResponse{
- private PolicyResponseStatus policyResponseStatus;
- private Map<String,String> actionAdvised;
- private Map<String,String> actionTaken;
- private Map<String,String> requestAttributes;
- private String policyResponseMessage;
-
- @Override
- public PolicyResponseStatus getPolicyResponseStatus() {
- return policyResponseStatus;
- }
-
- @Override
- public Map<String, String> getActionAdvised() {
- return actionAdvised;
- }
-
- @Override
- public Map<String, String> getActionTaken() {
- return actionTaken;
- }
-
- @Override
- public Map<String, String> getRequestAttributes() {
- return requestAttributes;
- }
-
- @Override
- public String getPolicyResponseMessage() {
- return policyResponseMessage;
- }
-
- public void setPolicyResponseStatus(PolicyResponseStatus policyResponseStatus) {
- this.policyResponseStatus = policyResponseStatus;
- }
-
- public void setActionAdvised(Map<String, String> actionAdvised) {
- this.actionAdvised = actionAdvised;
- }
-
- public void setActionTaken(Map<String, String> actionTaken) {
- this.actionTaken = actionTaken;
- }
-
- public void setRequestAttributes(Map<String, String> requestAttributes) {
- this.requestAttributes = requestAttributes;
- }
-
- public void setPolicyResponseMessage(String policyResponseMessage) {
- this.policyResponseMessage = policyResponseMessage;
- }
-
- public void setPolicyResponseStatus(String policyResponseMessage, PolicyResponseStatus policyResponseStatus) {
- this.policyResponseMessage = policyResponseMessage;
- this.policyResponseStatus = policyResponseStatus;
- }
-
- @Override
- public String toString() {
- return "PolicyResponse [ policyResponseStatus=" + policyResponseStatus + ", policyResponseMessage=" + policyResponseMessage + ", " +
- ""
- + "]";
- }
-}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdStatus.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdStatus.java
deleted file mode 100644
index a7d22b7cb..000000000
--- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdStatus.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * PolicyEngineAPI
- * ================================================================================
- * 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=========================================================
- */
-
-
-package org.openecomp.policy.std;
-
-import java.util.Map;
-import java.util.Properties;
-
-import javax.json.JsonObject;
-
-import org.openecomp.policy.api.DecisionResponse;
-import org.openecomp.policy.api.PolicyConfig;
-import org.openecomp.policy.api.PolicyConfigStatus;
-import org.openecomp.policy.api.PolicyDecision;
-import org.openecomp.policy.api.PolicyResponse;
-import org.openecomp.policy.api.PolicyResponseStatus;
-import org.openecomp.policy.api.PolicyType;
-import org.w3c.dom.Document;
-
-public class StdStatus extends StdPolicyResponse implements PolicyConfig, PolicyResponse, DecisionResponse{
- private PolicyType policyType;
- private Properties properties;
- private JsonObject jsonObject;
- private Document document;
- private String other;
- private PolicyConfigStatus policyConfigStatus;
- private String configStatus;
- private PolicyResponseStatus policyResponseStatus;
- private Map<String,String> actionAdvised;
- private Map<String,String> actionTaken;
- private Map<String,String> requestAttributes;
- private String policyResponseMessage;
- private String policyName;
- private String policyVersion;
- private Map<String,String> matchingConditions;
- private Map<String,String> responseAttributes;
- private PolicyDecision policyDecision;
- private String details;
-
- public void setStatus(String message, PolicyResponseStatus policyResponseStatus, PolicyConfigStatus policyConfigStatus) {
- this.configStatus = message;
- this.policyResponseMessage = message;
- this.policyResponseStatus = policyResponseStatus;
- this.policyConfigStatus = policyConfigStatus;
- }
- @Override
- public PolicyResponseStatus getPolicyResponseStatus() {
- return policyResponseStatus;
- }
-
- @Override
- public Map<String, String> getActionAdvised() {
- return actionAdvised;
- }
-
- @Override
- public Map<String, String> getActionTaken() {
- return actionTaken;
- }
-
- @Override
- public Map<String, String> getRequestAttributes() {
- return requestAttributes;
- }
-
- @Override
- public String getPolicyResponseMessage() {
- return policyResponseMessage;
- }
-
- public void setPolicyResponseStatus(PolicyResponseStatus policyResponseStatus) {
- this.policyResponseStatus = policyResponseStatus;
- }
-
- public void setActionAdvised(Map<String, String> actionAdvised) {
- this.actionAdvised = actionAdvised;
- }
-
- public void setActionTaken(Map<String, String> actionTaken) {
- this.actionTaken = actionTaken;
- }
-
- public void setRequestAttributes(Map<String, String> requestAttributes) {
- this.requestAttributes = requestAttributes;
- }
-
- public void setPolicyResponseMessage(String policyResponseMessage) {
- this.policyResponseMessage = policyResponseMessage;
- }
-
- public void setPolicyResponseStatus(String policyResponseMessage, PolicyResponseStatus policyResponseStatus) {
- this.policyResponseMessage = policyResponseMessage;
- this.policyResponseStatus = policyResponseStatus;
- }
-
- @Override
- public PolicyType getType() {
- return policyType;
- }
-
- @Override
- public Properties toProperties() {
- return properties;
- }
-
- @Override
- public JsonObject toJSON() {
- return jsonObject;
- }
-
- @Override
- public Document toXML() {
- return document;
- }
-
- @Override
- public PolicyConfigStatus getPolicyConfigStatus() {
- return policyConfigStatus;
- }
-
- @Override
- public String getPolicyConfigMessage() {
- return configStatus;
- }
-
- @Override
- public String getPolicyName() {
- if(policyName!=null && policyName.contains(".xml")){
- return (policyName.substring(0, policyName.substring(0, policyName.lastIndexOf(".")).lastIndexOf(".")));
- }
- return policyName;
- }
-
- @Override
- public String getPolicyVersion() {
- return policyVersion;
- }
-
- @Override
- public Map<String,String> getMatchingConditions(){
- return matchingConditions;
- }
-
- @Override
- public Map<String,String> getResponseAttributes(){
- return responseAttributes;
- }
-
- public void setPolicyType(PolicyType policyType) {
- this.policyType = policyType;
- }
-
- public void setProperties(Properties properties) {
- this.properties = properties;
- }
-
- public void setJsonObject(JsonObject jsonObject) {
- this.jsonObject = jsonObject;
- }
-
- public void setDocument(Document document) {
- this.document = document;
- }
-
- public void setConfigStatus(String configStatus) {
- this.configStatus = configStatus;
- }
-
- public void setPolicyName(String policyName) {
- this.policyName = policyName;
- }
-
- public void setPolicyVersion(String policyVersion) {
- this.policyVersion = policyVersion;
- }
-
- public void setMatchingConditions(Map<String,String> matchingConditions){
- this.matchingConditions = matchingConditions;
- }
-
- public void setResposneAttributes(Map<String,String> responseAttributes){
- this.responseAttributes = responseAttributes;
- }
-
- public void setPolicyConfigStatus(PolicyConfigStatus policyConfigStatus) {
- this.policyConfigStatus = policyConfigStatus;
- }
-
- public void setPolicyConfigStatus(String configStatus, PolicyConfigStatus policyConfigStatus) {
- this.policyConfigStatus = policyConfigStatus;
- this.configStatus = configStatus;
- }
-
- @Override
- public String toOther() {
- return other;
- }
-
- public void setOther(String other) {
- this.other = other;
- }
-
- public PolicyDecision getDecision() {
- return policyDecision;
- }
- public void setDecision(PolicyDecision policyDecision) {
- this.policyDecision = policyDecision;
- }
-
- public void setDetails(String details){
- this.details = details;
- }
-
- public String getDetails(){
- return details;
- }
-}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/package-info.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/package-info.java
deleted file mode 100644
index a10f347e9..000000000
--- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/package-info.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * PolicyEngineAPI
- * ================================================================================
- * 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=========================================================
- */
-
-package org.openecomp.policy.std;
-/**
- * Provides standard implementations of the interfaces from the {@link org.openecomp.policy.api} package.
- *
- * @version 0.3
- *
- */