You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by la...@apache.org on 2017/04/29 00:12:37 UTC
[07/18] geode git commit: GEODE-1597: use Spring shell's parser and
delete our own parsing code
http://git-wip-us.apache.org/repos/asf/geode/blob/63ffe764/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/HelpConverter.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/HelpConverter.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/HelpConverter.java
deleted file mode 100644
index e670274..0000000
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/HelpConverter.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You 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. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.management.internal.cli.converters;
-
-import java.util.List;
-
-import org.springframework.shell.core.Completion;
-import org.springframework.shell.core.Converter;
-import org.springframework.shell.core.MethodTarget;
-
-import org.apache.geode.management.internal.cli.commands.GfshHelpCommands;
-import org.apache.geode.management.internal.cli.i18n.CliStrings;
-import org.apache.geode.management.internal.cli.shell.Gfsh;
-
-/**
- * {@link Converter} for {@link GfshHelpCommands#obtainHelp(String)}
- *
- *
- * @since GemFire 7.0
- */
-public class HelpConverter implements Converter<String> {
-
- @Override
- public String convertFromText(String existingData, Class<?> dataType, String optionContext) {
-
- if (optionContext.equals(CliStrings.PARAM_CONTEXT_HELP)) {
- return existingData.replaceAll("\"", "").replaceAll("'", "");
- } else {
- return null;
- }
- }
-
- @Override
- public boolean getAllPossibleValues(List<Completion> completionCandidates, Class<?> dataType,
- String existingData, String optionContext, MethodTarget arg4) {
-
- List<String> commandNames = Gfsh.getCurrentInstance().obtainHelpCommandNames(existingData);
-
- for (String string : commandNames) {
- completionCandidates.add(new Completion(string));
- }
- if (completionCandidates.size() > 0) {
- return true;
- }
- return false;
- }
-
- @Override
- public boolean supports(Class<?> arg0, String optionContext) {
- if (String.class.isAssignableFrom(arg0)
- && optionContext.equals(CliStrings.PARAM_CONTEXT_HELP)) {
- return true;
- }
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/geode/blob/63ffe764/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/HintTopicConverter.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/HintTopicConverter.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/HintTopicConverter.java
deleted file mode 100644
index b6f9f81..0000000
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/HintTopicConverter.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You 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. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.management.internal.cli.converters;
-
-import java.util.List;
-import java.util.Set;
-
-import org.springframework.shell.core.Completion;
-import org.springframework.shell.core.Converter;
-import org.springframework.shell.core.MethodTarget;
-
-import org.apache.geode.management.cli.ConverterHint;
-import org.apache.geode.management.internal.cli.CommandManager;
-
-/**
- *
- * @since GemFire 7.0
- */
-public class HintTopicConverter implements Converter<String> {
-
- @Override
- public boolean supports(Class<?> type, String optionContext) {
- return String.class.equals(type) && ConverterHint.HINTTOPIC.equals(optionContext);
- }
-
- @Override
- public String convertFromText(String value, Class<?> targetType, String optionContext) {
- return value;
- }
-
- @Override
- public boolean getAllPossibleValues(List<Completion> completions, Class<?> targetType,
- String existingData, String optionContext, MethodTarget target) {
- if (String.class.equals(targetType) && ConverterHint.HINTTOPIC.equals(optionContext)) {
- CommandManager commandManager = CommandManager.getExisting();
- if (commandManager != null) {
- Set<String> topicNames = commandManager.getTopicNames();
-
- for (String topicName : topicNames) {
- if (existingData != null && !existingData.isEmpty()) {
- if (topicName.startsWith(existingData)) { // match exact case
- completions.add(new Completion(topicName));
- } else if (topicName.toLowerCase().startsWith(existingData.toLowerCase())) { // match
- // case
- // insensitive
- String completionStr = existingData + topicName.substring(existingData.length());
-
- completions.add(new Completion(completionStr));
- }
- } else {
- completions.add(new Completion(topicName));
- }
- }
- }
- }
-
- return !completions.isEmpty();
- }
-}
http://git-wip-us.apache.org/repos/asf/geode/blob/63ffe764/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/LogLevelConverter.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/LogLevelConverter.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/LogLevelConverter.java
index 3a26240..b303e77 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/LogLevelConverter.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/LogLevelConverter.java
@@ -41,7 +41,7 @@ public class LogLevelConverter implements Converter<String> {
@Override
public boolean supports(Class<?> type, String optionContext) {
- return String.class.equals(type) && ConverterHint.LOG_LEVEL.equals(optionContext);
+ return String.class.equals(type) && optionContext.contains(ConverterHint.LOG_LEVEL);
}
@Override
http://git-wip-us.apache.org/repos/asf/geode/blob/63ffe764/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/StringArrayConverter.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/StringArrayConverter.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/StringArrayConverter.java
deleted file mode 100644
index eacf181..0000000
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/StringArrayConverter.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You 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. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.management.internal.cli.converters;
-
-import java.util.List;
-
-import org.springframework.shell.core.Completion;
-import org.springframework.shell.core.MethodTarget;
-
-import org.apache.geode.management.cli.ConverterHint;
-import org.apache.geode.management.internal.cli.MultipleValueAdapter;
-
-/**
- *
- * @since GemFire 7.0
- *
- *
- */
-public class StringArrayConverter extends MultipleValueAdapter<String[]> {
-
- @Override
- public String[] convertFromText(String[] value, Class<?> targetType, String context) {
- return value;
- }
-
- @Override
- public boolean getAllPossibleValues(List<Completion> completions, Class<?> targetType,
- String[] existingData, String context, MethodTarget target) {
- return false;
- }
-
- @Override
- public boolean supports(Class<?> type, String optionContext) {
- if (String[].class.isAssignableFrom(type) && !optionContext.equals(ConverterHint.DIRS)) {
- return true;
- } else {
- return false;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/geode/blob/63ffe764/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/StringListConverter.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/StringListConverter.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/StringListConverter.java
deleted file mode 100644
index eab096b..0000000
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/StringListConverter.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You 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. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.management.internal.cli.converters;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.springframework.shell.core.Completion;
-import org.springframework.shell.core.MethodTarget;
-
-import org.apache.geode.management.cli.ConverterHint;
-import org.apache.geode.management.internal.cli.MultipleValueAdapter;
-
-/**
- *
- *
- * @since GemFire 7.0
- */
-public class StringListConverter extends MultipleValueAdapter<List<String>> {
-
- @Override
- public boolean supports(Class<?> type, String optionContext) {
- return List.class.isAssignableFrom(type) && ConverterHint.STRING_LIST.equals(optionContext);
- }
-
- @Override
- public List<String> convertFromText(String[] value, Class<?> targetType, String context) {
- List<String> list = null;
-
- if (List.class.isAssignableFrom(targetType) && ConverterHint.STRING_LIST.equals(context)
- && value != null && value.length > 0) {
- list = new ArrayList<String>(Arrays.asList(value));
- }
- return list;
- }
-
- @Override
- public boolean getAllPossibleValues(List<Completion> completions, Class<?> targetType,
- String[] existingData, String context, MethodTarget target) {
- return List.class.isAssignableFrom(targetType) && ConverterHint.STRING_LIST.equals(context);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/geode/blob/63ffe764/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandException.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandException.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandException.java
deleted file mode 100644
index 7e5cba0..0000000
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandException.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You 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. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.management.internal.cli.exceptions;
-
-import org.apache.geode.management.internal.cli.parser.CommandTarget;
-import org.apache.geode.management.internal.cli.parser.OptionSet;
-
-public class CliCommandException extends CliException {
- private static final long serialVersionUID = 968411094429216130L;
-
- private CommandTarget commandTarget;
- private OptionSet optionSet;
-
- public CliCommandException(final CommandTarget commandTarget) {
- this(commandTarget, null, null);
- }
-
- public CliCommandException(final CommandTarget commandTarget, final OptionSet optionSet) {
- this(commandTarget, optionSet, null);
- }
-
- public CliCommandException(final CommandTarget commandTarget, final OptionSet optionSet,
- final Throwable cause) {
- super(cause);
- this.setCommandTarget(commandTarget);
- this.setOptionSet(optionSet);
- }
-
- public CommandTarget getCommandTarget() {
- return commandTarget;
- }
-
- /**
- * TODO: make this immutable
- *
- * @param commandTarget the commandTarget to set
- */
- public void setCommandTarget(CommandTarget commandTarget) {
- this.commandTarget = commandTarget;
- }
-
- public OptionSet getOptionSet() {
- return optionSet;
- }
-
- /**
- * TODO: make this immutable
- *
- * @param optionSet the optionSet to set
- */
- public void setOptionSet(OptionSet optionSet) {
- this.optionSet = optionSet;
- }
-}
http://git-wip-us.apache.org/repos/asf/geode/blob/63ffe764/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandInvalidException.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandInvalidException.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandInvalidException.java
deleted file mode 100644
index a140059..0000000
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandInvalidException.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You 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. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.management.internal.cli.exceptions;
-
-import org.apache.geode.management.internal.cli.parser.CommandTarget;
-import org.apache.geode.management.internal.cli.parser.OptionSet;
-
-public class CliCommandInvalidException extends CliCommandException {
- private static final long serialVersionUID = -2195809850441234116L;
-
- public CliCommandInvalidException(final CommandTarget commandTarget) {
- this(commandTarget, null, null);
- }
-
- public CliCommandInvalidException(final CommandTarget commandTarget, OptionSet optionSet) {
- this(commandTarget, optionSet, null);
- }
-
- public CliCommandInvalidException(final Throwable cause) {
- this(null, null, cause);
- }
-
- public CliCommandInvalidException(final CommandTarget commandTarget, OptionSet optionSet,
- Throwable cause) {
- super(commandTarget, optionSet, cause);
- }
-}
http://git-wip-us.apache.org/repos/asf/geode/blob/63ffe764/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandMultiModeOptionException.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandMultiModeOptionException.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandMultiModeOptionException.java
deleted file mode 100644
index acbc496..0000000
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandMultiModeOptionException.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You 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. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.management.internal.cli.exceptions;
-
-import org.apache.geode.management.internal.cli.parser.CommandTarget;
-import org.apache.geode.management.internal.cli.parser.Option;
-import org.apache.geode.management.internal.cli.parser.OptionSet;
-
-public class CliCommandMultiModeOptionException extends CliCommandOptionException {
- private static final long serialVersionUID = -5658813370141696448L;
-
- public static final int MULTIPLE_LEAD_OPTIONS = 1; // TODO: move or delete
- public static final int OPTIONS_FROM_MULTIPLE_MODES = 2; // TODO: move or delete
-
- private String leadOptionString;
- private int code;
-
- public CliCommandMultiModeOptionException(final CommandTarget commandTarget, final Option option,
- final String string, final int code) {
- this(commandTarget, option, string, code, null);
- }
-
- public CliCommandMultiModeOptionException(final CommandTarget commandTarget, final Option option,
- final String string, final int code, final Throwable cause) {
- super(commandTarget, option, cause);
- this.leadOptionString = string;
- this.code = code;
- }
-
- public String getLeadOptionString() {
- return leadOptionString;
- }
-
- public int getCode() {
- return code;
- }
-}
http://git-wip-us.apache.org/repos/asf/geode/blob/63ffe764/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandNotAvailableException.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandNotAvailableException.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandNotAvailableException.java
deleted file mode 100644
index c471df2..0000000
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandNotAvailableException.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You 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. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.management.internal.cli.exceptions;
-
-import org.apache.geode.management.internal.cli.parser.CommandTarget;
-import org.apache.geode.management.internal.cli.parser.OptionSet;
-
-public class CliCommandNotAvailableException extends CliCommandException {
- private static final long serialVersionUID = -631339463163773007L;
-
- public CliCommandNotAvailableException(final CommandTarget commandTarget) {
- this(commandTarget, null, null);
- }
-
- public CliCommandNotAvailableException(final CommandTarget commandTarget,
- final OptionSet optionSet) {
- this(commandTarget, optionSet, null);
- }
-
- public CliCommandNotAvailableException(final CommandTarget commandTarget,
- final OptionSet optionSet, final Throwable cause) {
- super(commandTarget, optionSet, cause);
- }
-}
http://git-wip-us.apache.org/repos/asf/geode/blob/63ffe764/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandOptionException.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandOptionException.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandOptionException.java
deleted file mode 100644
index a7e56be..0000000
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandOptionException.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You 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. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.management.internal.cli.exceptions;
-
-import org.apache.geode.management.internal.cli.parser.CommandTarget;
-import org.apache.geode.management.internal.cli.parser.Option;
-import org.apache.geode.management.internal.cli.parser.OptionSet;
-
-public class CliCommandOptionException extends CliCommandException {
- private static final long serialVersionUID = -5443638512704442487L;
-
- private Option option;
-
- public CliCommandOptionException(final CommandTarget commandTarget, final Option option) {
- this(commandTarget, option, null, null);
- }
-
- public CliCommandOptionException(final CommandTarget commandTarget, final Option option,
- final OptionSet optionSet) {
- this(commandTarget, option, optionSet, null);
- }
-
- public CliCommandOptionException(final CommandTarget commandTarget, final Option option,
- final Throwable cause) {
- this(commandTarget, option, null, cause);
- }
-
- public CliCommandOptionException(final Throwable cause) {
- this(null, null, null, cause);
- }
-
- public CliCommandOptionException(final CommandTarget commandTarget, final Option option,
- final OptionSet optionSet, final Throwable cause) {
- super(commandTarget, optionSet, cause);
- this.setOption(option);
- }
-
- /**
- * @return option for which the exception occurred
- */
- public Option getOption() {
- return option;
- }
-
- /**
- * TODO: make this immutable
- *
- * @param option the option to set
- */
- public void setOption(Option option) {
- this.option = option;
- }
-}
http://git-wip-us.apache.org/repos/asf/geode/blob/63ffe764/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandOptionHasMultipleValuesException.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandOptionHasMultipleValuesException.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandOptionHasMultipleValuesException.java
deleted file mode 100644
index 4b365e3..0000000
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandOptionHasMultipleValuesException.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You 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. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.management.internal.cli.exceptions;
-
-import org.apache.geode.management.internal.cli.parser.CommandTarget;
-import org.apache.geode.management.internal.cli.parser.Option;
-import org.apache.geode.management.internal.cli.parser.OptionSet;
-
-public class CliCommandOptionHasMultipleValuesException extends CliCommandOptionValueException {
-
- private static final long serialVersionUID = -5277268341319591711L;
-
- public CliCommandOptionHasMultipleValuesException(final CommandTarget commandTarget,
- final Option option, final String value) {
- this(commandTarget, option, null, value, null);
- }
-
- public CliCommandOptionHasMultipleValuesException(final CommandTarget commandTarget,
- final Option option, final OptionSet optionSet, final String value) {
- this(commandTarget, option, optionSet, value, null);
- }
-
- public CliCommandOptionHasMultipleValuesException(final Throwable cause) {
- this(null, null, null, null, cause);
- }
-
- public CliCommandOptionHasMultipleValuesException(final Option option, final Throwable cause) {
- this(null, option, null, null, cause);
- }
-
- public CliCommandOptionHasMultipleValuesException(final CommandTarget commandTarget,
- final Option option, final OptionSet optionSet, final String value, final Throwable cause) {
- super(commandTarget, option, optionSet, value, cause);
- }
-}
http://git-wip-us.apache.org/repos/asf/geode/blob/63ffe764/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandOptionInvalidException.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandOptionInvalidException.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandOptionInvalidException.java
deleted file mode 100644
index 1db8906..0000000
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandOptionInvalidException.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You 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. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.management.internal.cli.exceptions;
-
-import org.apache.geode.management.internal.cli.parser.CommandTarget;
-import org.apache.geode.management.internal.cli.parser.Option;
-import org.apache.geode.management.internal.cli.parser.OptionSet;
-
-public class CliCommandOptionInvalidException extends CliCommandOptionException {
- private static final long serialVersionUID = 8773148664471110429L;
-
- public CliCommandOptionInvalidException(final CommandTarget commandTarget, final Option option) {
- this(commandTarget, option, null, null);
- }
-
- public CliCommandOptionInvalidException(final CommandTarget commandTarget, final Option option,
- final OptionSet optionSet) {
- this(commandTarget, option, optionSet, null);
- }
-
- public CliCommandOptionInvalidException(final CommandTarget commandTarget, final Option option,
- final OptionSet optionSet, final Throwable cause) {
- super(commandTarget, option, optionSet, cause);
- }
-}
http://git-wip-us.apache.org/repos/asf/geode/blob/63ffe764/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandOptionMissingException.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandOptionMissingException.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandOptionMissingException.java
deleted file mode 100644
index f263dce..0000000
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandOptionMissingException.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You 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. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.management.internal.cli.exceptions;
-
-import org.apache.geode.management.internal.cli.parser.CommandTarget;
-import org.apache.geode.management.internal.cli.parser.Option;
-import org.apache.geode.management.internal.cli.parser.OptionSet;
-
-public class CliCommandOptionMissingException extends CliCommandOptionException {
- private static final long serialVersionUID = 7152881150151676813L;
-
- public CliCommandOptionMissingException(final CommandTarget commandTarget, final Option option) {
- this(commandTarget, option, null, null);
- }
-
- public CliCommandOptionMissingException(final CommandTarget commandTarget, final Option option,
- final OptionSet optionSet) {
- this(commandTarget, option, optionSet, null);
- }
-
- public CliCommandOptionMissingException(final Throwable cause) {
- this(null, null, null, cause);
- }
-
- public CliCommandOptionMissingException(final Option option, final Throwable cause) {
- this(null, option, null, cause);
- }
-
- public CliCommandOptionMissingException(final CommandTarget commandTarget, final Option option,
- final OptionSet optionSet, final Throwable cause) {
- super(commandTarget, option, optionSet, cause);
- }
-}
http://git-wip-us.apache.org/repos/asf/geode/blob/63ffe764/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandOptionNotApplicableException.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandOptionNotApplicableException.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandOptionNotApplicableException.java
deleted file mode 100644
index 9814778..0000000
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandOptionNotApplicableException.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You 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. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.management.internal.cli.exceptions;
-
-import org.apache.geode.management.internal.cli.parser.CommandTarget;
-import org.apache.geode.management.internal.cli.parser.Option;
-import org.apache.geode.management.internal.cli.parser.OptionSet;
-
-public class CliCommandOptionNotApplicableException extends CliCommandOptionException {
- private static final long serialVersionUID = 4190478428338602501L;
-
- public CliCommandOptionNotApplicableException(final CommandTarget commandTarget,
- final Option option) {
- this(commandTarget, option, null, null);
- }
-
- public CliCommandOptionNotApplicableException(final CommandTarget commandTarget,
- final Option option, final OptionSet optionSet) {
- this(commandTarget, option, optionSet, null);
- }
-
- public CliCommandOptionNotApplicableException(final Throwable cause) {
- this(null, null, null, cause);
- }
-
- public CliCommandOptionNotApplicableException(final Option option, final Throwable cause) {
- this(null, option, null, cause);
- }
-
- public CliCommandOptionNotApplicableException(final CommandTarget commandTarget,
- final Option option, final OptionSet optionSet, Throwable cause) {
- super(commandTarget, option, optionSet, cause);
- }
-}
http://git-wip-us.apache.org/repos/asf/geode/blob/63ffe764/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandOptionValueConversionException.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandOptionValueConversionException.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandOptionValueConversionException.java
deleted file mode 100644
index 7dbf869..0000000
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandOptionValueConversionException.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You 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. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.management.internal.cli.exceptions;
-
-import org.apache.geode.management.internal.cli.parser.CommandTarget;
-import org.apache.geode.management.internal.cli.parser.Option;
-import org.apache.geode.management.internal.cli.parser.OptionSet;
-
-public class CliCommandOptionValueConversionException extends CliCommandOptionValueException {
- private static final long serialVersionUID = 5144720637801591L;
-
- public CliCommandOptionValueConversionException(final CommandTarget commandTarget,
- final Option option, final String value) {
- this(commandTarget, option, null, value, null);
- }
-
- public CliCommandOptionValueConversionException(final CommandTarget commandTarget,
- final Option option, final OptionSet optionSet, final String value) {
- this(commandTarget, option, optionSet, value, null);
- }
-
- public CliCommandOptionValueConversionException(final CommandTarget commandTarget,
- final Option option, final OptionSet optionSet, final String value, final Throwable cause) {
- super(commandTarget, option, optionSet, value, null);
- }
-}
http://git-wip-us.apache.org/repos/asf/geode/blob/63ffe764/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandOptionValueException.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandOptionValueException.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandOptionValueException.java
deleted file mode 100644
index ee02df8..0000000
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandOptionValueException.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You 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. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.management.internal.cli.exceptions;
-
-import org.apache.geode.management.internal.cli.parser.CommandTarget;
-import org.apache.geode.management.internal.cli.parser.Option;
-import org.apache.geode.management.internal.cli.parser.OptionSet;
-
-public class CliCommandOptionValueException extends CliCommandOptionException {
- private static final long serialVersionUID = -7339487978861146474L;
-
- private final String value;
-
- public CliCommandOptionValueException(final CommandTarget commandTarget, final Option option,
- final String value) {
- this(commandTarget, option, null, value, null);
- }
-
- public CliCommandOptionValueException(final CommandTarget commandTarget, final Option option,
- final OptionSet optionSet, final String value) {
- this(commandTarget, option, null, value, null);
- }
-
- public CliCommandOptionValueException(final Throwable cause) {
- this(null, null, null, null, cause);
- }
-
- public CliCommandOptionValueException(final CommandTarget commandTarget, final Option option,
- final OptionSet optionSet, final String value, final Throwable cause) {
- super(commandTarget, option, optionSet, cause);
- this.value = value;
- }
-
- public String getValue() {
- return value;
- }
-}
http://git-wip-us.apache.org/repos/asf/geode/blob/63ffe764/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandOptionValueMissingException.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandOptionValueMissingException.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandOptionValueMissingException.java
deleted file mode 100644
index 023a878..0000000
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/CliCommandOptionValueMissingException.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You 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. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.management.internal.cli.exceptions;
-
-import org.apache.geode.management.internal.cli.parser.CommandTarget;
-import org.apache.geode.management.internal.cli.parser.Option;
-import org.apache.geode.management.internal.cli.parser.OptionSet;
-
-public class CliCommandOptionValueMissingException extends CliCommandOptionValueException {
- private static final long serialVersionUID = 7842061609469545533L;
-
- public CliCommandOptionValueMissingException(final CommandTarget commandTarget,
- final Option option, final String value) {
- this(commandTarget, option, null, value, null);
- }
-
- public CliCommandOptionValueMissingException(final CommandTarget commandTarget,
- final Option option, final OptionSet optionSet, final String value) {
- this(commandTarget, option, optionSet, value, null);
- }
-
- public CliCommandOptionValueMissingException(final Throwable cause) {
- this(null, null, null, null, cause);
- }
-
- public CliCommandOptionValueMissingException(final Option option, final Throwable cause) {
- this(null, option, null, null, cause);
- }
-
- public CliCommandOptionValueMissingException(final CommandTarget commandTarget,
- final Option option, final OptionSet optionSet, final String value, final Throwable cause) {
- super(commandTarget, option, optionSet, value);
- }
-}
http://git-wip-us.apache.org/repos/asf/geode/blob/63ffe764/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/ExceptionGenerator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/ExceptionGenerator.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/ExceptionGenerator.java
deleted file mode 100644
index fda3135..0000000
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/ExceptionGenerator.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You 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. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.management.internal.cli.exceptions;
-
-import joptsimple.OptionException;
-
-import org.apache.geode.management.internal.cli.parser.CommandTarget;
-import org.apache.geode.management.internal.cli.parser.Option;
-import org.apache.geode.management.internal.cli.parser.OptionSet;
-
-/**
- * Converts joptsimple exceptions into corresponding exceptions for cli
- *
- * TODO: delete this class
- */
-public class ExceptionGenerator {
-
- public static CliCommandOptionException generate(Option option, OptionException cause) {
- if (cause.getClass().getSimpleName().contains("MissingRequiredOptionException")) {
- return new CliCommandOptionMissingException(option, cause);
-
- } else if (cause.getClass().getSimpleName()
- .contains("OptionMissingRequiredArgumentException")) {
- return new CliCommandOptionValueMissingException(option, cause);
-
- } else if (cause.getClass().getSimpleName().contains("UnrecognizedOptionException")) {
- return new CliCommandOptionNotApplicableException(option, cause);
-
- } else if (cause.getClass().getSimpleName().contains("MultipleArgumentsForOptionException")) {
- return new CliCommandOptionHasMultipleValuesException(option, cause);
-
- } else {
- return new CliCommandOptionException(cause);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/geode/blob/63ffe764/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/ExceptionHandler.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/ExceptionHandler.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/ExceptionHandler.java
deleted file mode 100644
index 95afbaf..0000000
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/exceptions/ExceptionHandler.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You 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. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.management.internal.cli.exceptions;
-
-import java.util.logging.Logger;
-
-import org.apache.geode.management.internal.cli.util.CLIConsoleBufferUtil;
-
-/**
- * Prints the warning according the CliException
- */
-public class ExceptionHandler {
-
- private static Logger LOGGER = Logger.getLogger(ExceptionHandler.class.getCanonicalName());
-
- // FIXME define handling when no match is present
- public static void handleException(CliException ce) {
- if (ce instanceof CliCommandNotAvailableException) {
- handleCommandNotAvailableException((CliCommandNotAvailableException) ce);
- } else if (ce instanceof CliCommandInvalidException) {
- handleCommandInvalidException((CliCommandInvalidException) ce);
- } else if (ce instanceof CliCommandOptionException) {
- handleOptionException((CliCommandOptionException) ce);
- }
- }
-
- private static void handleMultiModeOptionException(CliCommandMultiModeOptionException ce) {
- switch (ce.getCode()) {
- case CliCommandMultiModeOptionException.MULTIPLE_LEAD_OPTIONS:
- LOGGER.warning(CLIConsoleBufferUtil.processMessegeForExtraCharactersFromConsoleBuffer(
- "Input command contains multiple lead-options from modes : "
- + ce.getLeadOptionString()));
- break;
- case CliCommandMultiModeOptionException.OPTIONS_FROM_MULTIPLE_MODES:
- LOGGER.warning(CLIConsoleBufferUtil.processMessegeForExtraCharactersFromConsoleBuffer(
- "Input command contains options from multilpe modes : " + ce.getLeadOptionString()));
- break;
- }
- }
-
- private static void handleCommandInvalidException(CliCommandInvalidException ccie) {
- LOGGER.warning(CLIConsoleBufferUtil.processMessegeForExtraCharactersFromConsoleBuffer(
- ccie.getCommandTarget().getGfshMethodTarget().getKey() + " is not a valid Command"));
- }
-
- private static void handleCommandNotAvailableException(CliCommandNotAvailableException ccnae) {
- LOGGER.warning(CLIConsoleBufferUtil.processMessegeForExtraCharactersFromConsoleBuffer(
- ccnae.getCommandTarget().getGfshMethodTarget().getKey()
- + " is not available at the moment"));
- }
-
- private static void handleOptionException(CliCommandOptionException ccoe) {
- if (ccoe instanceof CliCommandOptionNotApplicableException) {
- handleOptionInvalidExcpetion((CliCommandOptionNotApplicableException) ccoe);
- } else if (ccoe instanceof CliCommandOptionValueException) {
- handleOptionValueException((CliCommandOptionValueException) ccoe);
- } else if (ccoe instanceof CliCommandMultiModeOptionException) {
- handleMultiModeOptionException((CliCommandMultiModeOptionException) ccoe);
- }
- }
-
- private static void handleOptionInvalidExcpetion(CliCommandOptionNotApplicableException cconae) {
- String messege = "Parameter " + cconae.getOption().getLongOption() + " is not applicable for "
- + cconae.getCommandTarget().getGfshMethodTarget().getKey();
- LOGGER.warning(CLIConsoleBufferUtil.processMessegeForExtraCharactersFromConsoleBuffer(messege));
- }
-
- private static void handleOptionValueException(CliCommandOptionValueException ccove) {
- if (ccove instanceof CliCommandOptionHasMultipleValuesException) {
- // unfortunately by changing from geode-joptsimple to jopt-simple we will lose ALL such
- // debugging info from exceptions
- // String parameter = ccove != null && ccove.getOption() != null ?
- // ccove.getOption().getLongOption() : "<null>";
- String parameter = ccove.getOption().getLongOption();
- String message = "Parameter " + parameter + " can only be specified once";
- LOGGER
- .warning(CLIConsoleBufferUtil.processMessegeForExtraCharactersFromConsoleBuffer(message));
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/geode/blob/63ffe764/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/CliTopic.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/CliTopic.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/CliTopic.java
deleted file mode 100644
index 791cdca..0000000
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/CliTopic.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You 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. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.management.internal.cli.help;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-
-import org.apache.geode.management.internal.cli.i18n.CliStrings;
-import org.apache.geode.management.internal.cli.parser.CommandTarget;
-
-/**
- *
- *
- * @since GemFire 7.0
- */
-public class CliTopic implements Comparable<CliTopic> {
- private static final Map<String, String> nameDescriptionMap = new HashMap<String, String>();
-
- static {
- nameDescriptionMap.put(CliStrings.DEFAULT_TOPIC_GEODE, CliStrings.DEFAULT_TOPIC_GEODE__DESC);
- nameDescriptionMap.put(CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_REGION__DESC);
- nameDescriptionMap.put(CliStrings.TOPIC_GEODE_WAN, CliStrings.TOPIC_GEODE_WAN__DESC);
- nameDescriptionMap.put(CliStrings.TOPIC_GEODE_JMX, CliStrings.TOPIC_GEODE_JMX__DESC);
- nameDescriptionMap.put(CliStrings.TOPIC_GEODE_DISKSTORE,
- CliStrings.TOPIC_GEODE_DISKSTORE__DESC);
- nameDescriptionMap.put(CliStrings.TOPIC_GEODE_LOCATOR, CliStrings.TOPIC_GEODE_LOCATOR__DESC);
- nameDescriptionMap.put(CliStrings.TOPIC_GEODE_SERVER, CliStrings.TOPIC_GEODE_SERVER__DESC);
- nameDescriptionMap.put(CliStrings.TOPIC_GEODE_MANAGER, CliStrings.TOPIC_GEODE_MANAGER__DESC);
- nameDescriptionMap.put(CliStrings.TOPIC_GEODE_STATISTICS,
- CliStrings.TOPIC_GEODE_STATISTICS__DESC);
- nameDescriptionMap.put(CliStrings.TOPIC_GEODE_LIFECYCLE,
- CliStrings.TOPIC_GEODE_LIFECYCLE__DESC);
- nameDescriptionMap.put(CliStrings.TOPIC_GEODE_M_AND_M, CliStrings.TOPIC_GEODE_M_AND_M__DESC);
- nameDescriptionMap.put(CliStrings.TOPIC_GEODE_DATA, CliStrings.TOPIC_GEODE_DATA__DESC);
- nameDescriptionMap.put(CliStrings.TOPIC_GEODE_CONFIG, CliStrings.TOPIC_GEODE_CONFIG__DESC);
- nameDescriptionMap.put(CliStrings.TOPIC_GEODE_FUNCTION, CliStrings.TOPIC_GEODE_FUNCTION__DESC);
- nameDescriptionMap.put(CliStrings.TOPIC_GEODE_HELP, CliStrings.TOPIC_GEODE_HELP__DESC);
- nameDescriptionMap.put(CliStrings.TOPIC_GEODE_DEBUG_UTIL,
- CliStrings.TOPIC_GEODE_DEBUG_UTIL__DESC);
- nameDescriptionMap.put(CliStrings.TOPIC_GFSH, CliStrings.TOPIC_GFSH__DESC);
- }
-
-
- private final String name;
- private final String oneLinerDescription;
- private Set<CommandTarget> commandTargets;
-
- public CliTopic(String name) {
- this.name = name;
- this.oneLinerDescription = nameDescriptionMap.get(this.name);
- this.commandTargets = new HashSet<CommandTarget>();
- }
-
- public String getName() {
- return name;
- }
-
- public String getOneLinerDescription() {
- return oneLinerDescription;
- }
-
- public void addCommandTarget(CommandTarget commandTarget) {
- commandTargets.add(commandTarget);
- }
-
- public Map<String, String> getCommandsNameHelp() {
- Map<String, String> commandsNameHelp = new TreeMap<String, String>();
-
- for (CommandTarget commandTarget : commandTargets) {
- commandsNameHelp.put(commandTarget.getCommandName(), commandTarget.getCommandHelp());
- }
-
- return commandsNameHelp;
- }
-
- @Override
- public int compareTo(CliTopic o) {
- if (o != null) {
- return this.name.compareTo(o.name);
- } else {
- return -1;
- }
- }
-
- // hashCode & equals created using Eclipse
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!getClass().isInstance(obj)) {
- return false;
- }
- CliTopic other = (CliTopic) obj;
- if (name == null) {
- if (other.name != null) {
- return false;
- }
- } else if (!name.equals(other.name)) {
- return false;
- }
- return true;
- }
-
- @Override
- public String toString() {
- return CliTopic.class.getSimpleName() + "[" + name + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/geode/blob/63ffe764/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/HelpBlock.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/HelpBlock.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/HelpBlock.java
new file mode 100644
index 0000000..4383044
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/HelpBlock.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You 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. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.management.internal.cli.help;
+
+import org.apache.geode.internal.lang.StringUtils;
+import org.apache.geode.management.internal.cli.GfshParser;
+import org.apache.geode.management.internal.cli.shell.Gfsh;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *
+ */
+public class HelpBlock {
+ private String data = null;
+ private List<HelpBlock> children = new ArrayList<>();
+ // indent level
+ private int level = -1;
+
+ public HelpBlock() {}
+
+ public HelpBlock(String data) {
+ if (!StringUtils.isBlank(data)) {
+ this.data = data;
+ this.level = 0;
+ }
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public List<HelpBlock> getChildren() {
+ return children;
+ }
+
+ public int getLevel() {
+ return this.level;
+ }
+
+ public void addChild(HelpBlock helpBlock) {
+ // before adding another block as the child, increment the indent level
+ helpBlock.setLevel(level + 1);
+ children.add(helpBlock);
+ }
+
+ // recursively set the indent level of the decendents
+ public void setLevel(int level) {
+ this.level = level;
+ for (HelpBlock child : children) {
+ child.setLevel(level + 1);
+ }
+ }
+
+ @Override
+ public String toString() {
+ // no indentation, no wrapping
+ return toString(-1);
+ }
+
+ public String toString(int terminalWidth) {
+ StringBuffer builder = new StringBuffer();
+
+ if (data != null) {
+ builder.append(Gfsh.wrapText(data, level, terminalWidth));
+ builder.append(GfshParser.LINE_SEPARATOR);
+ }
+ for (HelpBlock child : children) {
+ builder.append(child.toString(terminalWidth));
+ }
+ return builder.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/geode/blob/63ffe764/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/Helper.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/Helper.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/Helper.java
new file mode 100644
index 0000000..fe2dc7d
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/Helper.java
@@ -0,0 +1,345 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You 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. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.management.internal.cli.help;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.geode.management.cli.CliMetaData;
+import org.apache.geode.management.internal.cli.GfshParser;
+import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.springframework.shell.core.MethodTarget;
+import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+/**
+ *
+ *
+ * @since GemFire 7.0
+ */
+public class Helper {
+
+ static final String NAME_NAME = "NAME";
+ static final String SYNONYMS_NAME = "SYNONYMS";
+ static final String SYNOPSIS_NAME = "SYNOPSIS";
+ static final String SYNTAX_NAME = "SYNTAX";
+ static final String OPTIONS_NAME = "PARAMETERS";
+ static final String IS_AVAILABLE_NAME = "IS AVAILABLE";
+
+ static final String REQUIRED_SUB_NAME = "Required: ";
+ static final String SYNONYMS_SUB_NAME = "Synonyms: ";
+ static final String SPECIFIEDDEFAULTVALUE_SUB_NAME =
+ "Default (if the parameter is specified without value): ";
+ static final String UNSPECIFIEDDEFAULTVALUE_VALUE_SUB_NAME =
+ "Default (if the parameter is not specified): ";
+
+ static final String VALUE_FIELD = "value";
+ static final String TRUE_TOKEN = "true";
+ static final String FALSE_TOKEN = "false";
+
+ private final Map<String, Topic> topics = new HashMap<>();
+ private final Map<String, Method> commands = new TreeMap<String, Method>();
+ private final Map<String, MethodTarget> availabilityIndicators =
+ new HashMap<String, MethodTarget>();
+
+ public Helper() {
+ initTopic(CliStrings.DEFAULT_TOPIC_GEODE, CliStrings.DEFAULT_TOPIC_GEODE__DESC);
+ initTopic(CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_REGION__DESC);
+ initTopic(CliStrings.TOPIC_GEODE_WAN, CliStrings.TOPIC_GEODE_WAN__DESC);
+ initTopic(CliStrings.TOPIC_GEODE_JMX, CliStrings.TOPIC_GEODE_JMX__DESC);
+ initTopic(CliStrings.TOPIC_GEODE_DISKSTORE, CliStrings.TOPIC_GEODE_DISKSTORE__DESC);
+ initTopic(CliStrings.TOPIC_GEODE_LOCATOR, CliStrings.TOPIC_GEODE_LOCATOR__DESC);
+ initTopic(CliStrings.TOPIC_GEODE_SERVER, CliStrings.TOPIC_GEODE_SERVER__DESC);
+ initTopic(CliStrings.TOPIC_GEODE_MANAGER, CliStrings.TOPIC_GEODE_MANAGER__DESC);
+ initTopic(CliStrings.TOPIC_GEODE_STATISTICS, CliStrings.TOPIC_GEODE_STATISTICS__DESC);
+ initTopic(CliStrings.TOPIC_GEODE_LIFECYCLE, CliStrings.TOPIC_GEODE_LIFECYCLE__DESC);
+ initTopic(CliStrings.TOPIC_GEODE_M_AND_M, CliStrings.TOPIC_GEODE_M_AND_M__DESC);
+ initTopic(CliStrings.TOPIC_GEODE_DATA, CliStrings.TOPIC_GEODE_DATA__DESC);
+ initTopic(CliStrings.TOPIC_GEODE_CONFIG, CliStrings.TOPIC_GEODE_CONFIG__DESC);
+ initTopic(CliStrings.TOPIC_GEODE_FUNCTION, CliStrings.TOPIC_GEODE_FUNCTION__DESC);
+ initTopic(CliStrings.TOPIC_GEODE_HELP, CliStrings.TOPIC_GEODE_HELP__DESC);
+ initTopic(CliStrings.TOPIC_GEODE_DEBUG_UTIL, CliStrings.TOPIC_GEODE_DEBUG_UTIL__DESC);
+ initTopic(CliStrings.TOPIC_GFSH, CliStrings.TOPIC_GFSH__DESC);
+ initTopic(CliStrings.TOPIC_LOGS, CliStrings.TOPIC_LOGS__DESC);
+ initTopic(CliStrings.TOPIC_CLIENT, CliStrings.TOPIC_CLIENT__DESC);
+ }
+
+ private void initTopic(String topic, String desc) {
+ topics.put(topic, new Topic(topic, desc));
+ }
+
+ public void addCommand(CliCommand command, Method commandMethod) {
+ // put all the command synonyms in the command map
+ Arrays.stream(command.value()).forEach(cmd -> {
+ commands.put(cmd, commandMethod);
+ });
+
+ // resolve the hint message for each method
+ CliMetaData cliMetaData = commandMethod.getDeclaredAnnotation(CliMetaData.class);
+ if (cliMetaData == null)
+ return;
+ String[] related = cliMetaData.relatedTopic();
+
+ // for hint message, we only need to show the first synonym
+ String commandString = command.value()[0];
+ if (related == null) {
+ return;
+ }
+ Arrays.stream(related).forEach(topic -> {
+ Topic foundTopic = topics.get(topic);
+ if (foundTopic == null) {
+ throw new IllegalArgumentException("No such topic found in the initial map: " + topic);
+ }
+ foundTopic.addRelatedCommand(commandString, command.help());
+ });
+ }
+
+ public void addAvailabilityIndicator(CliAvailabilityIndicator availability, MethodTarget target) {
+ Arrays.stream(availability.value()).forEach(command -> {
+ availabilityIndicators.put(command, target);
+ });
+ }
+
+ public String getHelp(String buffer, int terminalWidth) {
+ Method method = commands.get(buffer);
+ if (method == null) {
+ return "no help exists for this command.";
+ }
+ return getHelp(method).toString(terminalWidth);
+ }
+
+ public String getHint(String buffer) {
+ StringBuilder builder = new StringBuilder();
+ // if no topic is provided, return a list of topics
+ if (StringUtils.isBlank(buffer)) {
+ builder.append(CliStrings.HINT__MSG__TOPICS_AVAILABLE).append(GfshParser.LINE_SEPARATOR)
+ .append(GfshParser.LINE_SEPARATOR);
+
+ List<String> sortedTopics = new ArrayList<>(topics.keySet());
+ Collections.sort(sortedTopics);
+ sortedTopics.stream()
+ .forEachOrdered(topic -> builder.append(topic).append(GfshParser.LINE_SEPARATOR));
+ return builder.toString();
+ }
+
+ Topic topic = topics.get(buffer);
+ if (topic == null) {
+ return CliStrings.format(CliStrings.HINT__MSG__UNKNOWN_TOPIC, buffer);
+ }
+
+ builder.append(topic.desc).append(GfshParser.LINE_SEPARATOR).append(GfshParser.LINE_SEPARATOR);
+ Collections.sort(topic.relatedCommands);
+ topic.relatedCommands.stream().forEachOrdered(command -> builder.append(command.command)
+ .append(": ").append(command.desc).append(GfshParser.LINE_SEPARATOR));
+ return builder.toString();
+ }
+
+ private HelpBlock getHelp(Method method) {
+ return getHelp(method.getDeclaredAnnotation(CliCommand.class), method.getParameterAnnotations(),
+ method.getParameterTypes());
+ }
+
+ HelpBlock getHelp(CliCommand cliCommand, Annotation[][] annotations, Class<?>[] parameterTypes) {
+ String commandName = cliCommand.value()[0];
+ HelpBlock root = new HelpBlock();
+ // First we will have the block for NAME of the command
+ HelpBlock name = new HelpBlock(NAME_NAME);
+ name.addChild(new HelpBlock(commandName));
+ root.addChild(name);
+
+ // add the availability flag
+ HelpBlock availability = new HelpBlock(IS_AVAILABLE_NAME);
+ boolean available = true;
+ MethodTarget target = availabilityIndicators.get(commandName);
+ if (target != null) {
+ try {
+ available = (Boolean) target.getMethod().invoke(target.getTarget());
+ } catch (Exception e) {
+ }
+ }
+ availability.addChild(new HelpBlock(available + ""));
+ root.addChild(availability);
+
+ // Now add synonyms if any
+ String[] allNames = cliCommand.value();
+ if (allNames.length > 1) {
+ HelpBlock synonyms = new HelpBlock(SYNONYMS_NAME);
+ for (int i = 1; i < allNames.length; i++) {
+ synonyms.addChild(new HelpBlock(allNames[i]));
+ }
+ root.addChild(synonyms);
+ }
+
+ // Now comes the turn to display synopsis if any
+ if (!StringUtils.isBlank(cliCommand.help())) {
+ HelpBlock synopsis = new HelpBlock(SYNOPSIS_NAME);
+ synopsis.addChild(new HelpBlock(cliCommand.help()));
+ root.addChild(synopsis);
+ }
+
+ // Now display the syntax for the command
+ HelpBlock syntaxBlock = new HelpBlock(SYNTAX_NAME);
+ String syntax = getSyntaxString(commandName, annotations, parameterTypes);
+ syntaxBlock.addChild(new HelpBlock(syntax));
+ root.addChild(syntaxBlock);
+
+ // Detailed description of all the Options
+ if (annotations.length > 0) {
+ HelpBlock options = new HelpBlock(OPTIONS_NAME);
+ for (int i = 0; i < annotations.length; i++) {
+ CliOption cliOption = getAnnotation(annotations[i], CliOption.class);
+ HelpBlock optionNode = getOptionDetail(cliOption);
+ options.addChild(optionNode);
+ }
+ root.addChild(options);
+ }
+ return root;
+ }
+
+ HelpBlock getOptionDetail(CliOption cliOption) {
+ HelpBlock optionNode = new HelpBlock(getPrimaryKey(cliOption));
+ String help = cliOption.help();
+ optionNode.addChild(new HelpBlock((!StringUtils.isBlank(help) ? help : "")));
+ if (getSynonyms(cliOption).size() > 0) {
+ StringBuilder builder = new StringBuilder();
+ for (String string : getSynonyms(cliOption)) {
+ if (builder.length() > 0) {
+ builder.append(",");
+ }
+ builder.append(string);
+ }
+ optionNode.addChild(new HelpBlock(SYNONYMS_SUB_NAME + builder.toString()));
+ }
+ optionNode.addChild(
+ new HelpBlock(REQUIRED_SUB_NAME + ((cliOption.mandatory()) ? TRUE_TOKEN : FALSE_TOKEN)));
+ if (!isNullOrBlank(cliOption.specifiedDefaultValue())) {
+ optionNode.addChild(
+ new HelpBlock(SPECIFIEDDEFAULTVALUE_SUB_NAME + cliOption.specifiedDefaultValue()));
+ }
+ if (!isNullOrBlank(cliOption.unspecifiedDefaultValue())) {
+ optionNode.addChild(new HelpBlock(
+ UNSPECIFIEDDEFAULTVALUE_VALUE_SUB_NAME + cliOption.unspecifiedDefaultValue()));
+ }
+ return optionNode;
+ }
+
+ private <T> T getAnnotation(Annotation[] annotations, Class<?> klass) {
+ for (Annotation annotation : annotations) {
+ if (klass.isAssignableFrom(annotation.getClass())) {
+ return (T) annotation;
+ }
+ }
+ return null;
+ }
+
+ String getSyntaxString(String commandName, Annotation[][] annotations, Class[] parameterTypes) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(commandName);
+ for (int i = 0; i < annotations.length; i++) {
+ CliOption cliOption = getAnnotation(annotations[i], CliOption.class);
+ String optionString = getOptionString(cliOption, parameterTypes[i]);
+ if (cliOption.mandatory()) {
+ buffer.append(" ").append(optionString);
+ } else {
+ buffer.append(" [").append(optionString).append("]");
+ }
+ }
+ return buffer.toString();
+ }
+
+ /**
+ * this builds the following format of strings: key (as in sh and help) --key=value --key(=value)?
+ * (if has specifiedDefaultValue) --key=value(,value)* (if the value is a list)
+ *
+ * @return option string
+ */
+ private static String getOptionString(CliOption cliOption, Class<?> optionType) {
+ String key0 = cliOption.key()[0];
+ if ("".equals(key0)) {
+ return (cliOption.key()[1]);
+ }
+
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(GfshParser.LONG_OPTION_SPECIFIER).append(key0);
+
+ boolean hasSpecifiedDefault = !isNullOrBlank(cliOption.specifiedDefaultValue());
+
+ if (hasSpecifiedDefault) {
+ buffer.append("(");
+ }
+
+ buffer.append(GfshParser.OPTION_VALUE_SPECIFIER).append(VALUE_FIELD);
+
+ if (hasSpecifiedDefault) {
+ buffer.append(")?");
+ }
+
+ if (isCollectionOrArrayType(optionType)) {
+ buffer.append("(").append(",").append(VALUE_FIELD).append(")*");
+ }
+
+ return buffer.toString();
+ }
+
+ private static boolean isCollectionOrArrayType(Class<?> typeToCheck) {
+ return typeToCheck != null
+ && (typeToCheck.isArray() || Collection.class.isAssignableFrom(typeToCheck));
+ }
+
+ private static String getPrimaryKey(CliOption option) {
+ String[] keys = option.key();
+ if (keys.length == 0) {
+ throw new RuntimeException("Invalid option keys");
+ } else if ("".equals(keys[0])) {
+ return keys[1];
+ } else {
+ return keys[0];
+ }
+ }
+
+ private static List<String> getSynonyms(CliOption option) {
+ List<String> synonyms = new ArrayList<>();
+ String[] keys = option.key();
+ if (keys.length < 2)
+ return synonyms;
+ // if the primary key is empty (like sh and help command), then there should be no synonyms.
+ if ("".equals(keys[0]))
+ return synonyms;
+
+ for (int i = 1; i < keys.length; i++) {
+ synonyms.add(keys[i]);
+ }
+ return synonyms;
+ }
+
+ private static boolean isNullOrBlank(String value) {
+ return StringUtils.isBlank(value) || CliMetaData.ANNOTATION_NULL_VALUE.equals(value);
+ }
+
+ public Set<String> getCommands() {
+ return commands.keySet();
+ }
+}
http://git-wip-us.apache.org/repos/asf/geode/blob/63ffe764/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/Topic.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/Topic.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/Topic.java
new file mode 100644
index 0000000..3ea896c
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/Topic.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You 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. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package org.apache.geode.management.internal.cli.help;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Topic implements Comparable<Topic> {
+ String topic;
+ String desc;
+ List<Command> relatedCommands = new ArrayList<>();
+
+ public Topic(String topic, String desc) {
+ this.topic = topic;
+ this.desc = desc;
+ }
+
+ public void addRelatedCommand(String command, String desc) {
+ relatedCommands.add(new Command(command, desc));
+ }
+
+ @Override
+ public int compareTo(Topic o) {
+ return topic.compareTo(o.topic);
+ }
+
+ public class Command implements Comparable<Command> {
+ String command;
+ String desc;
+
+ public Command(String command, String desc) {
+ this.command = command;
+ this.desc = desc;
+ }
+
+ @Override
+ public int compareTo(Command o) {
+ return this.command.compareTo(o.command);
+ }
+ }
+
+
+}
+
+
http://git-wip-us.apache.org/repos/asf/geode/blob/63ffe764/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/format/Block.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/format/Block.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/format/Block.java
deleted file mode 100644
index dde1a20..0000000
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/format/Block.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You 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. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.management.internal.cli.help.format;
-
-/**
- *
- */
-public class Block {
- private String heading;
- private Row[] rows;
-
- public String getHeading() {
- return heading;
- }
-
- public Block setHeading(String heading) {
- this.heading = heading;
- return this;
- }
-
- public Row[] getRows() {
- return rows;
- }
-
- public Block setRows(Row[] rows) {
- this.rows = rows;
- return this;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/geode/blob/63ffe764/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/format/DataNode.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/format/DataNode.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/format/DataNode.java
deleted file mode 100644
index 8f5e570..0000000
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/format/DataNode.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You 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. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.management.internal.cli.help.format;
-
-import java.util.List;
-
-/**
- *
- */
-public class DataNode {
- String data;
- List<DataNode> children;
-
- public DataNode(String data, List<DataNode> dataNode) {
- this.data = data;
- this.children = dataNode;
- }
-
- public String getData() {
- return data;
- }
-
- public List<DataNode> getChildren() {
- return children;
- }
-
- public boolean addChild(DataNode dataNode) {
- if (this.children != null) {
- this.children.add(dataNode);
- return true;
- } else {
- return false;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/geode/blob/63ffe764/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/format/Help.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/format/Help.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/format/Help.java
deleted file mode 100644
index 68c10bb..0000000
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/format/Help.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You 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. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.management.internal.cli.help.format;
-
-/**
- *
- */
-public class Help {
- private Block[] blocks;
-
- public Block[] getBlocks() {
- return blocks;
- }
-
- public Help setBlocks(Block[] block) {
- this.blocks = block;
- return this;
- }
-
- @Override
- public String toString() {
- StringBuffer buffer = new StringBuffer();
- for (Block block : blocks) {
- buffer.append(block.getHeading() + "\n");
- for (Row row : block.getRows()) {
- buffer.append("\t" + row.getInfo()[0] + "\n");
- }
- buffer.append("\n");
- }
- return buffer.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/geode/blob/63ffe764/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/format/NewHelp.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/format/NewHelp.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/format/NewHelp.java
deleted file mode 100644
index 90f9eda..0000000
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/format/NewHelp.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You 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. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.management.internal.cli.help.format;
-
-import org.apache.geode.management.internal.cli.GfshParser;
-import org.apache.geode.management.internal.cli.shell.Gfsh;
-
-/**
- *
- * @since GemFire 7.0
- */
-public class NewHelp {
- DataNode root;
-
- public NewHelp(DataNode root) {
- this.root = root;
- }
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- append(builder, root, 0);
- return builder.toString();
- }
-
- private void append(StringBuilder builder, DataNode dataNode, int level) {
- if (dataNode != null && builder != null) {
- String data = dataNode.getData();
- if (data != null && !data.equals("")) {
- builder.append(Gfsh.wrapText(data, level - 1));
- builder.append(GfshParser.LINE_SEPARATOR);
- }
- if (dataNode.getChildren() != null && dataNode.getChildren().size() > 0) {
- for (DataNode child : dataNode.getChildren()) {
- append(builder, child, level + 1);
- }
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/geode/blob/63ffe764/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/format/Row.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/format/Row.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/format/Row.java
deleted file mode 100644
index ac1ca21..0000000
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/format/Row.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You 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. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.management.internal.cli.help.format;
-
-public class Row {
- private String[] info;
-
- public String[] getInfo() {
- return info;
- }
-
- public Row setInfo(String[] info) {
- this.info = info;
- return this;
- }
-}