You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by bb...@apache.org on 2018/01/16 19:14:42 UTC
nifi git commit: NIFI-4782: Allow the value of a Required Property to
be moved when changing version of a flow or reverting a flow
Repository: nifi
Updated Branches:
refs/heads/master 7e2910399 -> 28e1bcc9d
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 <bb...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/28e1bcc9
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/28e1bcc9
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/28e1bcc9
Branch: refs/heads/master
Commit: 28e1bcc9d034261c8045c6b2c76ff21839f7eb95
Parents: 7e29103
Author: Mark Payne <ma...@hotmail.com>
Authored: Tue Jan 16 12:36:52 2018 -0500
Committer: Bryan Bende <bb...@apache.org>
Committed: Tue Jan 16 14:14:25 2018 -0500
----------------------------------------------------------------------
.../nifi/controller/AbstractConfiguredComponent.java | 12 ++++++++----
.../org/apache/nifi/controller/ConfiguredComponent.java | 6 +++++-
.../org/apache/nifi/groups/StandardProcessGroup.java | 8 ++++++--
3 files changed, 19 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/nifi/blob/28e1bcc9/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/AbstractConfiguredComponent.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/AbstractConfiguredComponent.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/AbstractConfiguredComponent.java
index ff5a8af..a5f2631 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/AbstractConfiguredComponent.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/AbstractConfiguredComponent.java
@@ -151,7 +151,7 @@ public abstract class AbstractConfiguredComponent implements ConfigurableCompone
}
@Override
- public void setProperties(Map<String, String> properties) {
+ public void setProperties(final Map<String, String> properties, final boolean allowRemovalOfRequiredProperties) {
if (properties == null) {
return;
}
@@ -170,7 +170,7 @@ public abstract class AbstractConfiguredComponent implements ConfigurableCompone
}
if (entry.getKey() != null && entry.getValue() == null) {
- removeProperty(entry.getKey());
+ removeProperty(entry.getKey(), allowRemovalOfRequiredProperties);
} else if (entry.getKey() != null) {
setProperty(entry.getKey(), CharacterFilterUtils.filterInvalidXmlCharacters(entry.getValue()));
}
@@ -231,17 +231,20 @@ public abstract class AbstractConfiguredComponent implements ConfigurableCompone
* if was a dynamic property.
*
* @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
* @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) {
throw new IllegalArgumentException("Name can not be null");
}
final PropertyDescriptor descriptor = getComponent().getPropertyDescriptor(name);
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 (value != null) {
@@ -541,6 +544,7 @@ public abstract class AbstractConfiguredComponent implements ConfigurableCompone
}
}
+ @Override
public ComponentVariableRegistry getVariableRegistry() {
return this.variableRegistry;
}
http://git-wip-us.apache.org/repos/asf/nifi/blob/28e1bcc9/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ConfiguredComponent.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ConfiguredComponent.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ConfiguredComponent.java
index 940ac21..b0f65a7 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ConfiguredComponent.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/ConfiguredComponent.java
@@ -50,7 +50,11 @@ public interface ConfiguredComponent extends ComponentAuthorizable {
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();
http://git-wip-us.apache.org/repos/asf/nifi/blob/28e1bcc9/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java
index baf02bc..15f2b5f 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java
@@ -3925,7 +3925,9 @@ public final class StandardProcessGroup implements ProcessGroup {
service.setAnnotationData(proposed.getAnnotationData());
service.setComments(proposed.getComments());
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())) {
final BundleCoordinate newBundleCoordinate = toCoordinate(proposed.getBundle());
@@ -4045,7 +4047,9 @@ public final class StandardProcessGroup implements ProcessGroup {
processor.setExecutionNode(ExecutionNode.valueOf(proposed.getExecutionNode()));
processor.setName(proposed.getName());
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.setScheduldingPeriod(proposed.getSchedulingPeriod());
processor.setSchedulingStrategy(SchedulingStrategy.valueOf(proposed.getSchedulingStrategy()));