Adding UI extensibility
[aai/sparky-be.git] / src / main / java / org / onap / aai / sparky / sync / task / PerformActiveInventoryRetrieval.java
  *
  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
  */
-package org.onap.aai.sparky.synchronizer.task;
+package org.onap.aai.sparky.sync.task;
 
 import java.util.Map;
 import java.util.function.Supplier;
 
+import org.onap.aai.cl.api.Logger;
+import org.onap.aai.cl.eelf.LoggerFactory;
+import org.onap.aai.restclient.client.OperationResult;
+import org.onap.aai.sparky.dal.ActiveInventoryAdapter;
 import org.onap.aai.sparky.dal.NetworkTransaction;
-import org.onap.aai.sparky.dal.aai.ActiveInventoryDataProvider;
-import org.onap.aai.sparky.dal.aai.config.ActiveInventoryConfig;
-import org.onap.aai.sparky.dal.rest.OperationResult;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.onap.aai.sparky.logging.AaiUiMsgs;
 import org.slf4j.MDC;
 
 /*
@@ -43,10 +43,11 @@ import org.slf4j.MDC;
  */
 public class PerformActiveInventoryRetrieval implements Supplier<NetworkTransaction> {
 
-  private static Logger logger = LoggerFactory.getLogger(PerformActiveInventoryRetrieval.class);
+  private static Logger logger =
+      LoggerFactory.getInstance().getLogger(PerformActiveInventoryRetrieval.class);
 
   private NetworkTransaction txn;
-  private ActiveInventoryDataProvider aaiProvider;
+  private ActiveInventoryAdapter aaiAdapter;
   private Map<String, String> contextMap;
 
   /**
@@ -56,9 +57,9 @@ public class PerformActiveInventoryRetrieval implements Supplier<NetworkTransact
    * @param aaiProvider the aai provider
    */
   public PerformActiveInventoryRetrieval(NetworkTransaction txn,
-      ActiveInventoryDataProvider aaiProvider) {
+      ActiveInventoryAdapter aaiAdapter) {
     this.txn = txn;
-    this.aaiProvider = aaiProvider;
+    this.aaiAdapter = aaiAdapter;
     this.contextMap = MDC.getCopyOfContextMap();
   }
 
@@ -76,76 +77,24 @@ public class PerformActiveInventoryRetrieval implements Supplier<NetworkTransact
     MDC.setContextMap(contextMap);
     OperationResult result = null;
     try {
-      // todo: use proper config instead of hard-coding parameters
+
       final String absoluteSelfLink =
-          ActiveInventoryConfig.getConfig().repairSelfLink(txn.getLink());
-      result = aaiProvider.queryActiveInventoryWithRetries(absoluteSelfLink, "application/json", 5);
+          aaiAdapter.repairSelfLink(txn.getLink(), txn.getQueryParameters());
+      result = aaiAdapter.queryActiveInventoryWithRetries(absoluteSelfLink, "application/json", 5);
     } catch (Exception exc) {
-      logger.error("Failure to resolve self link from AAI.  Error = ", exc);
+      logger.error(AaiUiMsgs.ERROR_GENERIC,
+          "Failure to resolve self link from AAI.  Error = " + exc.getMessage());
       result = new OperationResult(500,
           "Caught an exception while trying to resolve link = " + exc.getMessage());
     } finally {
-      result.setResponseTimeInMs(System.currentTimeMillis() - startTimeInMs);
       txn.setOperationResult(result);
+      txn.setOpTimeInMs(System.currentTimeMillis() - startTimeInMs);
     }
 
     return txn;
   }
 
-  /**
-   * @return the logger
-   */
-  public static Logger getLogger() {
-    return logger;
-  }
-
-  /**
-   * @param logger the logger to set
-   */
-  public static void setLogger(Logger logger) {
-    PerformActiveInventoryRetrieval.logger = logger;
-  }
-
-  /**
-   * @return the txn
-   */
-  public NetworkTransaction getTxn() {
-    return txn;
-  }
-
-  /**
-   * @param txn the txn to set
-   */
-  public void setTxn(NetworkTransaction txn) {
-    this.txn = txn;
-  }
-
-  /**
-   * @return the aaiProvider
-   */
-  public ActiveInventoryDataProvider getAaiProvider() {
-    return aaiProvider;
-  }
-
-  /**
-   * @param aaiProvider the aaiProvider to set
-   */
-  public void setAaiProvider(ActiveInventoryDataProvider aaiProvider) {
-    this.aaiProvider = aaiProvider;
-  }
-
-  /**
-   * @return the contextMap
-   */
-  public Map<String, String> getContextMap() {
-    return contextMap;
-  }
-
-  /**
-   * @param contextMap the contextMap to set
-   */
-  public void setContextMap(Map<String, String> contextMap) {
+  protected void setContextMap(Map<String, String> contextMap) {
     this.contextMap = contextMap;
   }
-
 }