@Override public void verifyUpdate(final ProcessorDTO processorDTO) { verifyUpdate(locateProcessor(processorDTO.getId()), processorDTO); }
@Override public void verifyUpdateProcessor(final ProcessorDTO processorDTO) { // if group does not exist, then the update request is likely creating it // so we don't verify since it will fail if (processorDAO.hasProcessor(processorDTO.getId())) { processorDAO.verifyUpdate(processorDTO); } else { verifyCreateProcessor(processorDTO); } }
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.getProperties().entrySet()) { final PropertyDescriptor descriptor = entry.getKey(); if (descriptor.isSensitive()) { processorProperties.put(descriptor.getName(), entry.getValue()); } } } } }
.map(proc -> proc.getId()) .forEach(id -> identifiers.add(id)); snippet.getConnections().stream()
@Override public ProcessorEntity createProcessor(final Revision revision, final String groupId, final ProcessorDTO processorDTO) { final RevisionUpdate<ProcessorDTO> snapshot = createComponent( revision, processorDTO, () -> processorDAO.createProcessor(groupId, processorDTO), processor -> { awaitValidationCompletion(processor); return dtoFactory.createProcessorDto(processor); }); final ProcessorNode processor = processorDAO.getProcessor(processorDTO.getId()); final PermissionsDTO permissions = dtoFactory.createPermissionsDto(processor); final PermissionsDTO operatePermissions = dtoFactory.createPermissionsDto(new OperationAuthorizable(processor)); final ProcessorStatusDTO status = dtoFactory.createProcessorStatusDto(controllerFacade.getProcessorStatus(processorDTO.getId())); final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(processorDTO.getId())); 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, operatePermissions, status, bulletinEntities); }
if (requestProcessor.getId() != null) { throw new IllegalArgumentException("Processor ID cannot be specified."); final Revision revision = getRevision(processorEntity, processor.getId()); final ProcessorEntity entity = serviceFacade.createProcessor(revision, groupId, processor); processorResource.populateRemainingProcessorEntityContent(entity);
@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 -> { awaitValidationCompletion(proc); return dtoFactory.createProcessorDto(proc); }); final PermissionsDTO permissions = dtoFactory.createPermissionsDto(processorNode); final PermissionsDTO operatePermissions = dtoFactory.createPermissionsDto(new OperationAuthorizable(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, operatePermissions, status, bulletinEntities); }
public ProcessorDiagnosticsEntity createProcessorDiagnosticsEntity(final ProcessorDiagnosticsDTO dto, final RevisionDTO revision, final PermissionsDTO processorPermissions, final ProcessorStatusDTO status, final List<BulletinEntity> bulletins) { final ProcessorDiagnosticsEntity entity = new ProcessorDiagnosticsEntity(); entity.setRevision(revision); if (dto != null) { entity.setPermissions(processorPermissions); entity.setId(dto.getProcessor().getId()); if (processorPermissions != null && processorPermissions.getCanRead()) { entity.setComponent(dto); entity.setBulletins(bulletins); } } entity.setBulletins(bulletins); return entity; }
public ConnectableDTO createConnectableDto(final ProcessorDTO processor) { final ConnectableDTO connectable = new ConnectableDTO(); connectable.setGroupId(processor.getParentGroupId()); connectable.setId(processor.getId()); connectable.setName(processor.getName()); connectable.setType(ConnectableType.PROCESSOR.name()); connectable.setVersionedComponentId(processor.getVersionedComponentId()); return connectable; }
@Override public ProcessorNode createProcessor(final String groupId, ProcessorDTO processorDTO) { if (processorDTO.getParentGroupId() != null && !flowController.getFlowManager().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 final BundleCoordinate bundleCoordinate = BundleUtils.getBundle(flowController.getExtensionManager(), processorDTO.getType(), processorDTO.getBundle()); ProcessorNode processor = flowController.getFlowManager().createProcessor(processorDTO.getType(), processorDTO.getId(), bundleCoordinate); // 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 (IllegalStateException | ComponentLifeCycleException ise) { throw new NiFiCoreException(ise.getMessage(), ise); } }
final ProcessorNode processorNode = processorDAO.getProcessor(processorDTO.getId()); processorDTO.setValidationStatus(processorNode.getValidationStatus().name());
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); } } } }
processorDetails.setType(StringUtils.substringAfterLast(processor.getType(), ".")); final FlowChangeAction action = generateAuditRecord(processor.getId(), processor.getName(), Component.Processor, Operation.Add, timestamp); action.setComponentDetails(processorDetails); actions.add(action);
}); snippet.getProcessors().forEach(processorDTO -> { rollbackClonedPolicy(ResourceFactory.getComponentResource(ResourceType.Processor, processorDTO.getId(), processorDTO.getName())); }); snippet.getRemoteProcessGroups().forEach(remoteProcessGroupDTO -> {
public ProcessorEntity createProcessorEntity(final ProcessorDTO dto, final RevisionDTO revision, final PermissionsDTO permissions, final PermissionsDTO operatePermissions, final ProcessorStatusDTO status, final List<BulletinEntity> bulletins) { final ProcessorEntity entity = new ProcessorEntity(); entity.setRevision(revision); if (dto != null) { entity.setPermissions(permissions); entity.setOperatePermissions(operatePermissions); entity.setStatus(status); entity.setId(dto.getId()); entity.setInputRequirement(dto.getInputRequirement()); entity.setPosition(dto.getPosition()); if (permissions != null && permissions.getCanRead()) { entity.setComponent(dto); entity.setBulletins(bulletins); } } return entity; }
private ComponentDetails getComponentConfiguration(final ProcessorDTO processor) { final ProcessorConfigDTO processorConfig = processor.getConfig(); return new ComponentDetails.Builder() .id(processor.getId()) .name(processor.getName()) .type(processor.getType()) .state(processor.getState()) .annotationData(processorConfig.getAnnotationData()) .properties(processorConfig.getProperties()) .descriptors(buildComponentDescriptorMap(processorConfig)) .validateErrors(processor.getValidationErrors()).build(); }
@Override public ProcessorNode updateProcessor(ProcessorDTO processorDTO) { ProcessorNode processor = locateProcessor(processorDTO.getId()); ProcessGroup parentGroup = processor.getProcessGroup();
public AffectedComponentEntity createAffectedComponentEntity(final ProcessorEntity processorEntity) { if (processorEntity == null) { return null; } final AffectedComponentEntity component = new AffectedComponentEntity(); component.setBulletins(processorEntity.getBulletins()); component.setId(processorEntity.getId()); component.setPermissions(processorEntity.getPermissions()); component.setPosition(processorEntity.getPosition()); component.setRevision(processorEntity.getRevision()); component.setUri(processorEntity.getUri()); final ProcessorDTO processorDto = processorEntity.getComponent(); final AffectedComponentDTO componentDto = new AffectedComponentDTO(); componentDto.setId(processorDto.getId()); componentDto.setName(processorDto.getName()); componentDto.setProcessGroupId(processorDto.getParentGroupId()); componentDto.setReferenceType(AffectedComponentDTO.COMPONENT_TYPE_PROCESSOR); componentDto.setState(processorDto.getState()); componentDto.setValidationErrors(processorDto.getValidationErrors()); component.setComponent(componentDto); return component; }
public ProcessorDTO copy(final ProcessorDTO original) { final ProcessorDTO copy = new ProcessorDTO(); copy.setConfig(copy(original.getConfig())); copy.setPosition(original.getPosition()); copy.setId(original.getId()); copy.setName(original.getName()); copy.setDescription(original.getDescription()); copy.setParentGroupId(original.getParentGroupId()); copy.setRelationships(copy(original.getRelationships())); copy.setState(original.getState()); copy.setStyle(copy(original.getStyle())); copy.setType(original.getType()); copy.setBundle(copy(original.getBundle())); copy.setSupportsParallelProcessing(original.getSupportsParallelProcessing()); copy.setSupportsEventDriven(original.getSupportsEventDriven()); copy.setSupportsBatching(original.getSupportsBatching()); copy.setPersistsState(original.getPersistsState()); copy.setExecutionNodeRestricted(original.isExecutionNodeRestricted()); copy.setExtensionMissing(original.getExtensionMissing()); copy.setMultipleVersionsAvailable(original.getMultipleVersionsAvailable()); copy.setValidationErrors(copy(original.getValidationErrors())); copy.setValidationStatus(original.getValidationStatus()); copy.setVersionedComponentId(original.getVersionedComponentId()); return copy; }