From 7136e9a83d131d0618c2a340d80079dcf8ae3c3b Mon Sep 17 00:00:00 2001 From: Driptaroop Das Date: Thu, 24 Jan 2019 16:45:41 +0530 Subject: update anonymous inner classes with lambdas update anonymous inner classes of some files with lambdas Issue-ID: AAF-731 Change-Id: Ifc37d1aef4017943a5d33ee7c89ca919df474436 Signed-off-by: Driptaroop Das --- .../auth/batch/actions/URFutureApproveExec.java | 14 +++-------- .../org/onap/aaf/auth/batch/reports/Expiring.java | 17 ++++++-------- .../org/onap/aaf/auth/batch/reports/NotInOrg.java | 15 +++++------- .../aaf/auth/batch/reports/NsRoleUserReport.java | 27 ++++++++++------------ .../main/java/org/onap/aaf/auth/cm/ca/JscepCA.java | 7 ++---- .../src/main/java/org/onap/aaf/auth/cmd/Cmd.java | 7 +----- 6 files changed, 31 insertions(+), 56 deletions(-) diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/actions/URFutureApproveExec.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/actions/URFutureApproveExec.java index 631a8115..6636f458 100644 --- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/actions/URFutureApproveExec.java +++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/actions/URFutureApproveExec.java @@ -66,15 +66,8 @@ public class URFutureApproveExec extends ActionDAO, OP_STATUS, Fu } } Result rv = f.performFutureOp(trans, FUTURE_OP.A, future.fdd, - new Lookup>() { - @Override - public List get(AuthzTrans trans, Object ... noop) { - return apprs; - } - }, - new Lookup() { - @Override - public UserRoleDAO.Data get(AuthzTrans trans, Object ... keys) { + (trans1, noop) -> apprs, + (trans12, keys) -> { List lur = UserRole.getByUser().get(keys[0]); if (lur!=null) { for (UserRole ur : lur) { @@ -84,8 +77,7 @@ public class URFutureApproveExec extends ActionDAO, OP_STATUS, Fu } } return null; - } - }); + }); if (rv.isOK()) { switch(rv.value) { case D: diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/Expiring.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/Expiring.java index e171d174..11eacd4e 100644 --- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/Expiring.java +++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/Expiring.java @@ -193,18 +193,15 @@ public class Expiring extends Batch { } trans.info().log("Checking for Expired X509s"); - X509.load(trans, session, new Visitor() { - @Override - public void visit(X509 x509) { - try { - for(Certificate cert : Factory.toX509Certificate(x509.x509)) { - writeAnalysis(trans, x509, (X509Certificate)cert); - } - } catch (CertificateException | IOException e) { - trans.error().log(e, "Error Decrypting X509"); + X509.load(trans, session, x509 -> { + try { + for(Certificate cert : Factory.toX509Certificate(x509.x509)) { + writeAnalysis(trans, x509, (X509Certificate)cert); } - + } catch (CertificateException | IOException e) { + trans.error().log(e, "Error Decrypting X509"); } + }); } catch (FileNotFoundException e) { trans.info().log(e); diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/NotInOrg.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/NotInOrg.java index fe754c10..ab8b6e8b 100644 --- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/NotInOrg.java +++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/NotInOrg.java @@ -105,16 +105,13 @@ public class NotInOrg extends Batch { trans.info().log("User Roles"); final AuthzTrans transNoAvg = trans.env().newTransNoAvg(); - UserRole.load(trans, session, UserRole.v2_0_11, new Visitor() { - @Override - public void visit(UserRole ur) { - try { - if(!check(transNoAvg, checked, ur.user())) { - ur.row(whichWriter(transNoAvg,ur.user())); - } - } catch (OrganizationException e) { - trans.error().log(e, "Error Decrypting X509"); + UserRole.load(trans, session, UserRole.v2_0_11, ur -> { + try { + if(!check(transNoAvg, checked, ur.user())) { + ur.row(whichWriter(transNoAvg,ur.user())); } + } catch (OrganizationException e) { + trans.error().log(e, "Error Decrypting X509"); } }); diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/NsRoleUserReport.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/NsRoleUserReport.java index 8281e747..1a7d7740 100644 --- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/NsRoleUserReport.java +++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/NsRoleUserReport.java @@ -86,24 +86,21 @@ public class NsRoleUserReport extends Batch { trans.info().log("Create Report on Roles by NS"); final AuthzTrans transNoAvg = trans.env().newTransNoAvg(); - UserRole.load(transNoAvg, session, UserRole.v2_0_11, new Visitor() { - @Override - public void visit(UserRole ur) { - if(ur.expires().after(now)) { - Map roleCount = theMap.get(ur.ns()); - Integer count; - if(roleCount==null) { - roleCount = new TreeMap<>(); - theMap.put(ur.ns(),roleCount); + UserRole.load(transNoAvg, session, UserRole.v2_0_11, ur -> { + if(ur.expires().after(now)) { + Map roleCount = theMap.get(ur.ns()); + Integer count; + if(roleCount==null) { + roleCount = new TreeMap<>(); + theMap.put(ur.ns(),roleCount); + count = 0; + } else { + count = roleCount.get(ur.rname()); + if(count == null) { count = 0; - } else { - count = roleCount.get(ur.rname()); - if(count == null) { - count = 0; - } } - roleCount.put(ur.rname(), count+1); } + roleCount.put(ur.rname(), count+1); } }); diff --git a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/ca/JscepCA.java b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/ca/JscepCA.java index 4caa3390..b7dd069d 100644 --- a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/ca/JscepCA.java +++ b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/ca/JscepCA.java @@ -225,14 +225,11 @@ public class JscepCA extends CA { protected Client _newClient(String urlinfo) throws LocatorException { try { String[] info = Split.split('/', urlinfo); - Client c = new Client(new URL(JscepCA.CA_PREFIX + info[0] + JscepCA.CA_POSTFIX), - new CertificateVerifier() { - @Override - public boolean verify(X509Certificate cert) { + Client c = new Client(new URL(JscepCA.CA_PREFIX + info[0] + JscepCA.CA_POSTFIX), + cert -> { //TODO checkIssuer return true; } - } ); // Map URL to Client, because Client doesn't expose Connection mxcwiC.put(c, mxcwiS.get(urlinfo)); diff --git a/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/Cmd.java b/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/Cmd.java index 0597640f..49fd4869 100644 --- a/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/Cmd.java +++ b/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/Cmd.java @@ -358,12 +358,7 @@ public abstract class Cmd { // Save Server time by Sorting locally List items = history.getItem(); - java.util.Collections.sort(items, new Comparator() { - @Override - public int compare(Item o1, Item o2) { - return o2.getTimestamp().compare(o1.getTimestamp()); - } - }); + java.util.Collections.sort(items, (Comparator) (o1, o2) -> o2.getTimestamp().compare(o1.getTimestamp())); for (History.Item item : items) { GregorianCalendar gc = item.getTimestamp().toGregorianCalendar(); -- cgit 1.2.3-korg