Add optional API for PM Mapper
[dmaap/datarouter.git] / datarouter-node / src / main / java / org / onap / dmaap / datarouter / node / NodeConfigManager.java
index 474f5dd..d98c47a 100644 (file)
@@ -57,6 +57,7 @@ public class NodeConfigManager implements DeliveryQueueHelper {
     private Timer timer = new Timer("Node Configuration Timer", true);
     private long maxfailuretimer;
     private long initfailuretimer;
+    private long waitForFileProcessFailureTimer;
     private long expirationtimer;
     private double failurebackoff;
     private long fairtimelimit;
@@ -187,6 +188,7 @@ public class NodeConfigManager implements DeliveryQueueHelper {
         followredirects = Boolean.parseBoolean(getProvParam("FOLLOW_REDIRECTS", "false"));
         eventloginterval = getProvParam("LOGROLL_INTERVAL", "30s");
         initfailuretimer = 10000;
+        waitForFileProcessFailureTimer = 600000;
         maxfailuretimer = 3600000;
         expirationtimer = 86400000;
         failurebackoff = 2.0;
@@ -199,6 +201,10 @@ public class NodeConfigManager implements DeliveryQueueHelper {
             initfailuretimer = (long) (Double.parseDouble(getProvParam("DELIVERY_INIT_RETRY_INTERVAL")) * 1000);
         } catch (Exception e) {
         }
+        try {
+            waitForFileProcessFailureTimer = (long) (Double.parseDouble(getProvParam("DELIVERY_FILE_PROCESS_INTERVAL")) * 1000);
+        } catch (Exception e) {
+        }
         try {
             maxfailuretimer = (long) (Double.parseDouble(getProvParam("DELIVERY_MAX_RETRY_INTERVAL")) * 1000);
         } catch (Exception e) {
@@ -328,6 +334,16 @@ public class NodeConfigManager implements DeliveryQueueHelper {
         return (config.isPublishPermitted(feedid, credentials, ip));
     }
 
+    /**
+     * Check whether delete file is allowed.
+     *
+     * @param subId The ID of the subscription being requested
+     * @return True if the delete file is permitted for the subscriber.
+     */
+    public boolean isDeletePermitted(String subId) {
+        return (config.isDeletePermitted(subId));
+    }
+
     /**
      * Check who the user is given the feed ID and the offered credentials.
      *
@@ -407,13 +423,13 @@ public class NodeConfigManager implements DeliveryQueueHelper {
     /**
      * Get the URL to deliver a message to.
      *
-     * @param destinfo The destination information
+     * @param destinationInfo The destination information
      * @param fileid The file ID
      * @return The URL to deliver to
      */
-    public String getDestURL(DestInfo destinfo, String fileid) {
-        String subid = destinfo.getSubId();
-        String purl = destinfo.getURL();
+    public String getDestURL(DestInfo destinationInfo, String fileid) {
+        String subid = destinationInfo.getSubId();
+        String purl = destinationInfo.getURL();
         if (followredirects && subid != null) {
             purl = rdmgr.lookup(subid, purl);
         }
@@ -430,10 +446,10 @@ public class NodeConfigManager implements DeliveryQueueHelper {
     /**
      * Set up redirection on receipt of a 3XX from a target URL
      */
-    public boolean handleRedirection(DestInfo destinfo, String redirto, String fileid) {
+    public boolean handleRedirection(DestInfo destinationInfo, String redirto, String fileid) {
         fileid = "/" + fileid;
-        String subid = destinfo.getSubId();
-        String purl = destinfo.getURL();
+        String subid = destinationInfo.getSubId();
+        String purl = destinationInfo.getURL();
         if (followredirects && subid != null && redirto.endsWith(fileid)) {
             redirto = redirto.substring(0, redirto.length() - fileid.length());
             if (!redirto.equals(purl)) {
@@ -447,8 +463,8 @@ public class NodeConfigManager implements DeliveryQueueHelper {
     /**
      * Handle unreachable target URL
      */
-    public void handleUnreachable(DestInfo destinfo) {
-        String subid = destinfo.getSubId();
+    public void handleUnreachable(DestInfo destinationInfo) {
+        String subid = destinationInfo.getSubId();
         if (followredirects && subid != null) {
             rdmgr.forget(subid);
         }
@@ -461,6 +477,13 @@ public class NodeConfigManager implements DeliveryQueueHelper {
         return (initfailuretimer);
     }
 
+    /**
+     * Get the timeout before retrying after delivery and wait for file processing
+     */
+    public long getWaitForFileProcessFailureTimer() {
+        return (waitForFileProcessFailureTimer);
+    }
+
     /**
      * Get the maximum timeout between delivery attempts
      */