Search in sources :

Example 26 with ResourceNotFoundException

use of org.apache.nifi.web.ResourceNotFoundException in project nifi by apache.

the class StandardLabelDAO method locateLabel.

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;
    }
}
Also used : ProcessGroup(org.apache.nifi.groups.ProcessGroup) Label(org.apache.nifi.controller.label.Label) ResourceNotFoundException(org.apache.nifi.web.ResourceNotFoundException)

Example 27 with ResourceNotFoundException

use of org.apache.nifi.web.ResourceNotFoundException in project nifi by apache.

the class StandardPolicyBasedAuthorizerDAO method getAccessPolicy.

@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;
}
Also used : Authorizable(org.apache.nifi.authorization.resource.Authorizable) ResourceNotFoundException(org.apache.nifi.web.ResourceNotFoundException) AccessPolicy(org.apache.nifi.authorization.AccessPolicy)

Example 28 with ResourceNotFoundException

use of org.apache.nifi.web.ResourceNotFoundException in project nifi by apache.

the class StandardProcessGroupDAO method updateVariableRegistry.

@Override
public ProcessGroup updateVariableRegistry(final NiFiUser user, final VariableRegistryDTO variableRegistry) {
    final ProcessGroup group = locateProcessGroup(flowController, variableRegistry.getProcessGroupId());
    if (group == null) {
        throw new ResourceNotFoundException("Could not find Process Group with ID " + variableRegistry.getProcessGroupId());
    }
    final Map<String, String> variableMap = new HashMap<>();
    // have to use forEach here instead of using Collectors.toMap because value may be null
    variableRegistry.getVariables().stream().map(VariableEntity::getVariable).forEach(var -> variableMap.put(var.getName(), var.getValue()));
    group.setVariables(variableMap);
    group.onComponentModified();
    return group;
}
Also used : HashMap(java.util.HashMap) ProcessGroup(org.apache.nifi.groups.ProcessGroup) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) ResourceNotFoundException(org.apache.nifi.web.ResourceNotFoundException)

Example 29 with ResourceNotFoundException

use of org.apache.nifi.web.ResourceNotFoundException in project nifi by apache.

the class StandardProcessorDAO method locateProcessor.

private ProcessorNode locateProcessor(final String processorId) {
    final ProcessGroup rootGroup = flowController.getGroup(flowController.getRootGroupId());
    final ProcessorNode processor = rootGroup.findProcessor(processorId);
    if (processor == null) {
        throw new ResourceNotFoundException(String.format("Unable to find processor with id '%s'.", processorId));
    } else {
        return processor;
    }
}
Also used : ProcessorNode(org.apache.nifi.controller.ProcessorNode) ProcessGroup(org.apache.nifi.groups.ProcessGroup) ResourceNotFoundException(org.apache.nifi.web.ResourceNotFoundException)

Example 30 with ResourceNotFoundException

use of org.apache.nifi.web.ResourceNotFoundException in project nifi by apache.

the class StandardRemoteProcessGroupDAO method locateRemoteProcessGroup.

private RemoteProcessGroup locateRemoteProcessGroup(final String remoteProcessGroupId) {
    final ProcessGroup rootGroup = flowController.getGroup(flowController.getRootGroupId());
    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;
    }
}
Also used : RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) ProcessGroup(org.apache.nifi.groups.ProcessGroup) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) ResourceNotFoundException(org.apache.nifi.web.ResourceNotFoundException)

Aggregations

ResourceNotFoundException (org.apache.nifi.web.ResourceNotFoundException)59 ProcessGroup (org.apache.nifi.groups.ProcessGroup)22 Authorizable (org.apache.nifi.authorization.resource.Authorizable)16 RemoteProcessGroup (org.apache.nifi.groups.RemoteProcessGroup)16 NiFiUser (org.apache.nifi.authorization.user.NiFiUser)12 Connection (org.apache.nifi.connectable.Connection)10 VersionedProcessGroup (org.apache.nifi.registry.flow.VersionedProcessGroup)10 IOException (java.io.IOException)9 RemoteGroupPort (org.apache.nifi.remote.RemoteGroupPort)7 ApiOperation (io.swagger.annotations.ApiOperation)6 ApiResponses (io.swagger.annotations.ApiResponses)6 Consumes (javax.ws.rs.Consumes)5 Path (javax.ws.rs.Path)5 Produces (javax.ws.rs.Produces)5 AuthorizationResult (org.apache.nifi.authorization.AuthorizationResult)5 DataAuthorizable (org.apache.nifi.authorization.resource.DataAuthorizable)5 FlowFileQueue (org.apache.nifi.controller.queue.FlowFileQueue)5 ProcessGroupStatus (org.apache.nifi.controller.status.ProcessGroupStatus)5 RemoteProcessGroupStatus (org.apache.nifi.controller.status.RemoteProcessGroupStatus)5 HashMap (java.util.HashMap)4