Repository: ambari Updated Branches: refs/heads/trunk 4d5050c23 -> f8b83e2f6
AMBARI-10443. Hide empty property_display_name from stack configuration API (mpapirkovskyy via srimanth) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/f8b83e2f Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/f8b83e2f Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/f8b83e2f Branch: refs/heads/trunk Commit: f8b83e2f699848ba1d4d913859af9fff3e405f53 Parents: 4d5050c Author: Srimanth Gunturi <[email protected]> Authored: Fri Apr 10 18:22:01 2015 -0700 Committer: Srimanth Gunturi <[email protected]> Committed: Fri Apr 10 18:22:01 2015 -0700 ---------------------------------------------------------------------- .../internal/StackConfigurationResourceProvider.java | 10 +++++++--- .../apache/ambari/server/state/ValueAttributesInfo.java | 2 +- .../ambari/server/api/services/AmbariMetaInfoTest.java | 5 ++--- 3 files changed, 10 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/f8b83e2f/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackConfigurationResourceProvider.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackConfigurationResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackConfigurationResourceProvider.java index f00a46f..cc624b1 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackConfigurationResourceProvider.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackConfigurationResourceProvider.java @@ -38,6 +38,7 @@ import org.apache.ambari.server.controller.spi.Resource.Type; import org.apache.ambari.server.controller.spi.SystemException; import org.apache.ambari.server.controller.spi.UnsupportedPropertyException; import org.apache.ambari.server.controller.utilities.PropertyHelper; +import org.apache.commons.lang.StringUtils; public class StackConfigurationResourceProvider extends ReadOnlyResourceProvider { @@ -149,9 +150,12 @@ public class StackConfigurationResourceProvider extends setResourceProperty(resource, PROPERTY_DESCRIPTION_PROPERTY_ID, response.getPropertyDescription(), requestedIds); - setResourceProperty(resource, PROPERTY_DISPLAY_NAME_PROPERTY_ID, - response.getPropertyDisplayName(), requestedIds); - + //should not be returned if empty + if (StringUtils.isNotEmpty(response.getPropertyDisplayName())) { + setResourceProperty(resource, PROPERTY_DISPLAY_NAME_PROPERTY_ID, + response.getPropertyDisplayName(), requestedIds); + } + setResourceProperty(resource, PROPERTY_PROPERTY_TYPE_PROPERTY_ID, response.getPropertyType(), requestedIds); http://git-wip-us.apache.org/repos/asf/ambari/blob/f8b83e2f/ambari-server/src/main/java/org/apache/ambari/server/state/ValueAttributesInfo.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ValueAttributesInfo.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ValueAttributesInfo.java index 7285374..bf8caff 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/state/ValueAttributesInfo.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ValueAttributesInfo.java @@ -43,7 +43,7 @@ public class ValueAttributesInfo { @XmlElementWrapper(name = "entries") @XmlElements(@XmlElement(name = "entry")) - private Collection<ValueEntryInfo> entries = new ArrayList<ValueEntryInfo>(); + private Collection<ValueEntryInfo> entries; @XmlElement(name = "entries_editable") private Boolean entriesEditable; http://git-wip-us.apache.org/repos/asf/ambari/blob/f8b83e2f/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java index 2b4d7da..14c66a2 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java @@ -812,10 +812,9 @@ public class AmbariMetaInfoTest { Assert.assertEquals("512", newEnhancedProperty.getPropertyValueAttributes().getMinimum()); Assert.assertEquals("15360", newEnhancedProperty.getPropertyValueAttributes().getMaximum()); Assert.assertEquals("256", newEnhancedProperty.getPropertyValueAttributes().getIncrementStep()); - Assert.assertTrue(newEnhancedProperty.getPropertyValueAttributes().getEntries().isEmpty()); + Assert.assertNull(newEnhancedProperty.getPropertyValueAttributes().getEntries()); Assert.assertNull(newEnhancedProperty.getPropertyValueAttributes().getEntriesEditable()); -// Assert.assertNull(newEnhancedProperty.getPropertyValueAttributes().getEntryDescriptions()); -// Assert.assertNull(newEnhancedProperty.getPropertyValueAttributes().getEntryLabels()); + // Original property Assert.assertNotNull(originalProperty); Assert.assertEquals("mapreduce.shuffle", originalProperty.getValue());
