use of org.apache.nifi.web.NiFiCoreException 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.NiFiCoreException in project nifi by apache.
the class StandardControllerServiceDAO method createControllerService.
@Override
public ControllerServiceNode createControllerService(final ControllerServiceDTO controllerServiceDTO) {
// ensure the type is specified
if (controllerServiceDTO.getType() == null) {
throw new IllegalArgumentException("The controller service type must be specified.");
}
try {
// create the controller service
final ControllerServiceNode controllerService = serviceProvider.createControllerService(controllerServiceDTO.getType(), controllerServiceDTO.getId(), BundleUtils.getBundle(controllerServiceDTO.getType(), controllerServiceDTO.getBundle()), Collections.emptySet(), true);
// ensure we can perform the update
verifyUpdate(controllerService, controllerServiceDTO);
// perform the update
configureControllerService(controllerService, controllerServiceDTO);
final String groupId = controllerServiceDTO.getParentGroupId();
if (groupId == null) {
flowController.addRootControllerService(controllerService);
} else {
final ProcessGroup group;
if (groupId.equals(ROOT_GROUP_ID_ALIAS)) {
group = flowController.getGroup(flowController.getRootGroupId());
} else {
group = flowController.getGroup(flowController.getRootGroupId()).findProcessGroup(groupId);
}
if (group == null) {
throw new ResourceNotFoundException(String.format("Unable to locate group with id '%s'.", groupId));
}
group.addControllerService(controllerService);
}
return controllerService;
} catch (final ControllerServiceInstantiationException csie) {
throw new NiFiCoreException(csie.getMessage(), csie);
}
}
use of org.apache.nifi.web.NiFiCoreException in project nifi by apache.
the class StandardProcessorDAO method createProcessor.
@Override
public ProcessorNode createProcessor(final String groupId, ProcessorDTO processorDTO) {
if (processorDTO.getParentGroupId() != null && !flowController.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
ProcessorNode processor = flowController.createProcessor(processorDTO.getType(), processorDTO.getId(), BundleUtils.getBundle(processorDTO.getType(), processorDTO.getBundle()));
// 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 (ProcessorInstantiationException pse) {
throw new NiFiCoreException(String.format("Unable to create processor of type %s due to: %s", processorDTO.getType(), pse.getMessage()), pse);
} catch (IllegalStateException | ComponentLifeCycleException ise) {
throw new NiFiCoreException(ise.getMessage(), ise);
}
}
use of org.apache.nifi.web.NiFiCoreException 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);
}
}
}
}
use of org.apache.nifi.web.NiFiCoreException in project nifi by apache.
the class StandardReportingTaskDAO method createReportingTask.
@Override
public ReportingTaskNode createReportingTask(final ReportingTaskDTO reportingTaskDTO) {
// ensure the type is specified
if (reportingTaskDTO.getType() == null) {
throw new IllegalArgumentException("The reporting task type must be specified.");
}
try {
// create the reporting task
final ReportingTaskNode reportingTask = reportingTaskProvider.createReportingTask(reportingTaskDTO.getType(), reportingTaskDTO.getId(), BundleUtils.getBundle(reportingTaskDTO.getType(), reportingTaskDTO.getBundle()), true);
// ensure we can perform the update
verifyUpdate(reportingTask, reportingTaskDTO);
// perform the update
configureReportingTask(reportingTask, reportingTaskDTO);
return reportingTask;
} catch (ReportingTaskInstantiationException rtie) {
throw new NiFiCoreException(rtie.getMessage(), rtie);
}
}
Aggregations