+++ /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 com.att.cadi.CadiException;\r
-import com.att.cadi.LocatorException;\r
-import com.att.cadi.client.Future;\r
-import com.att.cadi.client.Rcli;\r
-import com.att.cadi.client.Retryable;\r
-import com.att.cmd.AAFcli;\r
-import com.att.cmd.BaseCmd;\r
-import com.att.cmd.Param;\r
-import com.att.cssa.rserv.HttpMethods;\r
-import com.att.inno.env.APIException;\r
-\r
-public class Responsible extends BaseCmd<NS> {\r
- private final static String[] options = {"add","del"};\r
-\r
- public Responsible(NS ns) throws APIException {\r
- super(ns,"responsible",\r
- new Param(optionsToString(options),true),\r
- new Param("name",true),\r
- new Param("id[,id]*",true)\r
- );\r
- }\r
-\r
- @Override\r
- public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException {\r
- int idx = _idx;\r
-\r
- final int option = whichOption(options, args[idx++]);\r
- final String ns = args[idx++];\r
- final String ids[] = args[idx++].split(",");\r
- final String realm = getOrgRealm();\r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- Future<Void> fp=null;\r
- for(String id : ids) {\r
- if (id.indexOf('@') < 0 && realm != null) id += '@' + realm;\r
- String verb;\r
- switch(option) {\r
- case 0: \r
- fp = client.create("/authz/ns/"+ns+"/responsible/"+id,Void.class);\r
- verb = " is now ";\r
- break;\r
- case 1: \r
- fp = client.delete("/authz/ns/"+ns+"/responsible/"+id,Void.class);\r
- verb = " is no longer ";\r
- break;\r
- default:\r
- throw new CadiException("Bad Argument");\r
- };\r
- \r
- if(fp.get(AAFcli.timeout())) {\r
- pw().append(id);\r
- pw().append(verb);\r
- pw().append("responsible for ");\r
- pw().println(ns);\r
- } else {\r
- error(fp);\r
- return fp.code();\r
- }\r
- }\r
- return fp==null?500:fp.code();\r
- }\r
- });\r
- }\r
-\r
- @Override\r
- public void detailedHelp(int _indent, StringBuilder sb) {\r
- int indent = _indent;\r
- detailLine(sb,indent,"Add or Delete Responsible person to/from Namespace");\r
- indent+=2;\r
- detailLine(sb,indent,"Responsible persons receive Notifications and approve Requests ");\r
- detailLine(sb,indent,"regarding this Namespace. Companies have Policies as to who may");\r
- detailLine(sb,indent,"take on this responsibility");\r
-\r
- indent+=2;\r
- detailLine(sb,indent,"name - Name of Namespace");\r
- detailLine(sb,indent,"id - Credential of Person(s) to be made responsible");\r
- sb.append('\n');\r
- detailLine(sb,indent,"aafcli will call API on each ID presented.");\r
- indent-=4;\r
- api(sb,indent,HttpMethods.POST,"authz/ns/<ns>/responsible/<id>",Void.class,true);\r
- api(sb,indent,HttpMethods.DELETE,"authz/ns/<ns>/responsible/<id>",Void.class,false);\r
- }\r
-\r
-\r
-}\r