Search in sources :

Example 1 with BundleDTO

use of org.apache.nifi.web.api.dto.BundleDTO in project nifi by apache.

the class ControllerServiceResource method populateRemainingControllerServiceContent.

/**
 * 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;
}
Also used : UiExtension(org.apache.nifi.ui.extension.UiExtension) UiExtensionMapping(org.apache.nifi.ui.extension.UiExtensionMapping) BundleDTO(org.apache.nifi.web.api.dto.BundleDTO)

Example 2 with BundleDTO

use of org.apache.nifi.web.api.dto.BundleDTO in project nifi by apache.

the class ProcessorResource method populateRemainingProcessorContent.

/**
 * 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;
}
Also used : ProcessorConfigDTO(org.apache.nifi.web.api.dto.ProcessorConfigDTO) UiExtension(org.apache.nifi.ui.extension.UiExtension) UiExtensionMapping(org.apache.nifi.ui.extension.UiExtensionMapping) BundleDTO(org.apache.nifi.web.api.dto.BundleDTO)

Example 3 with BundleDTO

use of org.apache.nifi.web.api.dto.BundleDTO in project nifi by apache.

the class StandardControllerServiceDAO method verifyUpdate.

private void verifyUpdate(final ControllerServiceNode controllerService, final ControllerServiceDTO controllerServiceDTO) {
    // validate the new controller service state if appropriate
    if (isNotNull(controllerServiceDTO.getState())) {
        try {
            // attempt to parse the service state
            final ControllerServiceState purposedControllerServiceState = ControllerServiceState.valueOf(controllerServiceDTO.getState());
            // ensure the state is valid
            if (ControllerServiceState.ENABLING.equals(purposedControllerServiceState) || ControllerServiceState.DISABLING.equals(purposedControllerServiceState)) {
                throw new IllegalArgumentException();
            }
            // only attempt an action if it is changing
            if (!purposedControllerServiceState.equals(controllerService.getState())) {
                if (ControllerServiceState.ENABLED.equals(purposedControllerServiceState)) {
                    controllerService.verifyCanEnable();
                } else if (ControllerServiceState.DISABLED.equals(purposedControllerServiceState)) {
                    controllerService.verifyCanDisable();
                }
            }
        } catch (final IllegalArgumentException iae) {
            throw new IllegalArgumentException("Controller Service state: Value must be one of [ENABLED, DISABLED]");
        }
    }
    boolean modificationRequest = false;
    if (isAnyNotNull(controllerServiceDTO.getName(), controllerServiceDTO.getAnnotationData(), controllerServiceDTO.getComments(), controllerServiceDTO.getProperties(), controllerServiceDTO.getBundle())) {
        modificationRequest = true;
        // validate the request
        final List<String> requestValidation = validateProposedConfiguration(controllerService, controllerServiceDTO);
        // ensure there was no validation errors
        if (!requestValidation.isEmpty()) {
            throw new ValidationException(requestValidation);
        }
    }
    final BundleDTO bundleDTO = controllerServiceDTO.getBundle();
    if (bundleDTO != null) {
        // ensures all nodes in a cluster have the bundle, throws exception if bundle not found for the given type
        final BundleCoordinate bundleCoordinate = BundleUtils.getBundle(controllerService.getCanonicalClassName(), bundleDTO);
        // ensure we are only changing to a bundle with the same group and id, but different version
        controllerService.verifyCanUpdateBundle(bundleCoordinate);
    }
    if (modificationRequest) {
        controllerService.verifyCanUpdate();
    }
}
Also used : ControllerServiceState(org.apache.nifi.controller.service.ControllerServiceState) ValidationException(org.apache.nifi.controller.exception.ValidationException) BundleDTO(org.apache.nifi.web.api.dto.BundleDTO) BundleCoordinate(org.apache.nifi.bundle.BundleCoordinate)

Example 4 with BundleDTO

use of org.apache.nifi.web.api.dto.BundleDTO in project nifi by apache.

the class StandardControllerServiceDAO method updateBundle.

private void updateBundle(final ControllerServiceNode controllerService, final ControllerServiceDTO controllerServiceDTO) {
    final BundleDTO bundleDTO = controllerServiceDTO.getBundle();
    if (bundleDTO != null) {
        final BundleCoordinate incomingCoordinate = BundleUtils.getBundle(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.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);
            }
        }
    }
}
Also used : NiFiCoreException(org.apache.nifi.web.NiFiCoreException) ConfigurableComponent(org.apache.nifi.components.ConfigurableComponent) BundleDTO(org.apache.nifi.web.api.dto.BundleDTO) ControllerServiceInstantiationException(org.apache.nifi.controller.exception.ControllerServiceInstantiationException) BundleCoordinate(org.apache.nifi.bundle.BundleCoordinate) URL(java.net.URL)

Example 5 with BundleDTO

use of org.apache.nifi.web.api.dto.BundleDTO in project nifi by apache.

the class StandardProcessorDAO method updateBundle.

private void updateBundle(ProcessorNode processor, ProcessorDTO processorDTO) {
    final BundleDTO bundleDTO = processorDTO.getBundle();
    if (bundleDTO != null) {
        final BundleCoordinate incomingCoordinate = BundleUtils.getBundle(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.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);
            }
        }
    }
}
Also used : NiFiCoreException(org.apache.nifi.web.NiFiCoreException) ProcessorInstantiationException(org.apache.nifi.controller.exception.ProcessorInstantiationException) ConfigurableComponent(org.apache.nifi.components.ConfigurableComponent) BundleDTO(org.apache.nifi.web.api.dto.BundleDTO) BundleCoordinate(org.apache.nifi.bundle.BundleCoordinate) URL(java.net.URL)

Aggregations

BundleDTO (org.apache.nifi.web.api.dto.BundleDTO)21 BundleCoordinate (org.apache.nifi.bundle.BundleCoordinate)16 ConfigurableComponent (org.apache.nifi.components.ConfigurableComponent)4 ProcessorConfigDTO (org.apache.nifi.web.api.dto.ProcessorConfigDTO)4 URL (java.net.URL)3 Stateful (org.apache.nifi.annotation.behavior.Stateful)3 ValidationException (org.apache.nifi.controller.exception.ValidationException)3 ReportingTaskInstantiationException (org.apache.nifi.controller.reporting.ReportingTaskInstantiationException)3 UiExtension (org.apache.nifi.ui.extension.UiExtension)3 UiExtensionMapping (org.apache.nifi.ui.extension.UiExtensionMapping)3 NiFiCoreException (org.apache.nifi.web.NiFiCoreException)3 PositionDTO (org.apache.nifi.web.api.dto.PositionDTO)3 ProcessorDTO (org.apache.nifi.web.api.dto.ProcessorDTO)3 Element (org.w3c.dom.Element)3 ScheduledState (org.apache.nifi.controller.ScheduledState)2 ProcessorInstantiationException (org.apache.nifi.controller.exception.ProcessorInstantiationException)2 ControllerServiceNode (org.apache.nifi.controller.service.ControllerServiceNode)2 DummyProcessor (org.apache.nifi.controller.service.mock.DummyProcessor)2 ControllerServiceDTO (org.apache.nifi.web.api.dto.ControllerServiceDTO)2 FlowSnippetDTO (org.apache.nifi.web.api.dto.FlowSnippetDTO)2