Java Code Examples for org.apache.nifi.web.api.dto.FlowSnippetDTO#getProcessors()
The following examples show how to use
org.apache.nifi.web.api.dto.FlowSnippetDTO#getProcessors() .
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 |
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 |
/** * 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 |
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 |
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 |
private void verifyProcessorsInSnippet(final FlowSnippetDTO templateContents, final Map<String, Set<BundleCoordinate>> supportedTypes) { if (templateContents.getProcessors() != null) { templateContents.getProcessors().forEach(processor -> { if (processor.getBundle() == null) { throw new IllegalArgumentException("Processor bundle must be specified."); } if (supportedTypes.containsKey(processor.getType())) { verifyBundleInSnippet(processor.getBundle(), supportedTypes.get(processor.getType())); } else { throw new IllegalStateException("Invalid Processor Type: " + processor.getType()); } }); } if (templateContents.getProcessGroups() != null) { templateContents.getProcessGroups().forEach(processGroup -> verifyProcessorsInSnippet(processGroup.getContents(), supportedTypes)); } }
Example 6
Source File: NiFiClientUtil.java From nifi with Apache License 2.0 | 6 votes |
private void waitForProcessorsStopped(final ProcessGroupDTO group) throws IOException, NiFiClientException { final FlowSnippetDTO groupContents = group.getContents(); if (groupContents == null) { return; } for (final ProcessorDTO processor : groupContents.getProcessors()) { try { waitForStoppedProcessor(processor.getId()); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new NiFiClientException("Interrupted while waiting for Processor with ID " + processor.getId() + " to stop"); } } for (final ProcessGroupDTO child : groupContents.getProcessGroups()) { waitForProcessorsStopped(child); } }
Example 7
Source File: SnippetUtils.java From localization_nifi with Apache License 2.0 | 5 votes |
private void updateControllerServiceIdentifiers(final FlowSnippetDTO snippet, final Map<String, String> serviceIdMap) { final Set<ProcessorDTO> processors = snippet.getProcessors(); if (processors != null) { for (final ProcessorDTO processor : processors) { updateControllerServiceIdentifiers(processor.getConfig(), serviceIdMap); } } for (final ProcessGroupDTO processGroupDto : snippet.getProcessGroups()) { updateControllerServiceIdentifiers(processGroupDto.getContents(), serviceIdMap); } }
Example 8
Source File: TemplateUtils.java From localization_nifi with Apache License 2.0 | 5 votes |
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 9
Source File: SnippetUtils.java From localization_nifi with Apache License 2.0 | 5 votes |
/** * Gets all components, but not connections, that are part of the specified template. * * @param contents snippet * @return component dtos */ private static Collection<ComponentDTO> getComponents(FlowSnippetDTO contents) { final Collection<ComponentDTO> components = new HashSet<>(); // add all components if (contents.getInputPorts() != null) { components.addAll(contents.getInputPorts()); } if (contents.getLabels() != null) { components.addAll(contents.getLabels()); } if (contents.getOutputPorts() != null) { components.addAll(contents.getOutputPorts()); } if (contents.getProcessGroups() != null) { components.addAll(contents.getProcessGroups()); } if (contents.getProcessors() != null) { components.addAll(contents.getProcessors()); } if (contents.getFunnels() != null) { components.addAll(contents.getFunnels()); } if (contents.getRemoteProcessGroups() != null) { components.addAll(contents.getRemoteProcessGroups()); } return components; }
Example 10
Source File: SnippetUtils.java From nifi with Apache License 2.0 | 5 votes |
private void updateControllerServiceIdentifiers(final FlowSnippetDTO snippet, final Map<String, String> serviceIdMap) { final Set<ProcessorDTO> processors = snippet.getProcessors(); if (processors != null) { for (final ProcessorDTO processor : processors) { updateControllerServiceIdentifiers(processor.getConfig(), serviceIdMap); } } for (final ProcessGroupDTO processGroupDto : snippet.getProcessGroups()) { updateControllerServiceIdentifiers(processGroupDto.getContents(), serviceIdMap); } }
Example 11
Source File: TemplateUtils.java From nifi with Apache License 2.0 | 5 votes |
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 12
Source File: SnippetUtils.java From nifi with Apache License 2.0 | 5 votes |
/** * Gets all components, but not connections, that are part of the specified template. * * @param contents snippet * @return component dtos */ private static Collection<ComponentDTO> getComponents(FlowSnippetDTO contents) { final Collection<ComponentDTO> components = new HashSet<>(); // add all components if (contents.getInputPorts() != null) { components.addAll(contents.getInputPorts()); } if (contents.getLabels() != null) { components.addAll(contents.getLabels()); } if (contents.getOutputPorts() != null) { components.addAll(contents.getOutputPorts()); } if (contents.getProcessGroups() != null) { components.addAll(contents.getProcessGroups()); } if (contents.getProcessors() != null) { components.addAll(contents.getProcessors()); } if (contents.getFunnels() != null) { components.addAll(contents.getFunnels()); } if (contents.getRemoteProcessGroups() != null) { components.addAll(contents.getRemoteProcessGroups()); } return components; }
Example 13
Source File: JoinClusterWithDifferentFlow.java From nifi with Apache License 2.0 | 5 votes |
private void verifyFlowContentsOnDisk(final File backupFile) throws IOException, SAXException, ParserConfigurationException { // Read the flow and make sure that the backup looks the same as the original. We don't just do a byte comparison because the compression may result in different // gzipped bytes and because if the two flows do differ, we want to have the String representation so that we can compare to see how they are different. final String flowXml = readFlow(backupFile); final String expectedFlow = readFlow(new File("src/test/resources/flows/mismatched-flows/flow2.xml.gz")); assertEquals(expectedFlow, flowXml); // Verify some of the values that were persisted to disk final File confDir = backupFile.getParentFile(); final String loadedFlow = readFlow(new File(confDir, "flow.xml.gz")); final DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); final Document document = documentBuilder.parse(new InputSource(new StringReader(loadedFlow))); final Element rootElement = (Element) document.getElementsByTagName("flowController").item(0); final FlowEncodingVersion encodingVersion = FlowEncodingVersion.parse(rootElement); final NiFiInstance node2 = getNiFiInstance().getNodeInstance(2); final StringEncryptor encryptor = createEncryptorFromProperties(node2.getProperties()); final Element rootGroupElement = (Element) rootElement.getElementsByTagName("rootGroup").item(0); final ProcessGroupDTO groupDto = FlowFromDOMFactory.getProcessGroup(null, rootGroupElement, encryptor, encodingVersion); final Set<ProcessGroupDTO> childGroupDtos = groupDto.getContents().getProcessGroups(); assertEquals(1, childGroupDtos.size()); final ProcessGroupDTO childGroup = childGroupDtos.iterator().next(); assertFalse(childGroup.getId().endsWith("00")); final FlowSnippetDTO childContents = childGroup.getContents(); final Set<ProcessorDTO> childProcessors = childContents.getProcessors(); assertEquals(1, childProcessors.size()); final ProcessorDTO procDto = childProcessors.iterator().next(); assertFalse(procDto.getId().endsWith("00")); assertFalse(procDto.getName().endsWith("00")); }
Example 14
Source File: StandardFlowServiceTest.java From localization_nifi with Apache License 2.0 | 4 votes |
private void assertEquals(FlowSnippetDTO expected, FlowSnippetDTO actual) { if (expected == null && actual == null) { return; } // check connections Assert.assertEquals(expected.getConnections().size(), actual.getConnections().size()); List<ConnectionDTO> expectedConnections = new ArrayList<>(expected.getConnections()); List<ConnectionDTO> actualConnections = new ArrayList<>(actual.getConnections()); for (int i = 0; i < expectedConnections.size(); i++) { assertEquals(expectedConnections.get(i), actualConnections.get(i)); } // check groups Assert.assertEquals(expected.getProcessGroups().size(), actual.getProcessGroups().size()); List<ProcessGroupDTO> expectedProcessGroups = new ArrayList<>(expected.getProcessGroups()); List<ProcessGroupDTO> actualProcessGroups = new ArrayList<>(actual.getProcessGroups()); for (int i = 0; i < expectedProcessGroups.size(); i++) { assertEquals(expectedProcessGroups.get(i), actualProcessGroups.get(i)); } // check input ports Assert.assertEquals(expected.getInputPorts().size(), actual.getInputPorts().size()); List<PortDTO> expectedInputPorts = new ArrayList<>(expected.getInputPorts()); List<PortDTO> actualInputPort = new ArrayList<>(actual.getInputPorts()); for (int i = 0; i < expectedInputPorts.size(); i++) { assertEquals(expectedInputPorts.get(i), actualInputPort.get(i)); } // check labels Assert.assertEquals(expected.getLabels().size(), actual.getLabels().size()); List<LabelDTO> expectedLabels = new ArrayList<>(expected.getLabels()); List<LabelDTO> actualLabels = new ArrayList<>(actual.getLabels()); for (int i = 0; i < expectedLabels.size(); i++) { assertEquals(expectedLabels.get(i), actualLabels.get(i)); } // check output ports Assert.assertEquals(expected.getOutputPorts().size(), actual.getOutputPorts().size()); List<PortDTO> expectedOutputPorts = new ArrayList<>(expected.getOutputPorts()); List<PortDTO> actualOutputPort = new ArrayList<>(actual.getOutputPorts()); for (int i = 0; i < expectedOutputPorts.size(); i++) { assertEquals(expectedOutputPorts.get(i), actualOutputPort.get(i)); } // check processors Assert.assertEquals(expected.getProcessors().size(), actual.getProcessors().size()); List<ProcessorDTO> expectedProcessors = new ArrayList<>(expected.getProcessors()); List<ProcessorDTO> actualProcessors = new ArrayList<>(actual.getProcessors()); for (int i = 0; i < expectedProcessors.size(); i++) { assertEquals(expectedProcessors.get(i), actualProcessors.get(i)); } }
Example 15
Source File: StandardFlowServiceTest.java From nifi with Apache License 2.0 | 4 votes |
private void assertEquals(FlowSnippetDTO expected, FlowSnippetDTO actual) { if (expected == null && actual == null) { return; } // check connections Assert.assertEquals(expected.getConnections().size(), actual.getConnections().size()); List<ConnectionDTO> expectedConnections = new ArrayList<>(expected.getConnections()); List<ConnectionDTO> actualConnections = new ArrayList<>(actual.getConnections()); for (int i = 0; i < expectedConnections.size(); i++) { assertEquals(expectedConnections.get(i), actualConnections.get(i)); } // check groups Assert.assertEquals(expected.getProcessGroups().size(), actual.getProcessGroups().size()); List<ProcessGroupDTO> expectedProcessGroups = new ArrayList<>(expected.getProcessGroups()); List<ProcessGroupDTO> actualProcessGroups = new ArrayList<>(actual.getProcessGroups()); for (int i = 0; i < expectedProcessGroups.size(); i++) { assertEquals(expectedProcessGroups.get(i), actualProcessGroups.get(i)); } // check input ports Assert.assertEquals(expected.getInputPorts().size(), actual.getInputPorts().size()); List<PortDTO> expectedInputPorts = new ArrayList<>(expected.getInputPorts()); List<PortDTO> actualInputPort = new ArrayList<>(actual.getInputPorts()); for (int i = 0; i < expectedInputPorts.size(); i++) { assertEquals(expectedInputPorts.get(i), actualInputPort.get(i)); } // check labels Assert.assertEquals(expected.getLabels().size(), actual.getLabels().size()); List<LabelDTO> expectedLabels = new ArrayList<>(expected.getLabels()); List<LabelDTO> actualLabels = new ArrayList<>(actual.getLabels()); for (int i = 0; i < expectedLabels.size(); i++) { assertEquals(expectedLabels.get(i), actualLabels.get(i)); } // check output ports Assert.assertEquals(expected.getOutputPorts().size(), actual.getOutputPorts().size()); List<PortDTO> expectedOutputPorts = new ArrayList<>(expected.getOutputPorts()); List<PortDTO> actualOutputPort = new ArrayList<>(actual.getOutputPorts()); for (int i = 0; i < expectedOutputPorts.size(); i++) { assertEquals(expectedOutputPorts.get(i), actualOutputPort.get(i)); } // check processors Assert.assertEquals(expected.getProcessors().size(), actual.getProcessors().size()); List<ProcessorDTO> expectedProcessors = new ArrayList<>(expected.getProcessors()); List<ProcessorDTO> actualProcessors = new ArrayList<>(actual.getProcessors()); for (int i = 0; i < expectedProcessors.size(); i++) { assertEquals(expectedProcessors.get(i), actualProcessors.get(i)); } }