- 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;
- boolean 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 static 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();
- }
+ /**
+ * Result.
+ *
+ * @param scheme the scheme
+ * @return the PDP notification
+ */
+ public static PDPNotification result(NotificationScheme scheme) {
+ if (resultJson == null || notification == null) {
+ logger.info("ManualClientENd - No Result available");
+ return null;
+ } else {
+ if (scheme.equals(NotificationScheme.MANUAL_ALL_NOTIFICATIONS)) {
+ boolean removed = false;
+ boolean updated = false;
+ if (notification.getRemovedPolicies() != null && !notification.getRemovedPolicies().isEmpty()) {
+ removed = true;
+ notification.setNotificationType(NotificationType.REMOVE);
+ }
+ if (notification.getLoadedPolicies() != null && !notification.getLoadedPolicies().isEmpty()) {
+ updated = true;
+ notification.setNotificationType(NotificationType.UPDATE);
+ }
+ if (removed && updated) {
+ notification.setNotificationType(NotificationType.BOTH);
+ }
+ return notification;
+ } else if (scheme.equals(NotificationScheme.MANUAL_NOTIFICATIONS)) {
+ return MatchStore.checkMatch(notification);
+ } else {
+ return null;
+ }
+ }
+ }