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)); } }
@Override public void verifyCreate(final ProcessorDTO processorDTO) { verifyCreate(flowController.getExtensionManager(), processorDTO.getType(), processorDTO.getBundle()); }
@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); } }
/** * 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; }
final ConfigurableComponent configurableComponent = controllerFacade.getTemporaryComponent(dto.getType(), dto.getBundle()); configurableComponent.getPropertyDescriptors().forEach(descriptor -> { if (config.getProperties().get(descriptor.getName()) == null) { logger.warn(String.format("Unable to create Processor of type %s to populate default values.", dto.getType()));
snippet.getProcessors().forEach(processor -> { try { final BundleCoordinate bundle = BundleUtils.getCompatibleBundle(extensionManager, processor.getType(), processor.getBundle()); processors.add(getConfigurableComponent(processor.getType(), new BundleDTO(bundle.getGroup(), bundle.getId(), bundle.getVersion()))); } catch (final IllegalStateException e) {
/** * Discovers the compatible bundle details for the components in the specified snippet. * * @param snippet the snippet */ private void discoverCompatibleBundles(final FlowSnippetDTO snippet) { if (snippet.getProcessors() != null) { snippet.getProcessors().forEach(processor -> { final BundleCoordinate coordinate = serviceFacade.getCompatibleBundle(processor.getType(), processor.getBundle()); processor.setBundle(new BundleDTO(coordinate.getGroup(), coordinate.getId(), coordinate.getVersion())); }); } if (snippet.getControllerServices() != null) { snippet.getControllerServices().forEach(controllerService -> { final BundleCoordinate coordinate = serviceFacade.getCompatibleBundle(controllerService.getType(), controllerService.getBundle()); controllerService.setBundle(new BundleDTO(coordinate.getGroup(), coordinate.getId(), coordinate.getVersion())); }); } if (snippet.getProcessGroups() != null) { snippet.getProcessGroups().forEach(processGroup -> { discoverCompatibleBundles(processGroup.getContents()); }); } }
processorDetails.setType(StringUtils.substringAfterLast(processor.getType(), "."));
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(); }
coordinate = BundleUtils.getCompatibleBundle(extensionManager, processorDTO.getType(), processorDTO.getBundle()); } catch (final IllegalStateException e) { final BundleDTO bundleDTO = processorDTO.getBundle(); final ProcessorNode procNode = flowManager.createProcessor(processorDTO.getType(), processorDTO.getId(), coordinate, false); procNode.setVersionedComponentId(processorDTO.getVersionedComponentId()); processGroup.addProcessor(procNode);
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; }
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(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());