geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dschnei...@apache.org
Subject [39/47] geode git commit: GEODE-3472: Remove a great deal of commented-out code.
Date Thu, 31 Aug 2017 01:26:16 GMT
http://git-wip-us.apache.org/repos/asf/geode/blob/fb9a405f/geode-core/src/main/java/org/apache/geode/management/internal/configuration/domain/XmlEntity.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/domain/XmlEntity.java
b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/domain/XmlEntity.java
index 00902a9..6789416 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/domain/XmlEntity.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/domain/XmlEntity.java
@@ -14,25 +14,6 @@
  */
 package org.apache.geode.management.internal.configuration.domain;
 
-import org.apache.commons.lang.StringUtils;
-import org.apache.geode.DataSerializer;
-import org.apache.geode.InternalGemFireError;
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.CacheFactory;
-import org.apache.geode.internal.Assert;
-import org.apache.geode.internal.Version;
-import org.apache.geode.internal.VersionedDataSerializable;
-import org.apache.geode.internal.cache.xmlcache.CacheXml;
-import org.apache.geode.internal.cache.xmlcache.CacheXmlGenerator;
-import org.apache.geode.internal.logging.LogService;
-import org.apache.geode.management.internal.configuration.utils.XmlUtils;
-import org.apache.geode.management.internal.configuration.utils.XmlUtils.XPathContext;
-import org.apache.logging.log4j.Logger;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
@@ -43,11 +24,32 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Map.Entry;
+
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.transform.TransformerException;
 import javax.xml.transform.TransformerFactoryConfigurationError;
 import javax.xml.xpath.XPathExpressionException;
 
+import org.apache.commons.lang.StringUtils;
+import org.apache.logging.log4j.Logger;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import org.apache.geode.DataSerializer;
+import org.apache.geode.InternalGemFireError;
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.internal.Assert;
+import org.apache.geode.internal.Version;
+import org.apache.geode.internal.VersionedDataSerializable;
+import org.apache.geode.internal.cache.xmlcache.CacheXml;
+import org.apache.geode.internal.cache.xmlcache.CacheXmlGenerator;
+import org.apache.geode.internal.logging.LogService;
+import org.apache.geode.management.internal.configuration.utils.XmlUtils;
+import org.apache.geode.management.internal.configuration.utils.XmlUtils.XPathContext;
+
 /****
  * Domain class for defining a GemFire entity in XML.
  * 
@@ -60,7 +62,7 @@ public class XmlEntity implements VersionedDataSerializable {
   private String type;
   @SuppressWarnings("unused")
   private String parentType;
-  private Map<String, String> attributes = new HashMap<String, String>();
+  private Map<String, String> attributes = new HashMap<>();
   private String xmlDefinition;
   private String searchString;
 
@@ -112,13 +114,10 @@ public class XmlEntity implements VersionedDataSerializable {
    */
   public XmlEntity(final String parentType, final String parentKey, final String parentValue,
       final String childType, final String childKey, final String childValue) {
-    // TODO this should be replaced with a builder.
-    // TODO consider parent as nested XmlEntity type.
     this.parentType = parentType;
     this.type = childType;
     initializeSearchString(parentKey, parentValue, this.prefix, childKey, childValue);
 
-    // no init();
   }
 
   /****
@@ -268,13 +267,10 @@ public class XmlEntity implements VersionedDataSerializable {
     if (attributes.size() > 0) {
       queryStringBuilder.append("[");
       Entry<String, String> attrEntry = attributeIter.next();
-      // queryStringBuilder.append("@").append(attrEntry.getKey()).append("=\"").append(attrEntry.getValue()).append("\"");
       queryStringBuilder.append("@").append(attrEntry.getKey()).append("='")
           .append(attrEntry.getValue()).append("'");
       while (attributeIter.hasNext()) {
         attrEntry = attributeIter.next();
-        // queryStringBuilder.append(" and
-        // @").append(attrEntry.getKey()).append("=\"").append(attrEntry.getValue()).append("\"");
         queryStringBuilder.append(" and @").append(attrEntry.getKey()).append("='")
             .append(attrEntry.getValue()).append("'");
       }
@@ -463,7 +459,7 @@ public class XmlEntity implements VersionedDataSerializable {
     private XmlEntity xmlEntity;
 
     /**
-     * Private contstructor.
+     * Private constructor.
      * 
      * @since GemFire 8.1
      */

http://git-wip-us.apache.org/repos/asf/geode/blob/fb9a405f/geode-core/src/main/java/org/apache/geode/management/internal/configuration/messages/ConfigurationRequest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/messages/ConfigurationRequest.java
b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/messages/ConfigurationRequest.java
index ac5e99a..698c68a 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/messages/ConfigurationRequest.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/messages/ConfigurationRequest.java
@@ -14,23 +14,24 @@
  */
 package org.apache.geode.management.internal.configuration.messages;
 
-import org.apache.commons.lang.StringUtils;
-import org.apache.geode.internal.DataSerializableFixedID;
-import org.apache.geode.internal.Version;
-
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
 import java.util.HashSet;
 import java.util.Set;
 
+import org.apache.commons.lang.StringUtils;
+
+import org.apache.geode.internal.DataSerializableFixedID;
+import org.apache.geode.internal.Version;
+
 /***
  * Request sent by a member to the locator requesting the shared configuration
  *
  */
 public class ConfigurationRequest implements DataSerializableFixedID {
   private static int DEFAULT_NUM_ATTEMPTS = 5;
-  private Set<String> groups = new HashSet<String>();
+  private Set<String> groups = new HashSet<>();
   private boolean isRequestForEntireConfiguration = false;
   private int numAttempts = DEFAULT_NUM_ATTEMPTS;
 
@@ -74,7 +75,7 @@ public class ConfigurationRequest implements DataSerializableFixedID {
   public void fromData(DataInput in) throws IOException, ClassNotFoundException {
     this.isRequestForEntireConfiguration = in.readBoolean();
     int size = in.readInt();
-    Set<String> groups = new HashSet<String>();
+    Set<String> groups = new HashSet<>();
     if (size > 0) {
       for (int i = 0; i < size; i++) {
         groups.add(in.readUTF());
@@ -105,11 +106,8 @@ public class ConfigurationRequest implements DataSerializableFixedID
{
     return sb.toString();
   }
 
-  // TODO Sourabh, please review for correctness
-  // Asif: Returning null, as otherwise backward compatibility tests fail
-  // due to missing pre to & from data functions.
   public Version[] getSerializationVersions() {
-    return null;// new Version[] { Version.CURRENT };
+    return null;
   }
 
   public int getNumAttempts() {

http://git-wip-us.apache.org/repos/asf/geode/blob/fb9a405f/geode-core/src/main/java/org/apache/geode/management/internal/configuration/utils/XmlUtils.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/utils/XmlUtils.java
b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/utils/XmlUtils.java
index f86b9a3..63aa1ec 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/utils/XmlUtils.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/utils/XmlUtils.java
@@ -19,19 +19,6 @@ import static javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI;
 import static org.apache.geode.management.internal.configuration.utils.XmlConstants.W3C_XML_SCHEMA_INSTANCE_ATTRIBUTE_SCHEMA_LOCATION;
 import static org.apache.geode.management.internal.configuration.utils.XmlConstants.W3C_XML_SCHEMA_INSTANCE_PREFIX;
 
-import org.apache.commons.lang.StringUtils;
-import org.apache.geode.internal.cache.xmlcache.CacheXml;
-import org.apache.geode.internal.cache.xmlcache.CacheXmlParser;
-import org.apache.geode.management.internal.configuration.domain.CacheElement;
-import org.apache.geode.management.internal.configuration.domain.XmlEntity;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
 import java.io.IOException;
 import java.io.Reader;
 import java.io.StringReader;
@@ -45,6 +32,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.StringTokenizer;
+
 import javax.xml.namespace.NamespaceContext;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -61,6 +49,20 @@ import javax.xml.xpath.XPathConstants;
 import javax.xml.xpath.XPathExpressionException;
 import javax.xml.xpath.XPathFactory;
 
+import org.apache.commons.lang.StringUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import org.apache.geode.internal.cache.xmlcache.CacheXml;
+import org.apache.geode.internal.cache.xmlcache.CacheXmlParser;
+import org.apache.geode.management.internal.configuration.domain.CacheElement;
+import org.apache.geode.management.internal.configuration.domain.XmlEntity;
+
 public class XmlUtils {
 
   /**
@@ -75,7 +77,7 @@ public class XmlUtils {
    */
   public static Document createDocumentFromReader(final Reader reader)
       throws SAXException, ParserConfigurationException, IOException {
-    Document doc = null;
+    Document doc;
     InputSource inputSource = new InputSource(reader);
 
     doc = getDocumentBuilder().parse(inputSource);
@@ -148,7 +150,6 @@ public class XmlUtils {
         final String namespace = childElement.getNamespaceURI();
 
         if (namespace.equals(xmlEntity.getNamespace()) && type.equals(xmlEntity.getType()))
{
-          // TODO this should really be checking all attributes in xmlEntity.getAttributes
           // First check if the element has a name
           String nameOrId = getAttribute(childElement, "name");
           // If not then check if the element has an Id
@@ -233,15 +234,15 @@ public class XmlUtils {
    * Creates a node from the String xml definition
    * 
    * @param owner
-   * @param xmlDefintion
+   * @param xmlDefinition
    * @return Node representing the xml definition
    * @throws ParserConfigurationException
    * @throws IOException
    * @throws SAXException
    */
-  private static Node createNode(Document owner, String xmlDefintion)
+  private static Node createNode(Document owner, String xmlDefinition)
       throws SAXException, IOException, ParserConfigurationException {
-    InputSource inputSource = new InputSource(new StringReader(xmlDefintion));
+    InputSource inputSource = new InputSource(new StringReader(xmlDefinition));
     Document document = getDocumentBuilder().parse(inputSource);
     Node newNode = document.getDocumentElement();
     return owner.importNode(newNode, true);
@@ -279,7 +280,7 @@ public class XmlUtils {
    * @since GemFire 8.1
    */
   public static Map<String, List<String>> buildSchemaLocationMap(final String
schemaLocation) {
-    return buildSchemaLocationMap(new HashMap<String, List<String>>(), schemaLocation);
+    return buildSchemaLocationMap(new HashMap<>(), schemaLocation);
   }
 
   /**
@@ -296,12 +297,7 @@ public class XmlUtils {
    */
   static Map<String, List<String>> buildSchemaLocationMap(
       Map<String, List<String>> schemaLocationMap, final String schemaLocation)
{
-    if (null == schemaLocation) {
-      return schemaLocationMap;
-    }
-
     if (null == schemaLocation || schemaLocation.isEmpty()) {
-      // should really ever be null but being safe.
       return schemaLocationMap;
     }
 
@@ -323,7 +319,7 @@ public class XmlUtils {
   }
 
   /*****
-   * Deletes all the node from the document which match the definition provided by xmlentity
+   * Deletes all the node from the document which match the definition provided by xmlEntity
    * 
    * @param doc
    * @param xmlEntity
@@ -366,8 +362,8 @@ public class XmlUtils {
    *
    */
   public static class XPathContext implements NamespaceContext {
-    private HashMap<String, String> prefixToUri = new HashMap<String, String>();
-    private HashMap<String, String> uriToPrefix = new HashMap<String, String>();
+    private HashMap<String, String> prefixToUri = new HashMap<>();
+    private HashMap<String, String> uriToPrefix = new HashMap<>();
 
 
     public XPathContext() {}
@@ -408,7 +404,7 @@ public class XmlUtils {
    * @throws TransformerFactoryConfigurationError
    */
   public static String prettyXml(Node doc)
-      throws IOException, TransformerFactoryConfigurationError, TransformerException {
+      throws TransformerFactoryConfigurationError, TransformerException {
     Transformer transformer = TransformerFactory.newInstance().newTransformer();
     transformer.setOutputProperty(OutputKeys.INDENT, "yes");
 
@@ -428,8 +424,7 @@ public class XmlUtils {
     DOMSource source = new DOMSource(element);
     transformer.transform(source, result);
 
-    String xmlString = result.getWriter().toString();
-    return xmlString;
+    return result.getWriter().toString();
   }
 
   /****
@@ -510,7 +505,6 @@ public class XmlUtils {
     }
 
     if (null != document.getDoctype()) {
-      // doc.setDocType(null);
       Node root = document.getDocumentElement();
 
       Document copiedDocument = getDocumentBuilder().newDocument();
@@ -551,7 +545,7 @@ public class XmlUtils {
         buildSchemaLocationMap(schemaLocationAttribute);
     List<String> schemaLocations = schemaLocationMap.get(namespaceUri);
     if (null == schemaLocations) {
-      schemaLocations = new ArrayList<String>();
+      schemaLocations = new ArrayList<>();
       schemaLocationMap.put(namespaceUri, schemaLocations);
     }
     schemaLocations.clear();
@@ -665,7 +659,7 @@ public class XmlUtils {
    * @param xmlEntity xml entity for the root , it also contains the attributes
    * @throws IOException
    */
-  public static void modifyRootAttributes(Document doc, XmlEntity xmlEntity) throws IOException
{
+  public static void modifyRootAttributes(Document doc, XmlEntity xmlEntity) {
     if (xmlEntity == null || xmlEntity.getAttributes() == null) {
       return;
     }

http://git-wip-us.apache.org/repos/asf/geode/blob/fb9a405f/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DataCommandsController.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DataCommandsController.java
b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DataCommandsController.java
index ce7ebfc..8a16aa4 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DataCommandsController.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DataCommandsController.java
@@ -16,6 +16,7 @@ package org.apache.geode.management.internal.web.controllers;
 
 import java.util.concurrent.Callable;
 
+import org.apache.commons.lang.StringUtils;
 import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.PathVariable;
@@ -25,7 +26,6 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.context.request.WebRequest;
 
-import org.apache.geode.internal.lang.StringUtils;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
 
@@ -194,7 +194,6 @@ public class DataCommandsController extends AbstractCommandsController
{
       @RequestParam(CliStrings.QUERY__QUERY) final String oql,
       @RequestParam(value = CliStrings.QUERY__INTERACTIVE,
           defaultValue = "true") final Boolean interactive) {
-    // logRequest(request);
 
     final CommandStringBuilder command = new CommandStringBuilder(CliStrings.QUERY);
 
@@ -219,12 +218,12 @@ public class DataCommandsController extends AbstractCommandsController
{
 
     if (hasValue(includedRegions)) {
       command.addOption(CliStrings.REBALANCE__INCLUDEREGION,
-          StringUtils.join(includedRegions, StringUtils.COMMA_DELIMITER));
+          StringUtils.join(includedRegions, ","));
     }
 
     if (hasValue(excludedRegions)) {
       command.addOption(CliStrings.REBALANCE__EXCLUDEREGION,
-          StringUtils.join(excludedRegions, StringUtils.COMMA_DELIMITER));
+          StringUtils.join(excludedRegions, ","));
     }
 
     command.addOption(CliStrings.REBALANCE__SIMULATE, String.valueOf(simulate));

http://git-wip-us.apache.org/repos/asf/geode/blob/fb9a405f/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/RegionCommandsController.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/RegionCommandsController.java
b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/RegionCommandsController.java
index 815bc47..9180414 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/RegionCommandsController.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/RegionCommandsController.java
@@ -14,6 +14,7 @@
  */
 package org.apache.geode.management.internal.web.controllers;
 
+import org.apache.commons.lang.StringUtils;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -22,7 +23,6 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.context.request.WebRequest;
 
-import org.apache.geode.internal.lang.StringUtils;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
 
@@ -108,14 +108,13 @@ public class RegionCommandsController extends AbstractCommandsController
{
           required = false) final Boolean enableCloning,
       @RequestParam(value = CliStrings.ALTER_REGION__EVICTIONMAX,
           required = false) final Integer evictionMax) {
-    // logRequest(request);
 
     final CommandStringBuilder command = new CommandStringBuilder(CliStrings.ALTER_REGION);
 
     command.addOption(CliStrings.ALTER_REGION__REGION, decode(regionNamePath));
 
     if (hasValue(groups)) {
-      command.addOption(CliStrings.GROUP, StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
+      command.addOption(CliStrings.GROUP, StringUtils.join(groups, ","));
     }
 
     addCommandOption(request, command, CliStrings.ALTER_REGION__ENTRYEXPIRATIONIDLETIME,
@@ -240,7 +239,7 @@ public class RegionCommandsController extends AbstractCommandsController
{
     }
 
     if (hasValue(groups)) {
-      command.addOption(CliStrings.GROUP, StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
+      command.addOption(CliStrings.GROUP, StringUtils.join(groups, ","));
     }
 
     command.addOption(CliStrings.CREATE_REGION__SKIPIFEXISTS,
@@ -320,7 +319,7 @@ public class RegionCommandsController extends AbstractCommandsController
{
 
     if (hasValue(cacheListeners)) {
       command.addOption(CliStrings.CREATE_REGION__CACHELISTENER,
-          StringUtils.join(cacheListeners, StringUtils.COMMA_DELIMITER));
+          StringUtils.join(cacheListeners, ","));
     }
 
     if (hasValue(cacheLoader)) {
@@ -333,12 +332,12 @@ public class RegionCommandsController extends AbstractCommandsController
{
 
     if (hasValue(asyncEventQueueIds)) {
       command.addOption(CliStrings.CREATE_REGION__ASYNCEVENTQUEUEID,
-          StringUtils.join(asyncEventQueueIds, StringUtils.COMMA_DELIMITER));
+          StringUtils.join(asyncEventQueueIds, ","));
     }
 
     if (hasValue(gatewaySenderIds)) {
       command.addOption(CliStrings.CREATE_REGION__GATEWAYSENDERID,
-          StringUtils.join(gatewaySenderIds, StringUtils.COMMA_DELIMITER));
+          StringUtils.join(gatewaySenderIds, ","));
     }
 
     if (Boolean.TRUE.equals(enableConcurrencyChecks)) {

http://git-wip-us.apache.org/repos/asf/geode/blob/fb9a405f/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ShellCommandsController.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ShellCommandsController.java
b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ShellCommandsController.java
index e983f2a..63413b0 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ShellCommandsController.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ShellCommandsController.java
@@ -14,15 +14,15 @@
  */
 package org.apache.geode.management.internal.web.controllers;
 
+import java.io.IOException;
+import java.util.Set;
+
+import javax.management.AttributeNotFoundException;
+import javax.management.InstanceNotFoundException;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
 import org.apache.commons.lang.ArrayUtils;
-import org.apache.geode.internal.GemFireVersion;
-import org.apache.geode.internal.lang.ObjectUtils;
-import org.apache.geode.internal.util.IOUtils;
-import org.apache.geode.management.internal.cli.i18n.CliStrings;
-import org.apache.geode.management.internal.web.domain.Link;
-import org.apache.geode.management.internal.web.domain.LinkIndex;
-import org.apache.geode.management.internal.web.domain.QueryParameterSource;
-import org.apache.geode.management.internal.web.http.HttpMethod;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.MediaType;
 import org.springframework.http.ResponseEntity;
@@ -33,12 +33,14 @@ import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
 
-import java.io.IOException;
-import java.util.Set;
-import javax.management.AttributeNotFoundException;
-import javax.management.InstanceNotFoundException;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
+import org.apache.geode.internal.GemFireVersion;
+import org.apache.geode.internal.lang.ObjectUtils;
+import org.apache.geode.internal.util.IOUtils;
+import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.apache.geode.management.internal.web.domain.Link;
+import org.apache.geode.management.internal.web.domain.LinkIndex;
+import org.apache.geode.management.internal.web.domain.QueryParameterSource;
+import org.apache.geode.management.internal.web.http.HttpMethod;
 
 /**
  * The ShellCommandsController class implements GemFire REST API calls for Gfsh Shell Commands.
@@ -69,7 +71,6 @@ public class ShellCommandsController extends AbstractCommandsController
{
     return processCommand(decode(command));
   }
 
-  // TODO research the use of Jolokia instead
   @RequestMapping(method = RequestMethod.GET, value = "/mbean/attribute")
   public ResponseEntity<?> getAttribute(@RequestParam("resourceName") final String
resourceName,
       @RequestParam("attributeName") final String attributeName) {
@@ -77,19 +78,16 @@ public class ShellCommandsController extends AbstractCommandsController
{
       final Object attributeValue = getMBeanServer()
           .getAttribute(ObjectName.getInstance(decode(resourceName)), decode(attributeName));
 
-      return new ResponseEntity<byte[]>(IOUtils.serializeObject(attributeValue), HttpStatus.OK);
-    } catch (AttributeNotFoundException e) {
-      return new ResponseEntity<String>(printStackTrace(e), HttpStatus.BAD_REQUEST);
+      return new ResponseEntity<>(IOUtils.serializeObject(attributeValue), HttpStatus.OK);
+    } catch (AttributeNotFoundException | MalformedObjectNameException e) {
+      return new ResponseEntity<>(printStackTrace(e), HttpStatus.BAD_REQUEST);
     } catch (InstanceNotFoundException e) {
-      return new ResponseEntity<String>(printStackTrace(e), HttpStatus.NOT_FOUND);
-    } catch (MalformedObjectNameException e) {
-      return new ResponseEntity<String>(printStackTrace(e), HttpStatus.BAD_REQUEST);
+      return new ResponseEntity<>(printStackTrace(e), HttpStatus.NOT_FOUND);
     } catch (Exception e) {
-      return new ResponseEntity<String>(printStackTrace(e), HttpStatus.INTERNAL_SERVER_ERROR);
+      return new ResponseEntity<>(printStackTrace(e), HttpStatus.INTERNAL_SERVER_ERROR);
     }
   }
 
-  // TODO research the use of Jolokia instead
   @RequestMapping(method = RequestMethod.POST, value = "/mbean/operation")
   public ResponseEntity<?> invoke(@RequestParam("resourceName") final String resourceName,
       @RequestParam("operationName") final String operationName,
@@ -102,13 +100,13 @@ public class ShellCommandsController extends AbstractCommandsController
{
       final Object result = getMBeanServer().invoke(ObjectName.getInstance(decode(resourceName)),
           decode(operationName), parameters, signature);
 
-      return new ResponseEntity<byte[]>(IOUtils.serializeObject(result), HttpStatus.OK);
+      return new ResponseEntity<>(IOUtils.serializeObject(result), HttpStatus.OK);
     } catch (InstanceNotFoundException e) {
-      return new ResponseEntity<String>(printStackTrace(e), HttpStatus.NOT_FOUND);
+      return new ResponseEntity<>(printStackTrace(e), HttpStatus.NOT_FOUND);
     } catch (MalformedObjectNameException e) {
-      return new ResponseEntity<String>(printStackTrace(e), HttpStatus.BAD_REQUEST);
+      return new ResponseEntity<>(printStackTrace(e), HttpStatus.BAD_REQUEST);
     } catch (Exception e) {
-      return new ResponseEntity<String>(printStackTrace(e), HttpStatus.INTERNAL_SERVER_ERROR);
+      return new ResponseEntity<>(printStackTrace(e), HttpStatus.INTERNAL_SERVER_ERROR);
     }
   }
 
@@ -118,9 +116,9 @@ public class ShellCommandsController extends AbstractCommandsController
{
       final Set<ObjectName> objectNames =
           getMBeanServer().queryNames(query.getObjectName(), query.getQueryExpression());
 
-      return new ResponseEntity<byte[]>(IOUtils.serializeObject(objectNames), HttpStatus.OK);
+      return new ResponseEntity<>(IOUtils.serializeObject(objectNames), HttpStatus.OK);
     } catch (IOException e) {
-      return new ResponseEntity<String>(printStackTrace(e), HttpStatus.INTERNAL_SERVER_ERROR);
+      return new ResponseEntity<>(printStackTrace(e), HttpStatus.INTERNAL_SERVER_ERROR);
     }
   }
 
@@ -135,16 +133,11 @@ public class ShellCommandsController extends AbstractCommandsController
{
    * @see org.apache.geode.management.internal.web.domain.LinkIndex
    * @see org.apache.geode.management.internal.web.http.HttpMethod
    */
-  // TODO figure out a better way to maintain this link index, such as using an automated
way to
-  // introspect
-  // the Spring Web MVC Controller RequestMapping Annotations.
   @RequestMapping(method = RequestMethod.GET, value = "/index",
       produces = MediaType.APPLICATION_XML_VALUE)
   @ResponseBody
   public LinkIndex index(@RequestParam(value = "scheme", required = false,
       defaultValue = "http") final String scheme) {
-    // logger.warning(String.format("Returning Link Index for Context Path (%1$s).",
-    // ServletUriComponentsBuilder.fromCurrentContextPath().build().toString()));
     return new LinkIndex()
         // Cluster Commands
         .add(new Link(CliStrings.STATUS_SHARED_CONFIG, toUri("/services/cluster-config",
scheme)))
@@ -293,7 +286,7 @@ public class ShellCommandsController extends AbstractCommandsController
{
 
   @RequestMapping(method = {RequestMethod.GET, RequestMethod.HEAD}, value = "/ping")
   public ResponseEntity<String> ping() {
-    return new ResponseEntity<String>("<html><body><h1>Mischief Managed!</h1></body></html>",
+    return new ResponseEntity<>("<html><body><h1>Mischief Managed!</h1></body></html>",
         HttpStatus.OK);
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/fb9a405f/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/FunctionCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/FunctionCommandsDUnitTest.java
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/FunctionCommandsDUnitTest.java
index a0788a0..3bda1c0 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/FunctionCommandsDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/FunctionCommandsDUnitTest.java
@@ -41,7 +41,6 @@ import org.apache.geode.management.DistributedRegionMXBean;
 import org.apache.geode.management.ManagementService;
 import org.apache.geode.management.cli.Result;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
-import org.apache.geode.management.internal.cli.json.GfJsonException;
 import org.apache.geode.management.internal.cli.result.CommandResult;
 import org.apache.geode.management.internal.cli.result.TabularResultData;
 import org.apache.geode.test.dunit.Host;
@@ -227,7 +226,7 @@ public class FunctionCommandsDUnitTest extends CliCommandTestBase {
   SerializableRunnable checkRegionMBeans = new SerializableRunnable() {
     @Override
     public void run() {
-      final WaitCriterion waitForMaangerMBean = new WaitCriterion() {
+      final WaitCriterion waitForManagerMBean = new WaitCriterion() {
         @Override
         public boolean done() {
           final ManagementService service = ManagementService.getManagementService(getCache());
@@ -247,7 +246,7 @@ public class FunctionCommandsDUnitTest extends CliCommandTestBase {
           return "Probing for testExecuteFunctionOnRegionBug51480";
         }
       };
-      waitForCriterion(waitForMaangerMBean, 2 * 60 * 1000, 2000, true);
+      waitForCriterion(waitForManagerMBean, 2 * 60 * 1000, 2000, true);
       DistributedRegionMXBean bean = ManagementService.getManagementService(getCache())
           .getDistributedRegionMXBean(Region.SEPARATOR + REGION_ONE);
       assertNotNull(bean);
@@ -294,7 +293,7 @@ public class FunctionCommandsDUnitTest extends CliCommandTestBase {
     Function function = new TestFunction(true, TestFunction.TEST_FUNCTION1);
     FunctionService.registerFunction(function);
     final VM vm1 = Host.getHost(0).getVM(1);
-    final String vm1MemberId = (String) vm1.invoke(() -> getMemberId());
+    final String vm1MemberId = vm1.invoke(this::getMemberId);
 
     Host.getHost(0).getVM(0).invoke(new SerializableRunnable() {
       public void run() {
@@ -494,7 +493,7 @@ public class FunctionCommandsDUnitTest extends CliCommandTestBase {
     Function function = new TestFunction(true, TestFunction.TEST_FUNCTION1);
     FunctionService.registerFunction(function);
     final VM vm1 = Host.getHost(0).getVM(1);
-    final String vm1MemberId = (String) vm1.invoke(() -> getMemberId());
+    final String vm1MemberId = vm1.invoke(this::getMemberId);
     String command = "destroy function --id=" + function.getId() + " --member=" + vm1MemberId;
     getLogWriter().info("testDestroyOnMember command=" + command);
     CommandResult cmdResult = executeCommand(command);
@@ -560,13 +559,9 @@ public class FunctionCommandsDUnitTest extends CliCommandTestBase {
     CommandResult cmdResult = executeCommand(command);
     getLogWriter().info("testDestroyOnGroups cmdResult=" + cmdResult);
     assertEquals(Result.Status.OK, cmdResult.getStatus());
-    String content = null;
-    try {
-      content = cmdResult.getContent().get("message").toString();
-      getLogWriter().info("testDestroyOnGroups content = " + content);
-    } catch (GfJsonException e) {
-      fail("testDestroyOnGroups exception=" + e);
-    }
+    String content;
+    content = cmdResult.getContent().get("message").toString();
+    getLogWriter().info("testDestroyOnGroups content = " + content);
     assertNotNull(content);
     assertTrue(content
         .equals("[\"Destroyed " + TestFunction.TEST_FUNCTION1 + " Successfully on " + vm1id
+ ","


Mime
View raw message