+++ /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 org.onap.aaf.cmd.ns;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.NsRequest;\r
-\r
-/**\r
- * p\r
- *\r
- */\r
-public class Create extends Cmd {\r
- private static final String COMMA = ",";\r
-\r
- public Create(NS parent) {\r
- super(parent,"create", \r
- new Param("name",true),\r
- new Param("responsible (id[,id]*)",true), \r
- new Param("admin (id[,id]*)",false));\r
- }\r
-\r
- @Override\r
- public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException {\r
- int idx = _idx;\r
-\r
- final NsRequest nr = new NsRequest();\r
- \r
- String realm = getOrgRealm();\r
- \r
- nr.setName(args[idx++]);\r
- String[] responsible = args[idx++].split(COMMA);\r
- for(String s : responsible) {\r
- if (s.indexOf('@') < 0 && realm != null) s += '@' + realm;\r
- nr.getResponsible().add(s);\r
- }\r
- String[] admin;\r
- if(args.length>idx) {\r
- admin = args[idx++].split(COMMA);\r
- } else {\r
- admin = responsible;\r
- }\r
- for(String s : admin) {\r
- if (s.indexOf('@') < 0 && realm != null) s += '@' + realm;\r
- nr.getAdmin().add(s);\r
- }\r
- \r
- // Set Start/End commands\r
- setStartEnd(nr);\r
- \r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- // Requestable\r
- setQueryParamsOn(client);\r
- Future<NsRequest> fp = client.create(\r
- "/authz/ns", \r
- getDF(NsRequest.class),\r
- nr\r
- );\r
- if(fp.get(AAFcli.timeout())) {\r
- pw().println("Created Namespace");\r
- } else {\r
- if(fp.code()==202) {\r
- pw().println("Namespace Creation Accepted, but requires Approvals before actualizing");\r
- } else {\r
- error(fp);\r
- }\r
- }\r
- return fp.code();\r
- }\r
- });\r
- }\r
-\r
- @Override\r
- public void detailedHelp(int _indent, StringBuilder sb) {\r
- int indent = _indent;\r
- detailLine(sb,indent,"Create a Namespace");\r
- indent+=2;\r
- detailLine(sb,indent,"name - Namespaces are dot-delimited, ex com.att.myapp");\r
- detailLine(sb,indent+14,"and must be created with parent credentials.");\r
- detailLine(sb,indent+14,"Ex: to create com.att.myapp, you must be admin for com.att");\r
- detailLine(sb,indent+14,"or com");\r
- detailLine(sb,indent,"responsible - This is the person(s) who receives Notifications and");\r
- detailLine(sb,indent+14,"approves Requests regarding this Namespace. Companies have");\r
- detailLine(sb,indent+14,"Policies as to who may take on this responsibility");\r
- detailLine(sb,indent,"admin - These are the people who are allowed to make changes on");\r
- detailLine(sb,indent+14,"the Namespace, including creating Roles, Permissions");\r
- detailLine(sb,indent+14,"and Credentials");\r
- sb.append('\n');\r
- detailLine(sb,indent,"Namespaces can be created even though there are Roles/Permissions which");\r
- detailLine(sb,indent,"start with the requested sub-namespace. They are reassigned to the");\r
- detailLine(sb,indent,"Child Namespace");\r
- indent-=2;\r
- api(sb,indent,HttpMethods.POST,"authz/ns",NsRequest.class,true);\r
- }\r
-\r
-}\r