diff options
author | Instrumental <jonathan.gathman@att.com> | 2019-03-16 14:20:37 -0500 |
---|---|---|
committer | Instrumental <jonathan.gathman@att.com> | 2019-03-16 14:42:22 -0500 |
commit | 57effd69fb15e0c73f85296d10ff6b358a6cbebb (patch) | |
tree | 06c2c1fc116e6909615d75966467b891ef56f491 /auth/auth-batch/src | |
parent | 502da3cb1daf171395630dbaf4a2f2e2fb9aa93e (diff) |
Changes from Batch Test
Issue-ID: AAF-789
Change-Id: Id07cb5dbc29c52b85de09471510a5c44c8b368b8
Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'auth/auth-batch/src')
6 files changed, 51 insertions, 47 deletions
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/approvalsets/ApprovalSet.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/approvalsets/ApprovalSet.java index 500906d0..005397b2 100644 --- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/approvalsets/ApprovalSet.java +++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/approvalsets/ApprovalSet.java @@ -76,20 +76,25 @@ public class ApprovalSet { public Result<Void> write(AuthzTrans trans) { StringBuilder errs = null; - Result<FutureDAO.Data> rf = dataview.insert(trans, fdd); - if(rf.notOK()) { - errs = new StringBuilder(); - errs.append(rf.errorString()); + if(ladd == null || ladd.isEmpty()) { + errs = new StringBuilder("No Approvers for "); + errs .append(fdd.memo); } else { - for(ApprovalDAO.Data add : ladd) { - Result<ApprovalDAO.Data> af = dataview.insert(trans, add); - if(af.notOK()) { - if(errs==null) { - errs = new StringBuilder(); - } else { - errs.append('\n'); + Result<FutureDAO.Data> rf = dataview.insert(trans, fdd); + if(rf.notOK()) { + errs = new StringBuilder(); + errs.append(rf.errorString()); + } else { + for(ApprovalDAO.Data add : ladd) { + Result<ApprovalDAO.Data> af = dataview.insert(trans, add); + if(af.notOK()) { + if(errs==null) { + errs = new StringBuilder(); + } else { + errs.append('\n'); + } + errs.append(af.errorString()); } - errs.append(af.errorString()); } } } 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 d9e9e11e..d0b30c7c 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 @@ -77,7 +77,7 @@ public class Analyze extends Batch { private static final int approved=2; - private static final String APPROVALS = "Approvals"; + public static final String NEED_APPROVALS = "NeedApprovals"; private static final String EXTEND = "Extend"; private static final String EXPIRED_OWNERS = "ExpiredOwners"; private static final String CSV = ".csv"; @@ -87,7 +87,7 @@ public class Analyze extends Batch { private ExpireRange expireRange; private Date deleteDate; private CSV.Writer deleteCW; - private CSV.Writer approveCW; + private CSV.Writer needApproveCW; private CSV.Writer extendCW; private Range futureRange; private final String sdate; @@ -134,11 +134,11 @@ public class Analyze extends Batch { // Setup New Approvals file futureRange = ExpireRange.newFutureRange(); - File file = new File(logDir(),APPROVALS + sdate +CSV); + File file = new File(logDir(),NEED_APPROVALS + sdate +CSV); CSV approveCSV = new CSV(env.access(),file); - approveCW = approveCSV.writer(); - approveCW.row(INFO,APPROVALS,sdate,1); - writerList.put(APPROVALS,approveCW); + needApproveCW = approveCSV.writer(); + needApproveCW.row(INFO,NEED_APPROVALS,sdate,1); + writerList.put(NEED_APPROVALS,needApproveCW); // Setup Extend Approvals file file = new File(logDir(),EXTEND + sdate +CSV); @@ -318,7 +318,7 @@ public class Analyze extends Batch { if(p.newApprovals() || p.earliest() == null || p.earliest().after(remind)) { - p.row(approveCW,es.getKey()); + p.row(needApproveCW,es.getKey()); } } } finally { @@ -384,7 +384,7 @@ public class Analyze extends Batch { if(r!=null) { Approval existing = findApproval(ur); if(existing==null) { - ur.row(approveCW,UserRole.APPROVE_UR); + ur.row(needApproveCW,UserRole.APPROVE_UR); } } } @@ -427,14 +427,14 @@ public class Analyze extends Batch { if(r!=null) { Approval existing = findApproval(ur); if(existing==null) { - ur.row(approveCW,UserRole.APPROVE_UR); + ur.row(needApproveCW,UserRole.APPROVE_UR); } } } else { expOwner.row("owner",ur.role(), ur.user(), Chrono.dateOnlyStamp(ur.expires())); Approval existing = findApproval(ur); if(existing==null) { - ur.row(approveCW,UserRole.APPROVE_UR); + ur.row(needApproveCW,UserRole.APPROVE_UR); } } } 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 f4f3fda5..5a0b70a1 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 @@ -209,7 +209,8 @@ import org.onap.aaf.misc.env.util.Chrono; // now create Notification for(NotifyBody nb : NotifyBody.getAll()) { - notify(noAvg, nb); + int count = notify(noAvg, nb); + trans.info().printf("Emailed %d for %s",count,nb.name()); } // @@ -294,16 +295,15 @@ import org.onap.aaf.misc.env.util.Chrono; // Update cbl.preLoop(); lastN.update(cbl.inc(),es.getKey(),"pending",""); + npab.inc(); } } } } finally { cbl.flush(); tt.done(); + trans.info().printf("Notified %d persons of Pending Approvals", npab.count()); } - trans.info().printf("Created %d Notifications", count.get()); - - } catch (APIException | IOException e1) { trans.error().log(e1); @@ -314,17 +314,15 @@ import org.onap.aaf.misc.env.util.Chrono; } } - public int notify(AuthzTrans trans, NotifyBody nb) { + private int notify(AuthzTrans trans, NotifyBody nb) { List<String> toList = new ArrayList<>(); List<String> ccList = new ArrayList<>(); String run = nb.type()+nb.name(); String test = dryRun?run:null; - String last = null; ONE_EMAIL: for(String id : nb.users()) { - last = id; toList.clear(); ccList.clear(); try { @@ -380,11 +378,6 @@ import org.onap.aaf.misc.env.util.Chrono; trans.error().log(e); } } - if(nb.count()<=1) { - trans.info().printf("Notified %s for %s",last,run); - } else { - trans.info().printf("Emailed %d for %s",nb.count(),run); - } return nb.count(); } diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/bodies/NotifyBody.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/bodies/NotifyBody.java index bf20eb41..82c1f2cc 100644 --- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/bodies/NotifyBody.java +++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/bodies/NotifyBody.java @@ -39,7 +39,6 @@ import java.util.TreeMap; import org.onap.aaf.auth.batch.reports.Notify; import org.onap.aaf.auth.env.AuthzTrans; import org.onap.aaf.cadi.Access; -import org.onap.aaf.cadi.config.Config; import org.onap.aaf.misc.env.APIException; public abstract class NotifyBody { @@ -47,9 +46,11 @@ public abstract class NotifyBody { private static final Map<String,NotifyBody> bodyMap = new HashMap<>(); protected Map<String,List<List<String>>> rows; + protected final String env; + protected final String gui_url; + private final String name; private final String type; - protected final String env; private String date; private int escalation; private int count; @@ -61,7 +62,8 @@ public abstract class NotifyBody { date=""; escalation = 1; count = 0; - env = access.getProperty(Config.AAF_ENV,"DEVL"); + env = access.getProperty("CASS_ENV","DEVL"); + gui_url = access.getProperty("GUI_URL", ""); } public void store(List<String> row) { diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/bodies/NotifyURBody.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/bodies/NotifyURBody.java index 5e051e00..6f85d1bf 100644 --- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/bodies/NotifyURBody.java +++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/bodies/NotifyURBody.java @@ -38,9 +38,10 @@ public abstract class NotifyURBody extends NotifyBody { super(access,"ur",name); // Default - explanation = "The Roles for the IDs listed will expire on the dates shown. If " - + "allowed to expire, the ID will no longer authorized in that role.<br><br>" - + "If the ID is for a current <b><i>Application</i></b>, this <b><i>WILL</i></b> cause an outage."; + explanation = "The Roles for the IDs associated with you will expire on the dates shown. If " + + "allowed to expire, the ID will no longer authorized in that role on that date.<br><br>" + + "It is the responsibility of the Designated Approvers to approve, but you can monitor " + + "their progress by clicking the ID Link."; } @Override @@ -83,8 +84,10 @@ public abstract class NotifyURBody extends NotifyBody { println(sb,indent,"<tr>"); indent+=2; name = printCell(sb,indent,fullname,name); - fqi = printCell(sb,indent,row.get(1),fqi); - printCell(sb,indent,row.get(2)+'.'+row.get(3)); + String rid = row.get(1); + String fqiCell = "<a href=\"" + gui_url + "/myrequests\">" + rid + "</a>"; + fqi = printCell(sb,indent,fqiCell,fqi); + printCell(sb,indent,row.get(2)); Date expires = new Date(Long.parseLong(row.get(6))); printCell(sb,indent,Chrono.niceUTCStamp(expires)); indent-=2; 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 f307ddf1..57def168 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 @@ -40,6 +40,7 @@ import org.onap.aaf.auth.batch.helpers.BatchDataView; import org.onap.aaf.auth.batch.helpers.NS; import org.onap.aaf.auth.batch.helpers.Role; import org.onap.aaf.auth.batch.helpers.UserRole; +import org.onap.aaf.auth.batch.reports.Analyze; import org.onap.aaf.auth.dao.cass.UserRoleDAO; import org.onap.aaf.auth.env.AuthzTrans; import org.onap.aaf.auth.layer.Result; @@ -87,7 +88,7 @@ public class Approvals extends Batch { } } } else { - f = new File(logDir(), "Approvals"+Chrono.dateOnlyStamp()+".csv"); + f = new File(logDir(), Analyze.NEED_APPROVALS+Chrono.dateOnlyStamp()+".csv"); if(f.exists()) { csvList.add(new CSV(env.access(),f).processAll()); } else { @@ -109,10 +110,10 @@ public class Approvals extends Batch { Pending p = Pending.create(); Holder<Integer> count = new Holder<>(0); - for(CSV approveCSV : csvList) { - TimeTaken tt = trans.start("Processing %s's UserRoles",Trans.SUB,approveCSV.name()); + for(CSV neeedApproveCSV : csvList) { + TimeTaken tt = trans.start("Processing %s's UserRoles",Trans.SUB,neeedApproveCSV.name()); try { - approveCSV.visit(row -> { + neeedApproveCSV.visit(row -> { switch(row.get(0)) { case UserRole.APPROVE_UR: UserRoleDAO.Data urdd = UserRole.row(row); @@ -151,7 +152,7 @@ public class Approvals extends Batch { } trans.info().printf("Processed %d UserRoles", count.get()); - tt = trans.start("Processing %s's UserRoles",Trans.SUB,approveCSV.name()); + tt = trans.start("Writing Approvals to %s",Trans.SUB,neeedApproveCSV.name()); int cnt = 0; try { for(Entry<String, Pending> es : mpending.entrySet()) { |