Search in sources :

Example 1 with EntityShareResponse

use of org.graylog.security.shares.EntityShareResponse in project graylog2-server by Graylog2.

the class EntitySharesResource method updateEntityShares.

@POST
@ApiOperation(value = "Create / update shares for an entity or collection")
@Path("entities/{entityGRN}")
@NoAuditEvent("Audit events are created within EntitySharesService")
public Response updateEntityShares(@ApiParam(name = "entityGRN", required = true) @PathParam("entityGRN") @NotBlank String entityGRN, @ApiParam(name = "JSON Body", required = true) @NotNull @Valid EntityShareRequest request) {
    final GRN entity = grnRegistry.parse(entityGRN);
    checkOwnership(entity);
    final EntityShareResponse entityShareResponse = entitySharesService.updateEntityShares(entity, request, requireNonNull(getCurrentUser()));
    if (entityShareResponse.validationResult().failed()) {
        return Response.status(Response.Status.BAD_REQUEST).entity(entityShareResponse).build();
    } else {
        return Response.ok(entityShareResponse).build();
    }
}
Also used : EntityShareResponse(org.graylog.security.shares.EntityShareResponse) GRN(org.graylog.grn.GRN) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) ApiOperation(io.swagger.annotations.ApiOperation) NoAuditEvent(org.graylog2.audit.jersey.NoAuditEvent)

Aggregations

ApiOperation (io.swagger.annotations.ApiOperation)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 GRN (org.graylog.grn.GRN)1 EntityShareResponse (org.graylog.security.shares.EntityShareResponse)1 NoAuditEvent (org.graylog2.audit.jersey.NoAuditEvent)1