1 /*******************************************************************************
\r
2 * ============LICENSE_START====================================================
\r
4 * * ===========================================================================
\r
5 * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * * ===========================================================================
\r
7 * * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * * you may not use this file except in compliance with the License.
\r
9 * * You may obtain a copy of the License at
\r
11 * * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * * Unless required by applicable law or agreed to in writing, software
\r
14 * * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * * See the License for the specific language governing permissions and
\r
17 * * limitations under the License.
\r
18 * * ============LICENSE_END====================================================
\r
20 * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
22 ******************************************************************************/
\r
23 package org.onap.aaf.cmd.user;
\r
25 import java.util.Collections;
\r
26 import java.util.Comparator;
\r
28 import org.onap.aaf.cmd.BaseCmd;
\r
30 import org.onap.aaf.inno.env.util.Chrono;
\r
32 import aaf.v2_0.Approval;
\r
33 import aaf.v2_0.Approvals;
\r
34 import aaf.v2_0.Delg;
\r
35 import aaf.v2_0.Delgs;
\r
36 import aaf.v2_0.Users;
\r
38 public class List extends BaseCmd<User> {
\r
40 public List(User parent) {
\r
41 super(parent,"list");
\r
42 cmds.add(new ListForRoles(this));
\r
43 cmds.add(new ListForPermission(this));
\r
44 cmds.add(new ListForCreds(this));
\r
45 cmds.add(new ListDelegates(this));
\r
46 cmds.add(new ListApprovals(this));
\r
47 cmds.add(new ListActivity(this));
\r
51 void report(Users users, boolean count, String ... str) {
\r
53 String format = reportColHead("%-50s %-30s\n","User","Expires");
\r
54 String date = "XXXX-XX-XX";
\r
56 java.util.List<aaf.v2_0.Users.User> sorted = users.getUser();
\r
57 Collections.sort(sorted, new Comparator<aaf.v2_0.Users.User>() {
\r
59 public int compare(aaf.v2_0.Users.User u1, aaf.v2_0.Users.User u2) {
\r
60 if(u2==null || u2 == null) {
\r
63 return u1.getId().compareTo(u2.getId());
\r
66 for(aaf.v2_0.Users.User user : sorted) {
\r
67 if(!aafcli.isTest())
\r
68 date = Chrono.dateOnlyStamp(user.getExpires());
\r
70 pw().format(format,
\r
71 count? (Integer.valueOf(++idx) + ") " + user.getId()): user.getId(),
\r
77 public void report(Approvals approvals, String title, String id) {
\r
78 reportHead(title,id);
\r
79 String format = reportColHead(" %-20s %-20s %-11s %-6s %12s\n","User","Approver","Type","Status","Updated");
\r
80 java.util.List<Approval> lapp = approvals.getApprovals();
\r
81 Collections.sort(lapp, new Comparator<Approval>() {
\r
83 public int compare(Approval a1, Approval a2) {
\r
84 return a1.getTicket().compareTo(a2.getTicket());
\r
87 String ticket = null, prev = null;
\r
88 for(Approval app : lapp ) {
\r
89 ticket = app.getTicket();
\r
90 if(!ticket.equals(prev)) {
\r
91 pw().print("Ticket: ");
\r
92 pw().println(ticket);
\r
101 Chrono.niceDateStamp(app.getUpdated())
\r
106 public void report(Delgs delgs, String title, String id) {
\r
107 reportHead(title,id);
\r
108 String format = reportColHead(" %-25s %-25s %-10s\n","User","Delegate","Expires");
\r
109 String date = "XXXX-XX-XX";
\r
110 for(Delg delg : delgs.getDelgs()) {
\r
111 if(!this.aafcli.isTest())
\r
112 date = Chrono.dateOnlyStamp(delg.getExpires());
\r
113 pw().printf(format,
\r
115 delg.getDelegate(),
\r