mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-20 09:47:58 +01:00
Add ArchiveController
Adds endpoints for creating and managing backup objects with ZK anonymous credentials.
This commit is contained in:
committed by
ravi-signal
parent
ba139dddd8
commit
6b38b538f1
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2023 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.whispersystems.textsecuregcm.mappers;
|
||||
|
||||
import io.dropwizard.jersey.errors.ErrorMessage;
|
||||
import io.grpc.StatusRuntimeException;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.ext.ExceptionMapper;
|
||||
import javax.ws.rs.ext.Provider;
|
||||
|
||||
@Provider
|
||||
public class GrpcStatusRuntimeExceptionMapper implements ExceptionMapper<StatusRuntimeException> {
|
||||
|
||||
@Override
|
||||
public Response toResponse(final StatusRuntimeException exception) {
|
||||
int httpCode = switch (exception.getStatus().getCode()) {
|
||||
case OK -> 200;
|
||||
case INVALID_ARGUMENT, FAILED_PRECONDITION, OUT_OF_RANGE -> 400;
|
||||
case UNAUTHENTICATED -> 401;
|
||||
case PERMISSION_DENIED -> 403;
|
||||
case NOT_FOUND -> 404;
|
||||
case ALREADY_EXISTS, ABORTED -> 409;
|
||||
case CANCELLED -> 499;
|
||||
case UNKNOWN, UNIMPLEMENTED, DEADLINE_EXCEEDED, RESOURCE_EXHAUSTED, INTERNAL, UNAVAILABLE, DATA_LOSS -> 500;
|
||||
};
|
||||
|
||||
return Response.status(httpCode)
|
||||
.entity(new ErrorMessage(httpCode, exception.getMessage()))
|
||||
.type(MediaType.APPLICATION_JSON_TYPE)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user