From 729d13ecfbb4284d806d2087b76e5a20bf8c5c0f Mon Sep 17 00:00:00 2001 From: Matt Gilman Date: Mon, 2 Apr 2018 16:47:28 -0400 Subject: [PATCH 1/2] NIFI-5034: - Ensuring descriptors and properties of referencing components are populated like Processors, Reporting Tasks, etc. --- .../src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java | 4 ++-- 1 file changed, 2 insertions(+), 2 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 8ceffbe1ef9f..696112a2191f 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,6 +1502,8 @@ public ControllerServiceReferencingComponentDTO createControllerServiceReferenci processGroupId = null; } + dto.setDescriptors(new LinkedHashMap()); + dto.setProperties(new LinkedHashMap()); if (propertyDescriptors != null && !propertyDescriptors.isEmpty()) { final Map sortedProperties = new TreeMap<>(new Comparator() { @Override @@ -1518,8 +1520,6 @@ public int compare(final PropertyDescriptor o1, final PropertyDescriptor o2) { orderedProperties.putAll(sortedProperties); // build the descriptor and property dtos - dto.setDescriptors(new LinkedHashMap()); - dto.setProperties(new LinkedHashMap()); for (final Map.Entry entry : orderedProperties.entrySet()) { final PropertyDescriptor descriptor = entry.getKey(); From a6760c20253bf25d953a8e1ddb77dbdaf00adb77 Mon Sep 17 00:00:00 2001 From: Matt Gilman Date: Tue, 3 Apr 2018 09:42:17 -0400 Subject: [PATCH 2/2] NIFI-5034: - Processing properties and property descriptors in Controller Service referencing components unconditionally. --- .../apache/nifi/web/api/dto/DtoFactory.java | 56 ++++++++++--------- 1 file changed, 30 insertions(+), 26 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 696112a2191f..5372afa680fe 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 ControllerServiceReferencingComponentDTO createControllerServiceReferenci processGroupId = null; } - 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()); + // ensure descriptors is non null + if (propertyDescriptors == null) { + propertyDescriptors = new ArrayList<>(); + } - final Map 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 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()); } - orderedProperties.putAll(sortedProperties); + }); + sortedProperties.putAll(component.getProperties()); - // build the descriptor and property dtos - 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); + } + 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()); + dto.setProperties(new LinkedHashMap()); + for (final Map.Entry 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()) {