qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgodf...@apache.org
Subject svn commit: r1614333 - in /qpid/trunk/qpid/java: bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/ bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/b...
Date Tue, 29 Jul 2014 12:58:38 GMT
Author: rgodfrey
Date: Tue Jul 29 12:58:37 2014
New Revision: 1614333

URL: http://svn.apache.org/r1614333
Log:
QPID-5937 : [Java Broker] Add parameters to REST servlet to allow return of actual vs. effective
attribute values

Modified:
    qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/StandardEnvironmentFacadeFactory.java
    qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacadeFactory.java
    qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeImpl.java
    qpid/trunk/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreQuotaEventsTest.java
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNode.java
    qpid/trunk/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreQuotaEventsTest.java
    qpid/trunk/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCConfigurationStore.java
    qpid/trunk/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCMessageStore.java
    qpid/trunk/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCDetails.java
    qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java
    qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
    qpid/trunk/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverterTest.java

Modified: qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/StandardEnvironmentFacadeFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/StandardEnvironmentFacadeFactory.java?rev=1614333&r1=1614332&r2=1614333&view=diff
==============================================================================
--- qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/StandardEnvironmentFacadeFactory.java
(original)
+++ qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/StandardEnvironmentFacadeFactory.java
Tue Jul 29 12:58:37 2014
@@ -71,7 +71,7 @@ public class StandardEnvironmentFacadeFa
         for (ConfigParam cp : EnvironmentParams.SUPPORTED_PARAMS.values())
         {
             final String parameterName = cp.getName();
-            Set<String> contextKeys = parent.getContextKeys();
+            Set<String> contextKeys = parent.getContextKeys(false);
             if (!cp.isForReplication() && contextKeys.contains(parameterName))
             {
                 envConfigMap.put(parameterName, parent.getContextValue(String.class, parameterName));

Modified: qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacadeFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacadeFactory.java?rev=1614333&r1=1614332&r2=1614333&view=diff
==============================================================================
--- qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacadeFactory.java
(original)
+++ qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacadeFactory.java
Tue Jul 29 12:58:37 2014
@@ -126,7 +126,7 @@ public class ReplicatedEnvironmentFacade
     private Map<String, String> buildConfig(ConfiguredObject<?> parent, Pattern
paramName)
     {
         Map<String, String> targetMap = new HashMap<>();
-        for (String name : parent.getContextKeys())
+        for (String name : parent.getContextKeys(false))
         {
             if (paramName.matcher(name).matches())
             {

Modified: qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeImpl.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeImpl.java?rev=1614333&r1=1614332&r2=1614333&view=diff
==============================================================================
--- qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeImpl.java
(original)
+++ qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeImpl.java
Tue Jul 29 12:58:37 2014
@@ -418,7 +418,7 @@ public class BDBHAVirtualHostNodeImpl ex
                     LOGGER.debug("Creating new virtualhost with name : " + getGroupName());
                 }
 
-                boolean hasBlueprint = getContextKeys().contains(VIRTUALHOST_BLUEPRINT_CONTEXT_VAR);
+                boolean hasBlueprint = getContextKeys(false).contains(VIRTUALHOST_BLUEPRINT_CONTEXT_VAR);
                 boolean blueprintUtilised = getContext().containsKey(VIRTUALHOST_BLUEPRINT_UTILISED_CONTEXT_VAR)
                                             && Boolean.parseBoolean(String.valueOf(getContext().get(
                         VIRTUALHOST_BLUEPRINT_UTILISED_CONTEXT_VAR)));

Modified: qpid/trunk/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreQuotaEventsTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreQuotaEventsTest.java?rev=1614333&r1=1614332&r2=1614333&view=diff
==============================================================================
--- qpid/trunk/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreQuotaEventsTest.java
(original)
+++ qpid/trunk/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreQuotaEventsTest.java
Tue Jul 29 12:58:37 2014
@@ -64,7 +64,7 @@ public class BDBMessageStoreQuotaEventsT
         final BDBVirtualHost parent = mock(BDBVirtualHost.class);
         Map<String, String> contextMap = Collections.singletonMap("je.log.fileMax",
MAX_BDB_LOG_SIZE);
         when(parent.getContext()).thenReturn(contextMap);
-        when(parent.getContextKeys()).thenReturn(contextMap.keySet());
+        when(parent.getContextKeys(false)).thenReturn(contextMap.keySet());
         when(parent.getContextValue(eq(String.class),eq("je.log.fileMax"))).thenReturn(MAX_BDB_LOG_SIZE);
         when(parent.getStorePath()).thenReturn(storeLocation);
         when(parent.getStoreOverfullSize()).thenReturn(OVERFULL_SIZE);

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java?rev=1614333&r1=1614332&r2=1614333&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
Tue Jul 29 12:58:37 2014
@@ -1340,9 +1340,14 @@ public abstract class AbstractConfigured
     }
 
     @Override
-    public Set<String> getContextKeys()
+    public Set<String> getContextKeys(final boolean excludeSystem)
     {
         Map<String,String> inheritedContext = new HashMap<>();
+        if(!excludeSystem)
+        {
+            inheritedContext.putAll(System.getenv());
+            inheritedContext.putAll((Map) System.getProperties());
+        }
         generateInheritedContext(getModel(), this, inheritedContext);
         return Collections.unmodifiableSet(inheritedContext.keySet());
     }

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java?rev=1614333&r1=1614332&r2=1614333&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java
Tue Jul 29 12:58:37 2014
@@ -79,7 +79,7 @@ public interface ConfiguredObject<X exte
 
     <T> T getContextValue(Class<T> clazz, String propertyName);
 
-    Set<String> getContextKeys();
+    Set<String> getContextKeys(final boolean includeSystem);
 
     @DerivedAttribute( persist = true )
     String getLastUpdatedBy();

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNode.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNode.java?rev=1614333&r1=1614332&r2=1614333&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNode.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNode.java
Tue Jul 29 12:58:37 2014
@@ -90,7 +90,7 @@ public abstract class AbstractStandardVi
         if (host == null)
         {
 
-            boolean hasBlueprint = getContextKeys().contains(VIRTUALHOST_BLUEPRINT_CONTEXT_VAR);
+            boolean hasBlueprint = getContextKeys(false).contains(VIRTUALHOST_BLUEPRINT_CONTEXT_VAR);
             boolean blueprintUtilised = getContext().containsKey(VIRTUALHOST_BLUEPRINT_UTILISED_CONTEXT_VAR)
                     && Boolean.parseBoolean(String.valueOf(getContext().get(VIRTUALHOST_BLUEPRINT_UTILISED_CONTEXT_VAR)));
 

Modified: qpid/trunk/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreQuotaEventsTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreQuotaEventsTest.java?rev=1614333&r1=1614332&r2=1614333&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreQuotaEventsTest.java
(original)
+++ qpid/trunk/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreQuotaEventsTest.java
Tue Jul 29 12:58:37 2014
@@ -54,7 +54,7 @@ public class DerbyMessageStoreQuotaEvent
     {
         final DerbyVirtualHost parent = mock(DerbyVirtualHost.class);
         when(parent.getContext()).thenReturn(createContextSettings());
-        when(parent.getContextKeys()).thenReturn(Collections.emptySet());
+        when(parent.getContextKeys(false)).thenReturn(Collections.emptySet());
         when(parent.getStorePath()).thenReturn(storeLocation);
         when(parent.getStoreOverfullSize()).thenReturn(OVERFULL_SIZE);
         when(parent.getStoreUnderfullSize()).thenReturn(UNDERFULL_SIZE);

Modified: qpid/trunk/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCConfigurationStore.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCConfigurationStore.java?rev=1614333&r1=1614332&r2=1614333&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCConfigurationStore.java
(original)
+++ qpid/trunk/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCConfigurationStore.java
Tue Jul 29 12:58:37 2014
@@ -114,7 +114,7 @@ public class GenericJDBCConfigurationSto
             {
                 Map<String, String> providerAttributes = new HashMap<>();
                 Set<String> providerAttributeNames = connectionProviderFactory.getProviderAttributeNames();
-                providerAttributeNames.retainAll(parent.getContextKeys());
+                providerAttributeNames.retainAll(parent.getContextKeys(false));
                 for(String attr : providerAttributeNames)
                 {
                     providerAttributes.put(attr, parent.getContextValue(String.class, attr));

Modified: qpid/trunk/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCMessageStore.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCMessageStore.java?rev=1614333&r1=1614332&r2=1614333&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCMessageStore.java
(original)
+++ qpid/trunk/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCMessageStore.java
Tue Jul 29 12:58:37 2014
@@ -93,7 +93,7 @@ public class GenericJDBCMessageStore ext
         {
             Map<String, String> providerAttributes = new HashMap<>();
             Set<String> providerAttributeNames = connectionProviderFactory.getProviderAttributeNames();
-            providerAttributeNames.retainAll(parent.getContextKeys());
+            providerAttributeNames.retainAll(parent.getContextKeys(false));
             for(String attr : providerAttributeNames)
             {
                 providerAttributes.put(attr, parent.getContextValue(String.class, attr));

Modified: qpid/trunk/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCDetails.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCDetails.java?rev=1614333&r1=1614332&r2=1614333&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCDetails.java
(original)
+++ qpid/trunk/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCDetails.java
Tue Jul 29 12:58:37 2014
@@ -224,7 +224,7 @@ public abstract class JDBCDetails
 
     public static JDBCDetails getDetailsForJdbcUrl(String jdbcUrl, final ConfiguredObject<?>
object)
     {
-        final Set<String> contextKeys = object.getContextKeys();
+        final Set<String> contextKeys = object.getContextKeys(false);
         Map<String,String> mapConversion = new AbstractMap<String, String>()
         {
             @Override

Modified: qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java?rev=1614333&r1=1614332&r2=1614333&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java
(original)
+++ qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java
Tue Jul 29 12:58:37 2014
@@ -21,6 +21,7 @@ package org.apache.qpid.server.managemen
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -33,32 +34,54 @@ public class ConfiguredObjectToMapConver
     public static final String STATISTICS_MAP_KEY = "statistics";
 
     public Map<String, Object> convertObjectToMap(final ConfiguredObject<?> confObject,
-                                                  Class<? extends  ConfiguredObject>
clazz,
-                                                  int depth)
+                                                  Class<? extends ConfiguredObject>
clazz,
+                                                  int depth,
+                                                  final boolean useActualValues,
+                                                  final boolean includeSystemContext)
     {
         Map<String, Object> object = new LinkedHashMap<String, Object>();
 
-        incorporateAttributesIntoMap(confObject, object);
+        incorporateAttributesIntoMap(confObject, object, useActualValues, includeSystemContext);
         incorporateStatisticsIntoMap(confObject, object);
 
         if(depth > 0)
         {
-            incorporateChildrenIntoMap(confObject, clazz, depth, object);
+            incorporateChildrenIntoMap(confObject, clazz, depth, object, useActualValues,
includeSystemContext);
         }
         return object;
     }
 
 
     private void incorporateAttributesIntoMap(
-            final ConfiguredObject<?> confObject, Map<String, Object> object)
+            final ConfiguredObject<?> confObject,
+            Map<String, Object> object,
+            final boolean useActualValues,
+            final boolean includeSystemContext)
     {
+
         for(String name : confObject.getAttributeNames())
         {
-            Object value = confObject.getAttribute(name);
+            Object value = useActualValues ? confObject.getActualAttributes().get(name) :
confObject.getAttribute(name);
             if(value instanceof ConfiguredObject)
             {
                 object.put(name, ((ConfiguredObject) value).getName());
             }
+            else if(ConfiguredObject.CONTEXT.equals(name))
+            {
+                Map<String,Object> contextValues = new HashMap<>();
+                if(useActualValues)
+                {
+                    contextValues.putAll(confObject.getContext());
+                }
+                else
+                {
+                    for(String contextName : confObject.getContextKeys(!includeSystemContext))
+                    {
+                        contextValues.put(contextName, confObject.getContextValue(String.class,
contextName));
+                    }
+                }
+                object.put(ConfiguredObject.CONTEXT, contextValues);
+            }
             else if(value instanceof Collection)
             {
                 List<Object> converted = new ArrayList();
@@ -98,7 +121,7 @@ public class ConfiguredObjectToMapConver
     private void incorporateChildrenIntoMap(
             final ConfiguredObject confObject,
             Class<? extends ConfiguredObject> clazz, int depth,
-            Map<String, Object> object)
+            Map<String, Object> object, final boolean useActualValues, final boolean
includeSystemContext)
     {
         for(Class<? extends ConfiguredObject> childClass : confObject.getModel().getChildTypes(clazz))
         {
@@ -109,7 +132,7 @@ public class ConfiguredObjectToMapConver
 
                 for(ConfiguredObject child : children)
                 {
-                    childObjects.add(convertObjectToMap(child, childClass, depth-1));
+                    childObjects.add(convertObjectToMap(child, childClass, depth-1, useActualValues,
includeSystemContext));
                 }
 
                 if(!childObjects.isEmpty())

Modified: qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java?rev=1614333&r1=1614332&r2=1614333&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
(original)
+++ qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
Tue Jul 29 12:58:37 2014
@@ -53,9 +53,11 @@ public class RestServlet extends Abstrac
     private static final String HIERARCHY_INIT_PARAMETER = "hierarchy";
 
     public static final String DEPTH_PARAM = "depth";
+    public static final String ACTUALS_PARAM = "actuals";
     public static final String SORT_PARAM = "sort";
+    public static final String INCLUDE_SYS_CONTEXT_PARAM = "includeSysContext";
 
-    public static final Set<String> RESERVED_PARAMS = new HashSet<String>(Arrays.asList(DEPTH_PARAM,
SORT_PARAM));
+    public static final Set<String> RESERVED_PARAMS = new HashSet<String>(Arrays.asList(DEPTH_PARAM,
SORT_PARAM, ACTUALS_PARAM, INCLUDE_SYS_CONTEXT_PARAM));
 
     private Class<? extends ConfiguredObject>[] _hierarchy;
 
@@ -311,12 +313,14 @@ public class RestServlet extends Abstrac
 
         // TODO - sort special params, everything else should act as a filter
         int depth = getDepthParameterFromRequest(request);
+        boolean actuals = getBooleanParameterFromRequest(request, ACTUALS_PARAM);
+        boolean includeSystemContext = getBooleanParameterFromRequest(request, INCLUDE_SYS_CONTEXT_PARAM);
 
         List<Map<String, Object>> output = new ArrayList<Map<String, Object>>();
         for(ConfiguredObject configuredObject : allObjects)
         {
             output.add(_objectConverter.convertObjectToMap(configuredObject, getConfiguredClass(),
-                    depth));
+                    depth, actuals, includeSystemContext));
         }
 
         final Writer writer = new BufferedWriter(response.getWriter());
@@ -576,5 +580,22 @@ public class RestServlet extends Abstrac
         return depth;
     }
 
+    private boolean getBooleanParameterFromRequest(HttpServletRequest request, final String
paramName)
+    {
+        boolean value = false;
+        final String stringValue = request.getParameter(paramName);
+        if(stringValue!=null)
+        {
+            try
+            {
+                value = Boolean.parseBoolean(stringValue);
+            }
+            catch (NumberFormatException e)
+            {
+                LOGGER.warn("Could not parse " + stringValue + " as integer");
+            }
+        }
+        return value;
+    }
 
 }

Modified: qpid/trunk/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverterTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverterTest.java?rev=1614333&r1=1614332&r2=1614333&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverterTest.java
(original)
+++ qpid/trunk/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverterTest.java
Tue Jul 29 12:58:37 2014
@@ -19,15 +19,19 @@
  */
 package org.apache.qpid.server.management.plugin.servlet.rest;
 
+import static org.apache.qpid.server.management.plugin.servlet.rest.ConfiguredObjectToMapConverter.STATISTICS_MAP_KEY;
+import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
-import static org.apache.qpid.server.management.plugin.servlet.rest.ConfiguredObjectToMapConverter.STATISTICS_MAP_KEY;
 
 import java.util.ArrayList;
 import java.util.Arrays;
 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 junit.framework.TestCase;
 
@@ -52,7 +56,8 @@ public class ConfiguredObjectToMapConver
 
         when(_configuredObject.getStatistics()).thenReturn(Collections.singletonMap(statisticName,
(Number) statisticValue));
 
-        Map<String, Object> resultMap = _converter.convertObjectToMap(_configuredObject,
ConfiguredObject.class, 0);
+        Map<String, Object> resultMap = _converter.convertObjectToMap(_configuredObject,
ConfiguredObject.class, 0,
+                                                                      false, false);
         Map<String, Object> statsAsMap = (Map<String, Object>) resultMap.get(STATISTICS_MAP_KEY);
         assertNotNull("Statistics should be part of map", statsAsMap);
         assertEquals("Unexpected number of statistics", 1, statsAsMap.size());
@@ -65,7 +70,8 @@ public class ConfiguredObjectToMapConver
         final String attributeValue = "value";
         configureMockToReturnOneAttribute(_configuredObject, attributeName, attributeValue);
 
-        Map<String, Object> resultMap = _converter.convertObjectToMap(_configuredObject,
ConfiguredObject.class, 0);
+        Map<String, Object> resultMap = _converter.convertObjectToMap(_configuredObject,
ConfiguredObject.class, 0,
+                                                                      false, false);
         assertEquals("Unexpected number of attributes", 1, resultMap.size());
         assertEquals("Unexpected attribute value", attributeValue, resultMap.get(attributeName));
     }
@@ -82,7 +88,8 @@ public class ConfiguredObjectToMapConver
 
         configureMockToReturnOneAttribute(_configuredObject, attributeName, attributeValue);
 
-        Map<String, Object> resultMap = _converter.convertObjectToMap(_configuredObject,
ConfiguredObject.class, 0);
+        Map<String, Object> resultMap = _converter.convertObjectToMap(_configuredObject,
ConfiguredObject.class, 0,
+                                                                      false, false);
         assertEquals("Unexpected number of attributes", 1, resultMap.size());
         assertEquals("Unexpected attribute value", "attributeConfiguredObjectName", resultMap.get(attributeName));
     }
@@ -100,7 +107,8 @@ public class ConfiguredObjectToMapConver
         configureMockToReturnOneAttribute(mockChild, childAttributeName, childAttributeValue);
         when(_configuredObject.getChildren(TestChild.class)).thenReturn(Arrays.asList(mockChild));
 
-        Map<String, Object> resultMap = _converter.convertObjectToMap(_configuredObject,
ConfiguredObject.class, 1);
+        Map<String, Object> resultMap = _converter.convertObjectToMap(_configuredObject,
ConfiguredObject.class, 1,
+                                                                      false, false);
         assertEquals("Unexpected parent map size", 1, resultMap.size());
 
         final List<Map<String, Object>> childList = (List<Map<String, Object>>)
resultMap.get("testchilds");
@@ -112,6 +120,58 @@ public class ConfiguredObjectToMapConver
         assertEquals("Unexpected child attribute value", childAttributeValue, childMap.get(childAttributeName));
     }
 
+    public void testActuals()
+    {
+        final String childAttributeName = "childattribute";
+        final String childAttributeValue = "childvalue";
+        final String childActualAttributeValue = "${actualvalue}";
+        final Map<String,Object> actualContext = Collections.<String,Object>singletonMap("key","value");
+        final Set<String> inheritedKeys = new HashSet<>(Arrays.asList("key","inheritedkey"));
+
+        Model model = createTestModel();
+
+        TestChild mockChild = mock(TestChild.class);
+        when(mockChild.getModel()).thenReturn(model);
+        when(_configuredObject.getModel()).thenReturn(model);
+        when(_configuredObject.getAttributeNames()).thenReturn(Collections.singletonList(ConfiguredObject.CONTEXT));
+        when(_configuredObject.getContextValue(eq(String.class), eq("key"))).thenReturn("value");
+        when(_configuredObject.getContextValue(eq(String.class),eq("inheritedkey"))).thenReturn("foo");
+        when(_configuredObject.getContextKeys(false)).thenReturn(inheritedKeys);
+        when(_configuredObject.getContext()).thenReturn(actualContext);
+        when(mockChild.getAttributeNames()).thenReturn(Arrays.asList(childAttributeName,
ConfiguredObject.CONTEXT));
+        when(mockChild.getAttribute(childAttributeName)).thenReturn(childAttributeValue);
+        when(mockChild.getActualAttributes()).thenReturn(Collections.singletonMap(childAttributeName,
childActualAttributeValue));
+        when(_configuredObject.getChildren(TestChild.class)).thenReturn(Arrays.asList(mockChild));
+
+
+        Map<String, Object> resultMap = _converter.convertObjectToMap(_configuredObject,
ConfiguredObject.class, 1, true,
+                                                                      false);
+        assertEquals("Unexpected parent map size", 2, resultMap.size());
+        assertEquals("Incorrect context", resultMap.get(ConfiguredObject.CONTEXT), actualContext);
+        List<Map<String, Object>> childList = (List<Map<String, Object>>)
resultMap.get("testchilds");
+        assertEquals("Unexpected number of children", 1, childList.size());
+        Map<String, Object> childMap = childList.get(0);
+        assertEquals("Unexpected child map size", 2, childMap.size());
+        assertNotNull(childMap);
+
+        assertEquals("Unexpected child attribute value", childActualAttributeValue, childMap.get(childAttributeName));
+
+        resultMap = _converter.convertObjectToMap(_configuredObject, ConfiguredObject.class,
1, false, false);
+        assertEquals("Unexpected parent map size", 2, resultMap.size());
+        Map<String, Object> inheritedContext = new HashMap<>();
+        inheritedContext.put("key","value");
+        inheritedContext.put("inheritedkey","foo");
+        assertEquals("Incorrect context", resultMap.get(ConfiguredObject.CONTEXT), inheritedContext);
+        childList = (List<Map<String, Object>>) resultMap.get("testchilds");
+        assertEquals("Unexpected number of children", 1, childList.size());
+        childMap = childList.get(0);
+        assertEquals("Unexpected child map size", 2, childMap.size());
+        assertNotNull(childMap);
+
+        assertEquals("Unexpected child attribute value", childAttributeValue, childMap.get(childAttributeName));
+
+    }
+
     private Model createTestModel()
     {
         Model model = mock(Model.class);



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message