You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ji...@apache.org on 2016/12/06 16:43:25 UTC
[5/7] geode git commit: GEODE-1912: use Spring shell's parser and
delete our own parsing code
http://git-wip-us.apache.org/repos/asf/geode/blob/ce9e138c/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java
index 09d0a67..5484f40 100755
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java
@@ -1333,6 +1333,9 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
@CliMetaData(shellOnly = true,
relatedTopic = {CliStrings.TOPIC_GEODE_SERVER, CliStrings.TOPIC_GEODE_LIFECYCLE})
public Result startServer(
+ @CliOption(key = CliStrings.START_SERVER__NAME, mandatory = true,
+ unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
+ help = CliStrings.START_SERVER__NAME__HELP) final String memberName,
@CliOption(key = CliStrings.START_SERVER__ASSIGN_BUCKETS, unspecifiedDefaultValue = "false",
specifiedDefaultValue = "true",
help = CliStrings.START_SERVER__ASSIGN_BUCKETS__HELP) final Boolean assignBuckets,
@@ -1444,9 +1447,6 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
@CliOption(key = CliStrings.START_SERVER__MESSAGE__TIME__TO__LIVE,
unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__MESSAGE__TIME__TO__LIVE__HELP) final Integer messageTimeToLive,
- @CliOption(key = CliStrings.START_SERVER__NAME, mandatory = true,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
- help = CliStrings.START_SERVER__NAME__HELP) final String memberName,
@CliOption(key = CliStrings.START_SERVER__OFF_HEAP_MEMORY_SIZE,
unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__OFF_HEAP_MEMORY_SIZE__HELP) final String offHeapMemorySize,
http://git-wip-us.apache.org/repos/asf/geode/blob/ce9e138c/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShellCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShellCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShellCommands.java
index 2677464..54a0a95 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShellCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShellCommands.java
@@ -15,40 +15,10 @@
package org.apache.geode.management.internal.cli.commands;
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Writer;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.security.KeyStore;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Properties;
-import java.util.Set;
-
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManagerFactory;
-
-import org.springframework.shell.core.CommandMarker;
-import org.springframework.shell.core.ExitShellRequest;
-import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
+import static org.apache.geode.distributed.ConfigurationProperties.CLUSTER_SSL_CIPHERS;
+import static org.apache.geode.distributed.ConfigurationProperties.CLUSTER_SSL_PROTOCOLS;
+import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
+import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
import org.apache.geode.distributed.internal.DistributionConfig;
import org.apache.geode.internal.ClassPathLoader;
@@ -67,7 +37,6 @@ import org.apache.geode.management.internal.SSLUtil;
import org.apache.geode.management.internal.cli.CliUtil;
import org.apache.geode.management.internal.cli.GfshParser;
import org.apache.geode.management.internal.cli.LogWrapper;
-import org.apache.geode.management.internal.cli.annotation.CliArgument;
import org.apache.geode.management.internal.cli.converters.ConnectionEndpointConverter;
import org.apache.geode.management.internal.cli.domain.ConnectToLocatorResult;
import org.apache.geode.management.internal.cli.i18n.CliStrings;
@@ -85,6 +54,37 @@ import org.apache.geode.management.internal.web.http.support.SimpleHttpRequester
import org.apache.geode.management.internal.web.shell.HttpOperationInvoker;
import org.apache.geode.management.internal.web.shell.RestHttpOperationInvoker;
import org.apache.geode.security.AuthenticationFailedException;
+import org.springframework.shell.core.CommandMarker;
+import org.springframework.shell.core.ExitShellRequest;
+import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Writer;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.KeyStore;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Properties;
+import java.util.Set;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManagerFactory;
/**
*
@@ -92,6 +92,158 @@ import org.apache.geode.security.AuthenticationFailedException;
*/
public class ShellCommands implements CommandMarker {
+ // millis that connect --locator will wait for a response from the locator.
+ private final static int CONNECT_LOCATOR_TIMEOUT_MS = 60000; // see bug 45971
+
+ public static int getConnectLocatorTimeoutInMS() {
+ return ShellCommands.CONNECT_LOCATOR_TIMEOUT_MS;
+ }
+
+ private static String getGfshLogsCheckMessage(String logFilePath) {
+ return CliStrings.format(CliStrings.GFSH__PLEASE_CHECK_LOGS_AT_0, logFilePath);
+ }
+
+ /* package-private */
+ static Map<String, String> loadPropertiesFromURL(URL gfSecurityPropertiesUrl) {
+ Map<String, String> propsMap = Collections.emptyMap();
+
+ if (gfSecurityPropertiesUrl != null) {
+ InputStream inputStream = null;
+ try {
+ Properties props = new Properties();
+ inputStream = gfSecurityPropertiesUrl.openStream();
+ props.load(inputStream);
+ if (!props.isEmpty()) {
+ Set<String> jmxSpecificProps = new HashSet<String>();
+ propsMap = new LinkedHashMap<String, String>();
+ Set<Entry<Object, Object>> entrySet = props.entrySet();
+ for (Entry<Object, Object> entry : entrySet) {
+
+ String key = (String) entry.getKey();
+ if (key.endsWith(DistributionConfig.JMX_SSL_PROPS_SUFFIX)) {
+ key =
+ key.substring(0, key.length() - DistributionConfig.JMX_SSL_PROPS_SUFFIX.length());
+ jmxSpecificProps.add(key);
+
+ propsMap.put(key, (String) entry.getValue());
+ } else if (!jmxSpecificProps.contains(key)) {// Prefer properties ending with "-jmx"
+ // over default SSL props.
+ propsMap.put(key, (String) entry.getValue());
+ }
+ }
+ props.clear();
+ jmxSpecificProps.clear();
+ }
+ } catch (IOException io) {
+ throw new RuntimeException(
+ CliStrings.format(CliStrings.CONNECT__MSG__COULD_NOT_READ_CONFIG_FROM_0,
+ CliUtil.decodeWithDefaultCharSet(gfSecurityPropertiesUrl.getPath())),
+ io);
+ } finally {
+ IOUtils.close(inputStream);
+ }
+ }
+ return propsMap;
+ }
+
+ // Copied from DistributedSystem.java
+ public static URL getFileUrl(String fileName) {
+ File file = new File(fileName);
+
+ if (file.exists()) {
+ try {
+ return IOUtils.tryGetCanonicalFileElseGetAbsoluteFile(file).toURI().toURL();
+ } catch (MalformedURLException ignore) {
+ }
+ }
+
+ file = new File(System.getProperty("user.home"), fileName);
+
+ if (file.exists()) {
+ try {
+ return IOUtils.tryGetCanonicalFileElseGetAbsoluteFile(file).toURI().toURL();
+ } catch (MalformedURLException ignore) {
+ }
+ }
+
+ return ClassPathLoader.getLatest().getResource(ShellCommands.class, fileName);
+ }
+
+ public static ConnectToLocatorResult connectToLocator(String host, int port, int timeout,
+ Map<String, String> props) throws IOException {
+ // register DSFID types first; invoked explicitly so that all message type
+ // initializations do not happen in first deserialization on a possibly
+ // "precious" thread
+ DSFIDFactory.registerTypes();
+
+ JmxManagerLocatorResponse locatorResponse =
+ JmxManagerLocatorRequest.send(host, port, timeout, props);
+
+ if (StringUtils.isBlank(locatorResponse.getHost()) || locatorResponse.getPort() == 0) {
+ Throwable locatorResponseException = locatorResponse.getException();
+ String exceptionMessage = CliStrings.CONNECT__MSG__LOCATOR_COULD_NOT_FIND_MANAGER;
+
+ if (locatorResponseException != null) {
+ String locatorResponseExceptionMessage = locatorResponseException.getMessage();
+ locatorResponseExceptionMessage = (!StringUtils.isBlank(locatorResponseExceptionMessage)
+ ? locatorResponseExceptionMessage : locatorResponseException.toString());
+ exceptionMessage = "Exception caused JMX Manager startup to fail because: '"
+ .concat(locatorResponseExceptionMessage).concat("'");
+ }
+
+ throw new IllegalStateException(exceptionMessage, locatorResponseException);
+ }
+
+ ConnectionEndpoint memberEndpoint =
+ new ConnectionEndpoint(locatorResponse.getHost(), locatorResponse.getPort());
+
+ String resultMessage = CliStrings.format(CliStrings.CONNECT__MSG__CONNECTING_TO_MANAGER_AT_0,
+ memberEndpoint.toString(false));
+
+ return new ConnectToLocatorResult(memberEndpoint, resultMessage,
+ locatorResponse.isJmxManagerSslEnabled());
+ }
+
+ private static InfoResultData executeCommand(Gfsh gfsh, String userCommand, boolean useConsole)
+ throws IOException {
+ InfoResultData infoResultData = ResultBuilder.createInfoResultData();
+
+ String cmdToExecute = userCommand;
+ String cmdExecutor = "/bin/sh";
+ String cmdExecutorOpt = "-c";
+ if (SystemUtils.isWindows()) {
+ cmdExecutor = "cmd";
+ cmdExecutorOpt = "/c";
+ } else if (useConsole) {
+ cmdToExecute = cmdToExecute + " </dev/tty >/dev/tty";
+ }
+ String[] commandArray = {cmdExecutor, cmdExecutorOpt, cmdToExecute};
+
+ ProcessBuilder builder = new ProcessBuilder();
+ builder.command(commandArray);
+ builder.directory();
+ builder.redirectErrorStream();
+ Process proc = builder.start();
+
+ BufferedReader input = new BufferedReader(new InputStreamReader(proc.getInputStream()));
+
+ String lineRead = "";
+ while ((lineRead = input.readLine()) != null) {
+ infoResultData.addLine(lineRead);
+ }
+
+ proc.getOutputStream().close();
+
+ try {
+ if (proc.waitFor() != 0) {
+ gfsh.logWarning("The command '" + userCommand + "' did not complete successfully", null);
+ }
+ } catch (final InterruptedException e) {
+ throw new IllegalStateException(e);
+ }
+ return infoResultData;
+ }
+
private Gfsh getGfsh() {
return Gfsh.getCurrentInstance();
}
@@ -112,13 +264,6 @@ public class ShellCommands implements CommandMarker {
return exitShellRequest;
}
- // millis that connect --locator will wait for a response from the locator.
- private final static int CONNECT_LOCATOR_TIMEOUT_MS = 60000; // see bug 45971
-
- public static int getConnectLocatorTimeoutInMS() {
- return ShellCommands.CONNECT_LOCATOR_TIMEOUT_MS;
- }
-
@CliCommand(value = {CliStrings.CONNECT}, help = CliStrings.CONNECT__HELP)
@CliMetaData(shellOnly = true, relatedTopic = {CliStrings.TOPIC_GFSH, CliStrings.TOPIC_GEODE_JMX,
CliStrings.TOPIC_GEODE_MANAGER})
@@ -212,7 +357,6 @@ public class ShellCommands implements CommandMarker {
return result;
}
-
private Result httpConnect(Map<String, String> sslConfigProps, boolean useSsl, String url,
String userName, String passwordToUse) {
Gfsh gfsh = getGfsh();
@@ -389,7 +533,6 @@ public class ShellCommands implements CommandMarker {
return ResultBuilder.createConnectionErrorResult(errorMessage);
}
-
private String decrypt(String password) {
if (password != null) {
return PasswordUtil.decrypt(password);
@@ -579,112 +722,6 @@ public class ShellCommands implements CommandMarker {
return sslConfigProps;
}
- private static String getGfshLogsCheckMessage(String logFilePath) {
- return CliStrings.format(CliStrings.GFSH__PLEASE_CHECK_LOGS_AT_0, logFilePath);
- }
-
- /* package-private */
- static Map<String, String> loadPropertiesFromURL(URL gfSecurityPropertiesUrl) {
- Map<String, String> propsMap = Collections.emptyMap();
-
- if (gfSecurityPropertiesUrl != null) {
- InputStream inputStream = null;
- try {
- Properties props = new Properties();
- inputStream = gfSecurityPropertiesUrl.openStream();
- props.load(inputStream);
- if (!props.isEmpty()) {
- Set<String> jmxSpecificProps = new HashSet<String>();
- propsMap = new LinkedHashMap<String, String>();
- Set<Entry<Object, Object>> entrySet = props.entrySet();
- for (Entry<Object, Object> entry : entrySet) {
-
- String key = (String) entry.getKey();
- if (key.endsWith(DistributionConfig.JMX_SSL_PROPS_SUFFIX)) {
- key =
- key.substring(0, key.length() - DistributionConfig.JMX_SSL_PROPS_SUFFIX.length());
- jmxSpecificProps.add(key);
-
- propsMap.put(key, (String) entry.getValue());
- } else if (!jmxSpecificProps.contains(key)) {// Prefer properties ending with "-jmx"
- // over default SSL props.
- propsMap.put(key, (String) entry.getValue());
- }
- }
- props.clear();
- jmxSpecificProps.clear();
- }
- } catch (IOException io) {
- throw new RuntimeException(
- CliStrings.format(CliStrings.CONNECT__MSG__COULD_NOT_READ_CONFIG_FROM_0,
- CliUtil.decodeWithDefaultCharSet(gfSecurityPropertiesUrl.getPath())),
- io);
- } finally {
- IOUtils.close(inputStream);
- }
- }
- return propsMap;
- }
-
- // Copied from DistributedSystem.java
- public static URL getFileUrl(String fileName) {
- File file = new File(fileName);
-
- if (file.exists()) {
- try {
- return IOUtils.tryGetCanonicalFileElseGetAbsoluteFile(file).toURI().toURL();
- } catch (MalformedURLException ignore) {
- }
- }
-
- file = new File(System.getProperty("user.home"), fileName);
-
- if (file.exists()) {
- try {
- return IOUtils.tryGetCanonicalFileElseGetAbsoluteFile(file).toURI().toURL();
- } catch (MalformedURLException ignore) {
- }
- }
-
- return ClassPathLoader.getLatest().getResource(ShellCommands.class, fileName);
- }
-
- public static ConnectToLocatorResult connectToLocator(String host, int port, int timeout,
- Map<String, String> props) throws IOException {
- // register DSFID types first; invoked explicitly so that all message type
- // initializations do not happen in first deserialization on a possibly
- // "precious" thread
- DSFIDFactory.registerTypes();
-
- JmxManagerLocatorResponse locatorResponse =
- JmxManagerLocatorRequest.send(host, port, timeout, props);
-
- if (StringUtils.isBlank(locatorResponse.getHost()) || locatorResponse.getPort() == 0) {
- Throwable locatorResponseException = locatorResponse.getException();
- String exceptionMessage = CliStrings.CONNECT__MSG__LOCATOR_COULD_NOT_FIND_MANAGER;
-
- if (locatorResponseException != null) {
- String locatorResponseExceptionMessage = locatorResponseException.getMessage();
- locatorResponseExceptionMessage = (!StringUtils.isBlank(locatorResponseExceptionMessage)
- ? locatorResponseExceptionMessage : locatorResponseException.toString());
- exceptionMessage = "Exception caused JMX Manager startup to fail because: '"
- .concat(locatorResponseExceptionMessage).concat("'");
- }
-
- throw new IllegalStateException(exceptionMessage, locatorResponseException);
- }
-
- ConnectionEndpoint memberEndpoint =
- new ConnectionEndpoint(locatorResponse.getHost(), locatorResponse.getPort());
-
- String resultMessage = CliStrings.format(CliStrings.CONNECT__MSG__CONNECTING_TO_MANAGER_AT_0,
- memberEndpoint.toString(false));
-
- return new ConnectToLocatorResult(memberEndpoint, resultMessage,
- locatorResponse.isJmxManagerSslEnabled());
- }
-
-
@CliCommand(value = {CliStrings.DISCONNECT}, help = CliStrings.DISCONNECT__HELP)
@CliMetaData(shellOnly = true, relatedTopic = {CliStrings.TOPIC_GFSH, CliStrings.TOPIC_GEODE_JMX,
CliStrings.TOPIC_GEODE_MANAGER})
@@ -720,7 +757,6 @@ public class ShellCommands implements CommandMarker {
return result;
}
-
@CliCommand(value = {CliStrings.DESCRIBE_CONNECTION}, help = CliStrings.DESCRIBE_CONNECTION__HELP)
@CliMetaData(shellOnly = true, relatedTopic = {CliStrings.TOPIC_GFSH, CliStrings.TOPIC_GEODE_JMX})
public Result describeConnection() {
@@ -745,7 +781,6 @@ public class ShellCommands implements CommandMarker {
return result;
}
-
@CliCommand(value = {CliStrings.ECHO}, help = CliStrings.ECHO__HELP)
@CliMetaData(shellOnly = true, relatedTopic = {CliStrings.TOPIC_GFSH})
public Result echo(@CliOption(key = {CliStrings.ECHO__STR, ""},
@@ -779,6 +814,21 @@ public class ShellCommands implements CommandMarker {
return resultData;
}
+ // Enable when "use region" command is required. See #46110
+ // @CliCommand(value = { CliStrings.USE_REGION }, help = CliStrings.USE_REGION__HELP)
+ // @CliMetaData(shellOnly = true, relatedTopic = {CliStrings.TOPIC_GFSH,
+ // CliStrings.TOPIC_GEODE_REGION})
+ // public Result useRegion(
+ // @CliArgument(name = CliStrings.USE_REGION__REGION,
+ // unspecifiedDefaultValue = "/",
+ // argumentContext = CliStrings.PARAM_CONTEXT_REGIONPATH,
+ // help = CliStrings.USE_REGION__REGION__HELP)
+ // String toRegion) {
+ // Gfsh gfsh = Gfsh.getCurrentInstance();
+ //
+ // gfsh.setPromptPath(toRegion);
+ // return ResultBuilder.createInfoResult("");
+ // }
@CliCommand(value = {CliStrings.SET_VARIABLE}, help = CliStrings.SET_VARIABLE__HELP)
@CliMetaData(shellOnly = true, relatedTopic = {CliStrings.TOPIC_GFSH})
@@ -801,22 +851,6 @@ public class ShellCommands implements CommandMarker {
return result;
}
- // Enable when "use region" command is required. See #46110
- // @CliCommand(value = { CliStrings.USE_REGION }, help = CliStrings.USE_REGION__HELP)
- // @CliMetaData(shellOnly = true, relatedTopic = {CliStrings.TOPIC_GFSH,
- // CliStrings.TOPIC_GEODE_REGION})
- // public Result useRegion(
- // @CliArgument(name = CliStrings.USE_REGION__REGION,
- // unspecifiedDefaultValue = "/",
- // argumentContext = CliStrings.PARAM_CONTEXT_REGIONPATH,
- // help = CliStrings.USE_REGION__REGION__HELP)
- // String toRegion) {
- // Gfsh gfsh = Gfsh.getCurrentInstance();
- //
- // gfsh.setPromptPath(toRegion);
- // return ResultBuilder.createInfoResult("");
- // }
-
@CliCommand(value = {CliStrings.DEBUG}, help = CliStrings.DEBUG__HELP)
@CliMetaData(shellOnly = true,
relatedTopic = {CliStrings.TOPIC_GFSH, CliStrings.TOPIC_GEODE_DEBUG_UTIL})
@@ -870,8 +904,7 @@ public class ShellCommands implements CommandMarker {
GfshHistory gfshHistory = gfsh.getGfshHistory();
Iterator<?> it = gfshHistory.entries();
- boolean flagForLineNumbers =
- (saveHistoryTo != null && saveHistoryTo.length() > 0) ? false : true;
+ boolean flagForLineNumbers = !(saveHistoryTo != null && saveHistoryTo.length() > 0);
long lineNumber = 0;
while (it.hasNext()) {
@@ -951,7 +984,6 @@ public class ShellCommands implements CommandMarker {
}
-
@CliCommand(value = {CliStrings.RUN}, help = CliStrings.RUN__HELP)
@CliMetaData(shellOnly = true, relatedTopic = {CliStrings.TOPIC_GFSH})
public Result executeScript(
@@ -974,7 +1006,6 @@ public class ShellCommands implements CommandMarker {
return result;
}
-
@CliCommand(value = CliStrings.ENCRYPT, help = CliStrings.ENCRYPT__HELP)
@CliMetaData(shellOnly = true, relatedTopic = {CliStrings.TOPIC_GEODE_DEBUG_UTIL})
public Result encryptPassword(@CliOption(key = CliStrings.ENCRYPT_STRING,
@@ -1006,7 +1037,7 @@ public class ShellCommands implements CommandMarker {
@CliCommand(value = {CliStrings.SH}, help = CliStrings.SH__HELP)
@CliMetaData(shellOnly = true, relatedTopic = {CliStrings.TOPIC_GFSH})
public Result sh(
- @CliArgument(name = CliStrings.SH__COMMAND, mandatory = true,
+ @CliOption(key = {"", CliStrings.SH__COMMAND}, mandatory = true,
help = CliStrings.SH__COMMAND__HELP) String command,
@CliOption(key = CliStrings.SH__USE_CONSOLE, specifiedDefaultValue = "true",
unspecifiedDefaultValue = "false",
@@ -1027,47 +1058,6 @@ public class ShellCommands implements CommandMarker {
return result;
}
- private static InfoResultData executeCommand(Gfsh gfsh, String userCommand, boolean useConsole)
- throws IOException {
- InfoResultData infoResultData = ResultBuilder.createInfoResultData();
-
- String cmdToExecute = userCommand;
- String cmdExecutor = "/bin/sh";
- String cmdExecutorOpt = "-c";
- if (SystemUtils.isWindows()) {
- cmdExecutor = "cmd";
- cmdExecutorOpt = "/c";
- } else if (useConsole) {
- cmdToExecute = cmdToExecute + " </dev/tty >/dev/tty";
- }
- String[] commandArray = {cmdExecutor, cmdExecutorOpt, cmdToExecute};
-
- ProcessBuilder builder = new ProcessBuilder();
- builder.command(commandArray);
- builder.directory();
- builder.redirectErrorStream();
- Process proc = builder.start();
-
- BufferedReader input = new BufferedReader(new InputStreamReader(proc.getInputStream()));
-
- String lineRead = "";
- while ((lineRead = input.readLine()) != null) {
- infoResultData.addLine(lineRead);
- }
-
- proc.getOutputStream().close();
-
- try {
- if (proc.waitFor() != 0) {
- gfsh.logWarning("The command '" + userCommand + "' did not complete successfully", null);
- }
- } catch (final InterruptedException e) {
- throw new IllegalStateException(e);
- }
- return infoResultData;
- }
-
-
@CliAvailabilityIndicator({CliStrings.CONNECT, CliStrings.DISCONNECT,
CliStrings.DESCRIBE_CONNECTION})
public boolean isAvailable() {
http://git-wip-us.apache.org/repos/asf/geode/blob/ce9e138c/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/BooleanConverter.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/BooleanConverter.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/BooleanConverter.java
deleted file mode 100644
index 5e9cdb9..0000000
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/BooleanConverter.java
+++ /dev/null
@@ -1,54 +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;
-
-/**
- * {@link Converter} for {@link Boolean}. Use this BooleanConverter instead of SHL's
- * BooleanConverter. Removed completion & conversion for values like 0, 1, yes, no.
- *
- * @since GemFire 7.0
- */
-public class BooleanConverter implements Converter<Boolean> {
-
- public boolean supports(final Class<?> requiredType, final String optionContext) {
- return Boolean.class.isAssignableFrom(requiredType)
- || boolean.class.isAssignableFrom(requiredType);
- }
-
- public Boolean convertFromText(final String value, final Class<?> requiredType,
- final String optionContext) {
- if ("true".equalsIgnoreCase(value)) {
- return true;
- } else if ("false".equalsIgnoreCase(value)) {
- return false;
- } else {
- throw new IllegalArgumentException("Cannot convert " + value + " to type Boolean.");
- }
- }
-
- public boolean getAllPossibleValues(final List<Completion> completions,
- final Class<?> requiredType, final String existingData, final String optionContext,
- final MethodTarget target) {
- completions.add(new Completion("true"));
- completions.add(new Completion("false"));
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/geode/blob/ce9e138c/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/EnumConverter.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/EnumConverter.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/EnumConverter.java
deleted file mode 100644
index 354cef9..0000000
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/EnumConverter.java
+++ /dev/null
@@ -1,64 +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;
-
-/**
- * {@link Converter} for {@link Enum}.
- *
- * @since GemFire 7.0
- */
-/*
- * Use this EnumConverter instead of SHL's EnumConverter. Added null check for existingData in
- * getAllPossibleValues
- *
- * Original authors: Ben Alex & Alan Stewart
- */
-@SuppressWarnings("all") // Enum parameter warning
-public class EnumConverter implements Converter<Enum> {
-
- public Enum convertFromText(final String value, final Class<?> requiredType,
- final String optionContext) {
- Class<Enum> enumClass = (Class<Enum>) requiredType;
- return Enum.valueOf(enumClass, value);
- }
-
- public boolean getAllPossibleValues(final List<Completion> completions,
- final Class<?> requiredType, final String existingData, final String optionContext,
- final MethodTarget target) {
- Class<Enum> enumClass = (Class<Enum>) requiredType;
- for (Enum enumValue : enumClass.getEnumConstants()) {
- String candidate = enumValue.name();
- // GemFire/gfsh addition - check 'existingData == null'. GfshParser can
- // pass existingData as null
- if ("".equals(existingData) || existingData == null || candidate.startsWith(existingData)
- || existingData.startsWith(candidate)
- || candidate.toUpperCase().startsWith(existingData.toUpperCase())
- || existingData.toUpperCase().startsWith(candidate.toUpperCase())) {
- completions.add(new Completion(candidate));
- }
- }
- return true;
- }
-
- public boolean supports(final Class<?> requiredType, final String optionContext) {
- return Enum.class.isAssignableFrom(requiredType);
- }
-}
http://git-wip-us.apache.org/repos/asf/geode/blob/ce9e138c/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/ce9e138c/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/ce9e138c/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/ce9e138c/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/ce9e138c/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/ce9e138c/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/ce9e138c/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/ce9e138c/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/ce9e138c/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/ce9e138c/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/ce9e138c/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/ce9e138c/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/ce9e138c/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/ce9e138c/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/ce9e138c/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/ce9e138c/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/ce9e138c/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/ce9e138c/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/ce9e138c/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 + "]";
- }
-}