AT&T 2.0.19 Code drop, stage 4
[aaf/authz.git] / authz-cmd / src / main / java / org / onap / aaf / cmd / user / Delg.java
diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/user/Delg.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/user/Delg.java
deleted file mode 100644 (file)
index edb5c38..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************\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.user;\r
-\r
-import java.text.ParseException;\r
-import java.util.Date;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.BaseCmd;\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
-import org.onap.aaf.inno.env.util.Chrono;\r
-import org.onap.aaf.rosetta.env.RosettaDF;\r
-\r
-import aaf.v2_0.DelgRequest;\r
-\r
-public class Delg extends BaseCmd<User> {\r
-       static final String AUTHZ_DELG = "/authz/delegate";\r
-       private final static String[] options = {"add","upd","del"};\r
-\r
-       public Delg(User user) throws APIException {\r
-               super(user,"delegate",\r
-                               new Param(optionsToString(options),true),\r
-                               new Param("from",true),\r
-                               new Param("to REQ A&U",false),\r
-                               new Param("until (YYYY-MM-DD) REQ A", false)\r
-               );\r
-       }\r
-\r
-       @Override\r
-       public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException {\r
-               return same(new Retryable<Integer>() {\r
-                       @Override\r
-                       public Integer code(Rcli<?> client) throws CadiException, APIException {\r
-                               int idx = index;\r
-                               String realm = getOrgRealm();\r
-                               DelgRequest dr = new DelgRequest();\r
-                               setStartEnd(dr);\r
-               \r
-                               int option= whichOption(options, args[idx++]);\r
-                               String user = args[idx++];\r
-                               if (user.indexOf('@') < 0 && realm != null) user += '@' + realm;\r
-                               dr.setUser(user);\r
-                               if(option<2) {\r
-                                       String delegate = args[idx++];\r
-                                       if (delegate.indexOf('@') < 0 && realm != null) delegate += '@' + realm;\r
-                                       dr.setDelegate(delegate);\r
-                                       if(option<2 && args.length>idx) {\r
-                                               Date date;\r
-                                               try {\r
-                                                       date = Chrono.dateOnlyFmt.parse(args[idx++]);\r
-                                               } catch (ParseException e) {\r
-                                                       throw new CadiException(e);\r
-                                               }\r
-                                               dr.setEnd(Chrono.timeStamp(date));\r
-                                       }\r
-                               }\r
-               \r
-                               Future<DelgRequest> fp;\r
-                               RosettaDF<DelgRequest> df = getDF(DelgRequest.class);\r
-                               String verb;\r
-                               setQueryParamsOn(client);\r
-\r
-                               switch(option) {\r
-                                       case 0: \r
-                                               fp = client.create(AUTHZ_DELG, df, dr);\r
-                                               verb = "Added";\r
-                                               break;\r
-                                       case 1: \r
-                                               fp = client.update(AUTHZ_DELG, df, dr); \r
-                                               verb = "Updated";\r
-                                               break;\r
-                                       case 2: \r
-                                               fp = client.delete(AUTHZ_DELG, df, dr); \r
-                                               verb = "Deleted";\r
-                                               break;\r
-                                       default:\r
-                                               throw new CadiException("Bad Argument");\r
-                               };\r
-                               \r
-                               if(fp.get(AAFcli.timeout())) {\r
-                                       pw().append("Delegate ");\r
-                                       pw().println(verb);\r
-                               } else {\r
-                                       error(fp);\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,"Add, Update or Delete Delegate");\r
-               indent+=2;\r
-               detailLine(sb,indent,"A Delegate is a person who will temporarily cover the Approval and");\r
-               detailLine(sb,indent,"Ownership questions on behalf of the person Responsible.");\r
-               sb.append('\n');\r
-               detailLine(sb,indent,"fromID - the person who is the Responsible person of record");\r
-               detailLine(sb,indent,"toID   - the person who will be delegated (required for Add/Update)");\r
-               detailLine(sb,indent,"until  - the end date for this delegation");\r
-               indent-=2;\r
-               api(sb,indent,HttpMethods.POST,AUTHZ_DELG,DelgRequest.class,true);\r
-               api(sb,indent,HttpMethods.DELETE,AUTHZ_DELG,DelgRequest.class,false);\r
-               api(sb,indent,HttpMethods.PUT,AUTHZ_DELG,DelgRequest.class,false);\r
-       }\r
-\r
-}\r