Sonar Fixes, Formatting
[aaf/authz.git] / auth / auth-cmd / src / main / java / org / onap / aaf / auth / cmd / user / List.java
index 3074ab8..b301136 100644 (file)
@@ -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.
@@ -45,30 +45,34 @@ public class List extends BaseCmd<User> {
         cmds.add(new ListActivity(this));
     }
 
-     
+
     void report(Users users, boolean count, String ... str) {
         reportHead(str);
-        int idx = 0;
         java.util.List<aaf.v2_0.Users.User> sorted = users.getUser();
-        Collections.sort(sorted, new Comparator<aaf.v2_0.Users.User>() {
-            @Override
-            public int compare(aaf.v2_0.Users.User u1, aaf.v2_0.Users.User u2) {
-                if (u1==null || u2 == null) {
-                    return -1;
-                }
-                return u1.getId().compareTo(u2.getId());
+        Collections.sort(sorted, (Comparator<aaf.v2_0.Users.User>) (u1, u2) -> {
+            if (u1==null || u2 == null) {
+                return -1;
             }
+            return u1.getId().compareTo(u2.getId());
         });
-        String format = reportColHead("%-40s %-10s %-30s\n","User","Type","Expires");
+        String format = reportColHead("%-36s %-5s %-20s %-16s\n","User","Type","Expires","Tag");
         String date = "XXXX-XX-XX";
         for (aaf.v2_0.Users.User user : sorted) {
             if (!aafcli.isTest()) {
-                date = Chrono.dateOnlyStamp(user.getExpires());
+                date = Chrono.niceUTCStamp(user.getExpires());
             }
-            pw().format(format, 
-                    count? (Integer.valueOf(++idx) + ") " + user.getId()): user.getId(),
+            String tag=user.getTag();
+            Integer type = user.getType();
+            if(tag==null) {
+                tag="";
+            } else if(type!=null && type>=200) {
+                tag = "\n\tfingerprint: " + tag;
+            }
+            pw().format(format,
+                    user.getId(),
                     org.onap.aaf.auth.cmd.ns.List.getType(user),
-                    date);
+                    date,
+                    tag);
         }
         pw().println();
     }
@@ -77,13 +81,9 @@ public class List extends BaseCmd<User> {
         reportHead(title,id);
         String format = reportColHead("  %-20s %-20s %-11s %-6s %12s\n","User","Approver","Type","Status","Updated");
         java.util.List<Approval> lapp = approvals.getApprovals();
-        Collections.sort(lapp, new Comparator<Approval>() {
-            @Override
-            public int compare(Approval a1, Approval a2) {
-                return a1.getTicket().compareTo(a2.getTicket());
-            }
-        } );
-        String ticket = null, prev = null;
+        Collections.sort(lapp, (Comparator<Approval>) (a1, a2) -> a1.getTicket().compareTo(a2.getTicket()));
+        String ticket = null;
+        String prev = null;
         for (Approval app : lapp ) {
             ticket = app.getTicket();
             if (!ticket.equals(prev)) {
@@ -107,9 +107,9 @@ public class List extends BaseCmd<User> {
         String format = reportColHead(" %-25s %-25s  %-10s\n","User","Delegate","Expires");
         String date = "XXXX-XX-XX";
         for (Delg delg : delgs.getDelgs()) {
-            if (!this.aafcli.isTest()) 
+            if (!this.aafcli.isTest())
                 date = Chrono.dateOnlyStamp(delg.getExpires());
-            pw().printf(format, 
+            pw().printf(format,
                         delg.getUser(),
                         delg.getDelegate(),
                         date