mirror of https://github.com/apache/nifi.git
NIFI-4782: Allow the value of a Required Property to be moved when changing version of a flow or reverting a flow
This closes #2406. Signed-off-by: Bryan Bende <bbende@apache.org>
This commit is contained in:
parent
7e29103995
commit
28e1bcc9d0
|
@ -151,7 +151,7 @@ public abstract class AbstractConfiguredComponent implements ConfigurableCompone
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setProperties(Map<String, String> properties) {
|
public void setProperties(final Map<String, String> properties, final boolean allowRemovalOfRequiredProperties) {
|
||||||
if (properties == null) {
|
if (properties == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ public abstract class AbstractConfiguredComponent implements ConfigurableCompone
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.getKey() != null && entry.getValue() == null) {
|
if (entry.getKey() != null && entry.getValue() == null) {
|
||||||
removeProperty(entry.getKey());
|
removeProperty(entry.getKey(), allowRemovalOfRequiredProperties);
|
||||||
} else if (entry.getKey() != null) {
|
} else if (entry.getKey() != null) {
|
||||||
setProperty(entry.getKey(), CharacterFilterUtils.filterInvalidXmlCharacters(entry.getValue()));
|
setProperty(entry.getKey(), CharacterFilterUtils.filterInvalidXmlCharacters(entry.getValue()));
|
||||||
}
|
}
|
||||||
|
@ -231,17 +231,20 @@ public abstract class AbstractConfiguredComponent implements ConfigurableCompone
|
||||||
* if was a dynamic property.
|
* if was a dynamic property.
|
||||||
*
|
*
|
||||||
* @param name the property to remove
|
* @param name the property to remove
|
||||||
|
* @param allowRemovalOfRequiredProperties whether or not the property should be removed if it's required
|
||||||
* @return true if removed; false otherwise
|
* @return true if removed; false otherwise
|
||||||
* @throws java.lang.IllegalArgumentException if the name is null
|
* @throws java.lang.IllegalArgumentException if the name is null
|
||||||
*/
|
*/
|
||||||
private boolean removeProperty(final String name) {
|
private boolean removeProperty(final String name, final boolean allowRemovalOfRequiredProperties) {
|
||||||
if (null == name) {
|
if (null == name) {
|
||||||
throw new IllegalArgumentException("Name can not be null");
|
throw new IllegalArgumentException("Name can not be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
final PropertyDescriptor descriptor = getComponent().getPropertyDescriptor(name);
|
final PropertyDescriptor descriptor = getComponent().getPropertyDescriptor(name);
|
||||||
String value = null;
|
String value = null;
|
||||||
if (!descriptor.isRequired() && (value = properties.remove(descriptor)) != null) {
|
|
||||||
|
final boolean allowRemoval = allowRemovalOfRequiredProperties || !descriptor.isRequired();
|
||||||
|
if (allowRemoval && (value = properties.remove(descriptor)) != null) {
|
||||||
|
|
||||||
if (descriptor.getControllerServiceDefinition() != null) {
|
if (descriptor.getControllerServiceDefinition() != null) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
|
@ -541,6 +544,7 @@ public abstract class AbstractConfiguredComponent implements ConfigurableCompone
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ComponentVariableRegistry getVariableRegistry() {
|
public ComponentVariableRegistry getVariableRegistry() {
|
||||||
return this.variableRegistry;
|
return this.variableRegistry;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,11 @@ public interface ConfiguredComponent extends ComponentAuthorizable {
|
||||||
|
|
||||||
public void setAnnotationData(String data);
|
public void setAnnotationData(String data);
|
||||||
|
|
||||||
public void setProperties(Map<String, String> properties);
|
public default void setProperties(Map<String, String> properties) {
|
||||||
|
setProperties(properties, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProperties(Map<String, String> properties, boolean allowRemovalOfRequiredProperties);
|
||||||
|
|
||||||
public Map<PropertyDescriptor, String> getProperties();
|
public Map<PropertyDescriptor, String> getProperties();
|
||||||
|
|
||||||
|
|
|
@ -3925,7 +3925,9 @@ public final class StandardProcessGroup implements ProcessGroup {
|
||||||
service.setAnnotationData(proposed.getAnnotationData());
|
service.setAnnotationData(proposed.getAnnotationData());
|
||||||
service.setComments(proposed.getComments());
|
service.setComments(proposed.getComments());
|
||||||
service.setName(proposed.getName());
|
service.setName(proposed.getName());
|
||||||
service.setProperties(populatePropertiesMap(service.getProperties(), proposed.getProperties(), proposed.getPropertyDescriptors(), service.getProcessGroup()));
|
|
||||||
|
final Map<String, String> properties = populatePropertiesMap(service.getProperties(), proposed.getProperties(), proposed.getPropertyDescriptors(), service.getProcessGroup());
|
||||||
|
service.setProperties(properties, true);
|
||||||
|
|
||||||
if (!isEqual(service.getBundleCoordinate(), proposed.getBundle())) {
|
if (!isEqual(service.getBundleCoordinate(), proposed.getBundle())) {
|
||||||
final BundleCoordinate newBundleCoordinate = toCoordinate(proposed.getBundle());
|
final BundleCoordinate newBundleCoordinate = toCoordinate(proposed.getBundle());
|
||||||
|
@ -4045,7 +4047,9 @@ public final class StandardProcessGroup implements ProcessGroup {
|
||||||
processor.setExecutionNode(ExecutionNode.valueOf(proposed.getExecutionNode()));
|
processor.setExecutionNode(ExecutionNode.valueOf(proposed.getExecutionNode()));
|
||||||
processor.setName(proposed.getName());
|
processor.setName(proposed.getName());
|
||||||
processor.setPenalizationPeriod(proposed.getPenaltyDuration());
|
processor.setPenalizationPeriod(proposed.getPenaltyDuration());
|
||||||
processor.setProperties(populatePropertiesMap(processor.getProperties(), proposed.getProperties(), proposed.getPropertyDescriptors(), processor.getProcessGroup()));
|
|
||||||
|
final Map<String, String> properties = populatePropertiesMap(processor.getProperties(), proposed.getProperties(), proposed.getPropertyDescriptors(), processor.getProcessGroup());
|
||||||
|
processor.setProperties(properties, true);
|
||||||
processor.setRunDuration(proposed.getRunDurationMillis(), TimeUnit.MILLISECONDS);
|
processor.setRunDuration(proposed.getRunDurationMillis(), TimeUnit.MILLISECONDS);
|
||||||
processor.setScheduldingPeriod(proposed.getSchedulingPeriod());
|
processor.setScheduldingPeriod(proposed.getSchedulingPeriod());
|
||||||
processor.setSchedulingStrategy(SchedulingStrategy.valueOf(proposed.getSchedulingStrategy()));
|
processor.setSchedulingStrategy(SchedulingStrategy.valueOf(proposed.getSchedulingStrategy()));
|
||||||
|
|
Loading…
Reference in New Issue