Repository: nifi Updated Branches: refs/heads/master 2279fad67 -> 364985fb4
NIFI-5034: - Processing properties and property descriptors in Controller Service referencing components unconditionally. This closes #2602. Signed-off-by: Mark Payne <marka...@hotmail.com> Project: http://git-wip-us.apache.org/repos/asf/nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/364985fb Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/364985fb Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/364985fb Branch: refs/heads/master Commit: 364985fb412790155bd2665e861de046c42dddb8 Parents: 924c935 Author: Matt Gilman <matt.c.gil...@gmail.com> Authored: Tue Apr 3 09:42:17 2018 -0400 Committer: Mark Payne <marka...@hotmail.com> Committed: Tue Apr 3 10:34:33 2018 -0400 ---------------------------------------------------------------------- .../org/apache/nifi/web/api/dto/DtoFactory.java | 56 +++++++++++--------- 1 file changed, 30 insertions(+), 26 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi/blob/364985fb/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java ---------------------------------------------------------------------- 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 696112a..5372afa 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; } - dto.setDescriptors(new LinkedHashMap<String, PropertyDescriptorDTO>()); - dto.setProperties(new LinkedHashMap<String, String>()); - if (propertyDescriptors != null && !propertyDescriptors.isEmpty()) { - final Map<PropertyDescriptor, String> sortedProperties = new TreeMap<>(new Comparator<PropertyDescriptor>() { - @Override - public int compare(final PropertyDescriptor o1, final PropertyDescriptor o2) { - return Collator.getInstance(Locale.US).compare(o1.getName(), o2.getName()); - } - }); - sortedProperties.putAll(component.getProperties()); + // ensure descriptors is non null + if (propertyDescriptors == null) { + propertyDescriptors = new ArrayList<>(); + } - final Map<PropertyDescriptor, String> orderedProperties = new LinkedHashMap<>(); - for (final PropertyDescriptor descriptor : propertyDescriptors) { - orderedProperties.put(descriptor, null); + // process properties unconditionally since dynamic properties are available here and not in getPropertyDescriptors + final Map<PropertyDescriptor, String> sortedProperties = new TreeMap<>(new Comparator<PropertyDescriptor>() { + @Override + public int compare(final PropertyDescriptor o1, final PropertyDescriptor o2) { + return Collator.getInstance(Locale.US).compare(o1.getName(), o2.getName()); } - orderedProperties.putAll(sortedProperties); + }); + sortedProperties.putAll(component.getProperties()); - // build the descriptor and property dtos - for (final Map.Entry<PropertyDescriptor, String> entry : orderedProperties.entrySet()) { - final PropertyDescriptor descriptor = entry.getKey(); + final Map<PropertyDescriptor, String> orderedProperties = new LinkedHashMap<>(); + for (final PropertyDescriptor descriptor : propertyDescriptors) { + orderedProperties.put(descriptor, null); + } + orderedProperties.putAll(sortedProperties); - // store the property descriptor - dto.getDescriptors().put(descriptor.getName(), createPropertyDescriptorDto(descriptor, processGroupId)); + // build the descriptor and property dtos + dto.setDescriptors(new LinkedHashMap<String, PropertyDescriptorDTO>()); + dto.setProperties(new LinkedHashMap<String, String>()); + for (final Map.Entry<PropertyDescriptor, String> entry : orderedProperties.entrySet()) { + final PropertyDescriptor descriptor = entry.getKey(); - // determine the property value - don't include sensitive properties - String propertyValue = entry.getValue(); - if (propertyValue != null && descriptor.isSensitive()) { - propertyValue = SENSITIVE_VALUE_MASK; - } + // store the property descriptor + dto.getDescriptors().put(descriptor.getName(), createPropertyDescriptorDto(descriptor, processGroupId)); - // set the property value - dto.getProperties().put(descriptor.getName(), propertyValue); + // 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); } if (validationErrors != null && !validationErrors.isEmpty()) {