X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=auth%2Fauth-cmd%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fauth%2Fcmd%2FCmd.java;h=7913b76e2533d3117a40b99be664e788c85afb65;hb=HEAD;hp=49fd48695efd3d49d247f940a009665bb8a93a71;hpb=7136e9a83d131d0618c2a340d80079dcf8ae3c3b;p=aaf%2Fauthz.git diff --git a/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/Cmd.java b/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/Cmd.java index 49fd4869..7913b76e 100644 --- a/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/Cmd.java +++ b/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/Cmd.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -54,7 +54,6 @@ import aaf.v2_0.History; import aaf.v2_0.History.Item; import aaf.v2_0.Request; - public abstract class Cmd { // Sonar claims DateFormat is not thread safe. Leave as Instance Variable. private final DateFormat dateFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS"); @@ -67,7 +66,7 @@ public abstract class Cmd { public static final String STARTDATE = "startdate"; public static final String ENDDATE = "enddate"; - + private String name; private final Param[] params; private int required; @@ -104,7 +103,7 @@ public abstract class Cmd { ++required; } } - + String temp = access.getProperty(Config.AAF_DEFAULT_REALM,null); if (temp!=null && !temp.startsWith("@")) { defaultRealm = '@' + temp; @@ -112,16 +111,16 @@ public abstract class Cmd { defaultRealm=""; } } - + public final int exec(int idx, String ... args) throws CadiException, APIException, LocatorException { if (args.length-idx ": "] "); } - + boolean first = true; for (Cmd child : children) { if (!(child instanceof DeprecatedCMD)) { @@ -222,7 +221,7 @@ public abstract class Cmd { } return sb; } - + protected void error(Future future) { StringBuilder sb = new StringBuilder("Failed"); String desc = future.body(); @@ -272,10 +271,10 @@ public abstract class Cmd { sb.append(", "); sb.append(desc); } - pw().println(sb); + pw().println(sb.toString()); } - + private void withCode(StringBuilder sb, Integer code) { sb.append(" with code "); sb.append(code); @@ -303,7 +302,7 @@ public abstract class Cmd { if ((str = access.getProperty(Cmd.STARTDATE,null))!=null) { req.setStart(Chrono.timeStamp(Date.valueOf(str))); } - + if ((str = access.getProperty(Cmd.ENDDATE,null))!=null) { req.setEnd(Chrono.timeStamp(Date.valueOf(str))); } @@ -311,7 +310,7 @@ public abstract class Cmd { /** * For Derived classes, who have ENV in this parent - * + * * @param cls * @return * @throws APIException @@ -349,17 +348,17 @@ public abstract class Cmd { pw().print('-'); } pw().println(); - + pw().format(hformat,"Date","Table","User","Memo"); for (int i=0;i items = history.getItem(); java.util.Collections.sort(items, (Comparator) (o1, o2) -> o2.getTimestamp().compare(o1.getTimestamp())); - + for (History.Item item : items) { GregorianCalendar gc = item.getTimestamp().toGregorianCalendar(); pw().format(hformat, @@ -370,7 +369,7 @@ public abstract class Cmd { } } } - + /** * Turn String Array into a | delimited String * @param options @@ -389,12 +388,12 @@ public abstract class Cmd { } return sb.toString(); } - + /** * return which index number the Option matches. - * + * * throws an Exception if not part of this Option Set - * + * * @param options * @param test * @return @@ -406,6 +405,7 @@ public abstract class Cmd { return i; } } + pw().printf("%s is not a valid cmd\n",test); throw new CadiException(build(new StringBuilder("Invalid Option: "),null).toString()); } @@ -419,9 +419,9 @@ public abstract class Cmd { retryable.item(aafcli.prevCall.item()); retryable.lastClient=aafcli.prevCall.lastClient; } - + RET ret = aafcli.hman.same(aafcli.ss,retryable); - + // Store last call in AAFcli, because Cmds are all different instances. aafcli.prevCall = retryable; return ret; @@ -444,7 +444,7 @@ public abstract class Cmd { public String getName() { return name; } - + public void reportHead(String ... str) { pw().println(); boolean first = true; @@ -466,7 +466,7 @@ public abstract class Cmd { pw().println(); reportLine(); } - + public String reportColHead(String format, String ... args) { pw().format(format,(Object[])args); reportLine(); @@ -479,7 +479,7 @@ public abstract class Cmd { } pw().println(); } - + protected void setQueryParamsOn(Rcli rcli) { StringBuilder sb=null; String force; @@ -501,7 +501,7 @@ public abstract class Cmd { // // /** // * If Force is set, will return True once only, then revert to "FALSE". -// * +// * // * @return // */ // protected String checkForce() { @@ -524,7 +524,7 @@ public abstract class Cmd { /** * Appends shortID with Realm, but only when allowed by Organization - * @throws OrganizationException + * @throws OrganizationException */ public String fullID(String id) { if (id != null) {