mirror of https://github.com/apache/nifi.git
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
This commit is contained in:
parent
d9720239f5
commit
85877a73dc
|
@ -31,10 +31,10 @@ public class PropertyDescriptorDTO {
|
||||||
private String description;
|
private String description;
|
||||||
private String defaultValue;
|
private String defaultValue;
|
||||||
private List<AllowableValueDTO> allowableValues;
|
private List<AllowableValueDTO> allowableValues;
|
||||||
private boolean required;
|
private Boolean required;
|
||||||
private boolean sensitive;
|
private Boolean sensitive;
|
||||||
private boolean dynamic;
|
private Boolean dynamic;
|
||||||
private boolean supportsEl;
|
private Boolean supportsEl;
|
||||||
private String identifiesControllerService;
|
private String identifiesControllerService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -113,11 +113,11 @@ public class PropertyDescriptorDTO {
|
||||||
@ApiModelProperty(
|
@ApiModelProperty(
|
||||||
value = "Whether the property is required."
|
value = "Whether the property is required."
|
||||||
)
|
)
|
||||||
public boolean isRequired() {
|
public Boolean isRequired() {
|
||||||
return required;
|
return required;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRequired(boolean required) {
|
public void setRequired(Boolean required) {
|
||||||
this.required = required;
|
this.required = required;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,11 +127,11 @@ public class PropertyDescriptorDTO {
|
||||||
@ApiModelProperty(
|
@ApiModelProperty(
|
||||||
value = "Whether the property is sensitive and protected whenever stored or represented."
|
value = "Whether the property is sensitive and protected whenever stored or represented."
|
||||||
)
|
)
|
||||||
public boolean isSensitive() {
|
public Boolean isSensitive() {
|
||||||
return sensitive;
|
return sensitive;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSensitive(boolean sensitive) {
|
public void setSensitive(Boolean sensitive) {
|
||||||
this.sensitive = sensitive;
|
this.sensitive = sensitive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,11 +141,11 @@ public class PropertyDescriptorDTO {
|
||||||
@ApiModelProperty(
|
@ApiModelProperty(
|
||||||
value = "Whether the property is dynamic (user-defined)."
|
value = "Whether the property is dynamic (user-defined)."
|
||||||
)
|
)
|
||||||
public boolean isDynamic() {
|
public Boolean isDynamic() {
|
||||||
return dynamic;
|
return dynamic;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDynamic(boolean dynamic) {
|
public void setDynamic(Boolean dynamic) {
|
||||||
this.dynamic = dynamic;
|
this.dynamic = dynamic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,11 +155,11 @@ public class PropertyDescriptorDTO {
|
||||||
@ApiModelProperty(
|
@ApiModelProperty(
|
||||||
value = "Whether the property supports expression language."
|
value = "Whether the property supports expression language."
|
||||||
)
|
)
|
||||||
public boolean getSupportsEl() {
|
public Boolean getSupportsEl() {
|
||||||
return supportsEl;
|
return supportsEl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSupportsEl(boolean supportsEl) {
|
public void setSupportsEl(Boolean supportsEl) {
|
||||||
this.supportsEl = supportsEl;
|
this.supportsEl = supportsEl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -178,9 +178,11 @@ public class TemplateUtils {
|
||||||
if (processorConfig.getDescriptors() != null) {
|
if (processorConfig.getDescriptors() != null) {
|
||||||
final Collection<PropertyDescriptorDTO> descriptors = processorConfig.getDescriptors().values();
|
final Collection<PropertyDescriptorDTO> descriptors = processorConfig.getDescriptors().values();
|
||||||
for (PropertyDescriptorDTO descriptor : descriptors) {
|
for (PropertyDescriptorDTO descriptor : descriptors) {
|
||||||
if (descriptor.isSensitive()) {
|
if (Boolean.TRUE.equals(descriptor.isSensitive())) {
|
||||||
processorProperties.put(descriptor.getName(), null);
|
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) {
|
private static void scrubControllerServices(final Set<ControllerServiceDTO> controllerServices) {
|
||||||
for (final ControllerServiceDTO serviceDTO : controllerServices) {
|
for (final ControllerServiceDTO serviceDTO : controllerServices) {
|
||||||
final Map<String, String> properties = serviceDTO.getProperties();
|
final Map<String, String> properties = serviceDTO.getProperties();
|
||||||
|
@ -214,13 +236,14 @@ public class TemplateUtils {
|
||||||
|
|
||||||
if (properties != null && descriptors != null) {
|
if (properties != null && descriptors != null) {
|
||||||
for (final PropertyDescriptorDTO descriptor : descriptors.values()) {
|
for (final PropertyDescriptorDTO descriptor : descriptors.values()) {
|
||||||
if (descriptor.isSensitive()) {
|
if (Boolean.TRUE.equals(descriptor.isSensitive())) {
|
||||||
properties.put(descriptor.getName(), null);
|
properties.put(descriptor.getName(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scrubPropertyDescriptor(descriptor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
serviceDTO.setDescriptors(null);
|
|
||||||
serviceDTO.setCustomUiUrl(null);
|
serviceDTO.setCustomUiUrl(null);
|
||||||
serviceDTO.setValidationErrors(null);
|
serviceDTO.setValidationErrors(null);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue