Repository: nifi Updated Branches: refs/heads/master 220a870a1 -> 7e7f9a5de
NIFI-3705: - Using consistent logic when verifying connection creation. Removed some unecessary checks as verification has been changed to run in cluster and standalone mode. This closes #1672. Project: http://git-wip-us.apache.org/repos/asf/nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/7e7f9a5d Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/7e7f9a5d Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/7e7f9a5d Branch: refs/heads/master Commit: 7e7f9a5deb4f60d4612e7419902e12ac82ad4c52 Parents: 220a870 Author: Matt Gilman <[email protected]> Authored: Thu Apr 13 15:58:42 2017 -0400 Committer: Mark Payne <[email protected]> Committed: Wed Apr 19 15:49:11 2017 -0400 ---------------------------------------------------------------------- .../web/dao/impl/StandardConnectionDAO.java | 53 ++++++++++---------- 1 file changed, 26 insertions(+), 27 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi/blob/7e7f9a5d/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardConnectionDAO.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardConnectionDAO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardConnectionDAO.java index 55c872f..70d29a2 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardConnectionDAO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardConnectionDAO.java @@ -287,14 +287,7 @@ public class StandardConnectionDAO extends ComponentDAO implements ConnectionDAO if (ConnectableType.REMOTE_OUTPUT_PORT.name().equals(sourceConnectableDTO.getType())) { final ProcessGroup sourceParentGroup = locateProcessGroup(flowController, groupId); final RemoteProcessGroup remoteProcessGroup = sourceParentGroup.getRemoteProcessGroup(sourceConnectableDTO.getGroupId()); - final RemoteGroupPort remoteOutputPort = remoteProcessGroup.getOutputPort(sourceConnectableDTO.getId()); - - // ensure the remote port actually exists - if (!remoteOutputPort.getTargetExists()) { - throw new IllegalArgumentException("The specified remote output port does not exist."); - } else { - source = remoteOutputPort; - } + source = remoteProcessGroup.getOutputPort(sourceConnectableDTO.getId()); } else { final ProcessGroup sourceGroup = locateProcessGroup(flowController, sourceConnectableDTO.getGroupId()); source = sourceGroup.getConnectable(sourceConnectableDTO.getId()); @@ -305,19 +298,7 @@ public class StandardConnectionDAO extends ComponentDAO implements ConnectionDAO if (ConnectableType.REMOTE_INPUT_PORT.name().equals(destinationConnectableDTO.getType())) { final ProcessGroup destinationParentGroup = locateProcessGroup(flowController, groupId); final RemoteProcessGroup remoteProcessGroup = destinationParentGroup.getRemoteProcessGroup(destinationConnectableDTO.getGroupId()); - - if (remoteProcessGroup == null) { - throw new IllegalArgumentException("Unable to find the specified remote process group."); - } - - final RemoteGroupPort remoteInputPort = remoteProcessGroup.getInputPort(destinationConnectableDTO.getId()); - - // ensure the remote port actually exists - if (!remoteInputPort.getTargetExists()) { - throw new IllegalArgumentException("The specified remote input port does not exist."); - } else { - destination = remoteInputPort; - } + destination = remoteProcessGroup.getInputPort(destinationConnectableDTO.getId()); } else { final ProcessGroup destinationGroup = locateProcessGroup(flowController, destinationConnectableDTO.getGroupId()); destination = destinationGroup.getConnectable(destinationConnectableDTO.getId()); @@ -391,27 +372,45 @@ public class StandardConnectionDAO extends ComponentDAO implements ConnectionDAO throw new IllegalArgumentException("Cannot create connection without specifying destination"); } - final ProcessGroup rootGroup = flowController.getGroup(flowController.getRootGroupId()); - if (ConnectableType.REMOTE_OUTPUT_PORT.name().equals(sourceDto.getType())) { - final Connectable sourceConnectable = rootGroup.findRemoteGroupPort(sourceDto.getId()); + final ProcessGroup sourceParentGroup = locateProcessGroup(flowController, groupId); + + final RemoteProcessGroup remoteProcessGroup = sourceParentGroup.getRemoteProcessGroup(sourceDto.getGroupId()); + if (remoteProcessGroup == null) { + throw new IllegalArgumentException("Unable to find the specified remote process group."); + } + + final RemoteGroupPort sourceConnectable = remoteProcessGroup.getOutputPort(sourceDto.getId()); if (sourceConnectable == null) { throw new IllegalArgumentException("The specified source for the connection does not exist"); + } else if (!sourceConnectable.getTargetExists()) { + throw new IllegalArgumentException("The specified remote output port does not exist."); } } else { - final Connectable sourceConnectable = rootGroup.findLocalConnectable(sourceDto.getId()); + final ProcessGroup sourceGroup = locateProcessGroup(flowController, sourceDto.getGroupId()); + final Connectable sourceConnectable = sourceGroup.getConnectable(sourceDto.getId()); if (sourceConnectable == null) { throw new IllegalArgumentException("The specified source for the connection does not exist"); } } if (ConnectableType.REMOTE_INPUT_PORT.name().equals(destinationDto.getType())) { - final Connectable destinationConnectable = rootGroup.findRemoteGroupPort(destinationDto.getId()); + final ProcessGroup destinationParentGroup = locateProcessGroup(flowController, groupId); + + final RemoteProcessGroup remoteProcessGroup = destinationParentGroup.getRemoteProcessGroup(destinationDto.getGroupId()); + if (remoteProcessGroup == null) { + throw new IllegalArgumentException("Unable to find the specified remote process group."); + } + + final RemoteGroupPort destinationConnectable = remoteProcessGroup.getInputPort(destinationDto.getId()); if (destinationConnectable == null) { throw new IllegalArgumentException("The specified destination for the connection does not exist"); + } else if (!destinationConnectable.getTargetExists()) { + throw new IllegalArgumentException("The specified remote input port does not exist."); } } else { - final Connectable destinationConnectable = rootGroup.findLocalConnectable(destinationDto.getId()); + final ProcessGroup destinationGroup = locateProcessGroup(flowController, destinationDto.getGroupId()); + final Connectable destinationConnectable = destinationGroup.getConnectable(destinationDto.getId()); if (destinationConnectable == null) { throw new IllegalArgumentException("The specified destination for the connection does not exist"); }
