@Override public FlowRegistry removeFlowRegistry(final String registryId) { final FlowRegistry registry = flowRegistryClient.removeFlowRegistry(registryId); if (registry == null) { throw new ResourceNotFoundException("Unable to find Flow Registry with id '" + registryId + "'"); } return registry; }
@Override public Authorizable getLocalConnectable(String id) { final Connectable connectable = controllerFacade.findLocalConnectable(id); if (connectable == null) { throw new ResourceNotFoundException("Unable to find component with id " + id); } return connectable; }
@Override public AccessPolicy getAccessPolicy(final String accessPolicyId) { final AccessPolicy accessPolicy = accessPolicyProvider.getAccessPolicy(accessPolicyId); if (accessPolicy == null) { throw new ResourceNotFoundException(String.format("Unable to find access policy with id '%s'.", accessPolicyId)); } return accessPolicy; }
private ReportingTaskNode locateReportingTask(final String reportingTaskId) { // get the reporting task final ReportingTaskNode reportingTask = reportingTaskProvider.getReportingTaskNode(reportingTaskId); // ensure the reporting task exists if (reportingTask == null) { throw new ResourceNotFoundException(String.format("Unable to locate reporting task with id '%s'.", reportingTaskId)); } return reportingTask; }
@Override public Group getUserGroup(final String userGroupId) { final Group userGroup = userGroupProvider.getGroup(userGroupId); if (userGroup == null) { throw new ResourceNotFoundException(String.format("Unable to find user group with id '%s'.", userGroupId)); } return userGroup; }
private ControllerServiceNode locateControllerService(final String controllerServiceId) { // get the controller service final ControllerServiceNode controllerService = serviceProvider.getControllerServiceNode(controllerServiceId); // ensure the controller service exists if (controllerService == null) { throw new ResourceNotFoundException(String.format("Unable to locate controller service with id '%s'.", controllerServiceId)); } return controllerService; }
private StateMap getState(final String componentId, final Scope scope) { try { final StateManager manager = stateManagerProvider.getStateManager(componentId); if (manager == null) { throw new ResourceNotFoundException(String.format("State for the specified component %s could not be found.", componentId)); } return manager.getState(scope); } catch (final IOException ioe) { throw new IllegalStateException(String.format("Unable to get the state for the specified component %s: %s", componentId, ioe), ioe); } }
@Override public ListFlowFileStatus deleteFlowFileListingRequest(String connectionId, String listingRequestId) { final Connection connection = locateConnection(connectionId); final FlowFileQueue queue = connection.getFlowFileQueue(); final ListFlowFileStatus listFlowFileStatus = queue.cancelListFlowFileRequest(listingRequestId); if (listFlowFileStatus == null) { throw new ResourceNotFoundException(String.format("Unable to find listing request with id '%s'.", listingRequestId)); } return listFlowFileStatus; }
private Port locatePort(final String portId) { final ProcessGroup rootGroup = flowController.getFlowManager().getRootGroup(); final Port port = rootGroup.findOutputPort(portId); if (port == null) { throw new ResourceNotFoundException(String.format("Unable to find port with id '%s'.", portId)); } else { return port; } }
private Label locateLabel(final String labelId) { final ProcessGroup rootGroup = flowController.getFlowManager().getRootGroup(); final Label label = rootGroup.findLabel(labelId); if (label == null) { throw new ResourceNotFoundException(String.format("Unable to find label with id '%s'.", labelId)); } else { return label; } }
private RemoteProcessGroup locateRemoteProcessGroup(final String remoteProcessGroupId) { final ProcessGroup rootGroup = flowController.getFlowManager().getRootGroup(); final RemoteProcessGroup remoteProcessGroup = rootGroup.findRemoteProcessGroup(remoteProcessGroupId); if (remoteProcessGroup == null) { throw new ResourceNotFoundException(String.format("Unable to find remote process group with id '%s'.", remoteProcessGroupId)); } else { return remoteProcessGroup; } }
private Connection locateConnection(final String connectionId) { final ProcessGroup rootGroup = flowController.getFlowManager().getRootGroup(); final Connection connection = rootGroup.findConnection(connectionId); if (connection == null) { throw new ResourceNotFoundException(String.format("Unable to find connection with id '%s'.", connectionId)); } else { return connection; } }
@Override public DropFlowFileStatus getFlowFileDropRequest(String connectionId, String dropRequestId) { final Connection connection = locateConnection(connectionId); final FlowFileQueue queue = connection.getFlowFileQueue(); final DropFlowFileStatus dropRequest = queue.getDropFlowFileStatus(dropRequestId); if (dropRequest == null) { throw new ResourceNotFoundException(String.format("Unable to find drop request with id '%s'.", dropRequestId)); } return dropRequest; }
@Override public DropFlowFileStatus deleteFlowFileDropRequest(String connectionId, String dropRequestId) { final Connection connection = locateConnection(connectionId); final FlowFileQueue queue = connection.getFlowFileQueue(); final DropFlowFileStatus dropFlowFileStatus = queue.cancelDropFlowFileRequest(dropRequestId); if (dropFlowFileStatus == null) { throw new ResourceNotFoundException(String.format("Unable to find drop request with id '%s'.", dropRequestId)); } return dropFlowFileStatus; }
@Override public VersionedFlow registerVersionedFlow(final String registryId, final VersionedFlow flow) { final FlowRegistry registry = flowRegistryClient.getFlowRegistry(registryId); if (registry == null) { throw new ResourceNotFoundException("No Flow Registry exists with ID " + registryId); } try { return registry.registerVersionedFlow(flow, NiFiUserUtils.getNiFiUser()); } catch (final IOException | NiFiRegistryException e) { throw new NiFiCoreException("Failed to register flow with Flow Registry due to " + e.getMessage(), e); } }
private Port locatePort(final String portId) { final ProcessGroup rootGroup = flowController.getFlowManager().getRootGroup(); Port port = rootGroup.findInputPort(portId); if (port == null) { port = rootGroup.findOutputPort(portId); } if (port == null) { throw new ResourceNotFoundException(String.format("Unable to find port with id '%s'.", portId)); } else { return port; } }
private VersionedFlow getVersionedFlow(final String registryId, final String bucketId, final String flowId) throws IOException, NiFiRegistryException { final FlowRegistry registry = flowRegistryClient.getFlowRegistry(registryId); if (registry == null) { throw new ResourceNotFoundException("No Flow Registry exists with ID " + registryId); } return registry.getVersionedFlow(bucketId, flowId, NiFiUserUtils.getNiFiUser()); }
@Override public Authorizable getControllerServiceReferencingComponent(String controllerServiceId, String id) { final ControllerServiceNode controllerService = controllerServiceDAO.getControllerService(controllerServiceId); final ControllerServiceReference referencingComponents = controllerService.getReferences(); final ComponentNode reference = findControllerServiceReferencingComponent(referencingComponents, id); if (reference == null) { throw new ResourceNotFoundException("Unable to find referencing component with id " + id); } return reference; }
@Override public void verifyUpdateInputPort(String remoteProcessGroupId, RemoteProcessGroupPortDTO remoteProcessGroupPortDto) { final RemoteProcessGroup remoteProcessGroup = locateRemoteProcessGroup(remoteProcessGroupId); final RemoteGroupPort port = remoteProcessGroup.getInputPort(remoteProcessGroupPortDto.getId()); if (port == null) { throw new ResourceNotFoundException( String.format("Unable to find remote process group input port with id '%s'.", remoteProcessGroupPortDto.getId())); } verifyUpdatePort(port, remoteProcessGroupPortDto); }
@Override public void verifyUpdateOutputPort(String remoteProcessGroupId, RemoteProcessGroupPortDTO remoteProcessGroupPortDto) { final RemoteProcessGroup remoteProcessGroup = locateRemoteProcessGroup(remoteProcessGroupId); final RemoteGroupPort port = remoteProcessGroup.getOutputPort(remoteProcessGroupPortDto.getId()); if (port == null) { throw new ResourceNotFoundException( String.format("Unable to find remote process group output port with id '%s'.", remoteProcessGroupPortDto.getId())); } verifyUpdatePort(port, remoteProcessGroupPortDto); }