org.apache.nifi.web.api.dto.ProcessorDTO Java Examples
The following examples show how to use
org.apache.nifi.web.api.dto.ProcessorDTO.
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: StandardProcessorDAO.java From nifi with Apache License 2.0 | 6 votes |
private void updateBundle(ProcessorNode processor, ProcessorDTO processorDTO) { final BundleDTO bundleDTO = processorDTO.getBundle(); if (bundleDTO != null) { final ExtensionManager extensionManager = flowController.getExtensionManager(); final BundleCoordinate incomingCoordinate = BundleUtils.getBundle(extensionManager, processor.getCanonicalClassName(), bundleDTO); final BundleCoordinate existingCoordinate = processor.getBundleCoordinate(); if (!existingCoordinate.getCoordinate().equals(incomingCoordinate.getCoordinate())) { try { // we need to use the property descriptors from the temp component here in case we are changing from a ghost component to a real component final ConfigurableComponent tempComponent = extensionManager.getTempComponent(processor.getCanonicalClassName(), incomingCoordinate); final Set<URL> additionalUrls = processor.getAdditionalClasspathResources(tempComponent.getPropertyDescriptors()); flowController.getReloadComponent().reload(processor, processor.getCanonicalClassName(), incomingCoordinate, additionalUrls); } catch (ProcessorInstantiationException e) { throw new NiFiCoreException(String.format("Unable to update processor %s from %s to %s due to: %s", processorDTO.getId(), processor.getBundleCoordinate().getCoordinate(), incomingCoordinate.getCoordinate(), e.getMessage()), e); } } } }
Example #2
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 #3
Source File: NiFiClientUtil.java From nifi with Apache License 2.0 | 6 votes |
public ProcessorEntity createProcessor(final String type, final String processGroupId, final String bundleGroupId, final String artifactId, final String version) throws NiFiClientException, IOException { final ProcessorDTO dto = new ProcessorDTO(); dto.setType(type); final BundleDTO bundle = new BundleDTO(); bundle.setGroup(bundleGroupId); bundle.setArtifact(artifactId); bundle.setVersion(version); dto.setBundle(bundle); final ProcessorEntity entity = new ProcessorEntity(); entity.setComponent(dto); entity.setRevision(createNewRevision()); return nifiClient.getProcessorClient().createProcessor(processGroupId, entity); }
Example #4
Source File: AbstractAnonymousUserTest.java From nifi with Apache License 2.0 | 6 votes |
/** * Attempt to create a processor anonymously. * * @throws Exception ex */ protected Response testCreateProcessor(final String baseUrl, final NiFiTestUser niFiTestUser) throws Exception { final String url = baseUrl + "/process-groups/root/processors"; // create the processor final ProcessorDTO processor = new ProcessorDTO(); processor.setName("Copy"); processor.setType(SourceTestProcessor.class.getName()); // create the revision final RevisionDTO revision = new RevisionDTO(); revision.setClientId(CLIENT_ID); revision.setVersion(0l); // create the entity body final ProcessorEntity entity = new ProcessorEntity(); entity.setRevision(revision); entity.setComponent(processor); // perform the request return niFiTestUser.testPost(url, entity); }
Example #5
Source File: StandardFlowSynchronizer.java From nifi with Apache License 2.0 | 6 votes |
private void addProcessors(final Element processGroupElement, final ProcessGroup processGroup, final FlowController flowController, final FlowEncodingVersion encodingVersion) { final List<Element> processorNodeList = getChildrenByTagName(processGroupElement, "processor"); for (final Element processorElement : processorNodeList) { final ProcessorDTO processorDTO = FlowFromDOMFactory.getProcessor(processorElement, encryptor, encodingVersion); BundleCoordinate coordinate; try { coordinate = BundleUtils.getCompatibleBundle(extensionManager, processorDTO.getType(), processorDTO.getBundle()); } catch (final IllegalStateException e) { final BundleDTO bundleDTO = processorDTO.getBundle(); if (bundleDTO == null) { coordinate = BundleCoordinate.UNKNOWN_COORDINATE; } else { coordinate = new BundleCoordinate(bundleDTO.getGroup(), bundleDTO.getArtifact(), bundleDTO.getVersion()); } } final ProcessorNode procNode = flowController.getFlowManager().createProcessor(processorDTO.getType(), processorDTO.getId(), coordinate, false); procNode.setVersionedComponentId(processorDTO.getVersionedComponentId()); processGroup.addProcessor(procNode); updateProcessor(procNode, processorDTO, processGroup, flowController); } }
Example #6
Source File: ErrorMerger.java From nifi with Apache License 2.0 | 6 votes |
/** * Determines the appropriate Validation Status to use as the aggregate for the given validation statuses * * @param validationStatuses the components' validation statuses * @return {@link ProcessorDTO#INVALID} if any status is invalid, else {@link ProcessorDTO#VALIDATING} if any status is validating, else {@link ProcessorDTO#VALID} */ public static <T> String mergeValidationStatus(final Collection<String> validationStatuses) { final boolean anyValidating = validationStatuses.stream() .anyMatch(status -> ProcessorDTO.VALIDATING.equalsIgnoreCase(status)); if (anyValidating) { return ProcessorDTO.VALIDATING; } final boolean anyInvalid = validationStatuses.stream() .anyMatch(status -> ProcessorDTO.INVALID.equalsIgnoreCase(status)); if (anyInvalid) { return ProcessorDTO.INVALID; } return ProcessorDTO.VALID; }
Example #7
Source File: TemplateUtils.java From nifi with Apache License 2.0 | 6 votes |
private static void escapeParameterReferences(final ProcessorDTO processorDto) { final ProcessorConfigDTO config = processorDto.getConfig(); if (config == null) { return; } final ParameterParser parameterParser = new ExpressionLanguageAwareParameterParser(); final Map<String, String> escapedPropertyValues = new HashMap<>(); for (final Map.Entry<String, String> entry : config.getProperties().entrySet()) { final ParameterTokenList references = parameterParser.parseTokens(entry.getValue()); final String escaped = references.escape(); escapedPropertyValues.put(entry.getKey(), escaped); } config.setProperties(escapedPropertyValues); }
Example #8
Source File: ProcessorResource.java From localization_nifi with Apache License 2.0 | 6 votes |
/** * 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 #9
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 #10
Source File: StandardProcessorDAO.java From localization_nifi with Apache License 2.0 | 5 votes |
@Override public ProcessorNode createProcessor(final String groupId, ProcessorDTO processorDTO) { if (processorDTO.getParentGroupId() != null && !flowController.areGroupsSame(groupId, processorDTO.getParentGroupId())) { throw new IllegalArgumentException("Cannot specify a different Parent Group ID than the Group to which the Processor is being added."); } // ensure the type is specified if (processorDTO.getType() == null) { throw new IllegalArgumentException("The processor type must be specified."); } // get the group to add the processor to ProcessGroup group = locateProcessGroup(flowController, groupId); try { // attempt to create the processor ProcessorNode processor = flowController.createProcessor(processorDTO.getType(), processorDTO.getId()); // ensure we can perform the update before we add the processor to the flow verifyUpdate(processor, processorDTO); // add the processor to the group group.addProcessor(processor); // configure the processor configureProcessor(processor, processorDTO); return processor; } catch (ProcessorInstantiationException pse) { throw new NiFiCoreException(String.format("Unable to create processor of type %s due to: %s", processorDTO.getType(), pse.getMessage()), pse); } catch (IllegalStateException | ComponentLifeCycleException ise) { throw new NiFiCoreException(ise.getMessage(), ise); } }
Example #11
Source File: StandardNiFiServiceFacade.java From localization_nifi with Apache License 2.0 | 5 votes |
@Override public ProcessorEntity deleteProcessor(final Revision revision, final String processorId) { final ProcessorNode processor = processorDAO.getProcessor(processorId); final PermissionsDTO permissions = dtoFactory.createPermissionsDto(processor); final ProcessorDTO snapshot = deleteComponent( revision, processor.getResource(), () -> processorDAO.deleteProcessor(processorId), true, dtoFactory.createProcessorDto(processor)); return entityFactory.createProcessorEntity(snapshot, null, permissions, null, null); }
Example #12
Source File: StandardNiFiServiceFacade.java From localization_nifi with Apache License 2.0 | 5 votes |
@Override public ProcessorEntity updateProcessor(final Revision revision, final ProcessorDTO processorDTO) { // get the component, ensure we have access to it, and perform the update request final ProcessorNode processorNode = processorDAO.getProcessor(processorDTO.getId()); final RevisionUpdate<ProcessorDTO> snapshot = updateComponent(revision, processorNode, () -> processorDAO.updateProcessor(processorDTO), proc -> dtoFactory.createProcessorDto(proc)); final PermissionsDTO permissions = dtoFactory.createPermissionsDto(processorNode); final ProcessorStatusDTO status = dtoFactory.createProcessorStatusDto(controllerFacade.getProcessorStatus(processorNode.getIdentifier())); final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(processorNode.getIdentifier())); final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList()); return entityFactory.createProcessorEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, status, bulletinEntities); }
Example #13
Source File: ITProcessorAccessControl.java From nifi with Apache License 2.0 | 5 votes |
private void createExecuteCodeRestrictedProcessor(final NiFiTestUser user) throws Exception { String url = helper.getBaseUrl() + "/process-groups/root/processors"; // create the processor ProcessorDTO processor = new ProcessorDTO(); processor.setName("execute code restricted"); processor.setType(ExecuteCodeRestrictedProcessor.class.getName()); // create the revision final RevisionDTO revision = new RevisionDTO(); revision.setClientId(READ_WRITE_CLIENT_ID); revision.setVersion(0L); // create the entity body ProcessorEntity entity = new ProcessorEntity(); entity.setRevision(revision); entity.setComponent(processor); // perform the request as a user with read/write but no restricted access Response response = helper.getReadWriteUser().testPost(url, entity); // ensure the request is successful assertEquals(403, response.getStatus()); // perform the request as a user with read/write and restricted access response = user.testPost(url, entity); // ensure the request is successful assertEquals(201, response.getStatus()); final ProcessorEntity responseEntity = response.readEntity(ProcessorEntity.class); // remove the restricted component deleteRestrictedComponent(responseEntity, user); }
Example #14
Source File: ITProcessorAccessControl.java From nifi with Apache License 2.0 | 5 votes |
/** * Ensures the NONE user cannot put a processor. * * @throws Exception ex */ @Test public void testNoneUserPutProcessor() throws Exception { final ProcessorEntity entity = getRandomProcessor(helper.getNoneUser()); assertFalse(entity.getPermissions().getCanRead()); assertFalse(entity.getPermissions().getCanWrite()); assertNull(entity.getComponent()); final String updatedName = "Updated Name"; // attempt to update the name final ProcessorDTO requestDto = new ProcessorDTO(); requestDto.setId(entity.getId()); requestDto.setName(updatedName); final long version = entity.getRevision().getVersion(); final RevisionDTO requestRevision = new RevisionDTO(); requestRevision.setVersion(version); requestRevision.setClientId(AccessControlHelper.NONE_CLIENT_ID); final ProcessorEntity requestEntity = new ProcessorEntity(); requestEntity.setId(entity.getId()); requestEntity.setRevision(requestRevision); requestEntity.setComponent(requestDto); // perform the request final Response response = updateProcessor(helper.getNoneUser(), requestEntity); // ensure forbidden response assertEquals(403, response.getStatus()); }
Example #15
Source File: StandardSnippetDAO.java From localization_nifi with Apache License 2.0 | 5 votes |
private void lookupSensitiveProcessorProperties(final Set<ProcessorDTO> processors) { final ProcessGroup rootGroup = flowController.getGroup(flowController.getRootGroupId()); // 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 && processorConfig.getProperties() != null) { final Map<String, String> processorProperties = processorConfig.getProperties(); // find the corresponding processor final ProcessorNode processorNode = rootGroup.findProcessor(processorDTO.getId()); if (processorNode == null) { throw new IllegalArgumentException(String.format("Unable to create snippet because Processor '%s' could not be found", processorDTO.getId())); } // look for sensitive properties get the actual value for (Entry<PropertyDescriptor, String> entry : processorNode.getProperties().entrySet()) { final PropertyDescriptor descriptor = entry.getKey(); if (descriptor.isSensitive()) { processorProperties.put(descriptor.getName(), entry.getValue()); } } } } }
Example #16
Source File: StandardFlowServiceTest.java From nifi with Apache License 2.0 | 5 votes |
private void assertEquals(ProcessorDTO expected, ProcessorDTO actual) { if (expected == null && actual == null) { return; } Assert.assertEquals(expected.getId(), actual.getId()); Assert.assertEquals(expected.getName(), actual.getName()); Assert.assertEquals(expected.getParentGroupId(), actual.getParentGroupId()); Assert.assertEquals(expected.getStyle(), actual.getStyle()); Assert.assertEquals(expected.getType(), actual.getType()); Assert.assertEquals(expected.getState(), actual.getState()); Assert.assertEquals(expected.getRelationships(), actual.getRelationships()); Assert.assertEquals(expected.getValidationErrors(), actual.getValidationErrors()); assertEquals(expected.getConfig(), actual.getConfig()); }
Example #17
Source File: ITProcessorAccessControl.java From localization_nifi with Apache License 2.0 | 5 votes |
public static ProcessorEntity createProcessor(final AccessControlHelper ach, final String name) throws Exception { String url = ach.getBaseUrl() + "/process-groups/root/processors"; // create the processor ProcessorDTO processor = new ProcessorDTO(); processor.setName(name); processor.setType(SourceTestProcessor.class.getName()); // create the revision final RevisionDTO revision = new RevisionDTO(); revision.setClientId(READ_WRITE_CLIENT_ID); revision.setVersion(0L); // create the entity body ProcessorEntity entity = new ProcessorEntity(); entity.setRevision(revision); entity.setComponent(processor); // perform the request ClientResponse response = ach.getReadWriteUser().testPost(url, entity); // ensure the request is successful assertEquals(201, response.getStatus()); // get the entity body entity = response.getEntity(ProcessorEntity.class); // verify creation processor = entity.getComponent(); assertEquals(name, processor.getName()); assertEquals("org.apache.nifi.integration.util.SourceTestProcessor", processor.getType()); // get the processor return entity; }
Example #18
Source File: NiFiClientUtil.java From nifi with Apache License 2.0 | 5 votes |
public ProcessorEntity updateProcessorConfig(final ProcessorEntity currentEntity, final ProcessorConfigDTO config) throws NiFiClientException, IOException { final ProcessorDTO processorDto = new ProcessorDTO(); processorDto.setConfig(config); processorDto.setId(currentEntity.getId()); final ProcessorEntity updatedEntity = new ProcessorEntity(); updatedEntity.setRevision(currentEntity.getRevision()); updatedEntity.setComponent(processorDto); updatedEntity.setId(currentEntity.getId()); return nifiClient.getProcessorClient().updateProcessor(updatedEntity); }
Example #19
Source File: ITProcessorAccessControl.java From localization_nifi with Apache License 2.0 | 5 votes |
/** * Ensures the NONE user cannot put a processor. * * @throws Exception ex */ @Test public void testNoneUserPutProcessor() throws Exception { final ProcessorEntity entity = getRandomProcessor(helper.getNoneUser()); assertFalse(entity.getPermissions().getCanRead()); assertFalse(entity.getPermissions().getCanWrite()); assertNull(entity.getComponent()); final String updatedName = "Updated Name"; // attempt to update the name final ProcessorDTO requestDto = new ProcessorDTO(); requestDto.setId(entity.getId()); requestDto.setName(updatedName); final long version = entity.getRevision().getVersion(); final RevisionDTO requestRevision = new RevisionDTO(); requestRevision.setVersion(version); requestRevision.setClientId(AccessControlHelper.NONE_CLIENT_ID); final ProcessorEntity requestEntity = new ProcessorEntity(); requestEntity.setId(entity.getId()); requestEntity.setRevision(requestRevision); requestEntity.setComponent(requestDto); // perform the request final ClientResponse response = updateProcessor(helper.getNoneUser(), requestEntity); // ensure forbidden response assertEquals(403, response.getStatus()); }
Example #20
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 #21
Source File: LocalComponentLifecycle.java From nifi with Apache License 2.0 | 5 votes |
private boolean isProcessorActionComplete(final Set<ProcessorEntity> processorEntities, final Map<String, AffectedComponentEntity> affectedComponents, final ScheduledState desiredState, final InvalidComponentAction invalidComponentAction) throws LifecycleManagementException { final String desiredStateName = desiredState.name(); updateAffectedProcessors(processorEntities, affectedComponents); for (final ProcessorEntity entity : processorEntities) { if (!affectedComponents.containsKey(entity.getId())) { continue; } final ProcessorStatusDTO status = entity.getStatus(); if (ProcessorDTO.INVALID.equals(entity.getComponent().getValidationStatus())) { switch (invalidComponentAction) { case WAIT: return false; case SKIP: continue; case FAIL: final String action = desiredState == ScheduledState.RUNNING ? "start" : "stop"; throw new LifecycleManagementException("Could not " + action + " " + entity.getComponent().getName() + " because it is invalid"); } } final String runStatus = status.getAggregateSnapshot().getRunStatus(); final boolean stateMatches = desiredStateName.equalsIgnoreCase(runStatus); if (!stateMatches) { return false; } if (desiredState == ScheduledState.STOPPED && status.getAggregateSnapshot().getActiveThreadCount() != 0) { return false; } } return true; }
Example #22
Source File: FlowController.java From localization_nifi with Apache License 2.0 | 5 votes |
/** * Recursively finds all ProcessorDTO's * * @param group group * @return processor dto set */ private Set<ProcessorDTO> findAllProcessors(final ProcessGroupDTO group) { final Set<ProcessorDTO> procs = new HashSet<>(); for (final ProcessorDTO dto : group.getContents().getProcessors()) { procs.add(dto); } for (final ProcessGroupDTO childGroup : group.getContents().getProcessGroups()) { procs.addAll(findAllProcessors(childGroup)); } return procs; }
Example #23
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 #24
Source File: LocalComponentLifecycle.java From nifi with Apache License 2.0 | 5 votes |
private boolean isProcessorValidationComplete(final Set<ProcessorEntity> processorEntities, final Map<String, AffectedComponentEntity> affectedComponents) { updateAffectedProcessors(processorEntities, affectedComponents); for (final ProcessorEntity entity : processorEntities) { if (!affectedComponents.containsKey(entity.getId())) { continue; } if (ProcessorDTO.VALIDATING.equals(entity.getComponent().getValidationStatus())) { return false; } } return true; }
Example #25
Source File: StandardNiFiWebConfigurationContext.java From nifi with Apache License 2.0 | 5 votes |
private ProcessorDTO buildProcessorDto(String id, final String annotationData, Map<String, String> properties){ ProcessorDTO processorDto = new ProcessorDTO(); processorDto.setId(id); ProcessorConfigDTO configDto = new ProcessorConfigDTO(); processorDto.setConfig(configDto); configDto.setAnnotationData(annotationData); configDto.setProperties(properties); return processorDto; }
Example #26
Source File: ProcessorSchemaFunction.java From nifi-minifi with Apache License 2.0 | 5 votes |
@Override public ProcessorSchema apply(ProcessorDTO processorDTO) { ProcessorConfigDTO processorDTOConfig = processorDTO.getConfig(); Map<String, Object> map = new HashMap<>(); map.put(NAME_KEY, processorDTO.getName()); map.put(ID_KEY, processorDTO.getId()); map.put(CLASS_KEY, processorDTO.getType()); map.put(SCHEDULING_STRATEGY_KEY, processorDTOConfig.getSchedulingStrategy()); map.put(SCHEDULING_PERIOD_KEY, processorDTOConfig.getSchedulingPeriod()); map.put(CommonPropertyKeys.MAX_CONCURRENT_TASKS_KEY, processorDTOConfig.getConcurrentlySchedulableTaskCount()); map.put(ProcessorSchema.PENALIZATION_PERIOD_KEY, processorDTOConfig.getPenaltyDuration()); map.put(CommonPropertyKeys.YIELD_PERIOD_KEY, processorDTOConfig.getYieldDuration()); Long runDurationMillis = processorDTOConfig.getRunDurationMillis(); if (runDurationMillis != null) { map.put(ProcessorSchema.RUN_DURATION_NANOS_KEY, runDurationMillis * 1000); } map.put(ProcessorSchema.AUTO_TERMINATED_RELATIONSHIPS_LIST_KEY, nullToEmpty(processorDTO.getRelationships()).stream() .filter(RelationshipDTO::isAutoTerminate) .map(RelationshipDTO::getName) .collect(Collectors.toList())); map.put(PROPERTIES_KEY, new HashMap<>(nullToEmpty(processorDTOConfig.getProperties()))); String annotationData = processorDTOConfig.getAnnotationData(); if(annotationData != null && !annotationData.isEmpty()) { map.put(ANNOTATION_DATA_KEY, annotationData); } return new ProcessorSchema(map); }
Example #27
Source File: ProcessorSchemaTest.java From nifi-minifi with Apache License 2.0 | 5 votes |
@Before public void setup() { config = new ProcessorConfigDTO(); RelationshipDTO relationshipDTO = new RelationshipDTO(); relationshipDTO.setName(testRelationship); relationshipDTO.setAutoTerminate(true); dto = new ProcessorDTO(); dto.setConfig(config); dto.setName(testName); dto.setId(testId); dto.setType(testProcessorClass); config.setSchedulingStrategy(testSchedulingStrategy); config.setSchedulingPeriod(testSchedulingPeriod); config.setConcurrentlySchedulableTaskCount(testMaxConcurrentTasks); config.setPenaltyDuration(testPenalizationPeriod); config.setYieldDuration(testYieldDuration); config.setRunDurationMillis(testRunDurationNanos / 1000); config.setAnnotationData(testAnnotationData); dto.setRelationships(Arrays.asList(relationshipDTO)); Map<String, String> properties = new HashMap<>(); properties.put(testKey, testValue); config.setProperties(properties); map = new HashMap<>(); map.put(CommonPropertyKeys.NAME_KEY, testName); map.put(CommonPropertyKeys.ID_KEY, testId); map.put(CLASS_KEY, testProcessorClass); map.put(CommonPropertyKeys.SCHEDULING_STRATEGY_KEY, testSchedulingStrategy); map.put(CommonPropertyKeys.SCHEDULING_PERIOD_KEY, testSchedulingPeriod); map.put(CommonPropertyKeys.MAX_CONCURRENT_TASKS_KEY, testMaxConcurrentTasks); map.put(ProcessorSchema.PENALIZATION_PERIOD_KEY, testPenalizationPeriod); map.put(CommonPropertyKeys.YIELD_PERIOD_KEY, testYieldDuration); map.put(ProcessorSchema.RUN_DURATION_NANOS_KEY, testRunDurationNanos); map.put(ProcessorSchema.AUTO_TERMINATED_RELATIONSHIPS_LIST_KEY, Arrays.asList(testRelationship)); map.put(PROPERTIES_KEY, new HashMap<>(properties)); map.put(ANNOTATION_DATA_KEY, testAnnotationData); }
Example #28
Source File: ProcessorEntityMerger.java From nifi with Apache License 2.0 | 5 votes |
/** * Merges the ProcessorEntity responses. * * @param clientEntity the entity being returned to the client * @param entityMap all node responses */ @Override public void mergeComponents(final ProcessorEntity clientEntity, final Map<NodeIdentifier, ProcessorEntity> entityMap) { final ProcessorDTO clientDto = clientEntity.getComponent(); final Map<NodeIdentifier, ProcessorDTO> dtoMap = new HashMap<>(); for (final Map.Entry<NodeIdentifier, ProcessorEntity> entry : entityMap.entrySet()) { final ProcessorEntity nodeProcEntity = entry.getValue(); final ProcessorDTO nodeProcDto = nodeProcEntity.getComponent(); dtoMap.put(entry.getKey(), nodeProcDto); } mergeDtos(clientDto, dtoMap); }
Example #29
Source File: ProcessorResource.java From nifi with Apache License 2.0 | 5 votes |
/** * 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 #30
Source File: StandardSnippetDAO.java From nifi with Apache License 2.0 | 5 votes |
private void lookupSensitiveProcessorProperties(final Set<ProcessorDTO> processors) { final ProcessGroup rootGroup = flowController.getFlowManager().getRootGroup(); // 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 && processorConfig.getProperties() != null) { final Map<String, String> processorProperties = processorConfig.getProperties(); // find the corresponding processor final ProcessorNode processorNode = rootGroup.findProcessor(processorDTO.getId()); if (processorNode == null) { throw new IllegalArgumentException(String.format("Unable to create snippet because Processor '%s' could not be found", processorDTO.getId())); } // look for sensitive properties get the actual value for (Entry<PropertyDescriptor, String> entry : processorNode.getRawPropertyValues().entrySet()) { final PropertyDescriptor descriptor = entry.getKey(); if (descriptor.isSensitive()) { processorProperties.put(descriptor.getName(), entry.getValue()); } } } } }