geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstew...@apache.org
Subject [4/6] geode git commit: GEODE-2919: Provide finer grained security
Date Fri, 23 Jun 2017 22:49:01 GMT
http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/FunctionCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/FunctionCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/FunctionCommands.java
index c04820e..21d89c1 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/FunctionCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/FunctionCommands.java
@@ -14,6 +14,20 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.stream.Stream;
+
+import org.apache.commons.lang.BooleanUtils;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
 import org.apache.geode.SystemFailure;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.execute.Execution;
@@ -40,7 +54,6 @@ import org.apache.geode.management.internal.cli.functions.ListFunctionFunction;
 import org.apache.geode.management.internal.cli.functions.UnregisterFunction;
 import org.apache.geode.management.internal.cli.functions.UserFunctionExecution;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
-import org.apache.geode.management.internal.cli.result.CommandResultException;
 import org.apache.geode.management.internal.cli.result.CompositeResultData;
 import org.apache.geode.management.internal.cli.result.ErrorResultData;
 import org.apache.geode.management.internal.cli.result.ResultBuilder;
@@ -48,18 +61,7 @@ import org.apache.geode.management.internal.cli.result.TabularResultData;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
-import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
+import org.apache.geode.security.ResourcePermission.Target;
 
 /**
  * @since GemFire 7.0
@@ -77,25 +79,18 @@ public class FunctionCommands implements GfshCommand {
       @CliOption(key = CliStrings.EXECUTE_FUNCTION__ID, mandatory = true,
           help = CliStrings.EXECUTE_FUNCTION__ID__HELP) String functionId,
       @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           optionContext = ConverterHint.MEMBERGROUP,
           help = CliStrings.EXECUTE_FUNCTION__ONGROUPS__HELP) String[] onGroups,
-      @CliOption(key = CliStrings.MEMBER,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
-          optionContext = ConverterHint.MEMBERIDNAME,
+      @CliOption(key = CliStrings.MEMBER, optionContext = ConverterHint.MEMBERIDNAME,
           help = CliStrings.EXECUTE_FUNCTION__ONMEMBER__HELP) String onMember,
       @CliOption(key = CliStrings.EXECUTE_FUNCTION__ONREGION,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           optionContext = ConverterHint.REGION_PATH,
           help = CliStrings.EXECUTE_FUNCTION__ONREGION__HELP) String onRegion,
       @CliOption(key = CliStrings.EXECUTE_FUNCTION__ARGUMENTS,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.EXECUTE_FUNCTION__ARGUMENTS__HELP) String[] arguments,
       @CliOption(key = CliStrings.EXECUTE_FUNCTION__RESULTCOLLECTOR,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.EXECUTE_FUNCTION__RESULTCOLLECTOR__HELP) String resultCollector,
       @CliOption(key = CliStrings.EXECUTE_FUNCTION__FILTER,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.EXECUTE_FUNCTION__FILTER__HELP) String filterString) {
 
     Result result = null;
@@ -105,8 +100,8 @@ public class FunctionCommands implements GfshCommand {
     resultTable.setHeader(headerText);
     ResultCollector resultCollectorInstance = null;
     Function function;
-    Set<String> filters = new HashSet<String>();
-    Execution execution = null;
+    Set<String> filters = new HashSet<>();
+    Execution execution;
     if (functionId != null) {
       functionId = functionId.trim();
     }
@@ -130,31 +125,8 @@ public class FunctionCommands implements GfshCommand {
         return result;
       }
 
-      if (onRegion != null && onMember != null && onGroups != null) {
-        ErrorResultData errorResultData =
-            ResultBuilder.createErrorResultData().setErrorCode(ResultBuilder.ERRORCODE_DEFAULT)
-                .addLine(CliStrings.EXECUTE_FUNCTION__MSG__OPTIONS);
-        result = ResultBuilder.buildResult(errorResultData);
-        return result;
-      } else if (onRegion != null && onMember != null) {
-        ErrorResultData errorResultData =
-            ResultBuilder.createErrorResultData().setErrorCode(ResultBuilder.ERRORCODE_DEFAULT)
-                .addLine(CliStrings.EXECUTE_FUNCTION__MSG__OPTIONS);
-        result = ResultBuilder.buildResult(errorResultData);
-        return result;
-      } else if (onMember != null && onGroups != null) {
-        ErrorResultData errorResultData =
-            ResultBuilder.createErrorResultData().setErrorCode(ResultBuilder.ERRORCODE_DEFAULT)
-                .addLine(CliStrings.EXECUTE_FUNCTION__MSG__OPTIONS);
-        result = ResultBuilder.buildResult(errorResultData);
-        return result;
-      } else if (onRegion != null && onGroups != null) {
-        ErrorResultData errorResultData =
-            ResultBuilder.createErrorResultData().setErrorCode(ResultBuilder.ERRORCODE_DEFAULT)
-                .addLine(CliStrings.EXECUTE_FUNCTION__MSG__OPTIONS);
-        result = ResultBuilder.buildResult(errorResultData);
-        return result;
-      } else if (onRegion != null && onMember != null && onGroups != null) {
+      if (isMoreThanOneIsTrue(onRegion != null, onMember != null, onGroups != null)) {
+        // Provide Only one of region/member/groups
         ErrorResultData errorResultData =
             ResultBuilder.createErrorResultData().setErrorCode(ResultBuilder.ERRORCODE_DEFAULT)
                 .addLine(CliStrings.EXECUTE_FUNCTION__MSG__OPTIONS);
@@ -218,7 +190,7 @@ public class FunctionCommands implements GfshCommand {
           boolean matchFound = false;
 
           if (membersName.length > 0) {
-            while (it.hasNext() && matchFound == false) {
+            while (it.hasNext() && !matchFound) {
               DistributedMember dsmember = (DistributedMember) it.next();
               for (String memberName : membersName) {
                 if (MBeanJMXAdapter.getMemberNameOrId(dsmember).equals(memberName)) {
@@ -229,7 +201,7 @@ public class FunctionCommands implements GfshCommand {
               }
             }
           }
-          if (matchFound == true) {
+          if (matchFound) {
             executeAndGetResults(functionId, filterString, resultCollector, arguments, cache,
                 member, resultTable, onRegion);
             return ResultBuilder.buildResult(resultTable);
@@ -276,7 +248,7 @@ public class FunctionCommands implements GfshCommand {
         }
       } else if (onGroups != null) {
         // execute on group members
-        Set<DistributedMember> dsMembers = new HashSet<DistributedMember>();
+        Set<DistributedMember> dsMembers = new HashSet<>();
         for (String grp : onGroups) {
           dsMembers.addAll(cache.getDistributedSystem().getGroupMembers(grp));
         }
@@ -310,26 +282,6 @@ public class FunctionCommands implements GfshCommand {
         }
         return ResultBuilder.buildResult(resultTable);
       }
-    } catch (InstantiationException e) {
-      ErrorResultData errorResultData = ResultBuilder.createErrorResultData()
-          .setErrorCode(ResultBuilder.ERRORCODE_DEFAULT).addLine(e.getMessage());
-      result = ResultBuilder.buildResult(errorResultData);
-      return result;
-    } catch (IllegalAccessException e) {
-      ErrorResultData errorResultData = ResultBuilder.createErrorResultData()
-          .setErrorCode(ResultBuilder.ERRORCODE_DEFAULT).addLine(e.getMessage());
-      result = ResultBuilder.buildResult(errorResultData);
-      return result;
-    } catch (IllegalArgumentException e) {
-      ErrorResultData errorResultData = ResultBuilder.createErrorResultData()
-          .setErrorCode(ResultBuilder.ERRORCODE_DEFAULT).addLine(e.getMessage());
-      result = ResultBuilder.buildResult(errorResultData);
-      return result;
-    } catch (SecurityException e) {
-      ErrorResultData errorResultData = ResultBuilder.createErrorResultData()
-          .setErrorCode(ResultBuilder.ERRORCODE_DEFAULT).addLine(e.getMessage());
-      result = ResultBuilder.buildResult(errorResultData);
-      return result;
     } catch (Exception e) {
       ErrorResultData errorResultData = ResultBuilder.createErrorResultData()
           .setErrorCode(ResultBuilder.ERRORCODE_DEFAULT).addLine(e.getMessage());
@@ -340,10 +292,14 @@ public class FunctionCommands implements GfshCommand {
     return result;
   }
 
+  private boolean isMoreThanOneIsTrue(Boolean... values) {
+    return Stream.of(values).mapToInt(BooleanUtils::toInteger).sum() > 1;
+  }
+
   void executeAndGetResults(String functionId, String filterString, String resultCollector,
       String[] arguments, InternalCache cache, DistributedMember member,
       TabularResultData resultTable, String onRegion) {
-    StringBuilder resultMessege = new StringBuilder();
+    StringBuilder resultMessage = new StringBuilder();
     try {
       Function function = new UserFunctionExecution();
       Object[] args = new Object[5];
@@ -355,7 +311,7 @@ public class FunctionCommands implements GfshCommand {
         args[2] = resultCollector;
       }
       if (arguments != null && arguments.length > 0) {
-        args[3] = new String();
+        args[3] = "";
         for (String str : arguments) {
           // send via CSV separated value format
           if (str != null) {
@@ -372,30 +328,25 @@ public class FunctionCommands implements GfshCommand {
           for (Object resultObj : results) {
             if (resultObj != null) {
               if (resultObj instanceof String) {
-                resultMessege.append(((String) resultObj));
+                resultMessage.append(((String) resultObj));
               } else if (resultObj instanceof Exception) {
-                resultMessege.append(((Exception) resultObj).getMessage());
+                resultMessage.append(((Exception) resultObj).getMessage());
               } else {
-                resultMessege.append(resultObj);
+                resultMessage.append(resultObj);
               }
             }
           }
         }
-        toTabularResultData(resultTable, member.getId(), resultMessege.toString());
+        toTabularResultData(resultTable, member.getId(), resultMessage.toString());
       } else {
         toTabularResultData(resultTable, member.getId(),
             CliStrings.EXECUTE_FUNCTION__MSG__ERROR_IN_RETRIEVING_EXECUTOR);
       }
-    } catch (FunctionException e) {
-      resultMessege.append(CliStrings.format(
-          CliStrings.EXECUTE_FUNCTION__MSG__COULD_NOT_EXECUTE_FUNCTION_0_ON_MEMBER_1_ERROR_2,
-          functionId, member.getId(), e.getMessage()));
-      toTabularResultData(resultTable, member.getId(), resultMessege.toString());
     } catch (Exception e) {
-      resultMessege.append(CliStrings.format(
+      resultMessage.append(CliStrings.format(
           CliStrings.EXECUTE_FUNCTION__MSG__COULD_NOT_EXECUTE_FUNCTION_0_ON_MEMBER_1_ERROR_2,
           functionId, member.getId(), e.getMessage()));
-      toTabularResultData(resultTable, member.getId(), resultMessege.toString());
+      toTabularResultData(resultTable, member.getId(), resultMessage.toString());
     }
   }
 
@@ -409,23 +360,20 @@ public class FunctionCommands implements GfshCommand {
   @CliCommand(value = CliStrings.DESTROY_FUNCTION, help = CliStrings.DESTROY_FUNCTION__HELP)
   @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_FUNCTION},
       interceptor = "org.apache.geode.management.internal.cli.commands.FunctionCommands$Interceptor")
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE, target = Target.JAR)
   // TODO: Add optioncontext for functionId
   public Result destroyFunction(
       @CliOption(key = CliStrings.DESTROY_FUNCTION__ID, mandatory = true,
           help = CliStrings.DESTROY_FUNCTION__HELP) String functionId,
       @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           optionContext = ConverterHint.MEMBERGROUP,
           help = CliStrings.DESTROY_FUNCTION__ONGROUPS__HELP) String[] groups,
-      @CliOption(key = CliStrings.MEMBER,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
-          optionContext = ConverterHint.MEMBERIDNAME,
+      @CliOption(key = CliStrings.MEMBER, optionContext = ConverterHint.MEMBERIDNAME,
           help = CliStrings.DESTROY_FUNCTION__ONMEMBER__HELP) String memberId) {
-    Result result = null;
+    Result result;
     try {
       InternalCache cache = getCache();
-      Set<DistributedMember> dsMembers = new HashSet<DistributedMember>();
+      Set<DistributedMember> dsMembers = new HashSet<>();
       if (groups != null && memberId != null) {
         return ResultBuilder
             .createUserErrorResult(CliStrings.DESTROY_FUNCTION__MSG__PROVIDE_OPTION);
@@ -489,7 +437,7 @@ public class FunctionCommands implements GfshCommand {
     // unregister on a set of of members
     Function unregisterFunction = new UnregisterFunction();
     FunctionService.registerFunction(unregisterFunction);
-    List resultList = null;
+    List resultList;
 
     if (DsMembers.isEmpty()) {
       return ResultBuilder.createInfoResult("No members for execution");
@@ -564,9 +512,9 @@ public class FunctionCommands implements GfshCommand {
         } else if (result.isSuccessful()) {
           String[] strings = (String[]) result.getSerializables();
           Arrays.sort(strings);
-          for (int i = 0; i < strings.length; i++) {
+          for (String string : strings) {
             tabularData.accumulate("Member", result.getMemberIdOrName());
-            tabularData.accumulate("Function", strings[i]);
+            tabularData.accumulate("Function", string);
             accumulatedData = true;
           }
         }

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/GfshCommand.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/GfshCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/GfshCommand.java
index 86296b4..88f730e 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/GfshCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/GfshCommand.java
@@ -14,7 +14,14 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.HashSet;
+import java.util.Set;
+
 import org.apache.commons.lang.StringUtils;
+import org.springframework.shell.core.CommandMarker;
+
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.execute.Execution;
 import org.apache.geode.cache.execute.Function;
@@ -23,17 +30,12 @@ import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.distributed.internal.ClusterConfigurationService;
 import org.apache.geode.distributed.internal.InternalLocator;
 import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.internal.security.SecurityService;
 import org.apache.geode.management.cli.CliMetaData;
 import org.apache.geode.management.cli.Result;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.cli.shell.Gfsh;
 import org.apache.geode.management.internal.cli.util.MemberNotFoundException;
-import org.springframework.shell.core.CommandMarker;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.HashSet;
-import java.util.Set;
 
 /**
  * Encapsulates common functionality for implementing command classes for the Geode shell (gfsh).
@@ -102,6 +104,10 @@ public interface GfshCommand extends CommandMarker {
     return (InternalCache) CacheFactory.getAnyInstance();
   }
 
+  default SecurityService getSecurityService() {
+    return getCache().getSecurityService();
+  }
+
   default Gfsh getGfsh() {
     return Gfsh.getCurrentInstance();
   }
@@ -129,7 +135,7 @@ public interface GfshCommand extends CommandMarker {
    */
   @Deprecated
   default Set<DistributedMember> getMembers(final InternalCache cache) {
-    Set<DistributedMember> members = new HashSet<DistributedMember>(cache.getMembers());
+    Set<DistributedMember> members = new HashSet<>(cache.getMembers());
     members.add(cache.getDistributedSystem().getDistributedMember());
     return members;
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java
index 4d8d5fe..4734b4c 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java
@@ -14,7 +14,20 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.concurrent.atomic.AtomicReference;
+
 import org.apache.commons.lang.ArrayUtils;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
 import org.apache.geode.SystemFailure;
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
@@ -23,7 +36,6 @@ import org.apache.geode.cache.execute.Execution;
 import org.apache.geode.cache.execute.FunctionInvocationTargetException;
 import org.apache.geode.cache.execute.ResultCollector;
 import org.apache.geode.distributed.DistributedMember;
-import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.cache.execute.AbstractExecution;
 import org.apache.geode.internal.lang.StringUtils;
 import org.apache.geode.management.cli.CliMetaData;
@@ -47,18 +59,7 @@ import org.apache.geode.management.internal.configuration.domain.XmlEntity;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.concurrent.atomic.AtomicReference;
+import org.apache.geode.security.ResourcePermission.Target;
 
 /**
  * The IndexCommands class encapsulates all GemFire shell (Gfsh) commands related to indexes defined
@@ -80,10 +81,9 @@ public class IndexCommands implements GfshCommand {
       Collections.synchronizedSet(new HashSet<IndexInfo>());
 
   @CliCommand(value = CliStrings.LIST_INDEX, help = CliStrings.LIST_INDEX__HELP)
-  @CliMetaData(shellOnly = false,
-      relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
-  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
-  public Result listIndex(@CliOption(key = CliStrings.LIST_INDEX__STATS, mandatory = false,
+  @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ, target = Target.QUERY)
+  public Result listIndex(@CliOption(key = CliStrings.LIST_INDEX__STATS,
       specifiedDefaultValue = "true", unspecifiedDefaultValue = "false",
       help = CliStrings.LIST_INDEX__STATS__HELP) final boolean showStats) {
     try {
@@ -114,7 +114,7 @@ public class IndexCommands implements GfshCommand {
         functionExecutor.execute(new ListIndexFunction());
 
     final List<?> results = (List<?>) resultsCollector.getResult();
-    final List<IndexDetails> indexDetailsList = new ArrayList<IndexDetails>(results.size());
+    final List<IndexDetails> indexDetailsList = new ArrayList<>(results.size());
 
     for (Object result : results) {
       if (result instanceof Set) { // ignore FunctionInvocationTargetExceptions and other Exceptions
@@ -161,9 +161,10 @@ public class IndexCommands implements GfshCommand {
   }
 
   @CliCommand(value = CliStrings.CREATE_INDEX, help = CliStrings.CREATE_INDEX__HELP)
-  @CliMetaData(shellOnly = false,
-      relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
+  @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
   // TODO : Add optionContext for indexName
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.QUERY)
   public Result createIndex(@CliOption(key = CliStrings.CREATE_INDEX__NAME, mandatory = true,
       help = CliStrings.CREATE_INDEX__NAME__HELP) final String indexName,
 
@@ -174,26 +175,25 @@ public class IndexCommands implements GfshCommand {
           optionContext = ConverterHint.REGION_PATH,
           help = CliStrings.CREATE_INDEX__REGION__HELP) String regionPath,
 
-      @CliOption(key = {CliStrings.MEMBER, CliStrings.MEMBERS}, mandatory = false,
+      @CliOption(key = {CliStrings.MEMBER, CliStrings.MEMBERS},
           optionContext = ConverterHint.MEMBERIDNAME,
           help = CliStrings.CREATE_INDEX__MEMBER__HELP) final String[] memberNameOrID,
 
-      @CliOption(key = CliStrings.CREATE_INDEX__TYPE, mandatory = false,
-          unspecifiedDefaultValue = "range", optionContext = ConverterHint.INDEX_TYPE,
+      @CliOption(key = CliStrings.CREATE_INDEX__TYPE, unspecifiedDefaultValue = "range",
+          optionContext = ConverterHint.INDEX_TYPE,
           help = CliStrings.CREATE_INDEX__TYPE__HELP) final String indexType,
 
-      @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS}, mandatory = false,
+      @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
           optionContext = ConverterHint.MEMBERGROUP,
           help = CliStrings.CREATE_INDEX__GROUP__HELP) final String[] group) {
 
-    Result result = null;
+    Result result;
     AtomicReference<XmlEntity> xmlEntity = new AtomicReference<>();
 
-    getCache().getSecurityService().authorizeRegionManage(regionPath);
     try {
       final Cache cache = CacheFactory.getAnyInstance();
 
-      int idxType = IndexInfo.RANGE_INDEX;
+      int idxType;
 
       // Index type check
       if ("range".equalsIgnoreCase(indexType)) {
@@ -235,8 +235,8 @@ public class IndexCommands implements GfshCommand {
           CliUtil.executeFunction(createIndexFunction, indexInfo, targetMembers);
 
       final List<Object> funcResults = (List<Object>) rc.getResult();
-      final Set<String> successfulMembers = new TreeSet<String>();
-      final Map<String, Set<String>> indexOpFailMap = new HashMap<String, Set<String>>();
+      final Set<String> successfulMembers = new TreeSet<>();
+      final Map<String, Set<String>> indexOpFailMap = new HashMap<>();
 
       for (final Object funcResult : funcResults) {
         if (funcResult instanceof CliFunctionResult) {
@@ -253,7 +253,7 @@ public class IndexCommands implements GfshCommand {
             Set<String> failedMembers = indexOpFailMap.get(exceptionMessage);
 
             if (failedMembers == null) {
-              failedMembers = new TreeSet<String>();
+              failedMembers = new TreeSet<>();
             }
             failedMembers.add(cliFunctionResult.getMemberIdOrName());
             indexOpFailMap.put(exceptionMessage, failedMembers);
@@ -314,25 +314,25 @@ public class IndexCommands implements GfshCommand {
   }
 
   @CliCommand(value = CliStrings.DESTROY_INDEX, help = CliStrings.DESTROY_INDEX__HELP)
-  @CliMetaData(shellOnly = false,
-      relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
-  public Result destroyIndex(@CliOption(key = CliStrings.DESTROY_INDEX__NAME, mandatory = false,
-      unspecifiedDefaultValue = "",
-      help = CliStrings.DESTROY_INDEX__NAME__HELP) final String indexName,
-
-      @CliOption(key = CliStrings.DESTROY_INDEX__REGION, mandatory = false,
-          optionContext = ConverterHint.REGION_PATH,
+  @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.QUERY)
+  public Result destroyIndex(
+      @CliOption(key = CliStrings.DESTROY_INDEX__NAME, unspecifiedDefaultValue = "",
+          help = CliStrings.DESTROY_INDEX__NAME__HELP) final String indexName,
+
+      @CliOption(key = CliStrings.DESTROY_INDEX__REGION, optionContext = ConverterHint.REGION_PATH,
           help = CliStrings.DESTROY_INDEX__REGION__HELP) final String regionPath,
 
-      @CliOption(key = {CliStrings.MEMBER, CliStrings.MEMBERS}, mandatory = false,
+      @CliOption(key = {CliStrings.MEMBER, CliStrings.MEMBERS},
           optionContext = ConverterHint.MEMBERIDNAME,
           help = CliStrings.DESTROY_INDEX__MEMBER__HELP) final String[] memberNameOrID,
 
-      @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS}, mandatory = false,
+      @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
           optionContext = ConverterHint.MEMBERGROUP,
           help = CliStrings.DESTROY_INDEX__GROUP__HELP) final String[] group) {
 
-    Result result = null;
+    Result result;
 
     if (StringUtils.isBlank(indexName) && StringUtils.isBlank(regionPath)
         && ArrayUtils.isEmpty(group) && ArrayUtils.isEmpty(memberNameOrID)) {
@@ -340,18 +340,11 @@ public class IndexCommands implements GfshCommand {
           CliStrings.format(CliStrings.PROVIDE_ATLEAST_ONE_OPTION, CliStrings.DESTROY_INDEX));
     }
 
-    String regionName = null;
     final Cache cache = CacheFactory.getAnyInstance();
-
-    // If a regionName is specified, then authorize data manage on the regionName, otherwise, it
-    // requires data manage permission on all regions
-    if (StringUtils.isNotBlank(regionPath)) {
+    String regionName = null;
+    if (regionPath != null) {
       regionName = regionPath.startsWith("/") ? regionPath.substring(1) : regionPath;
-      getCache().getSecurityService().authorizeRegionManage(regionName);
-    } else {
-      getCache().getSecurityService().authorizeDataManage();
     }
-
     IndexInfo indexInfo = new IndexInfo(indexName, regionName);
     Set<DistributedMember> targetMembers = CliUtil.findMembers(group, memberNameOrID);
 
@@ -362,8 +355,8 @@ public class IndexCommands implements GfshCommand {
     ResultCollector rc = CliUtil.executeFunction(destroyIndexFunction, indexInfo, targetMembers);
     List<Object> funcResults = (List<Object>) rc.getResult();
 
-    Set<String> successfulMembers = new TreeSet<String>();
-    Map<String, Set<String>> indexOpFailMap = new HashMap<String, Set<String>>();
+    Set<String> successfulMembers = new TreeSet<>();
+    Map<String, Set<String>> indexOpFailMap = new HashMap<>();
 
     AtomicReference<XmlEntity> xmlEntity = new AtomicReference<>();
     for (Object funcResult : funcResults) {
@@ -383,7 +376,7 @@ public class IndexCommands implements GfshCommand {
         Set<String> failedMembers = indexOpFailMap.get(exceptionMessage);
 
         if (failedMembers == null) {
-          failedMembers = new TreeSet<String>();
+          failedMembers = new TreeSet<>();
         }
         failedMembers.add(cliFunctionResult.getMemberIdOrName());
         indexOpFailMap.put(exceptionMessage, failedMembers);
@@ -451,9 +444,10 @@ public class IndexCommands implements GfshCommand {
   }
 
   @CliCommand(value = CliStrings.DEFINE_INDEX, help = CliStrings.DEFINE_INDEX__HELP)
-  @CliMetaData(shellOnly = false,
-      relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
+  @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
   // TODO : Add optionContext for indexName
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.QUERY)
   public Result defineIndex(@CliOption(key = CliStrings.DEFINE_INDEX_NAME, mandatory = true,
       help = CliStrings.DEFINE_INDEX__HELP) final String indexName,
 
@@ -464,16 +458,14 @@ public class IndexCommands implements GfshCommand {
           optionContext = ConverterHint.REGION_PATH,
           help = CliStrings.DEFINE_INDEX__REGION__HELP) String regionPath,
 
-      @CliOption(key = CliStrings.DEFINE_INDEX__TYPE, mandatory = false,
-          unspecifiedDefaultValue = "range", optionContext = ConverterHint.INDEX_TYPE,
+      @CliOption(key = CliStrings.DEFINE_INDEX__TYPE, unspecifiedDefaultValue = "range",
+          optionContext = ConverterHint.INDEX_TYPE,
           help = CliStrings.DEFINE_INDEX__TYPE__HELP) final String indexType) {
 
-    Result result = null;
+    Result result;
     XmlEntity xmlEntity = null;
 
-    getCache().getSecurityService().authorizeRegionManage(regionPath);
-
-    int idxType = IndexInfo.RANGE_INDEX;
+    int idxType;
 
     // Index type check
     if ("range".equalsIgnoreCase(indexType)) {
@@ -518,21 +510,21 @@ public class IndexCommands implements GfshCommand {
   }
 
   @CliCommand(value = CliStrings.CREATE_DEFINED_INDEXES, help = CliStrings.CREATE_DEFINED__HELP)
-  @CliMetaData(shellOnly = false,
-      relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
+  @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.QUERY)
   // TODO : Add optionContext for indexName
   public Result createDefinedIndexes(
 
-      @CliOption(key = {CliStrings.MEMBER, CliStrings.MEMBERS}, mandatory = false,
+      @CliOption(key = {CliStrings.MEMBER, CliStrings.MEMBERS},
           optionContext = ConverterHint.MEMBERIDNAME,
           help = CliStrings.CREATE_DEFINED_INDEXES__MEMBER__HELP) final String[] memberNameOrID,
 
-      @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS}, mandatory = false,
+      @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
           optionContext = ConverterHint.MEMBERGROUP,
           help = CliStrings.CREATE_DEFINED_INDEXES__GROUP__HELP) final String[] group) {
 
-    Result result = null;
+    Result result;
     AtomicReference<XmlEntity> xmlEntity = new AtomicReference<>();
 
     if (indexDefinitions.isEmpty()) {
@@ -553,8 +545,8 @@ public class IndexCommands implements GfshCommand {
           CliUtil.executeFunction(createDefinedIndexesFunction, indexDefinitions, targetMembers);
 
       final List<Object> funcResults = (List<Object>) rc.getResult();
-      final Set<String> successfulMembers = new TreeSet<String>();
-      final Map<String, Set<String>> indexOpFailMap = new HashMap<String, Set<String>>();
+      final Set<String> successfulMembers = new TreeSet<>();
+      final Map<String, Set<String>> indexOpFailMap = new HashMap<>();
 
       for (final Object funcResult : funcResults) {
         if (funcResult instanceof CliFunctionResult) {
@@ -571,7 +563,7 @@ public class IndexCommands implements GfshCommand {
             Set<String> failedMembers = indexOpFailMap.get(exceptionMessage);
 
             if (failedMembers == null) {
-              failedMembers = new TreeSet<String>();
+              failedMembers = new TreeSet<>();
             }
             failedMembers.add(cliFunctionResult.getMemberIdOrName());
             indexOpFailMap.put(exceptionMessage, failedMembers);
@@ -624,9 +616,9 @@ public class IndexCommands implements GfshCommand {
   }
 
   @CliCommand(value = CliStrings.CLEAR_DEFINED_INDEXES, help = CliStrings.CLEAR_DEFINED__HELP)
-  @CliMetaData(shellOnly = false,
-      relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
+  @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.QUERY)
   // TODO : Add optionContext for indexName
   public Result clearDefinedIndexes() {
     indexDefinitions.clear();

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
index 637fa0e..1415bc6 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
@@ -14,7 +14,41 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.zip.DataFormatException;
+import java.util.zip.GZIPInputStream;
+
+import javax.management.ObjectName;
+
 import org.apache.commons.lang.StringUtils;
+import org.apache.logging.log4j.Logger;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
 import org.apache.geode.LogWriter;
 import org.apache.geode.cache.execute.Execution;
 import org.apache.geode.cache.execute.Function;
@@ -60,7 +94,6 @@ import org.apache.geode.management.internal.cli.functions.NetstatFunction.Netsta
 import org.apache.geode.management.internal.cli.functions.ShutDownFunction;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.cli.remote.CommandExecutionContext;
-import org.apache.geode.management.internal.cli.result.CommandResultException;
 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.ErrorResultData;
@@ -72,39 +105,6 @@ import org.apache.geode.management.internal.cli.result.TabularResultData;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
-import org.apache.logging.log4j.Logger;
-import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.zip.DataFormatException;
-import java.util.zip.GZIPInputStream;
-import javax.management.ObjectName;
 
 /**
  * @since GemFire 7.0
@@ -172,7 +172,7 @@ public class MiscellaneousCommands implements GfshCommand {
         return ResultBuilder.createInfoResult(CliStrings.SHUTDOWN__MSG__IMPROPER_TIMEOUT);
       }
 
-      // convert to mili-seconds
+      // convert to milliseconds
       long timeout = userSpecifiedTimeout * 1000;
 
       InternalCache cache = getCache();
@@ -211,7 +211,7 @@ public class MiscellaneousCommands implements GfshCommand {
         }
 
         for (DistributedMember locator : locators) {
-          Set<DistributedMember> lsSet = new HashSet<DistributedMember>();
+          Set<DistributedMember> lsSet = new HashSet<>();
           lsSet.add(locator);
           long elapsedTime = shutDownNodeWithTimeOut(timeout, lsSet);
           timeout = timeout - elapsedTime;
@@ -224,7 +224,7 @@ public class MiscellaneousCommands implements GfshCommand {
         return ResultBuilder.createInfoResult("Shutdown is triggered");
       }
       // now shut down this manager
-      Set<DistributedMember> mgrSet = new HashSet<DistributedMember>();
+      Set<DistributedMember> mgrSet = new HashSet<>();
       mgrSet.add(manager);
       // No need to check further timeout as this is the last node we will be
       // shutting down
@@ -290,18 +290,16 @@ public class MiscellaneousCommands implements GfshCommand {
   @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE)
   public Result gc(
       @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.GC__GROUP__HELP) String[] groups,
       @CliOption(key = CliStrings.MEMBER, optionContext = ConverterHint.ALL_MEMBER_IDNAME,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.GC__MEMBER__HELP) String memberId) {
     InternalCache cache = getCache();
-    Result result = null;
+    Result result;
     CompositeResultData gcResultTable = ResultBuilder.createCompositeResultData();
     TabularResultData resultTable = gcResultTable.addSection().addTable("Table1");
     String headerText = "GC Summary";
     resultTable.setHeader(headerText);
-    Set<DistributedMember> dsMembers = new HashSet<DistributedMember>();
+    Set<DistributedMember> dsMembers = new HashSet<>();
     if (memberId != null && memberId.length() > 0) {
       DistributedMember member = CliUtil.getDistributedMemberByNameOrId(memberId);
       if (member == null) {
@@ -328,13 +326,12 @@ public class MiscellaneousCommands implements GfshCommand {
 
   Result executeAndBuildResult(TabularResultData resultTable, Set<DistributedMember> dsMembers) {
     try {
-      List<?> resultList = null;
+      List<?> resultList;
       Function garbageCollectionFunction = new GarbageCollectionFunction();
       resultList =
           (List<?>) CliUtil.executeFunction(garbageCollectionFunction, null, dsMembers).getResult();
 
-      for (int i = 0; i < resultList.size(); i++) {
-        Object object = resultList.get(i);
+      for (Object object : resultList) {
         if (object instanceof Exception) {
           LogWrapper.getInstance().fine("Exception in GC " + ((Throwable) object).getMessage(),
               ((Throwable) object));
@@ -380,24 +377,20 @@ public class MiscellaneousCommands implements GfshCommand {
   @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
   // TODO : Verify the auto-completion for multiple values.
   public Result netstat(
-      @CliOption(key = {CliStrings.MEMBER, CliStrings.MEMBERS}, mandatory = false,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
+      @CliOption(key = {CliStrings.MEMBER, CliStrings.MEMBERS},
           optionContext = ConverterHint.ALL_MEMBER_IDNAME,
           help = CliStrings.NETSTAT__MEMBER__HELP) String[] members,
-      @CliOption(key = CliStrings.GROUP, mandatory = false,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
-          optionContext = ConverterHint.MEMBERGROUP,
+      @CliOption(key = CliStrings.GROUP, optionContext = ConverterHint.MEMBERGROUP,
           help = CliStrings.NETSTAT__GROUP__HELP) String group,
       @CliOption(key = CliStrings.NETSTAT__FILE,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.NETSTAT__FILE__HELP) String saveAs,
       @CliOption(key = CliStrings.NETSTAT__WITHLSOF, specifiedDefaultValue = "true",
           unspecifiedDefaultValue = "false",
           help = CliStrings.NETSTAT__WITHLSOF__HELP) boolean withlsof) {
-    Result result = null;
+    Result result;
 
-    Map<String, DistributedMember> hostMemberMap = new HashMap<String, DistributedMember>();
-    Map<String, List<String>> hostMemberListMap = new HashMap<String, List<String>>();
+    Map<String, DistributedMember> hostMemberMap = new HashMap<>();
+    Map<String, List<String>> hostMemberListMap = new HashMap<>();
 
     try {
       if (members != null && members.length > 0 && group != null) {
@@ -410,7 +403,7 @@ public class MiscellaneousCommands implements GfshCommand {
       InternalDistributedSystem system = InternalDistributedSystem.getConnectedInstance();
 
       if (members != null) {
-        Set<String> notFoundMembers = new HashSet<String>();
+        Set<String> notFoundMembers = new HashSet<>();
         for (String memberIdOrName : members) {
           Set<DistributedMember> membersToExecuteOn = CliUtil.getAllMembers(system);
           boolean memberFound = false;
@@ -435,7 +428,7 @@ public class MiscellaneousCommands implements GfshCommand {
                   new Object[] {CliUtil.collectionToString(notFoundMembers, -1)}));
         }
       } else {
-        Set<DistributedMember> membersToExecuteOn = null;
+        Set<DistributedMember> membersToExecuteOn;
         if (group != null) {
           membersToExecuteOn = system.getGroupMembers(group);
         } else {
@@ -453,7 +446,7 @@ public class MiscellaneousCommands implements GfshCommand {
         }
       }
 
-      String lineSeparatorToUse = null;
+      String lineSeparatorToUse;
       lineSeparatorToUse = CommandExecutionContext.getShellLineSeparator();
       if (lineSeparatorToUse == null) {
         lineSeparatorToUse = GfshParser.LINE_SEPARATOR;
@@ -461,13 +454,12 @@ public class MiscellaneousCommands implements GfshCommand {
       NetstatFunctionArgument nfa = new NetstatFunctionArgument(lineSeparatorToUse, withlsof);
 
       if (!hostMemberMap.isEmpty()) {
-        Set<DistributedMember> membersToExecuteOn =
-            new HashSet<DistributedMember>(hostMemberMap.values());
+        Set<DistributedMember> membersToExecuteOn = new HashSet<>(hostMemberMap.values());
         ResultCollector<?, ?> netstatResult =
             CliUtil.executeFunction(NetstatFunction.INSTANCE, nfa, membersToExecuteOn);
         List<?> resultList = (List<?>) netstatResult.getResult();
-        for (int i = 0; i < resultList.size(); i++) {
-          NetstatFunctionResult netstatFunctionResult = (NetstatFunctionResult) resultList.get(i);
+        for (Object aResultList : resultList) {
+          NetstatFunctionResult netstatFunctionResult = (NetstatFunctionResult) aResultList;
           DeflaterInflaterData deflaterInflaterData = netstatFunctionResult.getCompressedBytes();
           try {
             String remoteHost = netstatFunctionResult.getHost();
@@ -528,9 +520,9 @@ public class MiscellaneousCommands implements GfshCommand {
     }
 
     // Maintain all members for a host - display purpose
-    List<String> list = null;
+    List<String> list;
     if (!hostMemberListMap.containsKey(host)) {
-      list = new ArrayList<String>();
+      list = new ArrayList<>();
       hostMemberListMap.put(host, list);
     } else {
       list = hostMemberListMap.get(host);
@@ -539,13 +531,13 @@ public class MiscellaneousCommands implements GfshCommand {
   }
 
   @CliCommand(value = CliStrings.SHOW_DEADLOCK, help = CliStrings.SHOW_DEADLOCK__HELP)
-  @CliMetaData(shellOnly = false, relatedTopic = {CliStrings.TOPIC_GEODE_DEBUG_UTIL})
+  @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_DEBUG_UTIL})
   @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
   public Result showDeadlock(@CliOption(key = CliStrings.SHOW_DEADLOCK__DEPENDENCIES__FILE,
       help = CliStrings.SHOW_DEADLOCK__DEPENDENCIES__FILE__HELP,
       mandatory = true) String filename) {
 
-    Result result = null;
+    Result result;
     try {
       if (!filename.endsWith(".txt")) {
         return ResultBuilder
@@ -590,20 +582,19 @@ public class MiscellaneousCommands implements GfshCommand {
   }
 
   @CliCommand(value = CliStrings.SHOW_LOG, help = CliStrings.SHOW_LOG_HELP)
-  @CliMetaData(shellOnly = false, relatedTopic = {CliStrings.TOPIC_GEODE_DEBUG_UTIL})
+  @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_DEBUG_UTIL})
   @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
   public Result showLog(
       @CliOption(key = CliStrings.MEMBER, optionContext = ConverterHint.ALL_MEMBER_IDNAME,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.SHOW_LOG_MEMBER_HELP, mandatory = true) String memberNameOrId,
       @CliOption(key = CliStrings.SHOW_LOG_LINE_NUM, unspecifiedDefaultValue = "0",
-          help = CliStrings.SHOW_LOG_LINE_NUM_HELP, mandatory = false) int numberOfLines) {
-    Result result = null;
+          help = CliStrings.SHOW_LOG_LINE_NUM_HELP) int numberOfLines) {
+    Result result;
     try {
       InternalCache cache = getCache();
       SystemManagementService service =
           (SystemManagementService) ManagementService.getExistingManagementService(cache);
-      MemberMXBean bean = null;
+      MemberMXBean bean;
       DistributedMember memberToBeInvoked = CliUtil.getDistributedMemberByNameOrId(memberNameOrId);
       if (memberToBeInvoked != null) {
         String memberId = memberToBeInvoked.getId();
@@ -655,7 +646,7 @@ public class MiscellaneousCommands implements GfshCommand {
    * Current implementation supports writing it to a file and returning the location of the file
    */
   @CliCommand(value = CliStrings.EXPORT_STACKTRACE, help = CliStrings.EXPORT_STACKTRACE__HELP)
-  @CliMetaData(shellOnly = false, relatedTopic = {CliStrings.TOPIC_GEODE_DEBUG_UTIL})
+  @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_DEBUG_UTIL})
   @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
   public Result exportStackTrace(@CliOption(key = {CliStrings.MEMBER, CliStrings.MEMBERS},
       optionContext = ConverterHint.ALL_MEMBER_IDNAME,
@@ -671,7 +662,7 @@ public class MiscellaneousCommands implements GfshCommand {
           unspecifiedDefaultValue = "false",
           help = CliStrings.EXPORT_STACKTRACE__FAIL__IF__FILE__PRESENT__HELP) boolean failIfFilePresent) {
 
-    Result result = null;
+    Result result;
     StringBuffer filePrefix = new StringBuffer("stacktrace");
 
     if (fileName == null) {
@@ -690,7 +681,7 @@ public class MiscellaneousCommands implements GfshCommand {
 
       InfoResultData resultData = ResultBuilder.createInfoResultData();
 
-      Map<String, byte[]> dumps = new HashMap<String, byte[]>();
+      Map<String, byte[]> dumps = new HashMap<>();
       Set<DistributedMember> targetMembers = CliUtil.findMembers(group, memberNameOrId);
       if (targetMembers.isEmpty()) {
         return ResultBuilder.createUserErrorResult(CliStrings.NO_MEMBERS_FOUND_MESSAGE);
@@ -735,7 +726,7 @@ public class MiscellaneousCommands implements GfshCommand {
         return ResultBuilder
             .createShellClientAbortOperationResult(CliStrings.EXPORT_STACKTRACE_MSG_ABORTING);
       } else {
-        // we dont to show any info result
+        // we don't to show any info result
         return ResultBuilder.createInfoResult("");
       }
     }
@@ -750,17 +741,15 @@ public class MiscellaneousCommands implements GfshCommand {
    * @throws IOException
    */
   private String writeStacksToFile(Map<String, byte[]> dumps, String fileName) throws IOException {
-    String filePath = null;
-    OutputStream os = null;
-    PrintWriter ps = null;
-    File outputFile = null;
+    String filePath;
+    PrintWriter ps;
+    File outputFile;
 
-    try {
-      outputFile = new File(fileName);
-      os = new FileOutputStream(outputFile);
+    outputFile = new File(fileName);
+    try (OutputStream os = new FileOutputStream(outputFile)) {
       ps = new PrintWriter(os);
 
-      for (Map.Entry<String, byte[]> entry : dumps.entrySet()) {
+      for (Entry<String, byte[]> entry : dumps.entrySet()) {
         ps.append("*** Stack-trace for member " + entry.getKey() + " ***");
         ps.flush();
         GZIPInputStream zipIn = new GZIPInputStream(new ByteArrayInputStream(entry.getValue()));
@@ -774,15 +763,13 @@ public class MiscellaneousCommands implements GfshCommand {
       }
       ps.flush();
       filePath = outputFile.getCanonicalPath();
-    } finally {
-      os.close();
     }
 
     return filePath;
   }
 
   @CliCommand(value = CliStrings.SHOW_METRICS, help = CliStrings.SHOW_METRICS__HELP)
-  @CliMetaData(shellOnly = false, relatedTopic = {CliStrings.TOPIC_GEODE_STATISTICS})
+  @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_STATISTICS})
   @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
   public Result showMetrics(
       @CliOption(key = {CliStrings.MEMBER}, optionContext = ConverterHint.ALL_MEMBER_IDNAME,
@@ -796,7 +783,7 @@ public class MiscellaneousCommands implements GfshCommand {
       @CliOption(key = {CliStrings.SHOW_METRICS__CATEGORY},
           help = CliStrings.SHOW_METRICS__CATEGORY__HELP) String[] categories) {
 
-    Result result = null;
+    Result result;
     try {
 
       if (export_to_report_to != null && !export_to_report_to.isEmpty()) {
@@ -873,11 +860,10 @@ public class MiscellaneousCommands implements GfshCommand {
    * @return ResultData with required System wide statistics or ErrorResultData if DS MBean is not
    *         found to gather metrics
    */
-  private ResultData getSystemWideMetrics(String export_to_report_to, String[] categoriesArr)
-      throws Exception {
+  private ResultData getSystemWideMetrics(String export_to_report_to, String[] categoriesArr) {
     final InternalCache cache = getCache();
-    final ManagementService managmentService = ManagementService.getManagementService(cache);
-    DistributedSystemMXBean dsMxBean = managmentService.getDistributedSystemMXBean();
+    final ManagementService managementService = ManagementService.getManagementService(cache);
+    DistributedSystemMXBean dsMxBean = managementService.getDistributedSystemMXBean();
     StringBuilder csvBuilder = null;
     if (dsMxBean != null) {
 
@@ -898,7 +884,7 @@ public class MiscellaneousCommands implements GfshCommand {
 
       if (categoriesArr != null && categoriesArr.length != 0) {
         Set<String> categories = createSet(categoriesArr);
-        Set<String> checkSet = new HashSet<String>(categoriesMap.keySet());
+        Set<String> checkSet = new HashSet<>(categoriesMap.keySet());
         Set<String> userCategories = getSetDifference(categories, checkSet);
 
         // Checking if the categories specified by the user are valid or not
@@ -923,12 +909,12 @@ public class MiscellaneousCommands implements GfshCommand {
       }
       metricsTable.setHeader("Cluster-wide Metrics");
 
-      if (categoriesMap.get("cluster").booleanValue()) {
+      if (categoriesMap.get("cluster")) {
         writeToTableAndCsv(metricsTable, "cluster", "totalHeapSize", dsMxBean.getTotalHeapSize(),
             csvBuilder);
       }
 
-      if (categoriesMap.get("cache").booleanValue()) {
+      if (categoriesMap.get("cache")) {
         writeToTableAndCsv(metricsTable, "cache", "totalRegionEntryCount",
             dsMxBean.getTotalRegionEntryCount(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "totalRegionCount", dsMxBean.getTotalRegionCount(),
@@ -939,7 +925,7 @@ public class MiscellaneousCommands implements GfshCommand {
             csvBuilder);
       }
 
-      if (categoriesMap.get("diskstore").booleanValue()) {
+      if (categoriesMap.get("diskstore")) {
         writeToTableAndCsv(metricsTable, "diskstore", "totalDiskUsage",
             dsMxBean.getTotalDiskUsage(), csvBuilder); // deadcoded to workaround bug 46397
         writeToTableAndCsv(metricsTable, ""/* 46608 */, "diskReadsRate",
@@ -952,7 +938,7 @@ public class MiscellaneousCommands implements GfshCommand {
             dsMxBean.getTotalBackupInProgress(), csvBuilder);
       }
 
-      if (categoriesMap.get("query").booleanValue()) {
+      if (categoriesMap.get("query")) {
         writeToTableAndCsv(metricsTable, "query", "activeCQCount", dsMxBean.getActiveCQCount(),
             csvBuilder);
         writeToTableAndCsv(metricsTable, "", "queryRequestRate", dsMxBean.getQueryRequestRate(),
@@ -988,7 +974,7 @@ public class MiscellaneousCommands implements GfshCommand {
     ObjectName memberMBeanName = managementService.getMemberMBeanName(distributedMember);
     MemberMXBean memberMxBean =
         managementService.getMBeanInstance(memberMBeanName, MemberMXBean.class);
-    ObjectName csMxBeanName = null;
+    ObjectName csMxBeanName;
     CacheServerMXBean csMxBean = null;
 
     if (memberMxBean != null) {
@@ -1028,7 +1014,7 @@ public class MiscellaneousCommands implements GfshCommand {
 
       if (categoriesArr != null && categoriesArr.length != 0) {
         Set<String> categories = createSet(categoriesArr);
-        Set<String> checkSet = new HashSet<String>(categoriesMap.keySet());
+        Set<String> checkSet = new HashSet<>(categoriesMap.keySet());
         Set<String> userCategories = getSetDifference(categories, checkSet);
 
         // Checking if the categories specified by the user are valid or not
@@ -1056,7 +1042,7 @@ public class MiscellaneousCommands implements GfshCommand {
        */
       // member, jvm, region, serialization, communication, function, transaction, diskstore, lock,
       // eviction, distribution
-      if (categoriesMap.get("member").booleanValue()) {
+      if (categoriesMap.get("member")) {
         writeToTableAndCsv(metricsTable, "member", "upTime", memberMxBean.getMemberUpTime(),
             csvBuilder);
         writeToTableAndCsv(metricsTable, "", "cpuUsage", memberMxBean.getCpuUsage(), csvBuilder);
@@ -1068,7 +1054,7 @@ public class MiscellaneousCommands implements GfshCommand {
       /*
        * JVM Metrics
        */
-      if (categoriesMap.get("jvm").booleanValue()) {
+      if (categoriesMap.get("jvm")) {
         writeToTableAndCsv(metricsTable, "jvm ", "jvmThreads ", jvmMetrics.getTotalThreads(),
             csvBuilder);
         writeToTableAndCsv(metricsTable, "", "fileDescriptorLimit",
@@ -1079,7 +1065,7 @@ public class MiscellaneousCommands implements GfshCommand {
       /*
        * Member wide region metrics
        */
-      if (categoriesMap.get("region").booleanValue()) {
+      if (categoriesMap.get("region")) {
         writeToTableAndCsv(metricsTable, "region ", "totalRegionCount ",
             memberMxBean.getTotalRegionCount(), csvBuilder);
         String[] regionNames = memberMxBean.listRegions();
@@ -1120,7 +1106,7 @@ public class MiscellaneousCommands implements GfshCommand {
             csvBuilder);
         writeToTableAndCsv(metricsTable, "", "putAllAvgLatency", memberMxBean.getPutAllAvgLatency(),
             csvBuilder);
-        // Not available from stats. After Stats re-org it will be avaialble
+        // Not available from stats. After Stats re-org it will be available
         // writeToTableAndCsv(metricsTable, "", "getAllAvgLatency",
         // memberMxBean.getGetAllAvgLatency(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "totalMissCount", memberMxBean.getTotalMissCount(),
@@ -1140,7 +1126,7 @@ public class MiscellaneousCommands implements GfshCommand {
       /*
        * SERIALIZATION
        */
-      if (categoriesMap.get("serialization").booleanValue()) {
+      if (categoriesMap.get("serialization")) {
         writeToTableAndCsv(metricsTable, "serialization", "serializationRate",
             memberMxBean.getSerializationRate(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "serializationLatency",
@@ -1160,7 +1146,7 @@ public class MiscellaneousCommands implements GfshCommand {
       /*
        * Communication Metrics
        */
-      if (categoriesMap.get("communication").booleanValue()) {
+      if (categoriesMap.get("communication")) {
         writeToTableAndCsv(metricsTable, "communication", "bytesSentRate",
             memberMxBean.getBytesSentRate(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "bytesReceivedRate",
@@ -1177,23 +1163,20 @@ public class MiscellaneousCommands implements GfshCommand {
       /*
        * Member wide function metrics
        */
-      if (categoriesMap.get("function").booleanValue()) {
+      if (categoriesMap.get("function")) {
         writeToTableAndCsv(metricsTable, "function", "numRunningFunctions",
             memberMxBean.getNumRunningFunctions(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "functionExecutionRate",
             memberMxBean.getFunctionExecutionRate(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "numRunningFunctionsHavingResults",
             memberMxBean.getNumRunningFunctionsHavingResults(), csvBuilder);
-        // Not Avaialble from Stats
-        // writeToTableAndCsv(metricsTable, "", "funcExecutionQueueSize",
-        // memberMxBean.getFuncExecutionQueueSize(), csvBuilder);
       }
 
       /*
        * totalTransactionsCount currentTransactionalThreadIds transactionCommitsAvgLatency
        * transactionCommittedTotalCount transactionRolledBackTotalCount transactionCommitsRate
        */
-      if (categoriesMap.get("transaction").booleanValue()) {
+      if (categoriesMap.get("transaction")) {
         writeToTableAndCsv(metricsTable, "transaction", "totalTransactionsCount",
             memberMxBean.getTotalTransactionsCount(), csvBuilder);
 
@@ -1209,7 +1192,7 @@ public class MiscellaneousCommands implements GfshCommand {
       /*
        * Member wide disk metrics
        */
-      if (categoriesMap.get("diskstore").booleanValue()) {
+      if (categoriesMap.get("diskstore")) {
         writeToTableAndCsv(metricsTable, "diskstore", "totalDiskUsage",
             memberMxBean.getTotalDiskUsage(), csvBuilder); // deadcoded to workaround bug 46397
         writeToTableAndCsv(metricsTable, ""/* 46608 */, "diskReadsRate",
@@ -1227,7 +1210,7 @@ public class MiscellaneousCommands implements GfshCommand {
       /*
        * Member wide Lock
        */
-      if (categoriesMap.get("lock").booleanValue()) {
+      if (categoriesMap.get("lock")) {
         writeToTableAndCsv(metricsTable, "lock", "lockWaitsInProgress",
             memberMxBean.getLockWaitsInProgress(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "totalLockWaitTime",
@@ -1240,7 +1223,7 @@ public class MiscellaneousCommands implements GfshCommand {
       /*
        * Eviction
        */
-      if (categoriesMap.get("eviction").booleanValue()) {
+      if (categoriesMap.get("eviction")) {
         writeToTableAndCsv(metricsTable, "eviction", "lruEvictionRate",
             memberMxBean.getLruEvictionRate(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "lruDestroyRate", memberMxBean.getLruDestroyRate(),
@@ -1249,9 +1232,9 @@ public class MiscellaneousCommands implements GfshCommand {
       /*
        * Distribution
        */
-      if (categoriesMap.get("distribution").booleanValue()) {
+      if (categoriesMap.get("distribution")) {
         writeToTableAndCsv(metricsTable, "distribution", "getInitialImagesInProgress",
-            memberMxBean.getInitialImagesInProgres(), csvBuilder);
+            memberMxBean.getInitialImagesInProgress(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "getInitialImageTime",
             memberMxBean.getInitialImageTime(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "getInitialImageKeysReceived",
@@ -1261,7 +1244,7 @@ public class MiscellaneousCommands implements GfshCommand {
       /*
        * OffHeap
        */
-      if (categoriesMap.get("offheap").booleanValue()) {
+      if (categoriesMap.get("offheap")) {
         writeToTableAndCsv(metricsTable, "offheap", "maxMemory", memberMxBean.getOffHeapMaxMemory(),
             csvBuilder);
         writeToTableAndCsv(metricsTable, "", "freeMemory", memberMxBean.getOffHeapFreeMemory(),
@@ -1381,7 +1364,7 @@ public class MiscellaneousCommands implements GfshCommand {
 
       if (categoriesArr != null && categoriesArr.length != 0) {
         Set<String> categories = createSet(categoriesArr);
-        Set<String> checkSet = new HashSet<String>(categoriesMap.keySet());
+        Set<String> checkSet = new HashSet<>(categoriesMap.keySet());
         Set<String> userCategories = getSetDifference(categories, checkSet);
 
         // Checking if the categories specified by the user are valid or not
@@ -1407,14 +1390,14 @@ public class MiscellaneousCommands implements GfshCommand {
        * General System metrics
        */
       // cluster, region, partition , diskstore, callback, eviction
-      if (categoriesMap.get("cluster").booleanValue()) {
+      if (categoriesMap.get("cluster")) {
         writeToTableAndCsv(metricsTable, "cluster", "member count", regionMxBean.getMemberCount(),
             csvBuilder);
         writeToTableAndCsv(metricsTable, "", "region entry count",
             regionMxBean.getSystemRegionEntryCount(), csvBuilder);
       }
 
-      if (categoriesMap.get("region").booleanValue()) {
+      if (categoriesMap.get("region")) {
         writeToTableAndCsv(metricsTable, "region", "lastModifiedTime",
             regionMxBean.getLastModifiedTime(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "lastAccessedTime", regionMxBean.getLastAccessedTime(),
@@ -1432,7 +1415,7 @@ public class MiscellaneousCommands implements GfshCommand {
             csvBuilder);
       }
 
-      if (categoriesMap.get("partition").booleanValue()) {
+      if (categoriesMap.get("partition")) {
         writeToTableAndCsv(metricsTable, "partition", "putLocalRate",
             regionMxBean.getPutLocalRate(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "putRemoteRate", regionMxBean.getPutRemoteRate(),
@@ -1456,7 +1439,7 @@ public class MiscellaneousCommands implements GfshCommand {
       /*
        * Disk store
        */
-      if (categoriesMap.get("diskstore").booleanValue()) {
+      if (categoriesMap.get("diskstore")) {
         writeToTableAndCsv(metricsTable, "diskstore", "totalEntriesOnlyOnDisk",
             regionMxBean.getTotalEntriesOnlyOnDisk(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "diskReadsRate", regionMxBean.getDiskReadsRate(),
@@ -1472,7 +1455,7 @@ public class MiscellaneousCommands implements GfshCommand {
       /*
        * LISTENER
        */
-      if (categoriesMap.get("callback").booleanValue()) {
+      if (categoriesMap.get("callback")) {
         writeToTableAndCsv(metricsTable, "callback", "cacheWriterCallsAvgLatency",
             regionMxBean.getCacheWriterCallsAvgLatency(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "cacheListenerCallsAvgLatency",
@@ -1482,7 +1465,7 @@ public class MiscellaneousCommands implements GfshCommand {
       /*
        * Eviction
        */
-      if (categoriesMap.get("eviction").booleanValue()) {
+      if (categoriesMap.get("eviction")) {
         writeToTableAndCsv(metricsTable, "eviction", "lruEvictionRate",
             regionMxBean.getLruEvictionRate(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "lruDestroyRate", regionMxBean.getLruDestroyRate(),
@@ -1549,7 +1532,7 @@ public class MiscellaneousCommands implements GfshCommand {
 
       if (categoriesArr != null && categoriesArr.length != 0) {
         Set<String> categories = createSet(categoriesArr);
-        Set<String> checkSet = new HashSet<String>(categoriesMap.keySet());
+        Set<String> checkSet = new HashSet<>(categoriesMap.keySet());
         Set<String> userCategories = getSetDifference(categories, checkSet);
 
         // Checking if the categories specified by the user are valid or not
@@ -1572,7 +1555,7 @@ public class MiscellaneousCommands implements GfshCommand {
         }
       }
 
-      if (categoriesMap.get("region").booleanValue()) {
+      if (categoriesMap.get("region")) {
         writeToTableAndCsv(metricsTable, "region", "lastModifiedTime",
             regionMxBean.getLastModifiedTime(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "lastAccessedTime", regionMxBean.getLastAccessedTime(),
@@ -1590,7 +1573,7 @@ public class MiscellaneousCommands implements GfshCommand {
             csvBuilder);
       }
 
-      if (categoriesMap.get("partition").booleanValue()) {
+      if (categoriesMap.get("partition")) {
         writeToTableAndCsv(metricsTable, "partition", "putLocalRate",
             regionMxBean.getPutLocalRate(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "putRemoteRate", regionMxBean.getPutRemoteRate(),
@@ -1616,7 +1599,7 @@ public class MiscellaneousCommands implements GfshCommand {
       /*
        * Disk store
        */
-      if (categoriesMap.get("diskstore").booleanValue()) {
+      if (categoriesMap.get("diskstore")) {
         writeToTableAndCsv(metricsTable, "diskstore", "totalEntriesOnlyOnDisk",
             regionMxBean.getTotalEntriesOnlyOnDisk(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "diskReadsRate", "" + regionMxBean.getDiskReadsRate(),
@@ -1631,7 +1614,7 @@ public class MiscellaneousCommands implements GfshCommand {
       /*
        * LISTENER
        */
-      if (categoriesMap.get("callback").booleanValue()) {
+      if (categoriesMap.get("callback")) {
         writeToTableAndCsv(metricsTable, "callback", "cacheWriterCallsAvgLatency",
             regionMxBean.getCacheWriterCallsAvgLatency(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "cacheListenerCallsAvgLatency",
@@ -1641,7 +1624,7 @@ public class MiscellaneousCommands implements GfshCommand {
       /*
        * Eviction
        */
-      if (categoriesMap.get("eviction").booleanValue()) {
+      if (categoriesMap.get("eviction")) {
         writeToTableAndCsv(metricsTable, "eviction", "lruEvictionRate",
             regionMxBean.getLruEvictionRate(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "lruDestroyRate", regionMxBean.getLruDestroyRate(),
@@ -1686,7 +1669,7 @@ public class MiscellaneousCommands implements GfshCommand {
       double metricValue, StringBuilder csvBuilder) {
     metricsTable.accumulate(CliStrings.SHOW_METRICS__TYPE__HEADER, type);
     metricsTable.accumulate(CliStrings.SHOW_METRICS__METRIC__HEADER, metricName);
-    metricsTable.accumulate(CliStrings.SHOW_METRICS__VALUE__HEADER, Double.valueOf(metricValue));
+    metricsTable.accumulate(CliStrings.SHOW_METRICS__VALUE__HEADER, metricValue);
 
     if (csvBuilder != null) {
       csvBuilder.append(type);
@@ -1699,10 +1682,8 @@ public class MiscellaneousCommands implements GfshCommand {
   }
 
   private Set<String> createSet(String[] categories) {
-    Set<String> categoriesSet = new HashSet<String>();
-    for (String category : categories) {
-      categoriesSet.add(category);
-    }
+    Set<String> categoriesSet = new HashSet<>();
+    Collections.addAll(categoriesSet, categories);
     return categoriesSet;
   }
 
@@ -1712,7 +1693,7 @@ public class MiscellaneousCommands implements GfshCommand {
    * @return map with categories for system metrics and display flag set to true
    */
   private Map<String, Boolean> getSystemMetricsCategories() {
-    Map<String, Boolean> categories = new HashMap<String, Boolean>();
+    Map<String, Boolean> categories = new HashMap<>();
     categories.put("cluster", true);
     categories.put("cache", true);
     categories.put("diskstore", true);
@@ -1726,7 +1707,7 @@ public class MiscellaneousCommands implements GfshCommand {
    * @return map with categories for region metrics and display flag set to true
    */
   private Map<String, Boolean> getRegionMetricsCategories() {
-    Map<String, Boolean> categories = new HashMap<String, Boolean>();
+    Map<String, Boolean> categories = new HashMap<>();
 
     categories.put("region", true);
     categories.put("partition", true);
@@ -1756,7 +1737,7 @@ public class MiscellaneousCommands implements GfshCommand {
    * @return map with categories for member metrics and display flag set to true
    */
   private Map<String, Boolean> getMemberMetricsCategories() {
-    Map<String, Boolean> categories = new HashMap<String, Boolean>();
+    Map<String, Boolean> categories = new HashMap<>();
     categories.put("member", true);
     categories.put("jvm", true);
     categories.put("region", true);
@@ -1842,7 +1823,7 @@ public class MiscellaneousCommands implements GfshCommand {
       InternalCache cache = GemFireCacheImpl.getInstance();
       LogWriter logger = cache.getLogger();
 
-      Set<DistributedMember> dsMembers = new HashSet<DistributedMember>();
+      Set<DistributedMember> dsMembers = new HashSet<>();
       Set<DistributedMember> ds = CliUtil.getAllMembers(cache);
 
       if (grps != null && grps.length > 0) {
@@ -1853,9 +1834,7 @@ public class MiscellaneousCommands implements GfshCommand {
 
       if (memberIds != null && memberIds.length > 0) {
         for (String member : memberIds) {
-          Iterator<DistributedMember> it = ds.iterator();
-          while (it.hasNext()) {
-            DistributedMember mem = it.next();
+          for (DistributedMember mem : ds) {
             if (mem.getName() != null
                 && (mem.getName().equals(member) || mem.getId().equals(member))) {
               dsMembers.add(mem);
@@ -1909,7 +1888,6 @@ public class MiscellaneousCommands implements GfshCommand {
           }
         } catch (Exception ex) {
           LogWrapper.getInstance().warning("change log level command exception " + ex);
-          continue;
         }
       }
 
@@ -1937,7 +1915,7 @@ public class MiscellaneousCommands implements GfshCommand {
   }
 
   private Set<String> getSetDifference(Set<String> set1, Set<String> set2) {
-    Set<String> setDifference = new HashSet<String>();
+    Set<String> setDifference = new HashSet<>();
     for (String element : set1) {
       if (!(set2.contains(element.toLowerCase()))) {
         setDifference.add(element);

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/PDXCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/PDXCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/PDXCommands.java
index 9bfd47b..e0bad15 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/PDXCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/PDXCommands.java
@@ -14,6 +14,17 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
 import org.apache.geode.internal.cache.CacheConfig;
 import org.apache.geode.internal.cache.DiskStoreImpl;
 import org.apache.geode.internal.cache.xmlcache.CacheCreation;
@@ -32,42 +43,25 @@ import org.apache.geode.pdx.internal.EnumInfo;
 import org.apache.geode.pdx.internal.PdxType;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.Arrays;
-import java.util.Collection;
 
 public class PDXCommands implements GfshCommand {
 
 
   @CliCommand(value = CliStrings.CONFIGURE_PDX, help = CliStrings.CONFIGURE_PDX__HELP)
   @CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_REGION)
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE)
   public Result configurePDX(
       @CliOption(key = CliStrings.CONFIGURE_PDX__READ__SERIALIZED,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.CONFIGURE_PDX__READ__SERIALIZED__HELP) Boolean readSerialized,
       @CliOption(key = CliStrings.CONFIGURE_PDX__IGNORE__UNREAD_FIELDS,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.CONFIGURE_PDX__IGNORE__UNREAD_FIELDS__HELP) Boolean ignoreUnreadFields,
-      @CliOption(key = CliStrings.CONFIGURE_PDX__DISKSTORE,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, specifiedDefaultValue = "",
+      @CliOption(key = CliStrings.CONFIGURE_PDX__DISKSTORE, specifiedDefaultValue = "",
           help = CliStrings.CONFIGURE_PDX__DISKSTORE__HELP) String diskStore,
       @CliOption(key = CliStrings.CONFIGURE_PDX__AUTO__SERIALIZER__CLASSES,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
-          specifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.CONFIGURE_PDX__AUTO__SERIALIZER__CLASSES__HELP) String[] patterns,
       @CliOption(key = CliStrings.CONFIGURE_PDX__PORTABLE__AUTO__SERIALIZER__CLASSES,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
-          specifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.CONFIGURE_PDX__PORTABLE__AUTO__SERIALIZER__CLASSES__HELP) String[] portablePatterns) {
-    Result result = null;
+    Result result;
 
     try {
       InfoResultData ird = ResultBuilder.createInfoResultData();
@@ -105,7 +99,7 @@ public class PDXCommands implements GfshCommand {
           CliStrings.CONFIGURE_PDX__READ__SERIALIZED + " = " + cache.getPdxReadSerialized());
 
 
-      // Set ingoreUnreadFields
+      // Set ignoreUnreadFields
       if (ignoreUnreadFields != null) {
         cache.setPdxIgnoreUnreadFields(ignoreUnreadFields);
       } else {
@@ -153,7 +147,6 @@ public class PDXCommands implements GfshCommand {
 
   @CliCommand(value = CliStrings.PDX_RENAME, help = CliStrings.PDX_RENAME__HELP)
   @CliMetaData(shellOnly = true, relatedTopic = {CliStrings.TOPIC_GEODE_DISKSTORE})
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
   public Result pdxRename(@CliOption(key = CliStrings.PDX_RENAME_OLD, mandatory = true,
       help = CliStrings.PDX_RENAME_OLD__HELP) String oldClassName,
 
@@ -191,7 +184,7 @@ public class PDXCommands implements GfshCommand {
       }
       String resultString =
           CliStrings.format(CliStrings.PDX_RENAME__SUCCESS, outputStream.toString());
-      return ResultBuilder.createInfoResult(resultString.toString());
+      return ResultBuilder.createInfoResult(resultString);
 
     } catch (Exception e) {
       return ResultBuilder.createGemFireErrorResult(

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/QueueCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/QueueCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/QueueCommands.java
index 25b95cd..87c5bbc 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/QueueCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/QueueCommands.java
@@ -14,10 +14,18 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
 import org.apache.geode.SystemFailure;
 import org.apache.geode.cache.execute.ResultCollector;
 import org.apache.geode.distributed.DistributedMember;
-import org.apache.geode.management.cli.CliMetaData;
 import org.apache.geode.management.cli.ConverterHint;
 import org.apache.geode.management.cli.Result;
 import org.apache.geode.management.cli.Result.Status;
@@ -28,21 +36,13 @@ import org.apache.geode.management.internal.cli.functions.CliFunctionResult;
 import org.apache.geode.management.internal.cli.functions.CreateAsyncEventQueueFunction;
 import org.apache.geode.management.internal.cli.functions.ListAsyncEventQueuesFunction;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
-import org.apache.geode.management.internal.cli.result.CommandResultException;
 import org.apache.geode.management.internal.cli.result.ResultBuilder;
 import org.apache.geode.management.internal.cli.result.TabularResultData;
 import org.apache.geode.management.internal.configuration.domain.XmlEntity;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicReference;
+import org.apache.geode.security.ResourcePermission.Target;
 
 /**
  * The QueueCommands class encapsulates all GemFire Queue commands in Gfsh.
@@ -54,12 +54,11 @@ public class QueueCommands implements GfshCommand {
 
   @CliCommand(value = CliStrings.CREATE_ASYNC_EVENT_QUEUE,
       help = CliStrings.CREATE_ASYNC_EVENT_QUEUE__HELP)
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE, target = Target.JAR)
   public Result createAsyncEventQueue(
       @CliOption(key = CliStrings.CREATE_ASYNC_EVENT_QUEUE__ID, mandatory = true,
           help = CliStrings.CREATE_ASYNC_EVENT_QUEUE__ID__HELP) String id,
       @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           optionContext = ConverterHint.MEMBERGROUP,
           help = CliStrings.CREATE_ASYNC_EVENT_QUEUE__GROUP__HELP) String[] groups,
       @CliOption(key = CliStrings.CREATE_ASYNC_EVENT_QUEUE__PARALLEL,
@@ -78,7 +77,6 @@ public class QueueCommands implements GfshCommand {
           unspecifiedDefaultValue = "false", specifiedDefaultValue = "true",
           help = CliStrings.CREATE_ASYNC_EVENT_QUEUE__PERSISTENT__HELP) boolean persistent,
       @CliOption(key = CliStrings.CREATE_ASYNC_EVENT_QUEUE__DISK_STORE,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.CREATE_ASYNC_EVENT_QUEUE__DISK_STORE__HELP) String diskStore,
       @CliOption(key = CliStrings.CREATE_ASYNC_EVENT_QUEUE__DISKSYNCHRONOUS,
           unspecifiedDefaultValue = "true", specifiedDefaultValue = "true",
@@ -104,17 +102,20 @@ public class QueueCommands implements GfshCommand {
       @CliOption(key = CliStrings.CREATE_ASYNC_EVENT_QUEUE__LISTENER_PARAM_AND_VALUE,
           help = CliStrings.CREATE_ASYNC_EVENT_QUEUE__LISTENER_PARAM_AND_VALUE__HELP) String[] listenerParamsAndValues) {
 
+    if (persistent) {
+      getSecurityService().authorize(Resource.CLUSTER, Operation.WRITE, Target.DISK);
+    }
     Properties listenerProperties = new Properties();
 
     try {
       if (listenerParamsAndValues != null) {
-        for (int i = 0; i < listenerParamsAndValues.length; i++) {
-          final int hashPosition = listenerParamsAndValues[i].indexOf('#');
+        for (String listenerParamsAndValue : listenerParamsAndValues) {
+          final int hashPosition = listenerParamsAndValue.indexOf('#');
           if (hashPosition == -1) {
-            listenerProperties.put(listenerParamsAndValues[i], "");
+            listenerProperties.put(listenerParamsAndValue, "");
           } else {
-            listenerProperties.put(listenerParamsAndValues[i].substring(0, hashPosition),
-                listenerParamsAndValues[i].substring(hashPosition + 1));
+            listenerProperties.put(listenerParamsAndValue.substring(0, hashPosition),
+                listenerParamsAndValue.substring(hashPosition + 1));
           }
         }
       }
@@ -205,17 +206,17 @@ public class QueueCommands implements GfshCommand {
           tabularData.setStatus(Status.ERROR);
         } else {
           AsyncEventQueueDetails[] details = (AsyncEventQueueDetails[]) result.getSerializables();
-          for (int i = 0; i < details.length; i++) {
+          for (AsyncEventQueueDetails detail : details) {
             tabularData.accumulate("Member", result.getMemberIdOrName());
-            tabularData.accumulate("ID", details[i].getId());
-            tabularData.accumulate("Batch Size", details[i].getBatchSize());
-            tabularData.accumulate("Persistent", details[i].isPersistent());
-            tabularData.accumulate("Disk Store", details[i].getDiskStoreName());
-            tabularData.accumulate("Max Memory", details[i].getMaxQueueMemory());
+            tabularData.accumulate("ID", detail.getId());
+            tabularData.accumulate("Batch Size", detail.getBatchSize());
+            tabularData.accumulate("Persistent", detail.isPersistent());
+            tabularData.accumulate("Disk Store", detail.getDiskStoreName());
+            tabularData.accumulate("Max Memory", detail.getMaxQueueMemory());
 
-            Properties listenerProperties = details[i].getListenerProperties();
+            Properties listenerProperties = detail.getListenerProperties();
             if (listenerProperties == null || listenerProperties.size() == 0) {
-              tabularData.accumulate("Listener", details[i].getListener());
+              tabularData.accumulate("Listener", detail.getListener());
             } else {
               StringBuilder propsStringBuilder = new StringBuilder();
               propsStringBuilder.append('(');
@@ -232,7 +233,7 @@ public class QueueCommands implements GfshCommand {
               propsStringBuilder.append(')');
 
               tabularData.accumulate("Listener",
-                  details[i].getListener() + propsStringBuilder.toString());
+                  detail.getListener() + propsStringBuilder.toString());
             }
             accumulatedData = true;
           }


Mime
View raw message