From 364985fb412790155bd2665e861de046c42dddb8 Mon Sep 17 00:00:00 2001 From: Matt Gilman Date: Tue, 3 Apr 2018 09:42:17 -0400 Subject: [PATCH] NIFI-5034: - Processing properties and property descriptors in Controller Service referencing components unconditionally. This closes #2602. Signed-off-by: Mark Payne --- .../apache/nifi/web/api/dto/DtoFactory.java | 60 ++++++++++--------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java index 696112a219..5372afa680 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java @@ -1502,39 +1502,43 @@ public final class DtoFactory { processGroupId = null; } + // ensure descriptors is non null + if (propertyDescriptors == null) { + propertyDescriptors = new ArrayList<>(); + } + + // process properties unconditionally since dynamic properties are available here and not in getPropertyDescriptors + final Map sortedProperties = new TreeMap<>(new Comparator() { + @Override + public int compare(final PropertyDescriptor o1, final PropertyDescriptor o2) { + return Collator.getInstance(Locale.US).compare(o1.getName(), o2.getName()); + } + }); + sortedProperties.putAll(component.getProperties()); + + final Map orderedProperties = new LinkedHashMap<>(); + for (final PropertyDescriptor descriptor : propertyDescriptors) { + orderedProperties.put(descriptor, null); + } + orderedProperties.putAll(sortedProperties); + + // build the descriptor and property dtos dto.setDescriptors(new LinkedHashMap()); dto.setProperties(new LinkedHashMap()); - if (propertyDescriptors != null && !propertyDescriptors.isEmpty()) { - final Map sortedProperties = new TreeMap<>(new Comparator() { - @Override - public int compare(final PropertyDescriptor o1, final PropertyDescriptor o2) { - return Collator.getInstance(Locale.US).compare(o1.getName(), o2.getName()); - } - }); - sortedProperties.putAll(component.getProperties()); + for (final Map.Entry entry : orderedProperties.entrySet()) { + final PropertyDescriptor descriptor = entry.getKey(); - final Map orderedProperties = new LinkedHashMap<>(); - for (final PropertyDescriptor descriptor : propertyDescriptors) { - orderedProperties.put(descriptor, null); + // store the property descriptor + dto.getDescriptors().put(descriptor.getName(), createPropertyDescriptorDto(descriptor, processGroupId)); + + // determine the property value - don't include sensitive properties + String propertyValue = entry.getValue(); + if (propertyValue != null && descriptor.isSensitive()) { + propertyValue = SENSITIVE_VALUE_MASK; } - orderedProperties.putAll(sortedProperties); - // build the descriptor and property dtos - for (final Map.Entry entry : orderedProperties.entrySet()) { - final PropertyDescriptor descriptor = entry.getKey(); - - // store the property descriptor - dto.getDescriptors().put(descriptor.getName(), createPropertyDescriptorDto(descriptor, processGroupId)); - - // determine the property value - don't include sensitive properties - String propertyValue = entry.getValue(); - if (propertyValue != null && descriptor.isSensitive()) { - propertyValue = SENSITIVE_VALUE_MASK; - } - - // set the property value - dto.getProperties().put(descriptor.getName(), propertyValue); - } + // set the property value + dto.getProperties().put(descriptor.getName(), propertyValue); } if (validationErrors != null && !validationErrors.isEmpty()) {