org.apache.nifi.web.ResourceNotFoundException Java Examples
The following examples show how to use
org.apache.nifi.web.ResourceNotFoundException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StandardProcessGroupDAO.java From nifi with Apache License 2.0 | 6 votes |
private Connectable findConnectable(final String componentId, final String groupId, final Set<ProcessGroup> validProcessGroups) { // Get the component with the given ID and ensure that it belongs to the group that we are looking for. // We do this, rather than calling ProcessGroup.findLocalConnectable because for any component that is buried several // layers of Process Groups deep, that method becomes quite a bit more expensive than this method, due to all of the // Read Locks that must be obtained while recursing through the Process Group's descendant groups. final Connectable connectable = flowController.getFlowManager().findConnectable(componentId); if (connectable == null) { throw new ResourceNotFoundException("Could not find Component with ID " + componentId); } final ProcessGroup connectableGroup = connectable.getProcessGroup(); if (!validProcessGroups.contains(connectableGroup)) { throw new ResourceNotFoundException("Component with ID " + componentId + " does not belong to Process Group " + groupId + " or any of its descendent groups"); } return connectable; }
Example #2
Source File: FlowUpdateResource.java From nifi with Apache License 2.0 | 6 votes |
protected Set<AffectedComponentEntity> getUpdatedEntities(final Set<AffectedComponentEntity> originalEntities) { final Set<AffectedComponentEntity> entities = new LinkedHashSet<>(); for (final AffectedComponentEntity original : originalEntities) { try { final AffectedComponentEntity updatedEntity = AffectedComponentUtils.updateEntity(original, serviceFacade, dtoFactory); if (updatedEntity != null) { entities.add(updatedEntity); } } catch (final ResourceNotFoundException rnfe) { // Component was removed. Just continue on without adding anything to the entities. // We do this because the intent is to get updated versions of the entities with current // Revisions so that we can change the states of the components. If the component was removed, // then we can just drop the entity, since there is no need to change its state. } } return entities; }
Example #3
Source File: ControllerFacade.java From nifi with Apache License 2.0 | 6 votes |
/** * Gets status analytics for the specified connection. * * @param connectionId connection id * @return the statistics for the specified connection */ public StatusAnalytics getConnectionStatusAnalytics(final String connectionId) { final ProcessGroup root = getRootGroup(); final Connection connection = root.findConnection(connectionId); // ensure the connection was found if (connection == null) { throw new ResourceNotFoundException(String.format("Unable to locate connection with id '%s'.", connectionId)); } // calculate the process group status final String groupId = connection.getProcessGroup().getIdentifier(); final ProcessGroupStatus processGroupStatus = flowController.getEventAccess().getGroupStatus(groupId, NiFiUserUtils.getNiFiUser(), 1); if (processGroupStatus == null) { throw new ResourceNotFoundException(String.format("Unable to locate group with id '%s'.", groupId)); } // get from flow controller final StatusAnalyticsEngine statusAnalyticsEngine = flowController.getStatusAnalyticsEngine(); if (statusAnalyticsEngine == null) { throw new ResourceNotFoundException(String.format("Unable to provide analytics for connection with id '%s'. Analytics may not be enabled", connectionId)); } return statusAnalyticsEngine.getStatusAnalytics(connectionId); }
Example #4
Source File: StandardProcessGroupDAO.java From localization_nifi with Apache License 2.0 | 6 votes |
@Override public void verifyScheduleComponents(final String groupId, final ScheduledState state,final Set<String> componentIds) { final ProcessGroup group = locateProcessGroup(flowController, groupId); final Set<Connectable> connectables = new HashSet<>(componentIds.size()); for (final String componentId : componentIds) { final Connectable connectable = group.findLocalConnectable(componentId); if (connectable == null) { throw new ResourceNotFoundException("Unable to find component with id " + componentId); } connectables.add(connectable); } // verify as appropriate connectables.forEach(connectable -> { if (ScheduledState.RUNNING.equals(state)) { group.verifyCanStart(connectable); } else { group.verifyCanStop(connectable); } }); }
Example #5
Source File: ControllerFacade.java From nifi with Apache License 2.0 | 6 votes |
/** * Returns the status history for the specified processor. * * @param processorId processor id * @return status history */ public StatusHistoryDTO getProcessorStatusHistory(final String processorId) { final ProcessGroup root = getRootGroup(); final ProcessorNode processor = root.findProcessor(processorId); // ensure the processor was found if (processor == null) { throw new ResourceNotFoundException(String.format("Unable to locate processor with id '%s'.", processorId)); } final boolean authorized = processor.isAuthorized(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser()); final StatusHistoryDTO statusHistory = flowController.getProcessorStatusHistory(processorId, authorized); // if not authorized if (!authorized) { statusHistory.getComponentDetails().put(ComponentStatusRepository.COMPONENT_DETAIL_NAME, processorId); statusHistory.getComponentDetails().put(ComponentStatusRepository.COMPONENT_DETAIL_TYPE, "Processor"); } return statusHistory; }
Example #6
Source File: ControllerFacade.java From localization_nifi with Apache License 2.0 | 6 votes |
/** * Returns the status history for the specified remote process group. * * @param remoteProcessGroupId remote process group id * @return status history */ public StatusHistoryDTO getRemoteProcessGroupStatusHistory(final String remoteProcessGroupId) { final ProcessGroup root = flowController.getGroup(flowController.getRootGroupId()); final RemoteProcessGroup remoteProcessGroup = root.findRemoteProcessGroup(remoteProcessGroupId); // ensure the output port was found if (remoteProcessGroup == null) { throw new ResourceNotFoundException(String.format("Unable to locate remote process group with id '%s'.", remoteProcessGroupId)); } final StatusHistoryDTO statusHistory = flowController.getRemoteProcessGroupStatusHistory(remoteProcessGroupId); // if not authorized if (!remoteProcessGroup.isAuthorized(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser())) { statusHistory.getComponentDetails().put(ComponentStatusRepository.COMPONENT_DETAIL_NAME, remoteProcessGroupId); statusHistory.getComponentDetails().remove(ComponentStatusRepository.COMPONENT_DETAIL_URI); } return statusHistory; }
Example #7
Source File: ControllerFacade.java From localization_nifi with Apache License 2.0 | 6 votes |
/** * Returns the status history for the specified process group. * * @param groupId group id * @return status history */ public StatusHistoryDTO getProcessGroupStatusHistory(final String groupId) { final String searchId = groupId.equals(ROOT_GROUP_ID_ALIAS) ? flowController.getRootGroupId() : groupId; final ProcessGroup root = flowController.getGroup(flowController.getRootGroupId()); final ProcessGroup group = root.findProcessGroup(searchId); // ensure the processor was found if (group == null) { throw new ResourceNotFoundException(String.format("Unable to locate process group with id '%s'.", groupId)); } final StatusHistoryDTO statusHistory = flowController.getProcessGroupStatusHistory(groupId); // if not authorized if (!group.isAuthorized(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser())) { statusHistory.getComponentDetails().put(ComponentStatusRepository.COMPONENT_DETAIL_NAME, groupId); } return statusHistory; }
Example #8
Source File: ControllerFacade.java From localization_nifi with Apache License 2.0 | 6 votes |
/** * Returns the status history for the specified connection. * * @param connectionId connection id * @return status history */ public StatusHistoryDTO getConnectionStatusHistory(final String connectionId) { final ProcessGroup root = flowController.getGroup(flowController.getRootGroupId()); final Connection connection = root.findConnection(connectionId); // ensure the connection was found if (connection == null) { throw new ResourceNotFoundException(String.format("Unable to locate connection with id '%s'.", connectionId)); } final StatusHistoryDTO statusHistory = flowController.getConnectionStatusHistory(connectionId); // if not authorized if (!connection.isAuthorized(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser())) { statusHistory.getComponentDetails().put(ComponentStatusRepository.COMPONENT_DETAIL_NAME, connectionId); statusHistory.getComponentDetails().put(ComponentStatusRepository.COMPONENT_DETAIL_SOURCE_NAME, connection.getSource().getIdentifier()); statusHistory.getComponentDetails().put(ComponentStatusRepository.COMPONENT_DETAIL_DESTINATION_NAME, connection.getDestination().getIdentifier()); } return statusHistory; }
Example #9
Source File: ControllerFacade.java From nifi with Apache License 2.0 | 6 votes |
/** * Returns the status history for the specified process group. * * @param groupId group id * @return status history */ public StatusHistoryDTO getProcessGroupStatusHistory(final String groupId) { final FlowManager flowManager = flowController.getFlowManager(); final String searchId = groupId.equals(FlowManager.ROOT_GROUP_ID_ALIAS) ? flowManager.getRootGroupId() : groupId; final ProcessGroup root = flowManager.getRootGroup(); final ProcessGroup group = root.findProcessGroup(searchId); // ensure the processor was found if (group == null) { throw new ResourceNotFoundException(String.format("Unable to locate process group with id '%s'.", groupId)); } final StatusHistoryDTO statusHistory = flowController.getProcessGroupStatusHistory(groupId); // if not authorized if (!group.isAuthorized(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser())) { statusHistory.getComponentDetails().put(ComponentStatusRepository.COMPONENT_DETAIL_NAME, groupId); } return statusHistory; }
Example #10
Source File: ControllerFacade.java From nifi with Apache License 2.0 | 6 votes |
/** * Returns the status history for the specified remote process group. * * @param remoteProcessGroupId remote process group id * @return status history */ public StatusHistoryDTO getRemoteProcessGroupStatusHistory(final String remoteProcessGroupId) { final ProcessGroup root = getRootGroup(); final RemoteProcessGroup remoteProcessGroup = root.findRemoteProcessGroup(remoteProcessGroupId); // ensure the output port was found if (remoteProcessGroup == null) { throw new ResourceNotFoundException(String.format("Unable to locate remote process group with id '%s'.", remoteProcessGroupId)); } final StatusHistoryDTO statusHistory = flowController.getRemoteProcessGroupStatusHistory(remoteProcessGroupId); // if not authorized if (!remoteProcessGroup.isAuthorized(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser())) { statusHistory.getComponentDetails().put(ComponentStatusRepository.COMPONENT_DETAIL_NAME, remoteProcessGroupId); statusHistory.getComponentDetails().remove(ComponentStatusRepository.COMPONENT_DETAIL_URI); } return statusHistory; }
Example #11
Source File: DataAuthorizable.java From nifi with Apache License 2.0 | 6 votes |
@Override public void authorize(Authorizer authorizer, RequestAction action, NiFiUser user, Map<String, String> resourceContext) throws AccessDeniedException { if (user == null) { throw new AccessDeniedException("Unknown user."); } // authorize each element in the chain NiFiUser chainedUser = user; do { try { // perform the current user authorization Authorizable.super.authorize(authorizer, action, chainedUser, resourceContext); // go to the next user in the chain chainedUser = chainedUser.getChain(); } catch (final ResourceNotFoundException e) { throw new AccessDeniedException("Unknown source component."); } } while (chainedUser != null); }
Example #12
Source File: ControllerFacade.java From localization_nifi with Apache License 2.0 | 6 votes |
/** * Gets the status for the specified output port. * * @param portId output port id * @return the status for the specified output port */ public PortStatus getOutputPortStatus(final String portId) { final ProcessGroup root = flowController.getGroup(flowController.getRootGroupId()); final Port port = root.findOutputPort(portId); // ensure the output port was found if (port == null) { throw new ResourceNotFoundException(String.format("Unable to locate output port with id '%s'.", portId)); } final String groupId = port.getProcessGroup().getIdentifier(); final ProcessGroupStatus processGroupStatus = flowController.getGroupStatus(groupId, NiFiUserUtils.getNiFiUser()); if (processGroupStatus == null) { throw new ResourceNotFoundException(String.format("Unable to locate group with id '%s'.", groupId)); } final PortStatus status = processGroupStatus.getOutputPortStatus().stream().filter(portStatus -> portId.equals(portStatus.getId())).findFirst().orElse(null); if (status == null) { throw new ResourceNotFoundException(String.format("Unable to locate output port with id '%s'.", portId)); } return status; }
Example #13
Source File: AsyncRequestManager.java From nifi with Apache License 2.0 | 6 votes |
@Override public AsynchronousWebRequest<R, T> removeRequest(final String type, final String id, final NiFiUser user) { Objects.requireNonNull(type); Objects.requireNonNull(id); Objects.requireNonNull(user); final String key = getKey(type, id); final AsynchronousWebRequest<R, T> request = requests.get(key); if (request == null) { throw new ResourceNotFoundException("Could not find a Request with identifier " + id); } if (!request.getUser().equals(user)) { throw new IllegalArgumentException("Only the user that submitted the update request can delete it."); } if (!request.isComplete()) { request.cancel(); } requests.remove(key); return request; }
Example #14
Source File: StandardConnectionDAO.java From nifi with Apache License 2.0 | 6 votes |
@Override public FlowFileRecord getFlowFile(String id, String flowFileUuid) { try { final Connection connection = locateConnection(id); final FlowFileQueue queue = connection.getFlowFileQueue(); final FlowFileRecord flowFile = queue.getFlowFile(flowFileUuid); if (flowFile == null) { throw new ResourceNotFoundException(String.format("The FlowFile with UUID %s is no longer in the active queue.", flowFileUuid)); } // get the attributes and ensure appropriate access final Map<String, String> attributes = flowFile.getAttributes(); final Authorizable dataAuthorizable = new DataAuthorizable(connection.getSourceAuthorizable()); dataAuthorizable.authorize(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser(), attributes); return flowFile; } catch (final IOException ioe) { logger.error(String.format("Unable to get the flowfile (%s) at this time.", flowFileUuid), ioe); throw new IllegalStateException("Unable to get the FlowFile at this time."); } }
Example #15
Source File: StandardTemplateDAO.java From nifi with Apache License 2.0 | 6 votes |
@Override public Template createTemplate(final TemplateDTO templateDTO, final String groupId) { final ProcessGroup processGroup = flowController.getFlowManager().getGroup(groupId); if (processGroup == null) { throw new ResourceNotFoundException("Could not find Process Group with ID " + groupId); } verifyCanAddTemplate(templateDTO.getName(), groupId); TemplateUtils.scrubTemplate(templateDTO); TemplateUtils.escapeParameterReferences(templateDTO); final Template template = new Template(templateDTO); processGroup.addTemplate(template); return template; }
Example #16
Source File: ControllerFacade.java From nifi with Apache License 2.0 | 6 votes |
/** * Gets the status for the specified remote process group. * * @param remoteProcessGroupId remote process group id * @return the status for the specified remote process group */ public RemoteProcessGroupStatus getRemoteProcessGroupStatus(final String remoteProcessGroupId) { final ProcessGroup root = getRootGroup(); final RemoteProcessGroup remoteProcessGroup = root.findRemoteProcessGroup(remoteProcessGroupId); // ensure the output port was found if (remoteProcessGroup == null) { throw new ResourceNotFoundException(String.format("Unable to locate remote process group with id '%s'.", remoteProcessGroupId)); } final String groupId = remoteProcessGroup.getProcessGroup().getIdentifier(); final ProcessGroupStatus groupStatus = flowController.getEventAccess().getGroupStatus(groupId, NiFiUserUtils.getNiFiUser(), 1); if (groupStatus == null) { throw new ResourceNotFoundException(String.format("Unable to locate group with id '%s'.", groupId)); } final RemoteProcessGroupStatus status = groupStatus.getRemoteProcessGroupStatus().stream().filter(rpgStatus -> remoteProcessGroupId.equals(rpgStatus.getId())).findFirst().orElse(null); if (status == null) { throw new ResourceNotFoundException(String.format("Unable to locate remote process group with id '%s'.", remoteProcessGroupId)); } return status; }
Example #17
Source File: StandardConnectionDAO.java From localization_nifi with Apache License 2.0 | 6 votes |
@Override public FlowFileRecord getFlowFile(String id, String flowFileUuid) { try { final Connection connection = locateConnection(id); final FlowFileQueue queue = connection.getFlowFileQueue(); final FlowFileRecord flowFile = queue.getFlowFile(flowFileUuid); if (flowFile == null) { throw new ResourceNotFoundException(String.format("The FlowFile with UUID %s is no longer in the active queue.", flowFileUuid)); } // get the attributes and ensure appropriate access final Map<String, String> attributes = flowFile.getAttributes(); final Authorizable dataAuthorizable = new DataAuthorizable(connection.getSourceAuthorizable()); dataAuthorizable.authorize(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser(), attributes); return flowFile; } catch (final IOException ioe) { logger.error(String.format("Unable to get the flowfile (%s) at this time.", flowFileUuid), ioe); throw new IllegalStateException("Unable to get the FlowFile at this time."); } }
Example #18
Source File: ControllerFacade.java From nifi with Apache License 2.0 | 6 votes |
/** * Gets the status for the specified output port. * * @param portId output port id * @return the status for the specified output port */ public PortStatus getOutputPortStatus(final String portId) { final ProcessGroup root = getRootGroup(); final Port port = root.findOutputPort(portId); // ensure the output port was found if (port == null) { throw new ResourceNotFoundException(String.format("Unable to locate output port with id '%s'.", portId)); } final String groupId = port.getProcessGroup().getIdentifier(); final ProcessGroupStatus processGroupStatus = flowController.getEventAccess().getGroupStatus(groupId, NiFiUserUtils.getNiFiUser(), 1); if (processGroupStatus == null) { throw new ResourceNotFoundException(String.format("Unable to locate group with id '%s'.", groupId)); } final PortStatus status = processGroupStatus.getOutputPortStatus().stream().filter(portStatus -> portId.equals(portStatus.getId())).findFirst().orElse(null); if (status == null) { throw new ResourceNotFoundException(String.format("Unable to locate output port with id '%s'.", portId)); } return status; }
Example #19
Source File: ControllerFacade.java From nifi with Apache License 2.0 | 6 votes |
/** * Gets the status for the specified connection. * * @param connectionId connection id * @return the status for the specified connection */ public ConnectionStatus getConnectionStatus(final String connectionId) { final ProcessGroup root = getRootGroup(); final Connection connection = root.findConnection(connectionId); // ensure the connection was found if (connection == null) { throw new ResourceNotFoundException(String.format("Unable to locate connection with id '%s'.", connectionId)); } // calculate the process group status final String groupId = connection.getProcessGroup().getIdentifier(); final ProcessGroupStatus processGroupStatus = flowController.getEventAccess().getGroupStatus(groupId, NiFiUserUtils.getNiFiUser(), 1); if (processGroupStatus == null) { throw new ResourceNotFoundException(String.format("Unable to locate group with id '%s'.", groupId)); } final ConnectionStatus status = processGroupStatus.getConnectionStatus().stream().filter(connectionStatus -> connectionId.equals(connectionStatus.getId())).findFirst().orElse(null); if (status == null) { throw new ResourceNotFoundException(String.format("Unable to locate connection with id '%s'.", connectionId)); } return status; }
Example #20
Source File: MiNiFiPersistentProvenanceRepository.java From nifi-minifi with Apache License 2.0 | 6 votes |
public boolean isAuthorized(final ProvenanceEventRecord event, final NiFiUser user) { if (authorizer == null || user == null) { return true; } final Authorizable eventAuthorizable; try { if (event.isRemotePortType()) { eventAuthorizable = resourceFactory.createRemoteDataAuthorizable(event.getComponentId()); } else { eventAuthorizable = resourceFactory.createLocalDataAuthorizable(event.getComponentId()); } } catch (final ResourceNotFoundException rnfe) { return false; } final AuthorizationResult result = eventAuthorizable.checkAuthorization(authorizer, RequestAction.READ, user, event.getAttributes()); return Result.Approved.equals(result.getResult()); }
Example #21
Source File: StandardPolicyBasedAuthorizerDAO.java From localization_nifi with Apache License 2.0 | 6 votes |
@Override public AccessPolicy getAccessPolicy(final RequestAction requestAction, final Authorizable authorizable) { final String resource = authorizable.getResource().getIdentifier(); final AccessPolicy accessPolicy = findAccessPolicy(requestAction, authorizable.getResource().getIdentifier()); if (accessPolicy == null) { final Authorizable parentAuthorizable = authorizable.getParentAuthorizable(); if (parentAuthorizable == null) { throw new ResourceNotFoundException(String.format("Unable to find access policy for %s on %s", requestAction.toString(), resource)); } else { return getAccessPolicy(requestAction, parentAuthorizable); } } return accessPolicy; }
Example #22
Source File: ParameterContextResource.java From nifi with Apache License 2.0 | 6 votes |
private Set<AffectedComponentEntity> getUpdatedEntities(final Set<AffectedComponentEntity> originalEntities) { final Set<AffectedComponentEntity> entities = new LinkedHashSet<>(); for (final AffectedComponentEntity original : originalEntities) { try { final AffectedComponentEntity updatedEntity = AffectedComponentUtils.updateEntity(original, serviceFacade, dtoFactory); if (updatedEntity != null) { entities.add(updatedEntity); } } catch (final ResourceNotFoundException rnfe) { // Component was removed. Just continue on without adding anything to the entities. // We do this because the intent is to get updated versions of the entities with current // Revisions so that we can change the states of the components. If the component was removed, // then we can just drop the entity, since there is no need to change its state. } } return entities; }
Example #23
Source File: ParameterContextResource.java From nifi with Apache License 2.0 | 6 votes |
private Response deleteValidationRequest(final String requestType, final String contextId, final String requestId, final boolean disconnectedNodeAcknowledged) { if (requestId == null) { throw new IllegalArgumentException("Request ID must be specified."); } if (isDisconnectedFromCluster()) { verifyDisconnectedNodeModification(disconnectedNodeAcknowledged); } final NiFiUser user = NiFiUserUtils.getNiFiUser(); // request manager will ensure that the current is the user that submitted this request final AsynchronousWebRequest<?, ComponentValidationResultsEntity> asyncRequest = validationRequestManager.removeRequest(requestType, requestId, user); if (asyncRequest == null) { throw new ResourceNotFoundException("Could not find request of type " + requestType + " with ID " + requestId); } if (!asyncRequest.isComplete()) { asyncRequest.cancel(); } final ParameterContextValidationRequestEntity requestEntity = createValidationRequestEntity(asyncRequest, contextId, requestType, requestId); return generateOkResponse(requestEntity).build(); }
Example #24
Source File: ControllerFacade.java From nifi with Apache License 2.0 | 6 votes |
/** * Submits a replay request for the specified event id. * * @param eventId event id * @return provenance event */ public ProvenanceEventDTO submitReplay(final Long eventId) { try { final NiFiUser user = NiFiUserUtils.getNiFiUser(); if (user == null) { throw new WebApplicationException(new Throwable("Unable to access details for current user.")); } // lookup the original event final ProvenanceEventRecord originalEvent = flowController.getProvenanceRepository().getEvent(eventId, user); if (originalEvent == null) { throw new ResourceNotFoundException("Unable to find the specified event."); } // authorize the replay authorizeReplay(originalEvent); // replay the flow file final ProvenanceEventRecord event = flowController.replayFlowFile(originalEvent, user); // convert the event record return createProvenanceEventDto(event, false); } catch (final IOException ioe) { throw new NiFiCoreException("An error occurred while getting the specified event.", ioe); } }
Example #25
Source File: ControllerFacade.java From localization_nifi with Apache License 2.0 | 6 votes |
/** * Submits a replay request for the specified event id. * * @param eventId event id * @return provenance event */ public ProvenanceEventDTO submitReplay(final Long eventId) { try { final NiFiUser user = NiFiUserUtils.getNiFiUser(); if (user == null) { throw new WebApplicationException(new Throwable("Unable to access details for current user.")); } // lookup the original event final ProvenanceEventRecord originalEvent = flowController.getProvenanceRepository().getEvent(eventId); if (originalEvent == null) { throw new ResourceNotFoundException("Unable to find the specified event."); } // authorize the replay authorizeReplay(originalEvent); // replay the flow file final ProvenanceEventRecord event = flowController.replayFlowFile(originalEvent, user); // convert the event record return createProvenanceEventDto(event, false); } catch (final IOException ioe) { throw new NiFiCoreException("An error occurred while getting the specified event.", ioe); } }
Example #26
Source File: ParameterContextResource.java From nifi with Apache License 2.0 | 6 votes |
private Response deleteUpdateRequest(final String requestType, final String contextId, final String requestId, final boolean disconnectedNodeAcknowledged) { if (requestId == null) { throw new IllegalArgumentException("Request ID must be specified."); } if (isDisconnectedFromCluster()) { verifyDisconnectedNodeModification(disconnectedNodeAcknowledged); } final NiFiUser user = NiFiUserUtils.getNiFiUser(); // request manager will ensure that the current is the user that submitted this request final AsynchronousWebRequest<ParameterContextEntity, ParameterContextEntity> asyncRequest = updateRequestManager.removeRequest(requestType, requestId, user); if (asyncRequest == null) { throw new ResourceNotFoundException("Could not find request of type " + requestType + " with ID " + requestId); } if (!asyncRequest.isComplete()) { asyncRequest.cancel(); } final ParameterContextUpdateRequestEntity updateRequestEntity = createUpdateRequestEntity(asyncRequest, requestType, contextId, requestId); return generateOkResponse(updateRequestEntity).build(); }
Example #27
Source File: StandardRemoteProcessGroupDAO.java From localization_nifi with Apache License 2.0 | 5 votes |
@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); }
Example #28
Source File: StandardRemoteProcessGroupDAO.java From localization_nifi with Apache License 2.0 | 5 votes |
@Override public RemoteGroupPort updateRemoteProcessGroupOutputPort(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'.", remoteProcessGroupId)); } // verify the update verifyUpdatePort(port, remoteProcessGroupPortDto); // perform the update if (isNotNull(remoteProcessGroupPortDto.getConcurrentlySchedulableTaskCount())) { port.setMaxConcurrentTasks(remoteProcessGroupPortDto.getConcurrentlySchedulableTaskCount()); } if (isNotNull(remoteProcessGroupPortDto.getUseCompression())) { port.setUseCompression(remoteProcessGroupPortDto.getUseCompression()); } final Boolean isTransmitting = remoteProcessGroupPortDto.isTransmitting(); if (isNotNull(isTransmitting)) { // start or stop as necessary if (!port.isRunning() && isTransmitting) { remoteProcessGroup.startTransmitting(port); } else if (port.isRunning() && !isTransmitting) { remoteProcessGroup.stopTransmitting(port); } } return port; }
Example #29
Source File: StandardOutputPortDAO.java From localization_nifi with Apache License 2.0 | 5 votes |
private Port locatePort(final String portId) { final ProcessGroup rootGroup = flowController.getGroup(flowController.getRootGroupId()); 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; } }
Example #30
Source File: StandardLabelDAO.java From localization_nifi with Apache License 2.0 | 5 votes |
private Label locateLabel(final String labelId) { final ProcessGroup rootGroup = flowController.getGroup(flowController.getRootGroupId()); 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; } }