diff options
author | Alex Rudyy <orudyy@apache.org> | 2014-09-11 17:37:32 +0000 |
---|---|---|
committer | Alex Rudyy <orudyy@apache.org> | 2014-09-11 17:37:32 +0000 |
commit | 0909d3ee43d0dbd04d9d5931d5f037544e5a0624 (patch) | |
tree | 4b1151719d00d084178f1d67d1b79b2b57fa4baf /java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java | |
parent | 8a35eea63b0a7c05ba77c1aa6e18915c15c645c2 (diff) | |
download | qpid-python-0909d3ee43d0dbd04d9d5931d5f037544e5a0624.tar.gz |
QPID-6093: Add UI to set context variables
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1624345 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java')
-rw-r--r-- | java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java b/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java index 7769263e5a..7bde933bb9 100644 --- a/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java +++ b/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java @@ -35,6 +35,7 @@ import java.util.TreeMap; import org.apache.qpid.server.model.ConfiguredObject; import org.apache.qpid.server.model.ConfiguredObjectAttribute; +import org.apache.qpid.server.model.Model; public class ConfiguredObjectToMapConverter { @@ -56,9 +57,20 @@ public class ConfiguredObjectToMapConverter final boolean includeSystemContext, final boolean extractAsConfig) { + return convertObjectToMap(confObject, clazz, depth, useActualValues, false, includeSystemContext, extractAsConfig); + } + + public Map<String, Object> convertObjectToMap(final ConfiguredObject<?> confObject, + Class<? extends ConfiguredObject> clazz, + int depth, + final boolean useActualValues, + final boolean inheritedActuals, + final boolean includeSystemContext, + final boolean extractAsConfig) + { Map<String, Object> object = new LinkedHashMap<>(); - incorporateAttributesIntoMap(confObject, object, useActualValues, includeSystemContext, extractAsConfig); + incorporateAttributesIntoMap(confObject, object, useActualValues, inheritedActuals, includeSystemContext, extractAsConfig); if(!extractAsConfig) { incorporateStatisticsIntoMap(confObject, object); @@ -66,7 +78,7 @@ public class ConfiguredObjectToMapConverter if(depth > 0) { - incorporateChildrenIntoMap(confObject, clazz, depth, object, useActualValues, includeSystemContext, extractAsConfig); + incorporateChildrenIntoMap(confObject, clazz, depth, object, useActualValues, inheritedActuals, includeSystemContext, extractAsConfig); } return object; } @@ -76,6 +88,7 @@ public class ConfiguredObjectToMapConverter final ConfiguredObject<?> confObject, Map<String, Object> object, final boolean useActualValues, + final boolean inheritedActuals, final boolean includeSystemContext, final boolean extractAsConfig) { @@ -115,7 +128,7 @@ public class ConfiguredObjectToMapConverter Map<String, Object> contextValues = new HashMap<>(); if (useActualValues) { - contextValues.putAll(confObject.getContext()); + collectContext(contextValues, confObject.getModel(), confObject, inheritedActuals); } else { @@ -165,6 +178,27 @@ public class ConfiguredObjectToMapConverter } } + private void collectContext(Map<String, Object> contextValues, Model model, ConfiguredObject<?> confObject, boolean inheritedContext) + { + Object value = confObject.getActualAttributes().get(ConfiguredObject.CONTEXT); + if (inheritedContext) + { + Collection<Class<? extends ConfiguredObject>> parents = model.getParentTypes(confObject.getCategoryClass()); + if(parents != null && !parents.isEmpty()) + { + ConfiguredObject parent = confObject.getParent(parents.iterator().next()); + if(parent != null) + { + collectContext(contextValues, model, parent, inheritedContext); + } + } + } + if (value instanceof Map) + { + contextValues.putAll((Map<String,String>)value); + } + } + private void incorporateStatisticsIntoMap( final ConfiguredObject<?> confObject, Map<String, Object> object) { @@ -184,6 +218,7 @@ public class ConfiguredObjectToMapConverter int depth, Map<String, Object> object, final boolean useActualValues, + final boolean inheritedActuals, final boolean includeSystemContext, final boolean extractAsConfig) { @@ -225,6 +260,7 @@ public class ConfiguredObjectToMapConverter childClass, depth - 1, useActualValues, + inheritedActuals, includeSystemContext, extractAsConfig)); } |