summaryrefslogtreecommitdiffstats
path: root/auth/auth-batch/src/main/java/org/onap
diff options
context:
space:
mode:
authorInstrumental <jonathan.gathman@att.com>2019-03-14 14:30:00 -0500
committerInstrumental <jonathan.gathman@att.com>2019-03-14 14:32:26 -0500
commit502da3cb1daf171395630dbaf4a2f2e2fb9aa93e (patch)
tree0d3229b79197f2b8f21d9b85ed96e92d8e816567 /auth/auth-batch/src/main/java/org/onap
parent13b7a3bc25fba512024f2e599be3eb132b0c7b16 (diff)
Change Sonar flagged code
Issue-ID: AAF-788 Change-Id: Ib4a2f69be5b0c9d85d30855cedbb786d21ac56cc Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'auth/auth-batch/src/main/java/org/onap')
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/Batch.java4
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/ExpireRange.java6
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/LastNotified.java2
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/Analyze.java4
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/Notify.java3
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/temp/DataMigrateDublin.java2
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/update/Approvals.java6
7 files changed, 17 insertions, 10 deletions
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/Batch.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/Batch.java
index a588b808..d51ec600 100644
--- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/Batch.java
+++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/Batch.java
@@ -91,7 +91,9 @@ public abstract class Batch {
protected final Organization org;
protected String version;
-
+ protected static final Date now = new Date();
+ protected static final Date never = new Date(0);
+
protected Batch(AuthzEnv env) throws APIException, IOException, OrganizationException {
if (batchEnv != null) {
env.info().log("Redirecting to ",batchEnv,"environment");
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/ExpireRange.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/ExpireRange.java
index 13d74c8f..24a65108 100644
--- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/ExpireRange.java
+++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/ExpireRange.java
@@ -40,7 +40,7 @@ public class ExpireRange {
public static final String ONE_WEEK = "OneWeek";
private static final String AAF_BATCH_RANGE = "aaf_batch_range.";
public Map<String,List<Range>> ranges;
- public static final Date now = new Date();
+ private static final Date now = new Date();
private Range delRange;
@@ -182,6 +182,10 @@ public class ExpireRange {
}
return rv;
}
+
+ public Date now() {
+ return now;
+ }
}
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/LastNotified.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/LastNotified.java
index 0539fcdc..6af1cbea 100644
--- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/LastNotified.java
+++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/LastNotified.java
@@ -37,7 +37,7 @@ import com.datastax.driver.core.Session;
public class LastNotified {
private Map<String,Date> lastNotified = new TreeMap<>();
private Session session;
- public static final Date never = new Date(0);
+ private static final Date never = new Date(0);
public LastNotified(Session session) {
this.session = session;
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/Analyze.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/Analyze.java
index 70c950ec..d9e9e11e 100644
--- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/Analyze.java
+++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/Analyze.java
@@ -114,7 +114,7 @@ public class Analyze extends Batch {
writerList = new HashMap<>();
expireRange = new ExpireRange(trans.env().access());
- sdate = Chrono.dateOnlyStamp(ExpireRange.now);
+ sdate = Chrono.dateOnlyStamp(now);
for( List<Range> lr : expireRange.ranges.values()) {
for(Range r : lr ) {
if(writerList.get(r.name())==null) {
@@ -416,7 +416,7 @@ public class Analyze extends Batch {
for (Set<UserRole> sur : owners.values()) {
int goodOwners = 0;
for (UserRole ur : sur) {
- if (ur.expires().after(ExpireRange.now)) {
+ if (ur.expires().after(now)) {
++goodOwners;
}
}
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/Notify.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/Notify.java
index 7cddea2d..f4f3fda5 100644
--- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/Notify.java
+++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/Notify.java
@@ -251,8 +251,7 @@ import org.onap.aaf.misc.env.util.Chrono;
}
});
} catch (IOException | CadiException e) {
- e.printStackTrace();
- // .... but continue with next row
+ trans.error().log(e);
} finally {
tt.done();
}
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/temp/DataMigrateDublin.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/temp/DataMigrateDublin.java
index 4851662b..bcd727ac 100644
--- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/temp/DataMigrateDublin.java
+++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/temp/DataMigrateDublin.java
@@ -163,7 +163,7 @@ public class DataMigrateDublin extends Batch {
trans.info().printf("Processed %d x509 records, updated %d records in %d batches.", count, cbl.total(), cbl.batches());
count = 0;
} catch (Exception e) {
- e.printStackTrace();
+ trans.error().log(e);
}
}
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/update/Approvals.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/update/Approvals.java
index 0df49343..f307ddf1 100644
--- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/update/Approvals.java
+++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/update/Approvals.java
@@ -58,13 +58,15 @@ public class Approvals extends Batch {
private BatchDataView dataview;
private List<CSV> csvList;
private Writer napproveCW;
- private static final GregorianCalendar now = new GregorianCalendar();
- private static final String sdate = Chrono.dateOnlyStamp(now);
+ private final GregorianCalendar now;
+ private final String sdate;
private static final String CSV = ".csv";
private static final String APPROVALS_NEW = "ApprovalsNew";
public Approvals(AuthzTrans trans) throws APIException, IOException, OrganizationException {
super(trans.env());
+ now = new GregorianCalendar();
+ sdate = Chrono.dateOnlyStamp(now);
noAvg = env.newTransNoAvg();
noAvg.setUser(new BatchPrincipal("batch:Approvals"));
session = cluster.connect();