+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package com.att.cmd.ns;\r
-\r
-import java.util.Collections;\r
-import java.util.Comparator;\r
-\r
-import com.att.cadi.client.Future;\r
-import com.att.cmd.BaseCmd;\r
-import com.att.inno.env.util.Chrono;\r
-\r
-import aaf.v2_0.Nss;\r
-import aaf.v2_0.Nss.Ns;\r
-import aaf.v2_0.Nss.Ns.Attrib;\r
-import aaf.v2_0.Perms;\r
-import aaf.v2_0.Roles;\r
-import aaf.v2_0.Users;\r
-import aaf.v2_0.Users.User;\r
-\r
-public class List extends BaseCmd<NS> {\r
-\r
- public List(NS parent) {\r
- super(parent,"list");\r
- cmds.add(new ListByName(this));\r
- \r
-// TODO: uncomment when on cassandra 2.1.2 if we like cli command to get all ns's \r
-// a user is admin or responsible for \r
- cmds.add(new ListAdminResponsible(this));\r
- \r
- cmds.add(new ListActivity(this));\r
- cmds.add(new ListUsers(this));\r
- cmds.add(new ListChildren(this));\r
- cmds.add(new ListNsKeysByAttrib(this));\r
- }\r
-\r
- private static final String sformat = " %-72s\n";\r
- protected static final String kformat = " %-72s\n";\r
-\r
- \r
- public void report(Future<Nss> fp, String ... str) {\r
- reportHead(str);\r
- if(fp==null) {\r
- pw().println(" *** Namespace Not Found ***");\r
- }\r
- \r
- if(fp!=null && fp.value!=null) {\r
- for(Ns ns : fp.value.getNs()) {\r
- pw().println(ns.getName());\r
- if (this.aafcli.isDetailed()) {\r
- pw().println(" Description");\r
- pw().format(sformat,ns.getDescription()==null?"":ns.getDescription());\r
- }\r
- if(ns.getAdmin().size()>0) {\r
- pw().println(" Administrators");\r
- for(String admin : ns.getAdmin()) {\r
- pw().format(sformat,admin);\r
- }\r
- }\r
- if(ns.getResponsible().size()>0) {\r
- pw().println(" Responsible Parties");\r
- for(String responsible : ns.getResponsible()) {\r
- pw().format(sformat,responsible);\r
- }\r
- }\r
- if(ns.getAttrib().size()>0) {\r
- pw().println(" Namespace Attributes");\r
- for(Attrib attrib : ns.getAttrib()) {\r
- StringBuilder sb = new StringBuilder(attrib.getKey());\r
- if(attrib.getValue()==null || attrib.getValue().length()>0) {\r
- sb.append('=');\r
- sb.append(attrib.getValue());\r
- }\r
- pw().format(sformat,sb.toString());\r
- }\r
- \r
- }\r
- }\r
- }\r
- }\r
- \r
- public void reportName(Future<Nss> fp, String ... str) {\r
- reportHead(str);\r
- if(fp!=null && fp.value!=null) {\r
- java.util.List<Ns> nss = fp.value.getNs();\r
- Collections.sort(nss, new Comparator<Ns>() {\r
- @Override\r
- public int compare(Ns ns1, Ns ns2) {\r
- return ns1.getName().compareTo(ns2.getName());\r
- }\r
- });\r
- \r
- for(Ns ns : nss) {\r
- pw().println(ns.getName());\r
- if (this.aafcli.isDetailed() && ns.getDescription() != null) {\r
- pw().println(" " + ns.getDescription());\r
- }\r
- }\r
- }\r
- }\r
-\r
- public void reportRole(Future<Roles> fr) {\r
- if(fr!=null && fr.value!=null && fr.value.getRole().size()>0) {\r
- pw().println(" Roles");\r
- for(aaf.v2_0.Role r : fr.value.getRole()) {\r
- pw().format(sformat,r.getName());\r
- }\r
- }\r
- }\r
-\r
- private static final String pformat = " %-30s %-24s %-15s\n";\r
- public void reportPerm(Future<Perms> fp) {\r
- if(fp!=null && fp.value!=null && fp.value.getPerm().size()>0) {\r
- pw().println(" Permissions");\r
- for(aaf.v2_0.Perm p : fp.value.getPerm()) {\r
- pw().format(pformat,p.getType(),p.getInstance(),p.getAction());\r
- }\r
- }\r
- }\r
- \r
- \r
- private static final String cformat = " %-30s %-6s %-24s\n";\r
- public void reportCred(Future<Users> fc) { \r
- if(fc!=null && fc.value!=null && fc.value.getUser().size()>0) {\r
- pw().println(" Credentials");\r
- java.util.List<User> users = fc.value.getUser();\r
- Collections.sort(users, new Comparator<User>() {\r
- @Override\r
- public int compare(User u1, User u2) {\r
- return u1.getId().compareTo(u2.getId());\r
- }\r
- });\r
- for(aaf.v2_0.Users.User u : users) {\r
- if (this.aafcli.isTest()) {\r
- pw().format(sformat,u.getId());\r
- } else {\r
- String type;\r
- switch(u.getType()) {\r
- case 1: type = "U/P"; break;\r
- case 10: type="Cert"; break;\r
- case 200: type="x509"; break;\r
- default: type = "";\r
- }\r
- pw().format(cformat,u.getId(),type,Chrono.niceDateStamp(u.getExpires()));\r
- }\r
- }\r
- }\r
- }\r
-\r
-}\r