@Override public void verifyCreate(final ControllerServiceDTO controllerServiceDTO) { verifyCreate(serviceProvider.getExtensionManager(), controllerServiceDTO.getType(), controllerServiceDTO.getBundle()); }
private void verifyControllerServicesInSnippet(final FlowSnippetDTO templateContents, final Map<String, Set<BundleCoordinate>> supportedTypes) { if (templateContents.getControllerServices() != null) { templateContents.getControllerServices().forEach(controllerService -> { if (supportedTypes.containsKey(controllerService.getType())) { if (controllerService.getBundle() == null) { throw new IllegalArgumentException("Controller Service bundle must be specified."); } verifyBundleInSnippet(controllerService.getBundle(), supportedTypes.get(controllerService.getType())); } else { throw new IllegalStateException("Invalid Controller Service Type: " + controllerService.getType()); } }); } if (templateContents.getProcessGroups() != null) { templateContents.getProcessGroups().forEach(processGroup -> verifyControllerServicesInSnippet(processGroup.getContents(), supportedTypes)); } }
private void addControllerServiceFingerprint(final StringBuilder builder, final ControllerServiceDTO dto) { builder.append(dto.getId()); builder.append(dto.getVersionedComponentId()); builder.append(dto.getType()); builder.append(dto.getName()); addBundleFingerprint(builder, dto.getBundle()); builder.append(dto.getComments()); builder.append(dto.getAnnotationData()); builder.append(dto.getState()); // get the temp instance of the ControllerService so that we know the default property values final BundleCoordinate coordinate = getCoordinate(dto.getType(), dto.getBundle()); final ConfigurableComponent configurableComponent = extensionManager.getTempComponent(dto.getType(), coordinate); if (configurableComponent == null) { logger.warn("Unable to get ControllerService of type {}; its default properties will be fingerprinted instead of being ignored.", dto.getType()); } addPropertiesFingerprint(builder, configurableComponent, dto.getProperties()); }
values.put(ANNOTATION_DATA, controllerService.getAnnotationData()); if (controllerServiceDTO.getBundle() != null) { final BundleCoordinate bundle = controllerService.getBundleCoordinate(); values.put(EXTENSION_VERSION, formatExtensionVersion(controllerService.getComponentType(), bundle));
private static ControllerServiceNode createControllerService(final FlowController flowController, final Element controllerServiceElement, final StringEncryptor encryptor) { final ControllerServiceDTO dto = FlowFromDOMFactory.getControllerService(controllerServiceElement, encryptor); BundleCoordinate coordinate; try { coordinate = BundleUtils.getCompatibleBundle(flowController.getExtensionManager(), dto.getType(), dto.getBundle()); } catch (final IllegalStateException e) { final BundleDTO bundleDTO = dto.getBundle(); if (bundleDTO == null) { coordinate = BundleCoordinate.UNKNOWN_COORDINATE; } else { coordinate = new BundleCoordinate(bundleDTO.getGroup(), bundleDTO.getArtifact(), bundleDTO.getVersion()); } } final ControllerServiceNode node = flowController.getFlowManager().createControllerService(dto.getType(), dto.getId(), coordinate, Collections.emptySet(), false, true); node.setName(dto.getName()); node.setComments(dto.getComments()); node.setVersionedComponentId(dto.getVersionedComponentId()); return node; }
final ConfigurableComponent configurableComponent = controllerFacade.getTemporaryComponent(dto.getType(), dto.getBundle()); configurableComponent.getPropertyDescriptors().forEach(descriptor -> { if (dto.getProperties().get(descriptor.getName()) == null) {
authorizable = lookup.getConfigurableComponent(requestControllerService.getType(), requestControllerService.getBundle());
authorizable = lookup.getConfigurableComponent(requestControllerService.getType(), requestControllerService.getBundle());
final BundleCoordinate bundleCoordinate = BundleUtils.getBundle(extensionManager, controllerServiceDTO.getType(), controllerServiceDTO.getBundle()); final ControllerServiceNode controllerService = flowManager.createControllerService(controllerServiceDTO.getType(), controllerServiceDTO.getId(), bundleCoordinate, Collections.emptySet(), true, true);
/** * Populates the uri for the specified controller service. */ public ControllerServiceDTO populateRemainingControllerServiceContent(final ControllerServiceDTO controllerService) { final BundleDTO bundle = controllerService.getBundle(); // see if this processor has any ui extensions final UiExtensionMapping uiExtensionMapping = (UiExtensionMapping) servletContext.getAttribute("nifi-ui-extensions"); if (uiExtensionMapping.hasUiExtension(controllerService.getType(), bundle.getGroup(), bundle.getArtifact(), bundle.getVersion())) { final List<UiExtension> uiExtensions = uiExtensionMapping.getUiExtension(controllerService.getType(), bundle.getGroup(), bundle.getArtifact(), bundle.getVersion()); for (final UiExtension uiExtension : uiExtensions) { if (UiExtensionType.ControllerServiceConfiguration.equals(uiExtension.getExtensionType())) { controllerService.setCustomUiUrl(uiExtension.getContextPath() + "/configure"); } } } return controllerService; }
snippet.getControllerServices().forEach(controllerService -> { try { final BundleCoordinate bundle = BundleUtils.getCompatibleBundle(extensionManager, controllerService.getType(), controllerService.getBundle()); controllerServices.add(getConfigurableComponent(controllerService.getType(), new BundleDTO(bundle.getGroup(), bundle.getId(), bundle.getVersion()))); } catch (final IllegalStateException e) {
private void updateBundle(final ControllerServiceNode controllerService, final ControllerServiceDTO controllerServiceDTO) { final BundleDTO bundleDTO = controllerServiceDTO.getBundle(); if (bundleDTO != null) { final ExtensionManager extensionManager = serviceProvider.getExtensionManager(); final BundleCoordinate incomingCoordinate = BundleUtils.getBundle(extensionManager, controllerService.getCanonicalClassName(), bundleDTO); final BundleCoordinate existingCoordinate = controllerService.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(controllerService.getCanonicalClassName(), incomingCoordinate); final Set<URL> additionalUrls = controllerService.getAdditionalClasspathResources(tempComponent.getPropertyDescriptors()); flowController.getReloadComponent().reload(controllerService, controllerService.getCanonicalClassName(), incomingCoordinate, additionalUrls); } catch (ControllerServiceInstantiationException e) { throw new NiFiCoreException(String.format("Unable to update controller service %s from %s to %s due to: %s", controllerServiceDTO.getId(), controllerService.getBundleCoordinate().getCoordinate(), incomingCoordinate.getCoordinate(), e.getMessage()), 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()); }); } }
public ControllerServiceDTO copy(final ControllerServiceDTO original) { final ControllerServiceDTO copy = new ControllerServiceDTO(); copy.setAnnotationData(original.getAnnotationData()); copy.setControllerServiceApis(original.getControllerServiceApis()); copy.setComments(original.getComments()); copy.setCustomUiUrl(original.getCustomUiUrl()); copy.setDescriptors(copy(original.getDescriptors())); copy.setId(original.getId()); copy.setParentGroupId(original.getParentGroupId()); copy.setName(original.getName()); copy.setProperties(copy(original.getProperties())); copy.setReferencingComponents(copy(original.getReferencingComponents())); copy.setState(original.getState()); copy.setType(original.getType()); copy.setBundle(copy(original.getBundle())); copy.setExtensionMissing(original.getExtensionMissing()); copy.setMultipleVersionsAvailable(original.getMultipleVersionsAvailable()); copy.setPersistsState(original.getPersistsState()); copy.setValidationErrors(copy(original.getValidationErrors())); copy.setValidationStatus(original.getValidationStatus()); copy.setVersionedComponentId(original.getVersionedComponentId()); return copy; }
try { for (final ControllerServiceDTO controllerServiceDTO : dto.getControllerServices()) { final BundleCoordinate bundleCoordinate = BundleUtils.getBundle(extensionManager, controllerServiceDTO.getType(), controllerServiceDTO.getBundle()); final ControllerServiceNode serviceNode = flowManager.createControllerService(controllerServiceDTO.getType(), controllerServiceDTO.getId(), bundleCoordinate, Collections.emptySet(), true,true);