Remove the client load balancer use http client
[aai/aai-common.git] / aai-core / src / main / java / org / onap / aai / util / StoreNotificationEvent.java
index 96dbfeb..6bde482 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * org.onap.aai
  * ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  * ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
  */
 package org.onap.aai.util;
 
-import java.io.StringWriter;
-import java.util.Iterator;
-import java.util.UUID;
-
-import javax.xml.bind.Marshaller;
-
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
 import org.eclipse.persistence.dynamic.DynamicEntity;
 import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
 import org.json.JSONException;
 import org.json.JSONObject;
 import org.onap.aai.dmaap.AAIDmaapEventJMSProducer;
+import org.onap.aai.dmaap.MessageProducer;
 import org.onap.aai.domain.notificationEvent.NotificationEvent;
 import org.onap.aai.exceptions.AAIException;
 import org.onap.aai.introspection.Introspector;
 import org.onap.aai.introspection.Loader;
 import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.core.env.Environment;
+
+import javax.xml.bind.Marshaller;
+import java.io.StringWriter;
+import java.util.Iterator;
+import java.util.UUID;
 
 public class StoreNotificationEvent {
 
-       private AAIDmaapEventJMSProducer messageProducer;
+    private static final EELFLogger logger = EELFManager.getInstance().getLogger(StoreNotificationEvent.class);
+       private MessageProducer messageProducer;
        private String fromAppId = "";
        private String transId = "";
        private final String transactionId;
        private final String sourceOfTruth;
+
+       private ApplicationContext context;
+       private Environment env;
+
        /**
         * Instantiates a new store notification event.
         */
        public StoreNotificationEvent(String transactionId, String sourceOfTruth) {
-               this.messageProducer = new AAIDmaapEventJMSProducer();
-               this.transactionId = transactionId;
-               this.sourceOfTruth = sourceOfTruth;
+           this.messageProducer = new AAIDmaapEventJMSProducer();
+        this.transactionId   = transactionId;
+        this.sourceOfTruth   = sourceOfTruth;
+       }
+
+       public StoreNotificationEvent(AAIDmaapEventJMSProducer producer, String transactionId, String sourceOfTruth) {
+           this.messageProducer = producer;
+               this.transactionId   = transactionId;
+               this.sourceOfTruth   = sourceOfTruth;
        }
 
        /**
@@ -64,7 +77,7 @@ public class StoreNotificationEvent {
         * @throws AAIException
         *             the AAI exception
         */
-       public void storeEvent(NotificationEvent.EventHeader eh, Object obj) throws AAIException {
+       public String storeEvent(NotificationEvent.EventHeader eh, Object obj) throws AAIException {
 
                if (obj == null) {
                        throw new AAIException("AAI_7350");
@@ -123,6 +136,7 @@ public class StoreNotificationEvent {
                        PojoUtils pu = new PojoUtils();
                        String entityJson = pu.getJsonFromObject(ne);
                        sendToDmaapJmsQueue(entityJson);
+                       return entityJson;
                } catch (Exception e) {
                        throw new AAIException("AAI_7350", e);
                }
@@ -214,7 +228,7 @@ public class StoreNotificationEvent {
                }
        }
 
-       public void storeEvent(Loader loader, Introspector eventHeader, Introspector obj) throws AAIException {
+       public String storeEvent(Loader loader, Introspector eventHeader, Introspector obj) throws AAIException {
                if (obj == null) {
                        throw new AAIException("AAI_7350");
                }
@@ -271,6 +285,7 @@ public class StoreNotificationEvent {
 
                        String entityJson = notificationEvent.marshal(false);
                        sendToDmaapJmsQueue(entityJson);
+                       return entityJson;
                } catch (JSONException e) {
                        throw new AAIException("AAI_7350", e);
                } catch (AAIUnknownObjectException e) {