Java Code Examples for org.apache.nifi.web.api.dto.ProcessorDTO#setDescription()

The following examples show how to use org.apache.nifi.web.api.dto.ProcessorDTO#setDescription() . 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: 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 2
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);
    }
}
 
Example 3
Source File: TestFlowController.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void testInstantiateSnippetWhenProcessorMissingBundle() throws Exception {
    final String id = UUID.randomUUID().toString();
    final BundleCoordinate coordinate = systemBundle.getBundleDetails().getCoordinate();
    final ProcessorNode processorNode = controller.getFlowManager().createProcessor(DummyProcessor.class.getName(), id, coordinate);

    // create a processor dto
    final ProcessorDTO processorDTO = new ProcessorDTO();
    processorDTO.setId(UUID.randomUUID().toString()); // use a different id here
    processorDTO.setPosition(new PositionDTO(new Double(0), new Double(0)));
    processorDTO.setStyle(processorNode.getStyle());
    processorDTO.setParentGroupId("1234");
    processorDTO.setInputRequirement(processorNode.getInputRequirement().name());
    processorDTO.setPersistsState(processorNode.getProcessor().getClass().isAnnotationPresent(Stateful.class));
    processorDTO.setRestricted(processorNode.isRestricted());
    processorDTO.setExecutionNodeRestricted(processorNode.isExecutionNodeRestricted());
    processorDTO.setExtensionMissing(processorNode.isExtensionMissing());

    processorDTO.setType(processorNode.getCanonicalClassName());
    processorDTO.setBundle(null); // missing bundle
    processorDTO.setName(processorNode.getName());
    processorDTO.setState(processorNode.getScheduledState().toString());

    processorDTO.setRelationships(new ArrayList<>());

    processorDTO.setDescription("description");
    processorDTO.setSupportsParallelProcessing(!processorNode.isTriggeredSerially());
    processorDTO.setSupportsEventDriven(processorNode.isEventDrivenSupported());
    processorDTO.setSupportsBatching(processorNode.isSessionBatchingSupported());

    ProcessorConfigDTO configDTO = new ProcessorConfigDTO();
    configDTO.setSchedulingPeriod(processorNode.getSchedulingPeriod());
    configDTO.setPenaltyDuration(processorNode.getPenalizationPeriod());
    configDTO.setYieldDuration(processorNode.getYieldPeriod());
    configDTO.setRunDurationMillis(processorNode.getRunDuration(TimeUnit.MILLISECONDS));
    configDTO.setConcurrentlySchedulableTaskCount(processorNode.getMaxConcurrentTasks());
    configDTO.setLossTolerant(processorNode.isLossTolerant());
    configDTO.setComments(processorNode.getComments());
    configDTO.setBulletinLevel(processorNode.getBulletinLevel().name());
    configDTO.setSchedulingStrategy(processorNode.getSchedulingStrategy().name());
    configDTO.setExecutionNode(processorNode.getExecutionNode().name());
    configDTO.setAnnotationData(processorNode.getAnnotationData());

    processorDTO.setConfig(configDTO);

    // create the snippet with the processor
    final FlowSnippetDTO flowSnippetDTO = new FlowSnippetDTO();
    flowSnippetDTO.setProcessors(Collections.singleton(processorDTO));

    // instantiate the snippet
    assertEquals(0, controller.getFlowManager().getRootGroup().getProcessors().size());
    controller.getFlowManager().instantiateSnippet(controller.getFlowManager().getRootGroup(), flowSnippetDTO);
}
 
Example 4
Source File: TestFlowController.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Test
public void testInstantiateSnippetWithProcessor() throws ProcessorInstantiationException {
    final String id = UUID.randomUUID().toString();
    final BundleCoordinate coordinate = systemBundle.getBundleDetails().getCoordinate();
    final ProcessorNode processorNode = controller.getFlowManager().createProcessor(DummyProcessor.class.getName(), id, coordinate);

    // create a processor dto
    final ProcessorDTO processorDTO = new ProcessorDTO();
    processorDTO.setId(UUID.randomUUID().toString()); // use a different id here
    processorDTO.setPosition(new PositionDTO(new Double(0), new Double(0)));
    processorDTO.setStyle(processorNode.getStyle());
    processorDTO.setParentGroupId("1234");
    processorDTO.setInputRequirement(processorNode.getInputRequirement().name());
    processorDTO.setPersistsState(processorNode.getProcessor().getClass().isAnnotationPresent(Stateful.class));
    processorDTO.setRestricted(processorNode.isRestricted());
    processorDTO.setExecutionNodeRestricted(processorNode.isExecutionNodeRestricted());
    processorDTO.setExtensionMissing(processorNode.isExtensionMissing());

    processorDTO.setType(processorNode.getCanonicalClassName());
    processorDTO.setBundle(new BundleDTO(coordinate.getGroup(), coordinate.getId(), coordinate.getVersion()));
    processorDTO.setName(processorNode.getName());
    processorDTO.setState(processorNode.getScheduledState().toString());

    processorDTO.setRelationships(new ArrayList<>());

    processorDTO.setDescription("description");
    processorDTO.setSupportsParallelProcessing(!processorNode.isTriggeredSerially());
    processorDTO.setSupportsEventDriven(processorNode.isEventDrivenSupported());
    processorDTO.setSupportsBatching(processorNode.isSessionBatchingSupported());

    ProcessorConfigDTO configDTO = new ProcessorConfigDTO();
    configDTO.setSchedulingPeriod(processorNode.getSchedulingPeriod());
    configDTO.setPenaltyDuration(processorNode.getPenalizationPeriod());
    configDTO.setYieldDuration(processorNode.getYieldPeriod());
    configDTO.setRunDurationMillis(processorNode.getRunDuration(TimeUnit.MILLISECONDS));
    configDTO.setConcurrentlySchedulableTaskCount(processorNode.getMaxConcurrentTasks());
    configDTO.setLossTolerant(processorNode.isLossTolerant());
    configDTO.setComments(processorNode.getComments());
    configDTO.setBulletinLevel(processorNode.getBulletinLevel().name());
    configDTO.setSchedulingStrategy(processorNode.getSchedulingStrategy().name());
    configDTO.setExecutionNode(processorNode.getExecutionNode().name());
    configDTO.setAnnotationData(processorNode.getAnnotationData());

    processorDTO.setConfig(configDTO);

    // create the snippet with the processor
    final FlowSnippetDTO flowSnippetDTO = new FlowSnippetDTO();
    flowSnippetDTO.setProcessors(Collections.singleton(processorDTO));

    // instantiate the snippet
    assertEquals(0, controller.getFlowManager().getRootGroup().getProcessors().size());
    controller.getFlowManager().instantiateSnippet(controller.getFlowManager().getRootGroup(), flowSnippetDTO);
    assertEquals(1, controller.getFlowManager().getRootGroup().getProcessors().size());
}
 
Example 5
Source File: TestFlowController.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Test
public void testInstantiateSnippetWithDisabledProcessor() throws ProcessorInstantiationException {
    final String id = UUID.randomUUID().toString();
    final BundleCoordinate coordinate = systemBundle.getBundleDetails().getCoordinate();
    final ProcessorNode processorNode = controller.getFlowManager().createProcessor(DummyProcessor.class.getName(), id, coordinate);
    processorNode.disable();

    // create a processor dto
    final ProcessorDTO processorDTO = new ProcessorDTO();
    processorDTO.setId(UUID.randomUUID().toString()); // use a different id here
    processorDTO.setPosition(new PositionDTO(new Double(0), new Double(0)));
    processorDTO.setStyle(processorNode.getStyle());
    processorDTO.setParentGroupId("1234");
    processorDTO.setInputRequirement(processorNode.getInputRequirement().name());
    processorDTO.setPersistsState(processorNode.getProcessor().getClass().isAnnotationPresent(Stateful.class));
    processorDTO.setRestricted(processorNode.isRestricted());
    processorDTO.setExecutionNodeRestricted(processorNode.isExecutionNodeRestricted());
    processorDTO.setExtensionMissing(processorNode.isExtensionMissing());

    processorDTO.setType(processorNode.getCanonicalClassName());
    processorDTO.setBundle(new BundleDTO(coordinate.getGroup(), coordinate.getId(), coordinate.getVersion()));
    processorDTO.setName(processorNode.getName());
    processorDTO.setState(processorNode.getScheduledState().toString());

    processorDTO.setRelationships(new ArrayList<>());

    processorDTO.setDescription("description");
    processorDTO.setSupportsParallelProcessing(!processorNode.isTriggeredSerially());
    processorDTO.setSupportsEventDriven(processorNode.isEventDrivenSupported());
    processorDTO.setSupportsBatching(processorNode.isSessionBatchingSupported());

    ProcessorConfigDTO configDTO = new ProcessorConfigDTO();
    configDTO.setSchedulingPeriod(processorNode.getSchedulingPeriod());
    configDTO.setPenaltyDuration(processorNode.getPenalizationPeriod());
    configDTO.setYieldDuration(processorNode.getYieldPeriod());
    configDTO.setRunDurationMillis(processorNode.getRunDuration(TimeUnit.MILLISECONDS));
    configDTO.setConcurrentlySchedulableTaskCount(processorNode.getMaxConcurrentTasks());
    configDTO.setLossTolerant(processorNode.isLossTolerant());
    configDTO.setComments(processorNode.getComments());
    configDTO.setBulletinLevel(processorNode.getBulletinLevel().name());
    configDTO.setSchedulingStrategy(processorNode.getSchedulingStrategy().name());
    configDTO.setExecutionNode(processorNode.getExecutionNode().name());
    configDTO.setAnnotationData(processorNode.getAnnotationData());

    processorDTO.setConfig(configDTO);

    // create the snippet with the processor
    final FlowSnippetDTO flowSnippetDTO = new FlowSnippetDTO();
    flowSnippetDTO.setProcessors(Collections.singleton(processorDTO));

    // instantiate the snippet
    assertEquals(0, controller.getFlowManager().getRootGroup().getProcessors().size());
    controller.getFlowManager().instantiateSnippet(controller.getFlowManager().getRootGroup(), flowSnippetDTO);
    assertEquals(1, controller.getFlowManager().getRootGroup().getProcessors().size());
    assertTrue(controller.getFlowManager().getRootGroup().getProcessors().iterator().next().getScheduledState().equals(ScheduledState.DISABLED));
}