- final Holder<List<String>> info = new Holder<>(null);
- final Holder<StringBuilder> hsb = new Holder<>(null);
-
- for(File f : extFiles) {
- CSV csv = new CSV(env.access(),f);
- try {
- csv.visit(new CSV.Visitor() {
- final Holder<Integer> hi = new Holder<>(0);
-
- @Override
- public void visit(List<String> row) throws IOException, CadiException {
- GregorianCalendar gc;
- int i = hi.get();
- StringBuilder sb = hsb.get();
- if(sb==null) {
- hsb.set(sb=cqlBatch.begin());
- }
- switch(row.get(0)) {
- case "info":
- info.set(row);
- break;
- case "ur":
- hi.set(++i);
- gc = hgc.get();
- gc.setTime(new Date(Long.parseLong(row.get(5))));
- if(gc.before(now)) {
- gc.setTime(now.getTime());
- }
- gc.add(gcType, extendBy);
- UserRole.batchExtend(sb,row,Chrono.dateTime(gc));
- break;
- case "cred":
- int ctype = Integer.parseInt(row.get(3));
- if(ctype == CredDAO.BASIC_AUTH_SHA256 || ctype == CredDAO.BASIC_AUTH) {
- Result<List<Data>> result = credDAO.readID(noAvg, row.get(1));
- if(result.isOKhasData()) {
- 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))) {
- gc = hgc.get();
- gc.setTime(new Date(Long.parseLong(row.get(5))));
- if(gc.before(now)) {
- gc.setTime(now.getTime());
- }
- gc.add(gcType, extendBy);
- cd.expires = gc.getTime();
- if(dryRun) {
- noAvg.info().printf("Would extend %s, %d - %s to %s",cd.id,cd.type,prev, Chrono.dateOnlyStamp(cd.expires));
- } else {
- Result<Void> r = credDAO.update(noAvg, cd, true);
- noAvg.info().printf("%s %s, %d - %s to %s",
- r.isOK()?"Extended":"Failed to Extend",
- cd.id,cd.type,prev, Chrono.dateOnlyStamp(cd.expires));
- }
- }
- }
- }
- }
- }
- break;
- }
- if(i%maxBatch==0 && sb!=null) {
- cqlBatch.execute(dryRun);
- hi.set(1);
- hsb.set(sb=null);
- }
- }
- });
- } catch (IOException | CadiException e) {
- e.printStackTrace();
- }
- }
-
- // Cleanup, if required.
- cqlBatch.execute(dryRun);
-
- }
-
- @Override
- protected void _close(AuthzTrans trans) {
+ final Holder<List<String>> info = new Holder<>(null);
+ final Holder<StringBuilder> hsb = new Holder<>(null);
+
+ for(File f : extFiles) {
+ CSV csv = new CSV(env.access(),f);
+ try {
+ csv.visit(new CSV.Visitor() {
+ final Holder<Integer> hi = new Holder<>(0);
+
+ @Override
+ public void visit(List<String> row) throws IOException, CadiException {
+ GregorianCalendar gc;
+ int i = hi.get();
+ StringBuilder sb = hsb.get();
+ if(sb==null) {
+ sb=cqlBatch.begin();
+ hsb.set(sb);
+ }
+ switch(row.get(0)) {
+ case "info":
+ info.set(row);
+ break;
+ case "ur":
+ hi.set(++i);
+ gc = hgc.get();
+ gc.setTime(new Date(Long.parseLong(row.get(6))));
+ if(gc.before(now)) {
+ gc.setTime(now.getTime());
+ }
+ gc.add(gcType, extendBy);
+ UserRole.batchExtend(sb,row,gc.getTime());
+ break;
+ case "cred":
+ int ctype = Integer.parseInt(row.get(3));
+ if(ctype == CredDAO.BASIC_AUTH_SHA256 || ctype == CredDAO.BASIC_AUTH) {
+ Result<List<Data>> result = credDAO.readID(noAvg, row.get(1));
+ if(result.isOKhasData()) {
+ for(CredDAO.Data cd : result.value) {
+ if(cd.type == CredDAO.BASIC_AUTH_SHA256 || cd.type == CredDAO.BASIC_AUTH) {
+ String prev;
+ 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)) {
+ gc.setTime(now.getTime());
+ }
+ gc.add(gcType, extendBy);
+ cd.expires = gc.getTime();
+ if(dryRun) {
+ noAvg.info().printf("Would extend %s, %d - %s to %s",cd.id,cd.type,prev, Chrono.dateOnlyStamp(cd.expires));
+ } else {
+ Result<Void> r = credDAO.update(noAvg, cd, true);
+ noAvg.info().printf("%s %s, %d - %s to %s",
+ r.isOK()?"Extended":"Failed to Extend",
+ cd.id,cd.type,prev, Chrono.dateOnlyStamp(cd.expires));
+ }
+ }
+ }
+ }
+ }
+ }
+ break;
+ }
+ if(i%maxBatch==0 && sb!=null) {
+ cqlBatch.execute(dryRun);
+ hi.set(1);
+ sb=null;
+ hsb.set(sb);
+ }
+ }
+ });
+ } catch (IOException | CadiException e) {
+ e.printStackTrace();
+ }
+ }
+
+ // Cleanup, if required.
+ cqlBatch.execute(dryRun);
+
+ }
+
+ @Override
+ protected void _close(AuthzTrans trans) {