Repository: nifi
Updated Branches:
  refs/heads/master d9720239f -> 85877a73d


NIFI-2540: Exclude from templates the parts of property descriptors that are 
not necessary. Also ensure that Property Descriptors are not completely removed 
from Controller Services.

This closes #828


Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/85877a73
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/85877a73
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/85877a73

Branch: refs/heads/master
Commit: 85877a73dc454a4b7f2b567517d345332ccb3b52
Parents: d972023
Author: Mark Payne <[email protected]>
Authored: Wed Aug 10 11:36:21 2016 -0400
Committer: Oleg Zhurakousky <[email protected]>
Committed: Wed Aug 10 13:27:20 2016 -0400

----------------------------------------------------------------------
 .../nifi/web/api/dto/PropertyDescriptorDTO.java | 24 ++++++++--------
 .../apache/nifi/controller/TemplateUtils.java   | 29 ++++++++++++++++++--
 2 files changed, 38 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/85877a73/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/PropertyDescriptorDTO.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/PropertyDescriptorDTO.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/PropertyDescriptorDTO.java
index dae16f2..500420b 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/PropertyDescriptorDTO.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/PropertyDescriptorDTO.java
@@ -31,10 +31,10 @@ public class PropertyDescriptorDTO {
     private String description;
     private String defaultValue;
     private List<AllowableValueDTO> allowableValues;
-    private boolean required;
-    private boolean sensitive;
-    private boolean dynamic;
-    private boolean supportsEl;
+    private Boolean required;
+    private Boolean sensitive;
+    private Boolean dynamic;
+    private Boolean supportsEl;
     private String identifiesControllerService;
 
     /**
@@ -113,11 +113,11 @@ public class PropertyDescriptorDTO {
     @ApiModelProperty(
             value = "Whether the property is required."
     )
-    public boolean isRequired() {
+    public Boolean isRequired() {
         return required;
     }
 
-    public void setRequired(boolean required) {
+    public void setRequired(Boolean required) {
         this.required = required;
     }
 
@@ -127,11 +127,11 @@ public class PropertyDescriptorDTO {
     @ApiModelProperty(
             value = "Whether the property is sensitive and protected whenever 
stored or represented."
     )
-    public boolean isSensitive() {
+    public Boolean isSensitive() {
         return sensitive;
     }
 
-    public void setSensitive(boolean sensitive) {
+    public void setSensitive(Boolean sensitive) {
         this.sensitive = sensitive;
     }
 
@@ -141,11 +141,11 @@ public class PropertyDescriptorDTO {
     @ApiModelProperty(
             value = "Whether the property is dynamic (user-defined)."
     )
-    public boolean isDynamic() {
+    public Boolean isDynamic() {
         return dynamic;
     }
 
-    public void setDynamic(boolean dynamic) {
+    public void setDynamic(Boolean dynamic) {
         this.dynamic = dynamic;
     }
 
@@ -155,11 +155,11 @@ public class PropertyDescriptorDTO {
     @ApiModelProperty(
             value = "Whether the property supports expression language."
     )
-    public boolean getSupportsEl() {
+    public Boolean getSupportsEl() {
         return supportsEl;
     }
 
-    public void setSupportsEl(boolean supportsEl) {
+    public void setSupportsEl(Boolean supportsEl) {
         this.supportsEl = supportsEl;
     }
 

http://git-wip-us.apache.org/repos/asf/nifi/blob/85877a73/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/TemplateUtils.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/TemplateUtils.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/TemplateUtils.java
index 668872b..aa84594 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/TemplateUtils.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/TemplateUtils.java
@@ -178,9 +178,11 @@ public class TemplateUtils {
                     if (processorConfig.getDescriptors() != null) {
                         final Collection<PropertyDescriptorDTO> descriptors = 
processorConfig.getDescriptors().values();
                         for (PropertyDescriptorDTO descriptor : descriptors) {
-                            if (descriptor.isSensitive()) {
+                            if (Boolean.TRUE.equals(descriptor.isSensitive())) 
{
                                 processorProperties.put(descriptor.getName(), 
null);
                             }
+
+                            scrubPropertyDescriptor(descriptor);
                         }
                     }
                 }
@@ -207,6 +209,26 @@ public class TemplateUtils {
         }
     }
 
+    /**
+     * The only thing that we really need from the Property Descriptors in the 
templates is the
+     * flag that indicates whether or not the property identifies a controller 
service.
+     * Everything else is unneeded and makes templates very verbose and more 
importantly makes it
+     * so that if one of these things changes, the template itself changes, 
which makes it hard to
+     * use a CM tool for versioning. So we remove all that we don't need.
+     *
+     * @param descriptor the ProeprtyDescriptor to scrub
+     */
+    private static void scrubPropertyDescriptor(final PropertyDescriptorDTO 
descriptor) {
+        descriptor.setAllowableValues(null);
+        descriptor.setDefaultValue(null);
+        descriptor.setDescription(null);
+        descriptor.setDisplayName(null);
+        descriptor.setDynamic(null);
+        descriptor.setRequired(null);
+        descriptor.setSensitive(null);
+        descriptor.setSupportsEl(null);
+    }
+
     private static void scrubControllerServices(final 
Set<ControllerServiceDTO> controllerServices) {
         for (final ControllerServiceDTO serviceDTO : controllerServices) {
             final Map<String, String> properties = serviceDTO.getProperties();
@@ -214,13 +236,14 @@ public class TemplateUtils {
 
             if (properties != null && descriptors != null) {
                 for (final PropertyDescriptorDTO descriptor : 
descriptors.values()) {
-                    if (descriptor.isSensitive()) {
+                    if (Boolean.TRUE.equals(descriptor.isSensitive())) {
                         properties.put(descriptor.getName(), null);
                     }
+
+                    scrubPropertyDescriptor(descriptor);
                 }
             }
 
-            serviceDTO.setDescriptors(null);
             serviceDTO.setCustomUiUrl(null);
             serviceDTO.setValidationErrors(null);
         }

Reply via email to