Package org.yamcs.http
Class Context
- java.lang.Object
-
- org.yamcs.http.Context
-
- Direct Known Subclasses:
RouteContext,TopicContext
public abstract class Context extends Object
Request context used in RPC-style endpoints.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.yamcs.api.Api<Context>apiprotected Loglogio.netty.channel.ChannelHandlerContextnettyContextThe Netty request context for an RPC call.protected intstatusCodeprotected longtxSizeUseruserThe request user.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddTransferredSize(long byteCount)voidcheckObjectPrivileges(ObjectPrivilegeType type, String... objects)voidcheckObjectPrivileges(ObjectPrivilegeType type, Collection<String> objects)voidcheckSystemPrivilege(SystemPrivilege privilege)org.yamcs.api.Api<Context>getApi()StringgetClientAddress()intgetId()abstract com.google.protobuf.Descriptors.MethodDescriptorgetMethod()com.google.protobuf.MessagegetRequestPrototype()com.google.protobuf.MessagegetResponsePrototype()intgetStatusCode()longgetTransferredSize()Get the number of bytes transferred as the result of this call.booleanisClientStreaming()booleanisServerStreaming()voidparseJson(String json, com.google.protobuf.Message.Builder builder)StringprintJson(com.google.protobuf.Message message)voidreportStatusCode(int statusCode)StringtoString()
-
-
-
Field Detail
-
log
protected final Log log
-
nettyContext
public final io.netty.channel.ChannelHandlerContext nettyContext
The Netty request context for an RPC call. In general RPC implementation should avoid using this object. It is exposed only because we need it for some HTTP-specific functionalities that are not covered by our RPC implementation (e.g. http chunking)
-
api
protected final org.yamcs.api.Api<Context> api
-
user
public final User user
The request user.
-
txSize
protected long txSize
-
statusCode
protected int statusCode
-
-
Method Detail
-
getApi
public org.yamcs.api.Api<Context> getApi()
-
getMethod
public abstract com.google.protobuf.Descriptors.MethodDescriptor getMethod()
-
isServerStreaming
public boolean isServerStreaming()
-
isClientStreaming
public boolean isClientStreaming()
-
getRequestPrototype
public com.google.protobuf.Message getRequestPrototype()
-
getResponsePrototype
public com.google.protobuf.Message getResponsePrototype()
-
parseJson
public void parseJson(String json, com.google.protobuf.Message.Builder builder) throws com.google.protobuf.InvalidProtocolBufferException
- Throws:
com.google.protobuf.InvalidProtocolBufferException
-
printJson
public String printJson(com.google.protobuf.Message message) throws com.google.protobuf.InvalidProtocolBufferException
- Throws:
com.google.protobuf.InvalidProtocolBufferException
-
getTransferredSize
public long getTransferredSize()
Get the number of bytes transferred as the result of this call. It should not include the http headers. Note that the number might be increased before the data is sent so it will be wrong if there was an error sending data.- Returns:
- number of bytes transferred as part of the request
-
addTransferredSize
public void addTransferredSize(long byteCount)
-
getStatusCode
public int getStatusCode()
-
reportStatusCode
public void reportStatusCode(int statusCode)
-
getClientAddress
public String getClientAddress()
-
checkSystemPrivilege
public void checkSystemPrivilege(SystemPrivilege privilege) throws ForbiddenException
- Throws:
ForbiddenException
-
checkObjectPrivileges
public void checkObjectPrivileges(ObjectPrivilegeType type, Collection<String> objects) throws ForbiddenException
- Throws:
ForbiddenException
-
checkObjectPrivileges
public void checkObjectPrivileges(ObjectPrivilegeType type, String... objects) throws ForbiddenException
- Throws:
ForbiddenException
-
getId
public int getId()
-
-