Sonar Fixes: Auth Batch Helpers
[aaf/authz.git] / auth / auth-batch / src / main / java / org / onap / aaf / auth / batch / helpers / ExpireRange.java
index c7d4e7d..6a5dbad 100644 (file)
@@ -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.
@@ -23,6 +23,7 @@
 package org.onap.aaf.auth.batch.helpers;
 
 import java.util.ArrayList;
+import java.util.Calendar;
 import java.util.Date;
 import java.util.GregorianCalendar;
 import java.util.HashMap;
@@ -47,48 +48,44 @@ public class ExpireRange {
     public final Range approveDelete ;
 
     private Range delRange;
-    
+
     public ExpireRange(final Access access) {
         ranges = new HashMap<>();
         intervalDates = new HashMap<>();
         int i=0;
-        approveDelete = new Range(DELETE,0,0,0,-1,0,GregorianCalendar.DAY_OF_YEAR,-100);
+        approveDelete = new Range(DELETE,0,0,0,-1,0, Calendar.DAY_OF_YEAR,-100);
         String prop = access.getProperty(AAF_BATCH_RANGE + i,null);
         if(prop==null && i==0) {
                 List<Range> lcred = getRangeList("cred");
                 List<Range> lur = getRangeList("ur");
                 List<Range> lx509 = getRangeList("x509");
-    
-                
+
+
                 /*
                    Range(Name, ReportingLevel, PeopleInterval, AppInterval, Start(Type,Qty) End(Type,Qty) )
                    Interval of -1 Means "only once"
                    Interval of 0 means none
                    Interval > 0 means only X number of Days.
                 */
-                delRange = new Range(DELETE,0,0,0,-1,0,GregorianCalendar.WEEK_OF_MONTH,-2);
+                delRange = new Range(DELETE,0,0,0,-1,0,Calendar.WEEK_OF_MONTH,-2);
                 lur.add(delRange);
                 lcred.add(delRange);
                 lx509.add(delRange);
-                
-                lcred.add(new Range(ONE_WEEK ,3,-1,1,0,0,GregorianCalendar.WEEK_OF_MONTH,1));
-                lcred.add(new Range(TWO_WEEK ,2,-1,-1,GregorianCalendar.WEEK_OF_MONTH,1,GregorianCalendar.WEEK_OF_MONTH,2));
-                lcred.add(new Range(ONE_MONTH,1,7,7,GregorianCalendar.WEEK_OF_MONTH,2,GregorianCalendar.MONTH,1));
-                lcred.add(new Range(TWO_MONTH,1,-1,-1,GregorianCalendar.MONTH,1,GregorianCalendar.MONTH,2));
-                
-                lur.add(  new Range(ONE_MONTH,1,-1,-1,0,0,GregorianCalendar.MONTH,1));
-                // Comment out until we can get some more clear actions in place for GUI
-                // lur.add(  new Range(ONE_MONTH,1,-1,-1,GregorianCalendar.WEEK_OF_MONTH,2,GregorianCalendar.MONTH,1));
-                // lur.add(  new Range(ONE_WEEK,2,-1,1,0,0,GregorianCalendar.WEEK_OF_MONTH,1));
-                
-                lx509.add(new Range(ONE_MONTH,1,-1,-1,GregorianCalendar.WEEK_OF_MONTH,2,GregorianCalendar.MONTH,1));
+
+                lcred.add(new Range(ONE_WEEK ,3,-1,1,0,0,Calendar.WEEK_OF_MONTH,1));
+                lcred.add(new Range(TWO_WEEK ,2,-1,-1,Calendar.WEEK_OF_MONTH,1,Calendar.WEEK_OF_MONTH,2));
+                lcred.add(new Range(ONE_MONTH,1,7,7,Calendar.WEEK_OF_MONTH,2,Calendar.MONTH,1));
+                lcred.add(new Range(TWO_MONTH,1,-1,-1,Calendar.MONTH,1,Calendar.MONTH,2));
+
+                lur.add(  new Range(ONE_MONTH,1,-1,-1,0,0,Calendar.MONTH,1));
+                lx509.add(new Range(ONE_MONTH,1,-1,-1,Calendar.WEEK_OF_MONTH,2,Calendar.MONTH,1));
             }
     }
-    
+
     public Range newFutureRange() {
-        return new Range("Approval",7,7,1,0,0,GregorianCalendar.MONTH,1);
+        return new Range("Approval",7,7,1,0,0,Calendar.MONTH,1);
     }
-    
+
     public Set<String> names() {
         Set<String> names = new HashSet<>();
         for(List<Range> lr : ranges.values()) {
@@ -99,7 +96,7 @@ public class ExpireRange {
 
         return names;
     }
-    
+
     private synchronized List<Range> getRangeList(final String key) {
         List<Range> rv = ranges.get(key);
         if(rv==null) {
@@ -107,8 +104,10 @@ public class ExpireRange {
             ranges.put(key, rv);
         }
         return rv;
+
+
     }
-    
+
     public class Range {
         private final String name;
         private final int reportingLevel;
@@ -117,36 +116,36 @@ public class ExpireRange {
         private final Date start;
         private final Date end;
         private final Date lowerValid;
-        
+
         public Range(
-                final String name, final int reportingLevel, 
-                final int peopleInterval, final int appInterval,  
-                final int startGCType, final int startQty,  
+                final String name, final int reportingLevel,
+                final int peopleInterval, final int appInterval,
+                final int startGCType, final int startQty,
                 final int endGCType,final int endQty) {
             this.name = name;
             this.reportingLevel = reportingLevel;
             this.peopleInterval = peopleInterval;
             this.appInterval = appInterval;
-            GregorianCalendar gc = new GregorianCalendar();
+            Calendar gc = new GregorianCalendar();
             if(startGCType<0) {
-                gc.set(GregorianCalendar.YEAR, 1);
+                gc.set(Calendar.YEAR, 1);
             } else {
                 gc.setTime(now);
                 gc.add(startGCType, startQty);
             }
             start = gc.getTime();
-            
+
             if(endGCType<0) {
-                gc.set(GregorianCalendar.YEAR, 1);
+                gc.set(Calendar.YEAR, 1);
             } else {
                 gc.setTime(now);
                 gc.add(endGCType, endQty);
             }
             end = gc.getTime();
-            
+
 
             if(endGCType<0) {
-                gc.set(GregorianCalendar.YEAR, -1);
+                gc.set(Calendar.YEAR, -1);
             } else {
                 gc.setTime(now);
                 gc.add(endGCType, endQty * -1);
@@ -154,11 +153,11 @@ public class ExpireRange {
             lowerValid = gc.getTime();
 
         }
-        
+
         public String name() {
             return name;
         }
-        
+
         public int reportingLevel() {
             return reportingLevel;
         }
@@ -179,7 +178,7 @@ public class ExpireRange {
                 if(rv==null) {
                     GregorianCalendar gc = new GregorianCalendar();
                     gc.setTime(now);
-                    gc.add(GregorianCalendar.DAY_OF_YEAR, -1*interval);
+                    gc.add(Calendar.DAY_OF_YEAR, -1*interval);
                     rv = gc.getTime();
                     intervalDates.put(interval, rv);
                 }
@@ -190,11 +189,11 @@ public class ExpireRange {
         public Date getStart() {
             return start;
         }
-        
+
         public Date getEnd() {
             return end;
         }
-        
+
         public boolean inRange(final Date date) {
             if(date==null) {
                 return false;
@@ -226,6 +225,6 @@ public class ExpireRange {
     public Date now() {
         return now;
     }
-    
+
 
 }