X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=auth%2Fauth-batch%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fauth%2Fbatch%2Fhelpers%2FLastNotified.java;h=67203af20d89c4ee071960e13269201597a5325d;hb=1296352d8eafee57f982a4342ad79ada4aa56d28;hp=6f228e08c70b2831696da1d930156ffec743f352;hpb=4af23fd5fcffdc01089180e3839d0fd2cc9e3122;p=aaf%2Fauthz.git 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 6f228e08..67203af2 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 @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -45,43 +45,43 @@ import com.datastax.driver.core.SimpleStatement; import com.datastax.driver.core.Statement; public class LastNotified { - private Map lastNotified = new TreeMap<>(); + private Map lastNotifiedVar = new TreeMap<>(); private Session session; public static final Date NEVER = new Date(0); private static final String SELECT = "SELECT user,target,key,last FROM authz.notified"; - + public LastNotified(Session session) { this.session = session; } - + public void add(Set users) { StringBuilder query = new StringBuilder(); startQuery(query); int cnt = 0; for(String user : users) { - if(++cnt>1) { + if(++cnt > 1) { query.append(','); } query.append('\''); query.append(user); query.append('\''); - if(cnt>=30) { + if(cnt >= 30) { endQuery(query); - add(session.execute(query.toString()),lastNotified, (x,y) -> false); + add(session.execute(query.toString()),lastNotifiedVar, (x,y) -> false); query.setLength(0); startQuery(query); - cnt=0; + cnt = 0; } } if(cnt>0) { endQuery(query); - add(session.execute(query.toString()),lastNotified, (x,y) -> false); + add(session.execute(query.toString()),lastNotifiedVar, (x,y) -> false); } } /** * Note: target_key CAN also contain a Pipe. - * + * * @param user * @param target * @param targetkey @@ -91,12 +91,12 @@ public class LastNotified { String key = user + '|' + target + '|' + (targetkey==null?"":targetkey); return lastNotified(key); } - + public Date lastNotified(String key) { - Date d = lastNotified.get(key); + Date d = lastNotifiedVar.get(key); return d==null?NEVER:d; } - + private Date add(ResultSet result, Map lastNotified, MarkDelete md) { Date last = null; Row r; @@ -104,7 +104,7 @@ public class LastNotified { r = iter.next(); String ttKey = r.getString(1) + '|' + r.getString(2); - + String fullKey = r.getString(0) + '|' + ttKey; last=r.getTimestamp(3); @@ -118,7 +118,7 @@ public class LastNotified { } return last; } - + @FunctionalInterface private interface MarkDelete { boolean process(String fullKey, Date last); @@ -150,7 +150,7 @@ public class LastNotified { try { Statement stmt = new SimpleStatement( SELECT ); results = session.execute(stmt); - add(results,lastNotified, (fullKey, last) -> { + add(results,lastNotifiedVar, (fullKey, last) -> { if(delRange.inRange(last)) { String[] params = Split.splitTrim('|', fullKey,3); if(params.length==3) { @@ -167,7 +167,7 @@ public class LastNotified { } public static String newKey(UserRole ur) { - return "ur|" + ur.user() + '|'+ur.role(); + return "ur|" + ur.user() + '|' + ur.role(); } public static String newKey(Cred cred, Instance inst) {