2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6 * ===========================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END====================================================
22 package org.onap.aaf.auth.cmd.mgmt;
24 import org.onap.aaf.auth.cmd.AAFcli;
25 import org.onap.aaf.auth.cmd.BaseCmd;
26 import org.onap.aaf.auth.cmd.Param;
27 import org.onap.aaf.auth.common.Define;
28 import org.onap.aaf.auth.rserv.HttpMethods;
29 import org.onap.aaf.cadi.CadiException;
30 import org.onap.aaf.cadi.LocatorException;
31 import org.onap.aaf.cadi.client.Future;
32 import org.onap.aaf.cadi.client.Rcli;
33 import org.onap.aaf.cadi.client.Retryable;
34 import org.onap.aaf.cadi.config.Config;
35 import org.onap.aaf.misc.env.APIException;
37 public class Log extends BaseCmd<Mgmt> {
38 private final static String[] options = {"add","del"};
40 public Log(Mgmt mgmt) throws APIException {
42 new Param(optionsToString(options),true),
43 new Param("id[,id]*",true));
47 public int _exec(int _idx, String ... args) throws CadiException, APIException, LocatorException {
50 final int option = whichOption(options, args[idx++]);
52 for(String name : args[idx++].split(COMMA)) {
54 if(name.indexOf("@")<0) {
55 fname=name+'@'+ access.getProperty(Config.AAF_DEFAULT_REALM,null);
60 rv = all(new Retryable<Integer>() {
62 public Integer code(Rcli<?> client) throws APIException, CadiException {
65 String str = "/mgmt/log/id/"+fname;
69 fp = client.create(str,Void.class);
73 fp = client.delete(str,Void.class);
82 if(fp.get(AAFcli.timeout())) {
83 pw().println(msg + " Special Log for " + fname + " on " + client);
86 if(rv==409)rv = fp.code();
99 public void detailedHelp(int _indent, StringBuilder sb) {
100 int indent = _indent;
101 detailLine(sb,indent,"Clear the cache for certain tables");
103 detailLine(sb,indent,"name - name of table or 'all'");
104 detailLine(sb,indent+14,"Must have admin rights to '" + Define.ROOT_NS() + '\'');
106 api(sb,indent,HttpMethods.DELETE,"mgmt/cache/:name",Void.class,true);