summaryrefslogtreecommitdiffstats
path: root/auth/auth-batch/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'auth/auth-batch/src/main')
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/CQLBatch.java30
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/CQLBatchLoop.java2
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/Cred.java17
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/X509.java9
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/ApprovedRpt.java31
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/bodies/NotifyCredBody.java2
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/bodies/OneMonthNotifyCredBody.java2
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/bodies/OneWeekNotifyCredBody.java2
8 files changed, 54 insertions, 41 deletions
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/CQLBatch.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/CQLBatch.java
index b626bae7..d62c7781 100644
--- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/CQLBatch.java
+++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/CQLBatch.java
@@ -20,6 +20,7 @@
package org.onap.aaf.auth.batch.helpers;
+import org.onap.aaf.cadi.Access;
import org.onap.aaf.misc.env.LogTarget;
import com.datastax.driver.core.ResultSet;
@@ -30,12 +31,15 @@ public class CQLBatch {
private StringBuilder sb;
private int hasAdded;
private LogTarget log;
+ private long sleep;
+ private long last;
public CQLBatch(LogTarget log, Session session) {
this.log = log;
this.session = session;
sb = new StringBuilder();
hasAdded = 0;
+ sleep = 0L;
}
public StringBuilder begin() {
sb.setLength(0);
@@ -56,6 +60,17 @@ public class CQLBatch {
public ResultSet execute() {
if(end()) {
+ if(sleep>0) {
+ long left = last - System.currentTimeMillis();
+ if(left>0) {
+ try {
+ Thread.sleep(left);
+ } catch (InterruptedException e) {
+ Access.NULL.log(e); // Keep code check idiocy at bay
+ }
+ }
+ last = System.currentTimeMillis()+sleep;
+ }
return session.execute(sb.toString());
} else {
return null;
@@ -65,6 +80,17 @@ public class CQLBatch {
public ResultSet execute(boolean dryRun) {
ResultSet rv = null;
if(dryRun) {
+ if(sleep>0) {
+ long left = last - System.currentTimeMillis();
+ if(left>0) {
+ try {
+ Thread.sleep(left);
+ } catch (InterruptedException e) {
+ Access.NULL.log(e); // Keep code check idiocy at bay
+ }
+ }
+ last = System.currentTimeMillis()+sleep;
+ }
end();
} else {
rv = execute();
@@ -93,6 +119,10 @@ public class CQLBatch {
execute(dryRun);
}
+ public void sleep(int j) {
+ sleep = j*1000;
+ }
+
public String toString() {
return sb.toString();
}
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/CQLBatchLoop.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/CQLBatchLoop.java
index 2604364b..1a1bdf33 100644
--- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/CQLBatchLoop.java
+++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/CQLBatchLoop.java
@@ -32,7 +32,7 @@ public class CQLBatchLoop {
private int batches;
private final StringBuilder current;
private boolean showProgress;
-
+
public CQLBatchLoop(CQLBatch cb, int max, boolean dryRun) {
cqlBatch = cb;
i=0;
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/Cred.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/Cred.java
index 1f5a1f40..83638cc7 100644
--- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/Cred.java
+++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/Cred.java
@@ -21,6 +21,7 @@
package org.onap.aaf.auth.batch.helpers;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.GregorianCalendar;
@@ -139,7 +140,7 @@ public class Cred {
}
public static void loadOneNS(Trans trans, Session session, String ns,int ... types ) {
- load(trans, session,"select id, type, expires, other, writetime(cred), tag from authz.cred WHERE ns='" + ns + "';");
+ load(trans, session,"select id, type, expires, other, writetime(cred), tag from authz.cred WHERE ns='" + ns + "';", types);
}
private static void load(Trans trans, Session session, String query, int ...types) {
@@ -315,16 +316,22 @@ public class Cred {
inst.expires.getTime(),inst.tag,reason);
}
-
+ static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss+SSSS");
public static void batchDelete(StringBuilder sb, List<String> row) {
+ Long l = Long.parseLong(row.get(5));
+ String date = sdf.format(new Date(l));
sb.append("DELETE from authz.cred WHERE id='");
sb.append(row.get(1));
sb.append("' AND type=");
sb.append(Integer.parseInt(row.get(3)));
// Note: We have to work with long, because Expires is part of Key... can't easily do date.
- sb.append(" AND expires=dateof(maxtimeuuid(");
- sb.append(row.get(5));
- 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");
+
}
public String toString() {
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/X509.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/X509.java
index c68a9945..e2d86947 100644
--- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/X509.java
+++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/X509.java
@@ -59,10 +59,15 @@ public class X509 {
public static void load(Trans trans, Session session, Visitor<X509> visitor) {
- load(trans,session,"select ca, id, x500, x509, serial from authz.x509;", visitor);
+ load(trans,session, "" , visitor);
}
+
+ public static void load(Trans trans, Session session, String where, Visitor<X509> visitor) {
+ load(trans,session, visitor,"select ca, id, x500, x509, serial from authz.x509 " + where +';');
+ }
+
- private static void load(Trans trans, Session session, String query, Visitor<X509> visitor) {
+ private static void load(Trans trans, Session session, Visitor<X509> visitor, String query) {
trans.info().log( "query: " + query );
TimeTaken tt = trans.start("Read X509", Env.REMOTE);
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/ApprovedRpt.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/ApprovedRpt.java
index b2fd8a9a..ea196b1f 100644
--- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/ApprovedRpt.java
+++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/ApprovedRpt.java
@@ -3,6 +3,7 @@
* org.onap.aaf
* ===========================================================================
* Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 IBM.
* ===========================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -63,13 +64,6 @@ public class ApprovedRpt extends Batch {
TimeTaken tt0 = trans.start("Cassandra Initialization", Env.SUB);
try {
-// TimeTaken tt = trans.start("Connect to Cluster", Env.REMOTE);
-// try {
-// session = cluster.connect();
-// } finally {
-// tt.done();
-// }
-
now = new Date();
String sdate = Chrono.dateOnlyStamp(now);
File file = new File(logDir(),APPR_RPT + sdate +CSV);
@@ -90,29 +84,6 @@ public class ApprovedRpt extends Batch {
Map<String,Boolean> checked = new TreeMap<String, Boolean>();
final AuthzTrans transNoAvg = trans.env().newTransNoAvg();
-// ResultSet results;
-// Statement stmt = new SimpleStatement( "select dateof(id), approver, status, user, type, memo from authz.approved;" );
-// results = session.execute(stmt);
-// Iterator<Row> iter = results.iterator();
-// Row row;
- /*
- * while (iter.hasNext()) {
- ++totalLoaded;
- row = iter.next();
- d = row.getTimestamp(0);
- if(d.after(begin)) {
- approvedW.row("aprvd",
- Chrono.dateOnlyStamp(d),
- row.getString(1),
- row.getString(2),
- row.getString(3),
- row.getString(4),
- row.getString(5)
- );
- }
- }
-
- */
int totalLoaded = 0;
Date d;
GregorianCalendar gc = new GregorianCalendar();
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/bodies/NotifyCredBody.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/bodies/NotifyCredBody.java
index 7001c024..8eaf6a86 100644
--- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/bodies/NotifyCredBody.java
+++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/bodies/NotifyCredBody.java
@@ -22,7 +22,7 @@
*/
package org.onap.aaf.auth.batch.reports.bodies;
-import java.io.IOException;
+
import java.util.GregorianCalendar;
import java.util.List;
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/bodies/OneMonthNotifyCredBody.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/bodies/OneMonthNotifyCredBody.java
index 8747ebf8..417d4be4 100644
--- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/bodies/OneMonthNotifyCredBody.java
+++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/bodies/OneMonthNotifyCredBody.java
@@ -26,7 +26,7 @@ import org.onap.aaf.auth.batch.helpers.ExpireRange;
import org.onap.aaf.cadi.Access;
public class OneMonthNotifyCredBody extends NotifyCredBody {
- public OneMonthNotifyCredBody(Access access) throws IOException {
+ public OneMonthNotifyCredBody(Access access){
super(access, ExpireRange.ONE_MONTH);
}
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/bodies/OneWeekNotifyCredBody.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/bodies/OneWeekNotifyCredBody.java
index a1277d55..dae48d85 100644
--- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/bodies/OneWeekNotifyCredBody.java
+++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/bodies/OneWeekNotifyCredBody.java
@@ -26,7 +26,7 @@ import org.onap.aaf.auth.batch.helpers.ExpireRange;
import org.onap.aaf.cadi.Access;
public class OneWeekNotifyCredBody extends NotifyCredBody {
- public OneWeekNotifyCredBody(Access access) throws IOException {
+ public OneWeekNotifyCredBody(Access access){
super(access, ExpireRange.ONE_WEEK);
}