Package org.restheart.exchange
Class MongoResponse
java.lang.Object
org.restheart.exchange.Exchange<org.bson.BsonValue>
org.restheart.exchange.Response<org.bson.BsonValue>
org.restheart.exchange.ServiceResponse<org.bson.BsonValue>
org.restheart.exchange.BsonResponse
org.restheart.exchange.MongoResponse
- Direct Known Subclasses:
GraphQLResponse
Response implementation used by MongoService and backed by BsonValue that
provides simplify methods to deal mongo response
- Author:
- Andrea Di Cesare <andrea@softinstigate.com>
-
Field Summary
Fields inherited from class org.restheart.exchange.ServiceResponse
contentFields inherited from class org.restheart.exchange.Exchange
APPLICATION_PDF_TYPE, FORM_URLENCODED, HAL_JSON_MEDIA_TYPE, IN_ERROR_KEY, JSON_MEDIA_TYPE, MAX_BUFFERS, MAX_CONTENT_SIZE, MULTIPART, TEXT_PLAIN_CONTENT_TYPE, wrapped -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMongoResponse(io.undertow.server.HttpServerExchange exchange) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddWarning(String warning) longgetCount()static MongoResponseinit(io.undertow.server.HttpServerExchange exchange) static MongoResponseof(io.undertow.server.HttpServerExchange exchange) Reads the content as a String.voidrollback(com.mongodb.client.MongoClient mclient) Helper method to restore a modified document. rollback() can be used when verifing a document after being updated to rollback changes.voidsetCount(long count) voidsetDbOperationResult(OperationResult dbOperationResult) voidsetInError(int code, String message, Throwable t) Methods inherited from class org.restheart.exchange.BsonResponse
setContent, setContentMethods inherited from class org.restheart.exchange.ServiceResponse
getContent, getCustomSender, of, setContent, setCustomSenderMethods inherited from class org.restheart.exchange.Response
getContentType, getContentType, getHeader, getHeader, getHeaders, getMDCContext, getStatusCode, setContentType, setContentTypeAsJson, setHeader, setHeader, setInError, setMDCContext, setStatusCodeMethods inherited from class org.restheart.exchange.Exchange
getExchange, getWrappedExchange, isAccountInRole, isAuthenticated, isAuthenticated, isContentTypeFormOrMultipart, isContentTypeFormOrMultipart, isContentTypeJson, isContentTypeJson, isContentTypeText, isContentTypeXml, isInError, isInError, responseInterceptorsExecuted, setInError, setInError, setResponseInterceptorsExecuted, updateBufferSize
-
Constructor Details
-
MongoResponse
protected MongoResponse(io.undertow.server.HttpServerExchange exchange)
-
-
Method Details
-
init
-
of
-
readContent
Description copied from class:ServiceResponseReads the content as a String. This method is used by ResponseSender to generate the response content to send to the client.- Overrides:
readContentin classBsonResponse- Returns:
- the content as string
-
getDbOperationResult
- Returns:
- the dbOperationResult
-
setDbOperationResult
- Parameters:
dbOperationResult- the dbOperationResult to set
-
getWarnings
- Returns:
- the warnings
-
addWarning
- Parameters:
warning-
-
setInError
- Overrides:
setInErrorin classBsonResponse- Parameters:
code-message-t-
-
getCount
public long getCount()- Returns:
- the count
-
setCount
public void setCount(long count) - Parameters:
count- the count to set
-
rollback
Helper method to restore a modified document. rollback() can be used when verifing a document after being updated to rollback changes. A common use case is when the request body contains update operators and an Interceptor cannot verify it at InterceptPoint.REQUEST time; it can check it at InterceptPoint.RESPONSE time and restore data if the updated document doest not fullfil the required conditions. Note: rollback() does not support bulk updates.- Parameters:
mclient- the MongoClient instance- Throws:
Exception- in case of any error
-