You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by je...@apache.org on 2018/03/31 16:48:14 UTC

[geode] branch develop updated: GEODE-4386: Return 'not found' if the JNDI binding does not exist (#1710)

This is an automated email from the ASF dual-hosted git repository.

jensdeppe pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new 60614fb  GEODE-4386: Return 'not found' if the JNDI binding does not exist (#1710)
60614fb is described below

commit 60614fb818363128e6fe4587973a11e87e98ed45
Author: Jens Deppe <jd...@pivotal.io>
AuthorDate: Sat Mar 31 09:48:09 2018 -0700

    GEODE-4386: Return 'not found' if the JNDI binding does not exist (#1710)
    
    - Return with an error code if the JNDI binding is not found
    - Add availability indication
---
 .../internal/cli/commands/CommandAvailabilityIndicator.java  |  3 ++-
 .../internal/cli/commands/DescribeJndiBindingCommand.java    | 12 ++++++++++--
 .../cli/commands/DescribeJndiBindingCommandDUnitTest.java    |  6 ++++++
 3 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CommandAvailabilityIndicator.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CommandAvailabilityIndicator.java
index a38a9e1..02938c1 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CommandAvailabilityIndicator.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CommandAvailabilityIndicator.java
@@ -50,7 +50,8 @@ public class CommandAvailabilityIndicator implements CommandMarker {
       CliStrings.STOP_GATEWAYRECEIVER, CliStrings.LIST_GATEWAY, CliStrings.STATUS_GATEWAYSENDER,
       CliStrings.STATUS_GATEWAYRECEIVER, CliStrings.LOAD_BALANCE_GATEWAYSENDER,
       CliStrings.DESTROY_GATEWAYSENDER, AlterAsyncEventQueueCommand.COMMAND_NAME,
-      CreateJndiBindingCommand.CREATE_JNDIBINDING, DestroyJndiBindingCommand.DESTROY_JNDIBINDING})
+      CreateJndiBindingCommand.CREATE_JNDIBINDING, DestroyJndiBindingCommand.DESTROY_JNDIBINDING,
+      DescribeJndiBindingCommand.DESCRIBE_JNDI_BINDING})
   public boolean clientCommandsAvailable() {
     Gfsh gfsh = Gfsh.getCurrentInstance();
 
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DescribeJndiBindingCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DescribeJndiBindingCommand.java
index 963845c..6174b02 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DescribeJndiBindingCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DescribeJndiBindingCommand.java
@@ -26,6 +26,7 @@ import org.apache.geode.cache.configuration.JndiBindingsType;
 import org.apache.geode.cache.execute.Function;
 import org.apache.geode.distributed.internal.InternalClusterConfigurationService;
 import org.apache.geode.internal.logging.LogService;
+import org.apache.geode.management.cli.CliMetaData;
 import org.apache.geode.management.cli.Result;
 import org.apache.geode.management.internal.cli.functions.ListJndiBindingFunction;
 import org.apache.geode.management.internal.cli.result.ResultBuilder;
@@ -36,12 +37,13 @@ import org.apache.geode.security.ResourcePermission;
 public class DescribeJndiBindingCommand extends InternalGfshCommand {
   private static final Logger logger = LogService.getLogger();
 
-  private static final String DESCRIBE_JNDI_BINDING = "describe jndi-binding";
+  static final String DESCRIBE_JNDI_BINDING = "describe jndi-binding";
   private static final String DESCRIBE_JNDIBINDING__HELP =
-      "Describe the given active jndi binding. An active binding is one that is bound to the server's jndi context.";
+      "Describe the configuration of the given jndi binding.";
   private static final Function LIST_BINDING_FUNCTION = new ListJndiBindingFunction();
 
   @CliCommand(value = DESCRIBE_JNDI_BINDING, help = DESCRIBE_JNDIBINDING__HELP)
+  @CliMetaData
   @ResourceOperation(resource = ResourcePermission.Resource.CLUSTER,
       operation = ResourcePermission.Operation.READ)
   public Result describeJndiBinding(@CliOption(key = "name", mandatory = true,
@@ -54,6 +56,12 @@ public class DescribeJndiBindingCommand extends InternalGfshCommand {
     if (ccService != null) {
       CacheConfig cacheConfig = ccService.getCacheConfig("cluster");
       List<JndiBindingsType.JndiBinding> jndiBindings = cacheConfig.getJndiBindings();
+
+      if (jndiBindings.size() == 0) {
+        return ResultBuilder
+            .createUserErrorResult(String.format("JNDI binding : %s not found", bindingName));
+      }
+
       for (JndiBindingsType.JndiBinding binding : jndiBindings) {
         if (binding.getJndiName().equals(bindingName)
             || binding.getJndiName().equals("java:" + bindingName)) {
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DescribeJndiBindingCommandDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DescribeJndiBindingCommandDUnitTest.java
index b15b08e..92c046c 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DescribeJndiBindingCommandDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DescribeJndiBindingCommandDUnitTest.java
@@ -137,4 +137,10 @@ public class DescribeJndiBindingCommandDUnitTest {
         .tableHasRowWithValues("Property", "Value", "login-timeout-seconds", "7")
         .tableHasRowWithValues("Property", "Value", "prop1", "value1");
   }
+
+  @Test
+  public void describeJndiBindingDoesNotExist() {
+    gfsh.executeAndAssertThat("describe jndi-binding --name=unknown").statusIsError()
+        .containsOutput("JNDI binding : unknown not found");
+  }
 }

-- 
To stop receiving notification emails like this one, please contact
jensdeppe@apache.org.