Fix Batch Cred Deletes 83/97983/1
authorInstrumental <jonathan.gathman@att.com>
Tue, 5 Nov 2019 20:19:36 +0000 (14:19 -0600)
committerInstrumental <jonathan.gathman@att.com>
Tue, 5 Nov 2019 20:19:41 +0000 (14:19 -0600)
Issue-ID: AAF-1038
Change-Id: I30ea4ec04cd3ca6c416010f99e46aa44c5f2fd24
Signed-off-by: Instrumental <jonathan.gathman@att.com>
auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/Cred.java
auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/update/Remove.java
misc/env/src/main/java/org/onap/aaf/misc/env/util/Chrono.java

index 4930900..4c14f0f 100644 (file)
@@ -316,7 +316,7 @@ public class Cred  {
     }
 
     public static void batchDelete(StringBuilder sb, List<String> row) {
     }
 
     public static void batchDelete(StringBuilder sb, List<String> row) {
-        Long l = Long.parseLong(row.get(5));
+        long l = Long.parseLong(row.get(5));
         String date = Chrono.batchFmt.format(new Date(l));
         sb.append("DELETE from authz.cred WHERE id='");
         sb.append(row.get(1));
         String date = Chrono.batchFmt.format(new Date(l));
         sb.append("DELETE from authz.cred WHERE id='");
         sb.append(row.get(1));
@@ -326,9 +326,6 @@ public class Cred  {
         sb.append(" AND expires='");
         sb.append(date);
         sb.append("';\n");
         sb.append(" AND expires='");
         sb.append(date);
         sb.append("';\n");
-//        sb.append(" AND expires=dateof(maxtimeuuid(");
-//        sb.append(row.get(5));
-//        sb.append("));\n");
 
     }
 
 
     }
 
index 087ab95..3d26ce9 100644 (file)
@@ -94,7 +94,14 @@ public class Remove extends Batch {
                 remove.add(new File(logDir, args()[i]));
             }
         } else {
                 remove.add(new File(logDir, args()[i]));
             }
         } else {
-            remove.add(new File(logDir,"Delete"+Chrono.dateOnlyStamp()+".csv"));
+               final String ending = Chrono.dateOnlyStamp()+".csv";
+               for (File file : logDir.listFiles(f -> {
+                               String name = f.getName();
+                                       return name.endsWith(ending) && (
+                                                       name.startsWith("Delete") || name.startsWith("Clean."));
+                               }))  {
+                       remove.add(file);
+               };
         }
 
         for(File f : remove) {
         }
 
         for(File f : remove) {
index e6c95db..aa20dfa 100644 (file)
@@ -63,6 +63,8 @@ public class Chrono {
         niceUTCDateFmt.setTimeZone(TimeZone.getTimeZone("UTC"));\r
         iso8601Fmt =  new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX");\r
         batchFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss+SSSS");\r
         niceUTCDateFmt.setTimeZone(TimeZone.getTimeZone("UTC"));\r
         iso8601Fmt =  new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX");\r
         batchFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss+SSSS");\r
+        // Note: DB and thus Batch conversions should always be in UTC Time\r
+        batchFmt.setTimeZone(TimeZone.getTimeZone("UTC"));\r
     }\r
     \r
 \r
     }\r
     \r
 \r