Merge "Sonar fix: List.java"
[aaf/authz.git] / auth / auth-cmd / src / main / java / org / onap / aaf / auth / cmd / ns / Attrib.java
index f1b2621..feade45 100644 (file)
@@ -3,6 +3,8 @@
  * org.onap.aaf
  * ===========================================================================
  * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ *
+ * Modifications Copyright (C) 2018 IBM.
  * ===========================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -33,9 +35,11 @@ import org.onap.aaf.cadi.client.Retryable;
 import org.onap.aaf.misc.env.APIException;
 
 public class Attrib extends BaseCmd<NS> {
-    private final static String[] options = {"add","upd","del"};
+    private static final String[] options = {"add","upd","del"};
+    private String authzString = "/authz/ns/";
+    private String atrributeString = "/attrib/";
 
-    public Attrib(NS ns) throws APIException {
+    public Attrib(NS ns) {
         super(ns,"attrib",
                 new Param(optionsToString(options),true),
                 new Param("ns-name",true),
@@ -50,8 +54,8 @@ public class Attrib extends BaseCmd<NS> {
         final String ns = args[idx+1];
         final String key = args[idx+2];
         final String value;
-        if(option!=2) {
-            if(args.length<=idx+3) {
+        if (option!=2) {
+            if (args.length<=idx+3) {
                 throw new CadiException("Not added: Need more Data");
             }
             value = args[idx+3];
@@ -66,27 +70,27 @@ public class Attrib extends BaseCmd<NS> {
                 String message;
                 switch(option) {
                     case 0: 
-                        fp = client.create("/authz/ns/"+ns+"/attrib/"+key+'/'+value,Void.class);
+                        fp = client.create(authzString+ns+atrributeString+key+'/'+value,Void.class);
                         message = String.format("Add Attrib %s=%s to %s",
                                 key,value,ns);
                         break;
                     case 1: 
-                        fp = client.update("/authz/ns/"+ns+"/attrib/"+key+'/'+value);
+                        fp = client.update(authzString+ns+atrributeString+key+'/'+value);
                         message = String.format("Update Attrib %s=%s for %s",
                                 key,value,ns);
                         break;
                     case 2: 
-                        fp = client.delete("/authz/ns/"+ns+"/attrib/"+key,Void.class);
+                        fp = client.delete(authzString+ns+atrributeString+key,Void.class);
                         message = String.format("Attrib %s deleted from %s",
                                 key,ns);
                         break;
                     default:
                         throw new CadiException("Bad Argument");
                 };
-                if(fp==null) {
+                if (fp==null) {
                     return 500;
                 } else {
-                    if(fp.get(AAFcli.timeout())) {
+                    if (fp.get(AAFcli.timeout())) {
                         pw().println(message);
                     } else {
                         error(fp);
@@ -99,8 +103,8 @@ public class Attrib extends BaseCmd<NS> {
     }
 
     @Override
-    public void detailedHelp(int _indent, StringBuilder sb) {
-            int indent = _indent;
+    public void detailedHelp(int indentValue, StringBuilder sb) {
+            int indent = indentValue;
         detailLine(sb,indent,"Add or Delete Administrator to/from Namespace");
         indent+=4;
         detailLine(sb,indent,"name - Name of Namespace");