X-Git-Url: https://gerrit.onap.org/r/gitweb?p=aaf%2Fauthz.git;a=blobdiff_plain;f=auth%2Fauth-batch%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fauth%2Fbatch%2Fupdate%2FRemove.java;h=e41b61ccb4d853ab7ec44df026a16b8ea1c872e5;hp=89fbfacc1be681d96a3bae05756b751948e68d0d;hb=deb396a3d53a84b2eb5a46d40122b4902d72c601;hpb=3d1706fcbe7f95830ff6fd23cf679ee55c6d0595 diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/update/Remove.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/update/Remove.java index 89fbfacc..e41b61cc 100644 --- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/update/Remove.java +++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/update/Remove.java @@ -7,9 +7,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. @@ -47,7 +47,7 @@ import org.onap.aaf.auth.dao.cass.UserRoleDAO; import org.onap.aaf.auth.env.AuthzTrans; 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; @@ -76,9 +76,7 @@ public class Remove extends Batch { } finally { tt2.done(); } - cqlBatch = new CQLBatch(noAvg.info(),session); - - + cqlBatch = new CQLBatch(noAvg.info(),session); } finally { tt0.done(); } @@ -87,7 +85,7 @@ public class Remove extends Batch { @Override protected void run(AuthzTrans trans) { - // Create Intermediate Output + // Create Intermediate Output File logDir = logDir(); List remove = new ArrayList<>(); @@ -96,7 +94,14 @@ public class Remove extends Batch { remove.add(new File(logDir, args()[i])); } } else { - remove.add(new File(logDir,"Delete"+Chrono.dateOnlyStamp()+".csv")); + final String ending = Chrono.dateOnlyStamp()+".csv"; + for (File file : logDir.listFiles(f -> { + String name = f.getName(); + return name.endsWith(ending) && ( + name.startsWith("Delete") || name.startsWith("Clean.")); + })) { + remove.add(file); + }; } for(File f : remove) { @@ -106,7 +111,7 @@ public class Remove extends Batch { final Holder ur = new Holder<>(false); final Holder cred = new Holder<>(false); final Holder x509 = new Holder<>(false); - final Holder memoFmt = new Holder(""); + final Holder memoFmt = new Holder<>(""); final HistoryDAO.Data hdd = new HistoryDAO.Data(); final String orgName = trans.org().getName(); @@ -116,7 +121,7 @@ public class Remove extends Batch { SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM"); hdd.yr_mon = Integer.parseInt(sdf.format(new Date())); - try { + try { final CQLBatchLoop cbl = new CQLBatchLoop(cqlBatch,50,dryRun); for(File f : remove) { trans.info().log("Processing ",f.getAbsolutePath(),"for Deletions"); @@ -140,9 +145,9 @@ public class Remove extends Batch { ur.set(true); } //TODO If deleted because Role is no longer there, double check... - + UserRole.batchDelete(cbl.inc(),row); - hdd.target=UserRoleDAO.TABLE; + hdd.target=UserRoleDAO.TABLE; hdd.subject=UserRole.histSubject(row); hdd.memo=UserRole.histMemo(memoFmt.get(), row); historyDAO.createBatch(cbl.inc(), hdd); @@ -152,7 +157,7 @@ public class Remove extends Batch { cred.set(true); } Cred.batchDelete(cbl.inc(),row); - hdd.target=CredDAO.TABLE; + hdd.target=CredDAO.TABLE; hdd.subject=Cred.histSubject(row); hdd.memo=Cred.histMemo(memoFmt.get(), orgName,row); historyDAO.createBatch(cbl.inc(), hdd); @@ -162,7 +167,7 @@ public class Remove extends Batch { x509.set(true); } X509.batchDelete(cbl.inc(),row); - hdd.target="x509"; + hdd.target="x509"; hdd.subject=X509.histSubject(row); hdd.memo=X509.histMemo(memoFmt.get(),row); historyDAO.createBatch(cbl.inc(), hdd);