Java Code Examples for org.apache.nifi.groups.ProcessGroup#isRootGroup()

The following examples show how to use org.apache.nifi.groups.ProcessGroup#isRootGroup() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractComponentSearchResultEnricher.java    From nifi with Apache License 2.0 6 votes vote down vote up
/**
 * Builds the nearest versioned parent result group for a given user.
 *
 * @param group The containing group
 * @param user The current NiFi user
 * @return Versioned parent group
 */
protected SearchResultGroupDTO buildVersionedGroup(final ProcessGroup group, final NiFiUser user) {
    if (group == null) {
        return null;
    }

    ProcessGroup current = group;

    // search for a versioned group by traversing the group tree up to the root
    while (!current.isRootGroup()) {
        if (current.getVersionControlInformation() != null) {
            return buildResultGroup(current, user);
        }

        current = current.getParent();
    }

    // traversed all the way to the root
    return null;
}
 
Example 2
Source File: AbstractFlowFileServerProtocol.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Override
public void setRootProcessGroup(final ProcessGroup group) {
    if (!group.isRootGroup()) {
        throw new IllegalArgumentException("Specified group was not a root group.");
    }
    this.rootGroup = group;
}
 
Example 3
Source File: AbstractFlowFileServerProtocol.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
public void setRootProcessGroup(final ProcessGroup group) {
    if (!group.isRootGroup()) {
        throw new IllegalArgumentException("Specified group was not a root group.");
    }
    this.rootGroup = group;
}
 
Example 4
Source File: StandardFlowSynchronizer.java    From nifi with Apache License 2.0 4 votes vote down vote up
private void addInputPorts(final Element processGroupElement, final ProcessGroup processGroup, final FlowController flowController) {
    final FlowManager flowManager = flowController.getFlowManager();
    final List<Element> inputPortNodeList = getChildrenByTagName(processGroupElement, "inputPort");
    for (final Element inputPortElement : inputPortNodeList) {
        final PortDTO portDTO = FlowFromDOMFactory.getPort(inputPortElement);

        final Port port;
        if (processGroup.isRootGroup() || Boolean.TRUE.equals(portDTO.getAllowRemoteAccess())) {
            port = flowManager.createPublicInputPort(portDTO.getId(), portDTO.getName());
        } else {
            port = flowManager.createLocalInputPort(portDTO.getId(), portDTO.getName());
        }

        port.setVersionedComponentId(portDTO.getVersionedComponentId());
        port.setPosition(toPosition(portDTO.getPosition()));
        port.setComments(portDTO.getComments());
        port.setProcessGroup(processGroup);

        final Set<String> userControls = portDTO.getUserAccessControl();
        if (userControls != null && !userControls.isEmpty()) {
            if (!(port instanceof PublicPort)) {
                throw new IllegalStateException("Attempting to add User Access Controls to " + port.getIdentifier() + ", but it is not a RootGroupPort");
            }
            ((PublicPort) port).setUserAccessControl(userControls);
        }
        final Set<String> groupControls = portDTO.getGroupAccessControl();
        if (groupControls != null && !groupControls.isEmpty()) {
            if (!(port instanceof PublicPort)) {
                throw new IllegalStateException("Attempting to add Group Access Controls to " + port.getIdentifier() + ", but it is not a RootGroupPort");
            }
            ((PublicPort) port).setGroupAccessControl(groupControls);
        }

        processGroup.addInputPort(port);
        if (portDTO.getConcurrentlySchedulableTaskCount() != null) {
            port.setMaxConcurrentTasks(portDTO.getConcurrentlySchedulableTaskCount());
        }

        final ScheduledState scheduledState = ScheduledState.valueOf(portDTO.getState());
        if (ScheduledState.RUNNING.equals(scheduledState)) {
            flowController.startConnectable(port);
        } else if (ScheduledState.DISABLED.equals(scheduledState)) {
            processGroup.disableInputPort(port);
        }
    }
}
 
Example 5
Source File: StandardFlowSynchronizer.java    From nifi with Apache License 2.0 4 votes vote down vote up
private void addOutputPorts(final Element processGroupElement, final ProcessGroup processGroup, final FlowController flowController) {
    final FlowManager flowManager = flowController.getFlowManager();
    final List<Element> outputPortNodeList = getChildrenByTagName(processGroupElement, "outputPort");
    for (final Element outputPortElement : outputPortNodeList) {
        final PortDTO portDTO = FlowFromDOMFactory.getPort(outputPortElement);

        final Port port;
        if (processGroup.isRootGroup() || Boolean.TRUE.equals(portDTO.getAllowRemoteAccess())) {
            port = flowManager.createPublicOutputPort(portDTO.getId(), portDTO.getName());
        } else {
            port = flowManager.createLocalOutputPort(portDTO.getId(), portDTO.getName());
        }

        port.setVersionedComponentId(portDTO.getVersionedComponentId());
        port.setPosition(toPosition(portDTO.getPosition()));
        port.setComments(portDTO.getComments());
        port.setProcessGroup(processGroup);

        final Set<String> userControls = portDTO.getUserAccessControl();
        if (userControls != null && !userControls.isEmpty()) {
            if (!(port instanceof PublicPort)) {
                throw new IllegalStateException("Attempting to add User Access Controls to " + port.getIdentifier() + ", but it is not a RootGroupPort");
            }
            ((PublicPort) port).setUserAccessControl(userControls);
        }
        final Set<String> groupControls = portDTO.getGroupAccessControl();
        if (groupControls != null && !groupControls.isEmpty()) {
            if (!(port instanceof PublicPort)) {
                throw new IllegalStateException("Attempting to add Group Access Controls to " + port.getIdentifier() + ", but it is not a RootGroupPort");
            }
            ((PublicPort) port).setGroupAccessControl(groupControls);
        }

        processGroup.addOutputPort(port);
        if (portDTO.getConcurrentlySchedulableTaskCount() != null) {
            port.setMaxConcurrentTasks(portDTO.getConcurrentlySchedulableTaskCount());
        }

        final ScheduledState scheduledState = ScheduledState.valueOf(portDTO.getState());
        if (ScheduledState.RUNNING.equals(scheduledState)) {
            flowController.startConnectable(port);
        } else if (ScheduledState.DISABLED.equals(scheduledState)) {
            processGroup.disableOutputPort(port);
        }
    }
}