2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6 * ===========================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END====================================================
22 package org.onap.aaf.auth.update;
25 import java.io.IOException;
26 import java.util.List;
28 import org.onap.aaf.auth.Batch;
29 import org.onap.aaf.auth.BatchPrincipal;
30 import org.onap.aaf.auth.actions.CacheTouch;
31 import org.onap.aaf.auth.env.AuthzTrans;
32 import org.onap.aaf.auth.helpers.CQLBatch;
33 import org.onap.aaf.auth.helpers.Cred;
34 import org.onap.aaf.auth.helpers.UserRole;
35 import org.onap.aaf.auth.helpers.X509;
36 import org.onap.aaf.auth.org.OrganizationException;
37 import org.onap.aaf.cadi.CadiException;
38 import org.onap.aaf.cadi.client.Holder;
39 import org.onap.aaf.cadi.util.CSV;
40 import org.onap.aaf.misc.env.APIException;
41 import org.onap.aaf.misc.env.Env;
42 import org.onap.aaf.misc.env.TimeTaken;
43 import org.onap.aaf.misc.env.util.Chrono;
45 public class Remove extends Batch {
46 private final AuthzTrans noAvg;
47 private CacheTouch cacheTouch;
48 private CQLBatch cqlBatch;
50 public Remove(AuthzTrans trans) throws APIException, IOException, OrganizationException {
52 trans.info().log("Starting Connection Process");
54 noAvg = env.newTransNoAvg();
55 noAvg.setUser(new BatchPrincipal("batch:ExpiringP2"));
57 TimeTaken tt0 = trans.start("Cassandra Initialization", Env.SUB);
59 cacheTouch = new CacheTouch(trans, cluster, dryRun);
60 TimeTaken tt2 = trans.start("Connect to Cluster", Env.REMOTE);
62 session = cacheTouch.getSession(trans);
66 cqlBatch = new CQLBatch(session);
75 protected void run(AuthzTrans trans) {
76 final int maxBatch = 50;
78 // Create Intermediate Output
79 File logDir = new File(logDir());
80 File expired = new File(logDir,"Expired"+Chrono.dateOnlyStamp()+".csv");
81 CSV expiredCSV = new CSV(expired);
83 final StringBuilder sb = cqlBatch.begin();
84 final Holder<Integer> hi = new Holder<Integer>(0);
85 expiredCSV.visit(new CSV.Visitor() {
87 public void visit(List<String> row) throws IOException, CadiException {
90 cqlBatch.execute(dryRun);
111 cqlBatch.execute(dryRun);
112 } catch (IOException | CadiException e) {
118 protected void _close(AuthzTrans trans) {
120 cacheTouch.close(trans);