GEODE-3214: Remove support for multistep gfsh commands.
Project: http://git-wip-us.apache.org/repos/asf/geode/repo Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/5eb0b94d Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/5eb0b94d Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/5eb0b94d Branch: refs/heads/feature/GEM-1483 Commit: 5eb0b94da1c1680f23e66e1d1782d34eb3e5ee29 Parents: e502174 Author: Jared Stewart <[email protected]> Authored: Mon Jul 17 11:05:20 2017 -0700 Committer: Jared Stewart <[email protected]> Committed: Mon Jul 24 14:20:34 2017 -0700 ---------------------------------------------------------------------- .../internal/cli/i18n/CliStrings.java | 4 +- .../cli/multistep/CLIMultiStepHelper.java | 389 ------------------- .../internal/cli/multistep/CLIRemoteStep.java | 30 -- .../internal/cli/multistep/CLIStep.java | 31 -- .../cli/multistep/CLIStepExecption.java | 36 -- .../cli/multistep/MultiStepCommand.java | 35 -- .../cli/remote/RemoteExecutionStrategy.java | 26 +- .../cli/shell/GfshExecutionStrategy.java | 25 +- .../support/LoginHandlerInterceptor.java | 26 +- .../internal/web/http/ClientHttpRequest.java | 22 +- 10 files changed, 32 insertions(+), 592 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/geode/blob/5eb0b94d/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java index 5621b24..58c8ef7 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java @@ -1790,12 +1790,10 @@ public class CliStrings { + "\" variable." + " Page size will default to the value stored in the \"" + Gfsh.ENV_APP_COLLECTION_LIMIT + "\" variable."; public static final String QUERY__QUERY = "query"; - public static final String QUERY__STEPNAME = "step-name"; - public static final String QUERY__STEPNAME__DEFAULTVALUE = "ALL"; public static final String QUERY__INTERACTIVE = "interactive"; public static final String QUERY__QUERY__HELP = "The OQL string."; public static final String QUERY__INTERACTIVE__HELP = - "Whether or not this query is interactive. If false then all results will be displayed at once."; + "Deprecated. This option has no effect, but is kept around to maintain backwards compatibility with existing scripts."; public static final String QUERY__MSG__QUERY_EMPTY = "Query is either empty or Null"; public static final String QUERY__MSG__INVALID_QUERY = "Query is invalid due for error : <{0}>"; public static final String QUERY__MSG__REGIONS_NOT_FOUND = http://git-wip-us.apache.org/repos/asf/geode/blob/5eb0b94d/geode-core/src/main/java/org/apache/geode/management/internal/cli/multistep/CLIMultiStepHelper.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/multistep/CLIMultiStepHelper.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/multistep/CLIMultiStepHelper.java deleted file mode 100644 index 4eeb227..0000000 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/multistep/CLIMultiStepHelper.java +++ /dev/null @@ -1,389 +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.multistep; - -import org.apache.geode.LogWriter; -import org.apache.geode.cache.CacheFactory; -import org.apache.geode.management.cli.Result; -import org.apache.geode.management.internal.cli.CommandRequest; -import org.apache.geode.management.internal.cli.GfshParseResult; -import org.apache.geode.management.internal.cli.LogWrapper; -import org.apache.geode.management.internal.cli.json.GfJsonException; -import org.apache.geode.management.internal.cli.json.GfJsonObject; -import org.apache.geode.management.internal.cli.remote.CommandExecutionContext; -import org.apache.geode.management.internal.cli.result.CommandResult; -import org.apache.geode.management.internal.cli.result.CompositeResultData; -import org.apache.geode.management.internal.cli.result.CompositeResultData.SectionResultData; -import org.apache.geode.management.internal.cli.result.ResultBuilder; -import org.apache.geode.management.internal.cli.result.ResultData; -import org.apache.geode.management.internal.cli.result.TabularResultData; -import org.apache.geode.management.internal.cli.shell.Gfsh; -import org.springframework.shell.event.ParseResult; -import org.springframework.util.ReflectionUtils; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Utility class to abstract CompositeResultData for Multi-step commands Also contain execution - * strategy for multi-step commands - * - * - */ -public class CLIMultiStepHelper { - - public static final String STEP_SECTION = "STEP_SECTION"; - public static final String PAGE_SECTION = "PAGE_SECTION"; - public static final String ARG_SECTION = "ARG_SECTION"; - public static final String NEXT_STEP_NAME = "NEXT_STEP_NAME"; - public static final String NEXT_STEP_ARGS = "NEXT_STEP_ARGS"; - public static final String NEXT_STEP_NAMES = "NEXT_STEP_NAMES"; - public static final String STEP_ARGS = "stepArgs"; - public static final int DEFAULT_PAGE_SIZE = 20; - - public static Result execCLISteps(MultiStepCommand msc, LogWrapper logWrapper, Gfsh shell, - ParseResult parseResult) { - CLIStep[] steps = (CLIStep[]) ReflectionUtils.invokeMethod(parseResult.getMethod(), - parseResult.getInstance(), parseResult.getArguments()); - if (steps != null) { - boolean endStepReached = false; - int stepNumber = 0; - CLIStep nextStep = steps[stepNumber]; - Result lastResult = null; - SectionResultData nextStepArgs = null; - while (!endStepReached) { - try { - Result result = executeStep(logWrapper, shell, nextStep, parseResult, nextStepArgs); - String nextStepString = null; - nextStepString = getNextStep(result); - nextStepArgs = extractArgumentsForNextStep(result); - if (!"END".equals(nextStepString)) { - String step = nextStepString; - boolean stepFound = false; - for (CLIStep s : steps) - if (step.equals(s.getName())) { - nextStep = s; - stepFound = true; - } - if (!stepFound) { - return ResultBuilder.buildResult(ResultBuilder.createErrorResultData() - .addLine("Wrong step name returned by previous step : " + step)); - } - } else { - lastResult = result; - endStepReached = true; - } - - } catch (CLIStepExecption e) { - endStepReached = true; - lastResult = e.getResult(); - } - } - return lastResult; - } else { - Gfsh.println("Command returned null steps"); - return ResultBuilder.buildResult(ResultBuilder.createErrorResultData() - .addLine("Multi-step command Return NULL STEP Array")); - } - } - - private static Result executeStep(final LogWrapper logWrapper, final Gfsh shell, - final CLIStep nextStep, final ParseResult parseResult, final SectionResultData nextStepArgs) { - try { - if (nextStep instanceof CLIRemoteStep) { - if (shell.isConnectedAndReady()) { - if (GfshParseResult.class.isInstance(parseResult)) { - GfshParseResult gfshParseResult = (GfshParseResult) parseResult; - // this makes sure that "quit" step will correctly update the environment with empty - // stepArgs - if (nextStepArgs != null) { - GfJsonObject argsJSon = nextStepArgs.getSectionGfJsonObject(); - shell.setEnvProperty(CLIMultiStepHelper.STEP_ARGS, argsJSon.toString()); - } - CommandRequest commandRequest = new CommandRequest(gfshParseResult, shell.getEnv()); - commandRequest - .setCustomInput(changeStepName(gfshParseResult.getUserInput(), nextStep.getName())); - commandRequest.getCustomParameters().put(MultiStepCommand.STEP_PARAMETER_NAME, - nextStep.getName()); - - String json = (String) shell.getOperationInvoker().processCommand(commandRequest); - - return ResultBuilder.fromJson(json); - } else { - throw new IllegalArgumentException("Command Configuration/Definition error."); - } - } else { - throw new IllegalStateException( - "Can't execute a remote command without connection. Use 'connect' first to connect."); - } - } else { - Map<String, String> args = CommandExecutionContext.getShellEnv(); - if (args == null) { - args = new HashMap<String, String>(); - CommandExecutionContext.setShellEnv(args); - } - if (nextStepArgs != null) { - GfJsonObject argsJSon = nextStepArgs.getSectionGfJsonObject(); - Gfsh.getCurrentInstance().setEnvProperty(CLIMultiStepHelper.STEP_ARGS, - argsJSon.toString()); - } - return nextStep.exec(); - } - } catch (CLIStepExecption e) { - logWrapper.severe("CLIStep " + nextStep.getName() + " failed aborting command"); - throw e; - } - } - - private static String changeStepName(String userInput, String stepName) { - int i = userInput.indexOf("--step-name="); - if (i == -1) { - return userInput + " --step-name=" + stepName; - } else { - // TODO this is a dangerous assumption... to assume the "--step-name" query command option is - // the last parameter - // specified! - return userInput.substring(0, i) + "--step-name=" + stepName; - } - } - - public static SectionResultData extractArgumentsForNextStep(Result result) { - CommandResult cResult = (CommandResult) result; - if (ResultData.TYPE_COMPOSITE.equals(cResult.getType())) { - CompositeResultData rd = (CompositeResultData) cResult.getResultData(); - SectionResultData data = rd.retrieveSection(CLIMultiStepHelper.ARG_SECTION); - return data; - } else { - if (ResultData.TYPE_ERROR.equals(cResult.getType())) { - throw new CLIStepExecption(cResult); - } else { - throw new StepExecutionException("Step returned result of type other than " - + ResultData.TYPE_COMPOSITE + " Type " + cResult.getType()); - } - } - } - - public static String getNextStep(Result cdata) { - CommandResult cResult = (CommandResult) cdata; - if (ResultData.TYPE_COMPOSITE.equals(cResult.getType())) { - CompositeResultData rd = (CompositeResultData) cResult.getResultData(); - SectionResultData section = rd.retrieveSection(CLIMultiStepHelper.STEP_SECTION); - String nextStep = (String) section.retrieveObject(CLIMultiStepHelper.NEXT_STEP_NAME); - return nextStep; - } else { - if (ResultData.TYPE_ERROR.equals(cResult.getType())) { - throw new CLIStepExecption(cResult); - } else { - throw new RuntimeException("Step returned result of type other than " - + ResultData.TYPE_COMPOSITE + " Type " + cResult.getType()); - } - } - } - - public static CommandResult getDisplayResultFromArgs(GfJsonObject args) { - SectionResultData sectionData = new SectionResultData(args); - CompositeResultData data = ResultBuilder.createCompositeResultData(); - data.addSection(sectionData); - return (CommandResult) ResultBuilder.buildResult(data); - } - - public static GfJsonObject getStepArgs() { - Map<String, String> args = null; - if (Gfsh.getCurrentInstance() != null) { - args = Gfsh.getCurrentInstance().getEnv(); - } else { - args = CommandExecutionContext.getShellEnv(); - } - if (args == null) - return null; - String stepArg = args.get(CLIMultiStepHelper.STEP_ARGS); - if (stepArg == null) - return null; - GfJsonObject object; - try { - object = new GfJsonObject(stepArg); - } catch (GfJsonException e) { - throw new RuntimeException("Error converting arguments section into json object"); - } - return object; - } - - public static Object chooseStep(CLIStep[] steps, String stepName) { - if ("ALL".equals(stepName)) { - return steps; - } else { - for (CLIStep s : steps) - if (stepName.equals(s.getName())) { - return s.exec(); - } - return null; - } - } - - public static Result createStepSeqResult(CLIStep[] steps) { - CompositeResultData result = ResultBuilder.createCompositeResultData(); - SectionResultData section = result.addSection(STEP_SECTION); - section.addData(NEXT_STEP_NAME, steps[0].getName()); - String[] array = new String[steps.length]; - for (int i = 0; i < steps.length; i++) { - array[i] = steps[i++].getName(); - } - section.addData(NEXT_STEP_NAMES, array); - return ResultBuilder.buildResult(result); - } - - public static Result createEmptyResult(String step) { - CompositeResultData result = ResultBuilder.createCompositeResultData(); - SectionResultData section = result.addSection(STEP_SECTION); - section.addData(NEXT_STEP_NAME, step); - return ResultBuilder.buildResult(result); - } - - public static Result createPageResult(String fields[], Object values[], String step, - String[] header, Object[][] table) { - CompositeResultData result = ResultBuilder.createCompositeResultData(); - SectionResultData section = result.addSection(STEP_SECTION); - section.addData(NEXT_STEP_NAME, step); - SectionResultData page = result.addSection(ARG_SECTION); - - if (fields.length != values.length) - throw new RuntimeException("Fields array and its value arraylength dont match"); - for (int i = 0; i < fields.length; i++) { - page.addData(fields[i], values[i]); - } - createPageTableAndBanner(page, header, table); - return ResultBuilder.buildResult(result); - } - - public static Result createPageResult(List<String> fields, - @SuppressWarnings("rawtypes") List values, String step, String[] header, Object[][] table) { - CompositeResultData result = ResultBuilder.createCompositeResultData(); - SectionResultData section = result.addSection(STEP_SECTION); - section.addData(NEXT_STEP_NAME, step); - SectionResultData page = result.addSection(ARG_SECTION); - - if (fields.size() != values.size()) - throw new RuntimeException("Fields array and its value arraylength dont match"); - for (int i = 0; i < fields.size(); i++) { - page.addData(fields.get(i), values.get(i)); - } - createPageTableAndBanner(page, header, table); - return ResultBuilder.buildResult(result); - } - - private static void createPageTableAndBanner(SectionResultData page, String[] header, - Object[][] table) { - TabularResultData resultData = page.addTable(); - int columns = header.length; - for (int i = 0; i < table.length; i++) { - int rowLength = table[i].length; - if (rowLength != columns) - throw new RuntimeException("Row contains more than " + columns + " : " + rowLength); - } - - for (int i = 0; i < table.length; i++) { - for (int j = 0; j < columns; j++) { - resultData.accumulate(header[j], table[i][j]); - } - } - } - - public static Result createBannerResult(String fields[], Object values[], String step) { - CompositeResultData result = ResultBuilder.createCompositeResultData(); - SectionResultData section = result.addSection(STEP_SECTION); - section.addData(NEXT_STEP_NAME, step); - SectionResultData page = result.addSection(ARG_SECTION); - if (fields.length != values.length) { - throw new RuntimeException("Fields array and its value arraylength dont match"); - } - for (int i = 0; i < fields.length; i++) { - page.addData(fields[i], values[i]); - } - return ResultBuilder.buildResult(result); - } - - public static Result createBannerResult(List<String> fields, - @SuppressWarnings("rawtypes") List values, String step) { - CompositeResultData result = ResultBuilder.createCompositeResultData(); - SectionResultData section = result.addSection(STEP_SECTION); - section.addData(NEXT_STEP_NAME, step); - SectionResultData page = result.addSection(ARG_SECTION); - if (fields.size() != values.size()) { - throw new RuntimeException("Fields array and its value arraylength dont match"); - } - for (int i = 0; i < fields.size(); i++) { - page.addData(fields.get(i), values.get(i)); - } - return ResultBuilder.buildResult(result); - } - - public static void logFine(String msg) { - Gfsh.println(msg); - // TODO Use gemfire Logging for code path running on manager - } - - public static abstract class LocalStep implements CLIStep { - private String name = null; - protected Object[] commandArguments = null; - - public LocalStep(String name, Object[] arguments) { - this.name = name; - this.commandArguments = arguments; - } - - public String getName() { - return name; - } - } - - @SuppressWarnings("serial") - public static abstract class RemoteStep implements CLIRemoteStep { - private String name = null; - protected Object[] commandArguments = null; - - public RemoteStep(String name, Object[] arguments) { - this.name = name; - this.commandArguments = arguments; - } - - public String getName() { - return name; - } - } - - public static class StepExecutionException extends RuntimeException { - private static final long serialVersionUID = 1L; - private String message; - - public StepExecutionException(String message) { - LogWriter logger = CacheFactory.getAnyInstance().getLogger(); - logger.severe(message); - this.message = message; - } - - @Override - public String getMessage() { - return StepExecutionException.class.getName(); - } - - public String getStepExecutionExceptionMessage() { - return message; - } - - } - - -} http://git-wip-us.apache.org/repos/asf/geode/blob/5eb0b94d/geode-core/src/main/java/org/apache/geode/management/internal/cli/multistep/CLIRemoteStep.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/multistep/CLIRemoteStep.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/multistep/CLIRemoteStep.java deleted file mode 100644 index 4c38a31..0000000 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/multistep/CLIRemoteStep.java +++ /dev/null @@ -1,30 +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.multistep; - -import java.io.Serializable; - -/** - * Marker interface to identify remote steps from local steps - * - * Command has to populate the right context information in Remote step to get execution. - * - * For state-ful interactive commands like select where steps are iterating through the result(the - * state) to and fro, first step has to create the state on the manager. - * - */ -public interface CLIRemoteStep extends CLIStep, Serializable { - -} http://git-wip-us.apache.org/repos/asf/geode/blob/5eb0b94d/geode-core/src/main/java/org/apache/geode/management/internal/cli/multistep/CLIStep.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/multistep/CLIStep.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/multistep/CLIStep.java deleted file mode 100644 index a037f51..0000000 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/multistep/CLIStep.java +++ /dev/null @@ -1,31 +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.multistep; - -import org.apache.geode.management.cli.Result; - - -/** - * - * - * - */ -public interface CLIStep { - - public Result exec(); - - public String getName(); - -} http://git-wip-us.apache.org/repos/asf/geode/blob/5eb0b94d/geode-core/src/main/java/org/apache/geode/management/internal/cli/multistep/CLIStepExecption.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/multistep/CLIStepExecption.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/multistep/CLIStepExecption.java deleted file mode 100644 index 389e72f..0000000 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/multistep/CLIStepExecption.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.multistep; - -import org.apache.geode.management.cli.Result; - -public class CLIStepExecption extends RuntimeException { - - - private Result result; - - - public CLIStepExecption(Result result) { - this.result = result; - } - - - public Result getResult() { - return result; - } - - - -} http://git-wip-us.apache.org/repos/asf/geode/blob/5eb0b94d/geode-core/src/main/java/org/apache/geode/management/internal/cli/multistep/MultiStepCommand.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/multistep/MultiStepCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/multistep/MultiStepCommand.java deleted file mode 100644 index 75925f7..0000000 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/multistep/MultiStepCommand.java +++ /dev/null @@ -1,35 +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.multistep; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/*** - * Just a marker interface to identify interactive command from other regular commands - * - */ - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface MultiStepCommand { - public static String STEP_PARAMETER_NAME = "step-name"; - - String[] shellOnlyStep(); - - String stepParameterName() default STEP_PARAMETER_NAME; -} http://git-wip-us.apache.org/repos/asf/geode/blob/5eb0b94d/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/RemoteExecutionStrategy.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/RemoteExecutionStrategy.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/RemoteExecutionStrategy.java index 89cb9ad..75dce47 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/RemoteExecutionStrategy.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/RemoteExecutionStrategy.java @@ -14,7 +14,12 @@ */ package org.apache.geode.management.internal.cli.remote; -import org.apache.commons.lang.StringUtils; +import java.lang.reflect.Method; + +import org.springframework.shell.event.ParseResult; +import org.springframework.util.Assert; +import org.springframework.util.ReflectionUtils; + import org.apache.geode.internal.ClassPathLoader; import org.apache.geode.management.ManagementService; import org.apache.geode.management.cli.CliMetaData; @@ -23,15 +28,8 @@ import org.apache.geode.management.cli.Result.Status; import org.apache.geode.management.internal.cli.CliAroundInterceptor; import org.apache.geode.management.internal.cli.GfshParseResult; import org.apache.geode.management.internal.cli.LogWrapper; -import org.apache.geode.management.internal.cli.multistep.MultiStepCommand; import org.apache.geode.management.internal.cli.result.FileResult; import org.apache.geode.management.internal.cli.result.ResultBuilder; -import org.springframework.shell.event.ParseResult; -import org.springframework.util.Assert; -import org.springframework.util.ReflectionUtils; - -import java.lang.reflect.Method; -import java.util.Arrays; /** * @@ -131,17 +129,7 @@ public class RemoteExecutionStrategy { if (cliMetadata.shellOnly()) { return true; } - MultiStepCommand stepCommand = method.getAnnotation(MultiStepCommand.class); - if (stepCommand == null) { - return false; - } - String step = result.getParamValue(MultiStepCommand.STEP_PARAMETER_NAME); - if (StringUtils.isBlank(step)) { - return false; - } - if (Arrays.asList(stepCommand.shellOnlyStep()).contains(step)) { - return true; - } + return false; } http://git-wip-us.apache.org/repos/asf/geode/blob/5eb0b94d/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategy.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategy.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategy.java index 1cbdb15..6794b3b 100755 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategy.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategy.java @@ -14,9 +14,17 @@ */ package org.apache.geode.management.internal.cli.shell; -import static org.apache.geode.management.internal.cli.multistep.CLIMultiStepHelper.execCLISteps; +import java.lang.reflect.Method; +import java.nio.file.Path; +import java.util.Map; import org.apache.commons.lang.StringUtils; +import org.springframework.shell.core.ExecutionStrategy; +import org.springframework.shell.core.Shell; +import org.springframework.shell.event.ParseResult; +import org.springframework.util.Assert; +import org.springframework.util.ReflectionUtils; + import org.apache.geode.internal.ClassPathLoader; import org.apache.geode.management.cli.CliMetaData; import org.apache.geode.management.cli.CommandProcessingException; @@ -29,19 +37,9 @@ import org.apache.geode.management.internal.cli.CommandResponseBuilder; import org.apache.geode.management.internal.cli.GfshParseResult; import org.apache.geode.management.internal.cli.LogWrapper; import org.apache.geode.management.internal.cli.i18n.CliStrings; -import org.apache.geode.management.internal.cli.multistep.MultiStepCommand; import org.apache.geode.management.internal.cli.result.FileResult; import org.apache.geode.management.internal.cli.result.ResultBuilder; import org.apache.geode.security.NotAuthorizedException; -import org.springframework.shell.core.ExecutionStrategy; -import org.springframework.shell.core.Shell; -import org.springframework.shell.event.ParseResult; -import org.springframework.util.Assert; -import org.springframework.util.ReflectionUtils; - -import java.lang.reflect.Method; -import java.nio.file.Path; -import java.util.Map; /** * Defines the {@link ExecutionStrategy} for commands that are executed in GemFire SHell (gfsh). @@ -76,11 +74,6 @@ public class GfshExecutionStrategy implements ExecutionStrategy { Result result = null; Method method = parseResult.getMethod(); try { - // Check if it's a multi-step command - MultiStepCommand cmd = method.getAnnotation(MultiStepCommand.class); - if (cmd != null) { - return execCLISteps(cmd, logWrapper, shell, parseResult); - } // check if it's a shell only command if (isShellOnly(method)) { http://git-wip-us.apache.org/repos/asf/geode/blob/5eb0b94d/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/support/LoginHandlerInterceptor.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/support/LoginHandlerInterceptor.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/support/LoginHandlerInterceptor.java index 5e502f5..2ccb264 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/support/LoginHandlerInterceptor.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/support/LoginHandlerInterceptor.java @@ -16,26 +16,23 @@ package org.apache.geode.management.internal.web.controllers.support; import static org.apache.geode.internal.security.SecurityServiceFactory.findSecurityService; -import org.apache.geode.distributed.internal.DistributionConfig; -import org.apache.geode.internal.cache.GemFireCacheImpl; -import org.apache.geode.internal.cache.InternalCache; -import org.apache.geode.internal.logging.LogService; -import org.apache.geode.internal.security.SecurityService; -import org.apache.geode.internal.security.SecurityServiceFactory; -import org.apache.geode.management.internal.cli.multistep.CLIMultiStepHelper; -import org.apache.geode.management.internal.security.ResourceConstants; -import org.apache.geode.management.internal.web.util.UriUtils; -import org.apache.logging.log4j.Logger; -import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; - import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; import java.util.Properties; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.logging.log4j.Logger; +import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; + +import org.apache.geode.distributed.internal.DistributionConfig; +import org.apache.geode.internal.logging.LogService; +import org.apache.geode.internal.security.SecurityService; +import org.apache.geode.management.internal.security.ResourceConstants; + /** * The GetEnvironmentHandlerInterceptor class handles extracting Gfsh environment variables encoded * in the HTTP request message as request parameters. @@ -88,11 +85,6 @@ public class LoginHandlerInterceptor extends HandlerInterceptorAdapter { final String requestParameter = requestParameters.nextElement(); if (requestParameter.startsWith(ENVIRONMENT_VARIABLE_REQUEST_PARAMETER_PREFIX)) { String requestValue = request.getParameter(requestParameter); - // GEODE-1469: since we enced stepArgs, we will need to decode it here. See - // #ClientHttpRequest - if (requestParameter.contains(CLIMultiStepHelper.STEP_ARGS)) { - requestValue = UriUtils.decode(requestValue); - } requestParameterValues.put( requestParameter.substring(ENVIRONMENT_VARIABLE_REQUEST_PARAMETER_PREFIX.length()), requestValue); http://git-wip-us.apache.org/repos/asf/geode/blob/5eb0b94d/geode-core/src/main/java/org/apache/geode/management/internal/web/http/ClientHttpRequest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/http/ClientHttpRequest.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/http/ClientHttpRequest.java index 43657b9..7c60c9a 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/web/http/ClientHttpRequest.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/http/ClientHttpRequest.java @@ -20,13 +20,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.geode.internal.lang.Filter; -import org.apache.geode.internal.lang.ObjectUtils; -import org.apache.geode.internal.util.CollectionUtils; -import org.apache.geode.management.internal.cli.multistep.CLIMultiStepHelper; -import org.apache.geode.management.internal.web.domain.Link; -import org.apache.geode.management.internal.web.util.UriUtils; - import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; @@ -37,6 +30,12 @@ import org.springframework.util.MultiValueMap; import org.springframework.web.util.UriComponentsBuilder; import org.springframework.web.util.UriTemplate; +import org.apache.geode.internal.lang.Filter; +import org.apache.geode.internal.lang.ObjectUtils; +import org.apache.geode.internal.util.CollectionUtils; +import org.apache.geode.management.internal.web.domain.Link; +import org.apache.geode.management.internal.web.util.UriUtils; + /** * The ClientHttpRequest class is an abstraction modeling an HTTP request sent by a client and * serves as the envelop encapsulating all the necessary information (headers, request parameters, @@ -283,15 +282,6 @@ public class ClientHttpRequest implements HttpRequest { new Filter<Map.Entry<String, List<Object>>>() { @Override public boolean accept(final Map.Entry<String, List<Object>> entry) { - // GEODE-1469: since stepArgs has json string in there, we will need to encode it - // so that it won't interfere with the expand() call afterwards - if (entry.getKey().contains(CLIMultiStepHelper.STEP_ARGS)) { - List<Object> stepArgsList = entry.getValue(); - if (stepArgsList != null) { - String stepArgs = (String) stepArgsList.remove(0); - stepArgsList.add(UriUtils.encode(stepArgs)); - } - } return !pathVariables.contains(entry.getKey()); } });
