Java Code Examples for org.apache.nifi.web.api.dto.ProcessorConfigDTO#setCustomUiUrl()

The following examples show how to use org.apache.nifi.web.api.dto.ProcessorConfigDTO#setCustomUiUrl() . 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: ProcessorResource.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
/**
 * Populate the uri's for the specified processor and its relationships.
 */
public ProcessorDTO populateRemainingProcessorContent(ProcessorDTO processor) {
    // get the config details and see if there is a custom ui for this processor type
    ProcessorConfigDTO config = processor.getConfig();
    if (config != null) {
        // consider legacy custom ui fist
        String customUiUrl = servletContext.getInitParameter(processor.getType());
        if (StringUtils.isNotBlank(customUiUrl)) {
            config.setCustomUiUrl(customUiUrl);
        } else {
            // see if this processor has any ui extensions
            final UiExtensionMapping uiExtensionMapping = (UiExtensionMapping) servletContext.getAttribute("nifi-ui-extensions");
            if (uiExtensionMapping.hasUiExtension(processor.getType())) {
                final List<UiExtension> uiExtensions = uiExtensionMapping.getUiExtension(processor.getType());
                for (final UiExtension uiExtension : uiExtensions) {
                    if (UiExtensionType.ProcessorConfiguration.equals(uiExtension.getExtensionType())) {
                        config.setCustomUiUrl(uiExtension.getContextPath() + "/configure");
                    }
                }
            }
        }
    }

    return processor;
}
 
Example 2
Source File: ProcessorResource.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Populate the uri's for the specified processor and its relationships.
 */
public ProcessorDTO populateRemainingProcessorContent(ProcessorDTO processor) {
    // get the config details and see if there is a custom ui for this processor type
    ProcessorConfigDTO config = processor.getConfig();
    if (config != null) {
        // consider legacy custom ui fist
        String customUiUrl = servletContext.getInitParameter(processor.getType());
        if (StringUtils.isNotBlank(customUiUrl)) {
            config.setCustomUiUrl(customUiUrl);
        } else {
            final BundleDTO bundle = processor.getBundle();

            // see if this processor has any ui extensions
            final UiExtensionMapping uiExtensionMapping = (UiExtensionMapping) servletContext.getAttribute("nifi-ui-extensions");
            if (uiExtensionMapping.hasUiExtension(processor.getType(), bundle.getGroup(), bundle.getArtifact(), bundle.getVersion())) {
                final List<UiExtension> uiExtensions = uiExtensionMapping.getUiExtension(processor.getType(), bundle.getGroup(), bundle.getArtifact(), bundle.getVersion());
                for (final UiExtension uiExtension : uiExtensions) {
                    if (UiExtensionType.ProcessorConfiguration.equals(uiExtension.getExtensionType())) {
                        config.setCustomUiUrl(uiExtension.getContextPath() + "/configure");
                    }
                }
            }
        }
    }

    return processor;
}
 
Example 3
Source File: TemplateUtils.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
/**
 * Scrubs processors prior to saving. This includes removing sensitive properties, validation errors, property descriptors, etc.
 *
 * @param processors procs
 */
private static void scrubProcessors(final Set<ProcessorDTO> processors) {
    // go through each processor
    for (final ProcessorDTO processorDTO : processors) {
        final ProcessorConfigDTO processorConfig = processorDTO.getConfig();

        // ensure that some property configuration have been specified
        if (processorConfig != null) {
            // if properties have been specified, remove sensitive ones
            if (processorConfig.getProperties() != null) {
                Map<String, String> processorProperties = processorConfig.getProperties();

                // look for sensitive properties and remove them
                if (processorConfig.getDescriptors() != null) {
                    final Collection<PropertyDescriptorDTO> descriptors = processorConfig.getDescriptors().values();
                    for (PropertyDescriptorDTO descriptor : descriptors) {
                        if (Boolean.TRUE.equals(descriptor.isSensitive())) {
                            processorProperties.put(descriptor.getName(), null);
                        }

                        scrubPropertyDescriptor(descriptor);
                    }
                }
            }

            processorConfig.setCustomUiUrl(null);
            processorConfig.setDefaultConcurrentTasks(null);
            processorConfig.setDefaultSchedulingPeriod(null);
            processorConfig.setAutoTerminatedRelationships(null);
        }

        if (processorDTO.getRelationships() != null) {
            for (final RelationshipDTO relationship : processorDTO.getRelationships()) {
                relationship.setDescription(null);
            }
        }

        processorDTO.setValidationErrors(null);
        processorDTO.setInputRequirement(null);
        processorDTO.setDescription(null);
        processorDTO.setInputRequirement(null);
        processorDTO.setPersistsState(null);
        processorDTO.setState(null);
        processorDTO.setSupportsBatching(null);
        processorDTO.setSupportsEventDriven(null);
        processorDTO.setSupportsParallelProcessing(null);
    }
}
 
Example 4
Source File: TemplateUtils.java    From nifi with Apache License 2.0 4 votes vote down vote up
/**
 * Scrubs processors prior to saving. This includes removing sensitive properties, validation errors, property descriptors, etc.
 *
 * @param processors procs
 */
private static void scrubProcessors(final Set<ProcessorDTO> processors) {
    // go through each processor
    for (final ProcessorDTO processorDTO : processors) {
        final ProcessorConfigDTO processorConfig = processorDTO.getConfig();

        // ensure that some property configuration have been specified
        if (processorConfig != null) {
            // if properties have been specified, remove sensitive ones
            if (processorConfig.getProperties() != null) {
                Map<String, String> processorProperties = processorConfig.getProperties();

                // look for sensitive properties and remove them
                if (processorConfig.getDescriptors() != null) {
                    final Collection<PropertyDescriptorDTO> descriptors = processorConfig.getDescriptors().values();
                    for (PropertyDescriptorDTO descriptor : descriptors) {
                        if (Boolean.TRUE.equals(descriptor.isSensitive())) {
                            processorProperties.put(descriptor.getName(), null);
                        }

                        scrubPropertyDescriptor(descriptor);
                    }
                }
            }

            processorConfig.setCustomUiUrl(null);
            processorConfig.setDefaultConcurrentTasks(null);
            processorConfig.setDefaultSchedulingPeriod(null);
            processorConfig.setAutoTerminatedRelationships(null);
        }

        if (processorDTO.getRelationships() != null) {
            for (final RelationshipDTO relationship : processorDTO.getRelationships()) {
                relationship.setDescription(null);
            }
        }

        processorDTO.setExtensionMissing(null);
        processorDTO.setMultipleVersionsAvailable(null);
        processorDTO.setValidationErrors(null);
        processorDTO.setValidationStatus(null);
        processorDTO.setInputRequirement(null);
        processorDTO.setDescription(null);
        processorDTO.setInputRequirement(null);
        processorDTO.setPersistsState(null);
        processorDTO.setSupportsBatching(null);
        processorDTO.setSupportsEventDriven(null);
        processorDTO.setSupportsParallelProcessing(null);
    }
}