Java Code Examples for org.apache.nifi.web.api.dto.FlowSnippetDTO#getControllerServices()

The following examples show how to use org.apache.nifi.web.api.dto.FlowSnippetDTO#getControllerServices() . 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: StandardSnippetDAO.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
private void lookupSensitiveProperties(final FlowSnippetDTO snippet) {
    // ensure that contents have been specified
    if (snippet != null) {
        // go through each processor if specified
        if (snippet.getProcessors() != null) {
            lookupSensitiveProcessorProperties(snippet.getProcessors());
        }

        if (snippet.getControllerServices() != null) {
            lookupSensitiveControllerServiceProperties(snippet.getControllerServices());
        }

        // go through each process group if specified
        if (snippet.getProcessGroups() != null) {
            for (final ProcessGroupDTO group : snippet.getProcessGroups()) {
                lookupSensitiveProperties(group.getContents());
            }
        }
    }
}
 
Example 2
Source File: StandardAuthorizableLookup.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
/**
 * Creates temporary instances of all processors and controller services found in the specified snippet.
 *
 * @param snippet               snippet
 * @param processors            processors
 * @param controllerServices    controller services
 */
private void createTemporaryProcessorsAndControllerServices(final FlowSnippetDTO snippet,
                                                            final Set<ConfigurableComponentAuthorizable> processors,
                                                            final Set<ConfigurableComponentAuthorizable> controllerServices) {

    if (snippet == null) {
        return;
    }

    if (snippet.getProcessors() != null) {
        processors.addAll(snippet.getProcessors().stream().map(processor -> getProcessorByType(processor.getType())).collect(Collectors.toSet()));
    }

    if (snippet.getControllerServices() != null) {
        controllerServices.addAll(snippet.getControllerServices().stream().map(controllerService -> getControllerServiceByType(controllerService.getType())).collect(Collectors.toSet()));
    }

    if (snippet.getProcessGroups() != null) {
        snippet.getProcessGroups().stream().forEach(group -> createTemporaryProcessorsAndControllerServices(group.getContents(), processors, controllerServices));
    }
}
 
Example 3
Source File: StandardSnippetDAO.java    From nifi with Apache License 2.0 6 votes vote down vote up
private void lookupSensitiveProperties(final FlowSnippetDTO snippet) {
    // ensure that contents have been specified
    if (snippet != null) {
        // go through each processor if specified
        if (snippet.getProcessors() != null) {
            lookupSensitiveProcessorProperties(snippet.getProcessors());
        }

        if (snippet.getControllerServices() != null) {
            lookupSensitiveControllerServiceProperties(snippet.getControllerServices());
        }

        // go through each process group if specified
        if (snippet.getProcessGroups() != null) {
            for (final ProcessGroupDTO group : snippet.getProcessGroups()) {
                lookupSensitiveProperties(group.getContents());
            }
        }
    }
}
 
Example 4
Source File: AuthorizeParameterReference.java    From nifi with Apache License 2.0 6 votes vote down vote up
public static void authorizeParameterReferences(final FlowSnippetDTO flowSnippet, final Authorizer authorizer, final Authorizable parameterContextAuthorizable, final NiFiUser user) {
    for (final ProcessorDTO processorDto : flowSnippet.getProcessors()) {
        final ProcessorConfigDTO configDto = processorDto.getConfig();
        if (configDto == null) {
            continue;
        }

        authorizeParameterReferences(configDto.getProperties(), authorizer, parameterContextAuthorizable, user);
    }

    for (final ControllerServiceDTO serviceDto : flowSnippet.getControllerServices()) {
        authorizeParameterReferences(serviceDto.getProperties(), authorizer, parameterContextAuthorizable, user);
    }

    // Note: there is no need to recurse here because when a template/snippet is instantiated, if there are any components in child Process Groups, a new Process Group will be created
    // without any Parameter Context, so there is no need to perform any authorization beyond the top-level group where the instantiation is occurring.
}
 
Example 5
Source File: StandardFlowSnippet.java    From nifi with Apache License 2.0 6 votes vote down vote up
private void verifyControllerServicesInSnippet(final FlowSnippetDTO templateContents, final Map<String, Set<BundleCoordinate>> supportedTypes) {
    if (templateContents.getControllerServices() != null) {
        templateContents.getControllerServices().forEach(controllerService -> {
            if (supportedTypes.containsKey(controllerService.getType())) {
                if (controllerService.getBundle() == null) {
                    throw new IllegalArgumentException("Controller Service bundle must be specified.");
                }

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

    if (templateContents.getProcessGroups() != null) {
        templateContents.getProcessGroups().forEach(processGroup -> verifyControllerServicesInSnippet(processGroup.getContents(), supportedTypes));
    }
}
 
Example 6
Source File: TemplateUtils.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
private static void scrubSnippet(final FlowSnippetDTO snippet) {
    // ensure that contents have been specified
    if (snippet != null) {
        // go through each processor if specified
        if (snippet.getProcessors() != null) {
            scrubProcessors(snippet.getProcessors());
        }

        // go through each connection if specified
        if (snippet.getConnections() != null) {
            scrubConnections(snippet.getConnections());
        }

        // go through each remote process group if specified
        if (snippet.getRemoteProcessGroups() != null) {
            scrubRemoteProcessGroups(snippet.getRemoteProcessGroups());
        }

        // go through each process group if specified
        if (snippet.getProcessGroups() != null) {
            scrubProcessGroups(snippet.getProcessGroups());
        }

        // go through each controller service if specified
        if (snippet.getControllerServices() != null) {
            scrubControllerServices(snippet.getControllerServices());
        }
    }
}
 
Example 7
Source File: TemplateUtils.java    From nifi with Apache License 2.0 5 votes vote down vote up
private static void scrubSnippet(final FlowSnippetDTO snippet) {
    // ensure that contents have been specified
    if (snippet != null) {
        // go through each processor if specified
        if (snippet.getProcessors() != null) {
            scrubProcessors(snippet.getProcessors());
        }

        // go through each connection if specified
        if (snippet.getConnections() != null) {
            scrubConnections(snippet.getConnections());
        }

        // go through each remote process group if specified
        if (snippet.getRemoteProcessGroups() != null) {
            scrubRemoteProcessGroups(snippet.getRemoteProcessGroups());
        }

        // go through each process group if specified
        if (snippet.getProcessGroups() != null) {
            scrubProcessGroups(snippet.getProcessGroups());
        }

        // go through each controller service if specified
        if (snippet.getControllerServices() != null) {
            scrubControllerServices(snippet.getControllerServices());
        }
    }
}