[Policy-20] getConfig & Policy resolved blockers
[policy/engine.git] / ECOMP-PDP-REST / src / main / java / org / openecomp / policy / pdp / rest / notifications / NotificationServer.java
index fe295eb..21fb8f3 100644 (file)
@@ -140,35 +140,29 @@ public class NotificationServer {
                                
                        } catch (MalformedURLException e1) {
                                LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error creating the UEB publisher" + e1.getMessage());
-                               e1.printStackTrace();
                        } catch (GeneralSecurityException e1) {
                                LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error creating the UEB publisher" + e1.getMessage());
-                               e1.printStackTrace();
                        }
-
-                       try {
-                               pub.send( "MyPartitionKey", notification );
-                       } catch (IOException e) {
-                               LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error sending notification update" + e.getMessage());
-                       }
-                       
-                       // close the publisher. The batching publisher does not send events
-                       // immediately, so you MUST use close to send any remaining messages.
-                       // You provide the amount of time you're willing to wait for the sends
-                       // to succeed before giving up. If any messages are unsent after that time,
-                       // they're returned to your app. You could, for example, persist to disk
-                       // and try again later.
-                       final List stuck = pub.close ( 20, TimeUnit.SECONDS );
-                       
-                       if ( stuck.size () > 0 )
-                       {
-                               System.err.println ( stuck.size() + " messages unsent" );
-                       }
-                       else
-                       {
-                               System.out.println ( "Clean exit; all messages sent: " + notification );
+                       if(pub != null){
+                               try {
+                                       pub.send( "MyPartitionKey", notification );
+                               } catch (IOException e) {
+                                       LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error sending notification update" + e.getMessage() + e);
+                               }
+                               // close the publisher. The batching publisher does not send events
+                               // immediately, so you MUST use close to send any remaining messages.
+                               // You provide the amount of time you're willing to wait for the sends
+                               // to succeed before giving up. If any messages are unsent after that time,
+                               // they're returned to your app. You could, for example, persist to disk
+                               // and try again later.
+                               final List<?> stuck = pub.close ( 20, TimeUnit.SECONDS );
+                               
+                               if (!stuck.isEmpty()){
+                                       LOGGER.error( stuck.size() + " messages unsent" );
+                               }else{
+                                       LOGGER.info( "Clean exit; all messages sent: " + notification );
+                               }
                        }
-                       
                } else if (propNotificationType.equals("dmaap")) {
                        
                        // Setting up the Publisher for DMaaP MR
@@ -192,7 +186,7 @@ public class NotificationServer {
                                if(dmaapServers.contains(",")) {
                                        dmaapList = new ArrayList<String>(Arrays.asList(dmaapServers.split("\\s*,\\s*")));
                                } else {
-                                       dmaapList = new ArrayList<String>();
+                                       dmaapList = new ArrayList<>();
                                        dmaapList.add(dmaapServers);
                                }