Search in sources :

Example 21 with ResourceNotFoundException

use of org.apache.nifi.registry.exception.ResourceNotFoundException in project nifi-registry by apache.

the class TenantResource method removeUser.

/**
 * Removes the specified user.
 *
 * @param httpServletRequest request
 * @param identifier         The id of the user to remove.
 * @return A entity containing the client id and an updated revision.
 */
@DELETE
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("users/{id}")
@ApiOperation(value = "Deletes a user", notes = NON_GUARANTEED_ENDPOINT, response = User.class, extensions = { @Extension(name = "access-policy", properties = { @ExtensionProperty(name = "action", value = "delete"), @ExtensionProperty(name = "resource", value = "/tenants") }) })
@ApiResponses({ @ApiResponse(code = 400, message = HttpStatusMessages.MESSAGE_400), @ApiResponse(code = 401, message = HttpStatusMessages.MESSAGE_401), @ApiResponse(code = 403, message = HttpStatusMessages.MESSAGE_403), @ApiResponse(code = 404, message = HttpStatusMessages.MESSAGE_404), @ApiResponse(code = 409, message = HttpStatusMessages.MESSAGE_409) })
public Response removeUser(@Context final HttpServletRequest httpServletRequest, @ApiParam(value = "The user id.", required = true) @PathParam("id") final String identifier) {
    verifyAuthorizerSupportsConfigurableUserGroups();
    authorizeAccess(RequestAction.DELETE);
    final User user = authorizationService.deleteUser(identifier);
    if (user == null) {
        logger.warn("The specified user id [{}] does not exist.", identifier);
        throw new ResourceNotFoundException("The specified user ID does not exist in this registry.");
    }
    return generateOkResponse(user).build();
}
Also used : User(org.apache.nifi.registry.authorization.User) ResourceNotFoundException(org.apache.nifi.registry.exception.ResourceNotFoundException) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 22 with ResourceNotFoundException

use of org.apache.nifi.registry.exception.ResourceNotFoundException in project nifi-registry by apache.

the class TenantResource method getUserGroup.

/**
 * Retrieves the specified user group.
 *
 * @param identifier The id of the user group to retrieve
 * @return An userGroupEntity.
 */
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("user-groups/{id}")
@ApiOperation(value = "Gets a user group", notes = NON_GUARANTEED_ENDPOINT, response = UserGroup.class, extensions = { @Extension(name = "access-policy", properties = { @ExtensionProperty(name = "action", value = "read"), @ExtensionProperty(name = "resource", value = "/tenants") }) })
@ApiResponses({ @ApiResponse(code = 400, message = HttpStatusMessages.MESSAGE_400), @ApiResponse(code = 401, message = HttpStatusMessages.MESSAGE_401), @ApiResponse(code = 403, message = HttpStatusMessages.MESSAGE_403), @ApiResponse(code = 404, message = HttpStatusMessages.MESSAGE_404), @ApiResponse(code = 409, message = HttpStatusMessages.MESSAGE_409) })
public Response getUserGroup(@ApiParam(value = "The user group id.", required = true) @PathParam("id") final String identifier) {
    verifyAuthorizerIsManaged();
    authorizeAccess(RequestAction.READ);
    final UserGroup userGroup = authorizationService.getUserGroup(identifier);
    if (userGroup == null) {
        logger.warn("The specified user group id [{}] does not exist.", identifier);
        throw new ResourceNotFoundException("The specified user group ID does not exist in this registry.");
    }
    return generateOkResponse(userGroup).build();
}
Also used : ResourceNotFoundException(org.apache.nifi.registry.exception.ResourceNotFoundException) UserGroup(org.apache.nifi.registry.authorization.UserGroup) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 23 with ResourceNotFoundException

use of org.apache.nifi.registry.exception.ResourceNotFoundException in project nifi-registry by apache.

the class TenantResource method getUser.

/**
 * Retrieves the specified user.
 *
 * @param identifier The id of the user to retrieve
 * @return An userEntity.
 */
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("users/{id}")
@ApiOperation(value = "Gets a user", notes = NON_GUARANTEED_ENDPOINT, response = User.class, extensions = { @Extension(name = "access-policy", properties = { @ExtensionProperty(name = "action", value = "read"), @ExtensionProperty(name = "resource", value = "/tenants") }) })
@ApiResponses({ @ApiResponse(code = 400, message = HttpStatusMessages.MESSAGE_400), @ApiResponse(code = 401, message = HttpStatusMessages.MESSAGE_401), @ApiResponse(code = 403, message = HttpStatusMessages.MESSAGE_403), @ApiResponse(code = 404, message = HttpStatusMessages.MESSAGE_404), @ApiResponse(code = 409, message = HttpStatusMessages.MESSAGE_409) })
public Response getUser(@ApiParam(value = "The user id.", required = true) @PathParam("id") final String identifier) {
    verifyAuthorizerIsManaged();
    authorizeAccess(RequestAction.READ);
    final User user = authorizationService.getUser(identifier);
    if (user == null) {
        logger.warn("The specified user id [{}] does not exist.", identifier);
        throw new ResourceNotFoundException("The specified user ID does not exist in this registry.");
    }
    return generateOkResponse(user).build();
}
Also used : User(org.apache.nifi.registry.authorization.User) ResourceNotFoundException(org.apache.nifi.registry.exception.ResourceNotFoundException) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

ResourceNotFoundException (org.apache.nifi.registry.exception.ResourceNotFoundException)23 BucketEntity (org.apache.nifi.registry.db.entity.BucketEntity)14 FlowEntity (org.apache.nifi.registry.db.entity.FlowEntity)12 ApiOperation (io.swagger.annotations.ApiOperation)9 ApiResponses (io.swagger.annotations.ApiResponses)9 Consumes (javax.ws.rs.Consumes)9 Path (javax.ws.rs.Path)9 Produces (javax.ws.rs.Produces)9 FlowSnapshotEntity (org.apache.nifi.registry.db.entity.FlowSnapshotEntity)7 GET (javax.ws.rs.GET)4 VersionedFlowSnapshotMetadata (org.apache.nifi.registry.flow.VersionedFlowSnapshotMetadata)4 TreeSet (java.util.TreeSet)3 DELETE (javax.ws.rs.DELETE)3 User (org.apache.nifi.registry.authorization.User)3 Bucket (org.apache.nifi.registry.bucket.Bucket)3 VersionedFlow (org.apache.nifi.registry.flow.VersionedFlow)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2