X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=auth%2Fauth-batch%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fauth%2Fbatch%2Fupdate%2FExtend.java;h=bb09c6c772396335203fa6af8a04a15eced14e3f;hb=deb396a3d53a84b2eb5a46d40122b4902d72c601;hp=98a01d763f9254779c04fc95f7c485eaa51201fe;hpb=3d1706fcbe7f95830ff6fd23cf679ee55c6d0595;p=aaf%2Fauthz.git diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/update/Extend.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/update/Extend.java index 98a01d76..bb09c6c7 100644 --- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/update/Extend.java +++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/update/Extend.java @@ -3,13 +3,14 @@ * org.onap.aaf * =========================================================================== * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 IBM. * =========================================================================== * 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. @@ -41,7 +42,7 @@ import org.onap.aaf.auth.env.AuthzTrans; import org.onap.aaf.auth.layer.Result; import org.onap.aaf.auth.org.OrganizationException; import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.client.Holder; +import org.onap.aaf.cadi.util.Holder; import org.onap.aaf.cadi.util.CSV; import org.onap.aaf.misc.env.APIException; import org.onap.aaf.misc.env.Env; @@ -55,11 +56,11 @@ public class Extend extends Batch { private List extFiles; private final int extendBy; private int gcType; - + public Extend(AuthzTrans trans) throws APIException, IOException, OrganizationException { super(trans.env()); trans.info().log("Starting Connection Process"); - + noAvg = env.newTransNoAvg(); noAvg.setUser(new BatchPrincipal("Extend")); @@ -72,14 +73,14 @@ public class Extend extends Batch { } finally { tt.done(); } - cqlBatch = new CQLBatch(noAvg.info(),session); + cqlBatch = new CQLBatch(noAvg.info(),session); } finally { tt0.done(); } gcType = GregorianCalendar.WEEK_OF_YEAR; int weeks = 4; - + Set cmd = new HashSet<>(); for(int i=0; i< args().length;++i) { if("-weeks".equals(args()[i])) { @@ -90,13 +91,13 @@ public class Extend extends Batch { cmd.add(args()[i]); } } - + if(weeks<1 || weeks > 24) { throw new APIException("Invalid --weeks"); } extendBy = weeks; - // Create Intermediate Output + // Create Intermediate Output File logDir = logDir(); extFiles = new ArrayList<>(); if(cmd.isEmpty()) { @@ -106,7 +107,7 @@ public class Extend extends Batch { extFiles.add(new File(logDir, fn)); } } - + // Load Cred. We don't follow Visitor, because we have to gather up everything into Identity Anyway // to find the last one. } @@ -129,7 +130,7 @@ public class Extend extends Batch { CSV csv = new CSV(env.access(),f); try { csv.visit(new CSV.Visitor() { - final Holder hi = new Holder<>(0); + final Holder hi = new Holder<>(0); @Override public void visit(List row) throws IOException, CadiException { @@ -137,7 +138,8 @@ public class Extend extends Batch { int i = hi.get(); StringBuilder sb = hsb.get(); if(sb==null) { - hsb.set(sb=cqlBatch.begin()); + sb=cqlBatch.begin(); + hsb.set(sb); } switch(row.get(0)) { case "info": @@ -161,7 +163,8 @@ public class Extend extends Batch { for(CredDAO.Data cd : result.value) { if(cd.type == CredDAO.BASIC_AUTH_SHA256 || cd.type == CredDAO.BASIC_AUTH) { String prev; - if(row.get(4).equals(prev=Chrono.dateOnlyStamp(cd.expires))) { + prev=Chrono.dateOnlyStamp(cd.expires); + if(row.get(4).equals(prev)){ gc = hgc.get(); gc.setTime(new Date(Long.parseLong(row.get(5)))); if(gc.before(now)) { @@ -187,7 +190,8 @@ public class Extend extends Batch { if(i%maxBatch==0 && sb!=null) { cqlBatch.execute(dryRun); hi.set(1); - hsb.set(sb=null); + sb=null; + hsb.set(sb); } } }); @@ -195,12 +199,12 @@ public class Extend extends Batch { e.printStackTrace(); } } - + // Cleanup, if required. cqlBatch.execute(dryRun); } - + @Override protected void _close(AuthzTrans trans) { trans.info().log("End " + this.getClass().getSimpleName() + " processing" );