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

public class MongoResponse extends BsonResponse
Response implementation used by MongoService and backed by BsonValue that provides simplify methods to deal mongo response
Author:
Andrea Di Cesare <andrea@softinstigate.com>
  • Constructor Details

    • MongoResponse

      protected MongoResponse(io.undertow.server.HttpServerExchange exchange)
  • Method Details

    • init

      public static MongoResponse init(io.undertow.server.HttpServerExchange exchange)
    • of

      public static MongoResponse of(io.undertow.server.HttpServerExchange exchange)
    • readContent

      public String readContent()
      Description copied from class: ServiceResponse
      Reads the content as a String. This method is used by ResponseSender to generate the response content to send to the client.
      Overrides:
      readContent in class BsonResponse
      Returns:
      the content as string
    • getDbOperationResult

      public OperationResult getDbOperationResult()
      Returns:
      the dbOperationResult
    • setDbOperationResult

      public void setDbOperationResult(OperationResult dbOperationResult)
      Parameters:
      dbOperationResult - the dbOperationResult to set
    • getWarnings

      public List<String> getWarnings()
      Returns:
      the warnings
    • addWarning

      public void addWarning(String warning)
      Parameters:
      warning -
    • setInError

      public void setInError(int code, String message, Throwable t)
      Overrides:
      setInError in class BsonResponse
      Parameters:
      code -
      message -
      t -
    • getCount

      public long getCount()
      Returns:
      the count
    • setCount

      public void setCount(long count)
      Parameters:
      count - the count to set
    • rollback

      public void rollback(com.mongodb.client.MongoClient mclient) throws Exception
      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