Java Code Examples for org.apache.nifi.registry.flow.VersionedProcessGroup#getProcessGroups()

The following examples show how to use org.apache.nifi.registry.flow.VersionedProcessGroup#getProcessGroups() . 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: FlowController.java    From nifi with Apache License 2.0 6 votes vote down vote up
private void verifyProcessorsInVersionedFlow(final VersionedProcessGroup versionedFlow, final Map<String, Set<BundleCoordinate>> supportedTypes) {
    if (versionedFlow.getProcessors() != null) {
        versionedFlow.getProcessors().forEach(processor -> {
            if (processor.getBundle() == null) {
                throw new IllegalArgumentException("Processor bundle must be specified.");
            }

            if (supportedTypes.containsKey(processor.getType())) {
                verifyBundleInVersionedFlow(processor.getBundle(), supportedTypes.get(processor.getType()));
            } else {
                throw new IllegalStateException("Invalid Processor Type: " + processor.getType());
            }
        });
    }

    if (versionedFlow.getProcessGroups() != null) {
        versionedFlow.getProcessGroups().forEach(processGroup -> {
            verifyProcessorsInVersionedFlow(processGroup, supportedTypes);
        });
    }
}
 
Example 2
Source File: FlowController.java    From nifi with Apache License 2.0 6 votes vote down vote up
private void verifyControllerServicesInVersionedFlow(final VersionedProcessGroup versionedFlow, final Map<String, Set<BundleCoordinate>> supportedTypes) {
    if (versionedFlow.getControllerServices() != null) {
        versionedFlow.getControllerServices().forEach(controllerService -> {
            if (supportedTypes.containsKey(controllerService.getType())) {
                if (controllerService.getBundle() == null) {
                    throw new IllegalArgumentException("Controller Service bundle must be specified.");
                }

                verifyBundleInVersionedFlow(controllerService.getBundle(), supportedTypes.get(controllerService.getType()));
            } else {
                throw new IllegalStateException("Invalid Controller Service Type: " + controllerService.getType());
            }
        });
    }

    if (versionedFlow.getProcessGroups() != null) {
        versionedFlow.getProcessGroups().forEach(processGroup -> {
            verifyControllerServicesInVersionedFlow(processGroup, supportedTypes);
        });
    }
}
 
Example 3
Source File: VersionsResource.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Recursively clear the registry info in the given versioned process group and all nested versioned process groups
 *
 * @param versionedProcessGroup the process group to sanitize
 */
private void sanitizeRegistryInfo(final VersionedProcessGroup versionedProcessGroup) {
    versionedProcessGroup.setVersionedFlowCoordinates(null);

    for (final VersionedProcessGroup innerVersionedProcessGroup : versionedProcessGroup.getProcessGroups()) {
        sanitizeRegistryInfo(innerVersionedProcessGroup);
    }
}
 
Example 4
Source File: RegistryUtil.java    From nifi with Apache License 2.0 5 votes vote down vote up
public VersionedFlowSnapshot getFlowContents(final String bucketId, final String flowId, final int version, final boolean fetchRemoteFlows, final NiFiUser user)
    throws IOException, NiFiRegistryException {

    final FlowSnapshotClient snapshotClient = getFlowSnapshotClient(user);
    final VersionedFlowSnapshot flowSnapshot = snapshotClient.get(bucketId, flowId, version);

    if (fetchRemoteFlows) {
        final VersionedProcessGroup contents = flowSnapshot.getFlowContents();
        for (final VersionedProcessGroup child : contents.getProcessGroups()) {
            populateVersionedContentsRecursively(child, user);
        }
    }

    return flowSnapshot;
}
 
Example 5
Source File: RegistryUtil.java    From nifi with Apache License 2.0 5 votes vote down vote up
private void populateVersionedContentsRecursively(final VersionedProcessGroup group, final NiFiUser user) throws NiFiRegistryException, IOException {
    if (group == null) {
        return;
    }

    final VersionedFlowCoordinates coordinates = group.getVersionedFlowCoordinates();
    if (coordinates != null) {
        final String registryUrl = coordinates.getRegistryUrl();
        final String bucketId = coordinates.getBucketId();
        final String flowId = coordinates.getFlowId();
        final int version = coordinates.getVersion();

        final RegistryUtil subFlowUtil = new RegistryUtil(registryUrl, sslContext);
        final VersionedFlowSnapshot snapshot = subFlowUtil.getFlowByID(bucketId, flowId, version);
        final VersionedProcessGroup contents = snapshot.getFlowContents();

        group.setComments(contents.getComments());
        group.setConnections(contents.getConnections());
        group.setControllerServices(contents.getControllerServices());
        group.setFunnels(contents.getFunnels());
        group.setInputPorts(contents.getInputPorts());
        group.setLabels(contents.getLabels());
        group.setOutputPorts(contents.getOutputPorts());
        group.setProcessGroups(contents.getProcessGroups());
        group.setProcessors(contents.getProcessors());
        group.setRemoteProcessGroups(contents.getRemoteProcessGroups());
        group.setVariables(contents.getVariables());
        coordinates.setLatest(snapshot.isLatest());
    }

    for (final VersionedProcessGroup child : group.getProcessGroups()) {
        populateVersionedContentsRecursively(child, user);
    }
}
 
Example 6
Source File: FlowController.java    From nifi with Apache License 2.0 5 votes vote down vote up
private Set<VersionedConnection> findAllConnections(final VersionedProcessGroup group) {
    final Set<VersionedConnection> conns = new HashSet<>();
    for (final VersionedConnection connection : group.getConnections()) {
        conns.add(connection);
    }

    for (final VersionedProcessGroup childGroup : group.getProcessGroups()) {
        conns.addAll(findAllConnections(childGroup));
    }
    return conns;
}