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=dfacd81b5b6872bd9e43c953c07e6fce5a20f2e2;hpb=b974205e2b2617e6d6dd3c6a6576012071cc9937;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 dfacd81b..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. @@ -49,28 +49,28 @@ public class LastNotified { 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()),lastNotifiedVar, (x,y) -> false); query.setLength(0); startQuery(query); - cnt=0; + cnt = 0; } } if(cnt>0) { @@ -81,7 +81,7 @@ public class LastNotified { /** * 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 = 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); @@ -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) {