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;
}
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;
}
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();
}
}
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);
}
}
}
}
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);
}
}
}
}
Aggregations