[34/50] nifi git commit: NIFI-4841 Fixing NPE when reverting local changes involving remote group ports. This closes #2454.

2018-05-10 Thread aldrin
NIFI-4841 Fixing NPE when reverting local changes involving remote group ports. 
This closes #2454.

Signed-off-by: Mark Payne 


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

Branch: refs/heads/HDF-3.1-maint
Commit: 828dd76c137c71edb783231c6e118853620d
Parents: da8bf83
Author: Bryan Bende 
Authored: Tue Feb 6 17:43:59 2018 -0500
Committer: Mark Payne 
Committed: Fri Feb 9 10:33:10 2018 -0500

--
 .../nifi/groups/StandardProcessGroup.java   | 25 ++-
 .../apache/nifi/util/FlowDifferenceFilters.java | 52 ++
 .../nifi/util/TestFlowDifferenceFilters.java| 76 
 .../nifi/web/StandardNiFiServiceFacade.java |  7 ++
 .../apache/nifi/web/api/VersionsResource.java   |  4 +-
 .../org/apache/nifi/web/api/dto/DtoFactory.java |  6 ++
 .../nifi/web/util/AffectedComponentUtils.java   |  5 +-
 7 files changed, 169 insertions(+), 6 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/nifi/blob/828dd799/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 15f2b5f..8b7dcd2 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
@@ -110,6 +110,7 @@ import 
org.apache.nifi.remote.StandardRemoteProcessGroupPortDescriptor;
 import org.apache.nifi.remote.protocol.SiteToSiteTransportProtocol;
 import org.apache.nifi.scheduling.ExecutionNode;
 import org.apache.nifi.scheduling.SchedulingStrategy;
+import org.apache.nifi.util.FlowDifferenceFilters;
 import org.apache.nifi.util.NiFiProperties;
 import org.apache.nifi.util.ReflectionUtils;
 import org.apache.nifi.util.SnippetUtils;
@@ -1649,6 +1650,18 @@ public final class StandardProcessGroup implements 
ProcessGroup {
 return funnel;
 }
 
+for (final RemoteProcessGroup remoteProcessGroup : 
group.getRemoteProcessGroups()) {
+final RemoteGroupPort remoteInputPort = 
remoteProcessGroup.getInputPort(identifier);
+if (remoteInputPort != null) {
+return remoteInputPort;
+}
+
+final RemoteGroupPort remoteOutputPort = 
remoteProcessGroup.getOutputPort(identifier);
+if (remoteOutputPort != null) {
+return remoteOutputPort;
+}
+}
+
 for (final ProcessGroup childGroup : group.getProcessGroups()) {
 final Connectable childGroupConnectable = 
findLocalConnectable(identifier, childGroup);
 if (childGroupConnectable != null) {
@@ -3257,6 +3270,11 @@ public final class StandardProcessGroup implements 
ProcessGroup {
 continue;
 }
 
+// Ignore differences for adding a remote port
+if (FlowDifferenceFilters.isAddedRemotePort(diff)) {
+continue;
+}
+
 // If this update adds a new Controller Service, then we need 
to check if the service already exists at a higher level
 // and if so compare our VersionedControllerService to the 
existing service.
 if (diff.getDifferenceType() == 
DifferenceType.COMPONENT_ADDED) {
@@ -3901,7 +3919,7 @@ public final class StandardProcessGroup implements 
ProcessGroup {
 final String rpgId = connectableComponent.getGroupId();
 final Optional rpgOption = 
group.getRemoteProcessGroups().stream()
 .filter(component -> 
component.getVersionedComponentId().isPresent())
-.filter(component -> 
id.equals(component.getVersionedComponentId().get()))
+.filter(component -> 
rpgId.equals(component.getVersionedComponentId().get()))
 .findAny();
 
 if (!rpgOption.isPresent()) {
@@ -4197,8 +4215,9 @@ public final class StandardProcessGroup implements 
ProcessGroup {
 final FlowComparator flowComparator = new 
StandardFlowComparator(snapshotFlow, currentFlow, getAncestorGroupServiceIds(), 
new 

nifi git commit: NIFI-4841 Fixing NPE when reverting local changes involving remote group ports. This closes #2454.

2018-02-09 Thread markap14
Repository: nifi
Updated Branches:
  refs/heads/master 25e0bbb68 -> 34b678d30


NIFI-4841 Fixing NPE when reverting local changes involving remote group ports. 
This closes #2454.

Signed-off-by: Mark Payne 


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

Branch: refs/heads/master
Commit: 34b678d30d25c930678b008a5db8a26a6a2938b3
Parents: 25e0bbb
Author: Bryan Bende 
Authored: Tue Feb 6 17:43:59 2018 -0500
Committer: Mark Payne 
Committed: Fri Feb 9 10:26:19 2018 -0500

--
 .../nifi/groups/StandardProcessGroup.java   | 25 ++-
 .../apache/nifi/util/FlowDifferenceFilters.java | 52 ++
 .../nifi/util/TestFlowDifferenceFilters.java| 76 
 .../nifi/web/StandardNiFiServiceFacade.java |  7 ++
 .../apache/nifi/web/api/VersionsResource.java   |  4 +-
 .../org/apache/nifi/web/api/dto/DtoFactory.java |  6 ++
 .../nifi/web/util/AffectedComponentUtils.java   |  5 +-
 7 files changed, 169 insertions(+), 6 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/nifi/blob/34b678d3/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 15f2b5f..8b7dcd2 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
@@ -110,6 +110,7 @@ import 
org.apache.nifi.remote.StandardRemoteProcessGroupPortDescriptor;
 import org.apache.nifi.remote.protocol.SiteToSiteTransportProtocol;
 import org.apache.nifi.scheduling.ExecutionNode;
 import org.apache.nifi.scheduling.SchedulingStrategy;
+import org.apache.nifi.util.FlowDifferenceFilters;
 import org.apache.nifi.util.NiFiProperties;
 import org.apache.nifi.util.ReflectionUtils;
 import org.apache.nifi.util.SnippetUtils;
@@ -1649,6 +1650,18 @@ public final class StandardProcessGroup implements 
ProcessGroup {
 return funnel;
 }
 
+for (final RemoteProcessGroup remoteProcessGroup : 
group.getRemoteProcessGroups()) {
+final RemoteGroupPort remoteInputPort = 
remoteProcessGroup.getInputPort(identifier);
+if (remoteInputPort != null) {
+return remoteInputPort;
+}
+
+final RemoteGroupPort remoteOutputPort = 
remoteProcessGroup.getOutputPort(identifier);
+if (remoteOutputPort != null) {
+return remoteOutputPort;
+}
+}
+
 for (final ProcessGroup childGroup : group.getProcessGroups()) {
 final Connectable childGroupConnectable = 
findLocalConnectable(identifier, childGroup);
 if (childGroupConnectable != null) {
@@ -3257,6 +3270,11 @@ public final class StandardProcessGroup implements 
ProcessGroup {
 continue;
 }
 
+// Ignore differences for adding a remote port
+if (FlowDifferenceFilters.isAddedRemotePort(diff)) {
+continue;
+}
+
 // If this update adds a new Controller Service, then we need 
to check if the service already exists at a higher level
 // and if so compare our VersionedControllerService to the 
existing service.
 if (diff.getDifferenceType() == 
DifferenceType.COMPONENT_ADDED) {
@@ -3901,7 +3919,7 @@ public final class StandardProcessGroup implements 
ProcessGroup {
 final String rpgId = connectableComponent.getGroupId();
 final Optional rpgOption = 
group.getRemoteProcessGroups().stream()
 .filter(component -> 
component.getVersionedComponentId().isPresent())
-.filter(component -> 
id.equals(component.getVersionedComponentId().get()))
+.filter(component -> 
rpgId.equals(component.getVersionedComponentId().get()))
 .findAny();
 
 if (!rpgOption.isPresent()) {
@@ -4197,8 +4215,9 @@ public final class StandardProcessGroup implements 
ProcessGroup {
 final FlowComparator flowComparator = new