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.cmd.user;
24 import java.util.Collections;
25 import java.util.Comparator;
27 import org.onap.aaf.auth.cmd.BaseCmd;
28 import org.onap.aaf.misc.env.util.Chrono;
30 import aaf.v2_0.Approval;
31 import aaf.v2_0.Approvals;
33 import aaf.v2_0.Delgs;
34 import aaf.v2_0.Users;
36 public class List extends BaseCmd<User> {
38 public List(User parent) {
40 cmds.add(new ListForRoles(this));
41 cmds.add(new ListForPermission(this));
42 cmds.add(new ListForCreds(this));
43 cmds.add(new ListDelegates(this));
44 cmds.add(new ListApprovals(this));
45 cmds.add(new ListActivity(this));
49 void report(Users users, boolean count, String ... str) {
52 java.util.List<aaf.v2_0.Users.User> sorted = users.getUser();
53 Collections.sort(sorted, new Comparator<aaf.v2_0.Users.User>() {
55 public int compare(aaf.v2_0.Users.User u1, aaf.v2_0.Users.User u2) {
56 if (u1==null || u2 == null) {
59 return u1.getId().compareTo(u2.getId());
62 String format = reportColHead("%-40s %-10s %-30s\n","User","Type","Expires");
63 String date = "XXXX-XX-XX";
64 for (aaf.v2_0.Users.User user : sorted) {
65 if (!aafcli.isTest()) {
66 date = Chrono.dateOnlyStamp(user.getExpires());
69 count? (Integer.valueOf(++idx) + ") " + user.getId()): user.getId(),
70 org.onap.aaf.auth.cmd.ns.List.getType(user),
76 public void report(Approvals approvals, String title, String id) {
78 String format = reportColHead(" %-20s %-20s %-11s %-6s %12s\n","User","Approver","Type","Status","Updated");
79 java.util.List<Approval> lapp = approvals.getApprovals();
80 Collections.sort(lapp, new Comparator<Approval>() {
82 public int compare(Approval a1, Approval a2) {
83 return a1.getTicket().compareTo(a2.getTicket());
86 String ticket = null, prev = null;
87 for (Approval app : lapp ) {
88 ticket = app.getTicket();
89 if (!ticket.equals(prev)) {
90 pw().print("Ticket: ");
100 Chrono.niceDateStamp(app.getUpdated())
105 public void report(Delgs delgs, String title, String id) {
106 reportHead(title,id);
107 String format = reportColHead(" %-25s %-25s %-10s\n","User","Delegate","Expires");
108 String date = "XXXX-XX-XX";
109 for (Delg delg : delgs.getDelgs()) {
110 if (!this.aafcli.isTest())
111 date = Chrono.dateOnlyStamp(delg.getExpires());