Class MongoRequest


  • public class MongoRequest
    extends BsonRequest
    Request implementation used by MongoService and backed by BsonValue that provides simplified methods to deal with headers and query parameters specific to mongo requests
    Author:
    Andrea Di Cesare
    • Constructor Detail

      • MongoRequest

        protected MongoRequest​(io.undertow.server.HttpServerExchange exchange,
                               String requestUri,
                               String resourceUri)
    • Method Detail

      • init

        public static MongoRequest init​(io.undertow.server.HttpServerExchange exchange,
                                        String requestUri,
                                        String resourceUri)
        Parameters:
        exchange - the exchange request path (mapped uri) is rewritten replacing the resourceUri with the requestUri the special resourceUri value * means any resource: the requestUri is mapped to the root resource / example 1 resourceUri = /db/mycollection requestUri = / then the requestPath / is rewritten to /db/mycollection example 2 resourceUri = * requestUri = /data then the requestPath /data is rewritten to /
        requestUri - the request URI to map to the resource URI
        resourceUri - the resource URI identifying a resource in the DB
        Returns:
        the MongoRequest
      • of

        public static MongoRequest of​(io.undertow.server.HttpServerExchange exchange)
      • type

        public static Type type()
      • isReservedDbName

        public static boolean isReservedDbName​(String dbName)
        Parameters:
        dbName -
        Returns:
        true if the dbName is a reserved resource
      • isReservedCollectionName

        public static boolean isReservedCollectionName​(String collectionName)
        Parameters:
        collectionName -
        Returns:
        true if the collectionName is a reserved resource
      • isReservedDocumentId

        public static boolean isReservedDocumentId​(ExchangeKeys.TYPE type,
                                                   org.bson.BsonValue documentId)
        Parameters:
        type -
        documentId -
        Returns:
        true if the documentIdRaw is a reserved resource
      • mapUri

        public String mapUri​(String unmappedUri)
        given a canonical uri (/db/coll) returns the mapped uri (/some/mapping/uri) relative to this context. URLs are mapped to mongodb resources via the mongo-mounts configuration properties
        Parameters:
        unmappedUri -
        Returns:
      • isParentAccessible

        public boolean isParentAccessible()
        check if the parent of the requested resource is accessible in this request context for instance if /db/mycollection is mapped to /coll then: the db is accessible from the collection the root is not accessible from the collection (since / is actually mapped to the db)
        Returns:
        true if parent of the requested resource is accessible
      • getDBName

        public String getDBName()
        Returns:
        DB Name
      • getCollectionName

        public String getCollectionName()
        Returns:
        collection name
      • getDocumentIdRaw

        public String getDocumentIdRaw()
        Returns:
        document id
      • getIndexId

        public String getIndexId()
        Returns:
        index id
      • getSid

        public String getSid()
        Returns:
        the txn id or null if request type is not SESSIONS, TRANSACTIONS or TRANSACTION
      • getTxnId

        public long getTxnId()
        Returns:
        the txn id or null if request type is not TRANSACTION
      • getAggregationOperation

        public String getAggregationOperation()
        Returns:
        collection name
      • getChangeStreamOperation

        public String getChangeStreamOperation()
        Returns:
        change stream operation name
      • getChangeStreamIdentifier

        public String getChangeStreamIdentifier()
        Returns:
      • isReservedResource

        public boolean isReservedResource()
        Returns:
        isReservedResource
      • getUriPrefix

        public String getUriPrefix()
        Returns:
        the whereUri
      • getMappingUri

        public String getMappingUri()
        Returns:
        the whatUri
      • getPage

        public int getPage()
        Returns:
        the page
      • setPage

        public void setPage​(int page)
        Parameters:
        page - the page to set
      • getPagesize

        public int getPagesize()
        Returns:
        the pagesize
      • setPagesize

        public void setPagesize​(int pagesize)
        Parameters:
        pagesize - the pagesize to set
      • setRepresentationFormat

        public void setRepresentationFormat​(ExchangeKeys.REPRESENTATION_FORMAT representationFormat)
        sets representationFormat
        Parameters:
        representationFormat -
      • isCount

        public boolean isCount()
        Returns:
        the count
      • setCount

        public void setCount​(boolean count)
        Parameters:
        count - the count to set
      • getFilter

        public Deque<String> getFilter()
        Returns:
        the filter
      • setFilter

        public void setFilter​(Deque<String> filter)
        Parameters:
        filter - the filter to set
      • getHint

        public Deque<String> getHint()
        Returns:
        the hint
      • setHint

        public void setHint​(Deque<String> hint)
        Parameters:
        hint - the hint to set
      • getFiltersDocument

        public org.bson.BsonDocument getFiltersDocument()
                                                 throws org.bson.json.JsonParseException
        Returns:
        the $and composed filter qparam values
        Throws:
        org.bson.json.JsonParseException
      • getSortByDocument

        public org.bson.BsonDocument getSortByDocument()
                                                throws org.bson.json.JsonParseException
        Returns:
        Throws:
        org.bson.json.JsonParseException
      • getHintDocument

        public org.bson.BsonDocument getHintDocument()
                                              throws org.bson.json.JsonParseException
        Returns:
        Throws:
        org.bson.json.JsonParseException
      • getProjectionDocument

        public org.bson.BsonDocument getProjectionDocument()
                                                    throws org.bson.json.JsonParseException
        Returns:
        Throws:
        org.bson.json.JsonParseException
      • getAggreationVars

        public org.bson.BsonDocument getAggreationVars()
        Returns:
        the aggregationVars
      • setAggregationVars

        public void setAggregationVars​(org.bson.BsonDocument aggregationVars)
        Parameters:
        aggregationVars - the aggregationVars to set
      • getSortBy

        public Deque<String> getSortBy()
        Returns:
        the sortBy
      • setSortBy

        public void setSortBy​(Deque<String> sortBy)
        Parameters:
        sortBy - the sortBy to set
      • getCollectionProps

        public org.bson.BsonDocument getCollectionProps()
        Returns:
        the collectionProps
      • setCollectionProps

        public void setCollectionProps​(org.bson.BsonDocument collectionProps)
        Parameters:
        collectionProps - the collectionProps to set
      • getDbProps

        public org.bson.BsonDocument getDbProps()
        Returns:
        the dbProps
      • setDbProps

        public void setDbProps​(org.bson.BsonDocument dbProps)
        Parameters:
        dbProps - the dbProps to set
      • getUnmappedRequestUri

        public String getUnmappedRequestUri()
        The unmapped uri is the cononical uri of a mongodb resource (e.g. /db/coll).
        Returns:
        the unmappedUri
      • getMappedRequestUri

        public String getMappedRequestUri()
        The mapped uri is the exchange request uri. This is "mapped" by the mongo-mounts mapping paramenters.
        Returns:
        the mappedUri
      • getPathTemplateParamenters

        public Map<String,​String> getPathTemplateParamenters()
        if mongo-mounts specifies a path template (i.e. /{foo}/*) this returns the request template parameters (/x/y => foo=x, *=y)
        Returns:
      • setDocIdType

        public void setDocIdType​(ExchangeKeys.DOC_ID_TYPE docIdType)
        Parameters:
        docIdType - the docIdType to set
      • setDocumentId

        public void setDocumentId​(org.bson.BsonValue documentId)
        Parameters:
        documentId - the documentId to set
      • getDocumentId

        public org.bson.BsonValue getDocumentId()
        Returns:
        the documentId
      • getClientSession

        public ClientSessionImpl getClientSession()
        Returns:
        the clientSession
      • setClientSession

        public void setClientSession​(ClientSessionImpl clientSession)
        Parameters:
        clientSession - the clientSession to set
      • getJsonMode

        public org.bson.json.JsonMode getJsonMode()
        Returns:
        the jsonMode as specified by jsonMode query paramter
      • getFilePath

        public Path getFilePath()
        Returns:
        the filePath
      • setFilePath

        public void setFilePath​(Path filePath)
        Parameters:
        filePath - the filePath to set
      • getKeys

        public Deque<String> getKeys()
        Returns:
        keys
      • setKeys

        public void setKeys​(Deque<String> keys)
        Parameters:
        keys - keys to set
      • isFullHalMode

        public boolean isFullHalMode()
        Returns:
      • setHalMode

        public void setHalMode​(ExchangeKeys.HAL_MODE halMode)
        Parameters:
        halMode - the halMode to set
      • isDbNameInvalid

        public boolean isDbNameInvalid()
        Returns:
      • getRequestStartTime

        public long getRequestStartTime()
        Returns:
      • isDbNameInvalid

        public boolean isDbNameInvalid​(String dbName)
        Parameters:
        dbName -
        Returns:
      • isDbNameInvalidOnWindows

        public boolean isDbNameInvalidOnWindows()
        Returns:
      • isDbNameInvalidOnWindows

        public boolean isDbNameInvalidOnWindows​(String dbName)
        Parameters:
        dbName -
        Returns:
      • isCollectionNameInvalid

        public boolean isCollectionNameInvalid()
        Returns:
      • isCollectionNameInvalid

        public boolean isCollectionNameInvalid​(String collectionName)
        Parameters:
        collectionName -
        Returns:
      • getETag

        public String getETag()
        Returns:
      • getShardKey

        public org.bson.BsonDocument getShardKey()
        Returns:
        the shardKey
      • setShardKey

        public void setShardKey​(org.bson.BsonDocument shardKey)
        Parameters:
        shardKey - the shardKey to set
      • isNoProps

        public boolean isNoProps()
        Returns:
        the noProps
      • setNoProps

        public void setNoProps​(boolean noProps)
        Parameters:
        noProps - the noProps to set
      • getAuthenticatedAccount

        public io.undertow.security.idm.Account getAuthenticatedAccount()
        Overrides:
        getAuthenticatedAccount in class Request<org.bson.BsonValue>
        Returns:
        the authenticatedAccount
      • setAuthenticatedAccount

        public void setAuthenticatedAccount​(io.undertow.security.idm.Account authenticatedAccount)
        Parameters:
        authenticatedAccount - the authenticatedAccount to set
      • isAggregation

        public boolean isAggregation()
        helper method to check request resource type
        Returns:
        true if type is TYPE.AGGREGATION
      • isBulkDocuments

        public boolean isBulkDocuments()
        helper method to check request resource type
        Returns:
        true if type is TYPE.BULK_DOCUMENTS
      • isCollection

        public boolean isCollection()
        helper method to check request resource type
        Returns:
        true if type is TYPE.COLLECTION
      • isCollectionIndexes

        public boolean isCollectionIndexes()
        helper method to check request resource type
        Returns:
        true if type is TYPE.COLLECTION_INDEXES
      • isDb

        public boolean isDb()
        helper method to check request resource type
        Returns:
        true if type is TYPE.DB
      • isDocument

        public boolean isDocument()
        helper method to check request resource type
        Returns:
        true if type is TYPE.DOCUMENT
      • isFile

        public boolean isFile()
        helper method to check request resource type
        Returns:
        true if type is TYPE.FILE
      • isFilesBucket

        public boolean isFilesBucket()
        helper method to check request resource type
        Returns:
        true if type is TYPE.FILES_BUCKET
      • isFileBinary

        public boolean isFileBinary()
        helper method to check request resource type
        Returns:
        true if type is TYPE.FILE_BINARY
      • isIndex

        public boolean isIndex()
        helper method to check request resource type
        Returns:
        true if type is TYPE.INDEX
      • isRoot

        public boolean isRoot()
        helper method to check request resource type
        Returns:
        true if type is TYPE.ROOT
      • isSessions

        public boolean isSessions()
        helper method to check request resource type
        Returns:
        true if type is TYPE.TRANSACTIONS
      • isTxns

        public boolean isTxns()
        helper method to check request resource type
        Returns:
        true if type is TYPE.TRANSACTIONS
      • isTxn

        public boolean isTxn()
        helper method to check request resource type
        Returns:
        true if type is TYPE.TRANSACTION
      • isSchema

        public boolean isSchema()
        helper method to check request resource type
        Returns:
        true if type is TYPE.SCHEMA
      • isSchemaStore

        public boolean isSchemaStore()
        helper method to check request resource type
        Returns:
        true if type is TYPE.SCHEMA_STORE
      • isRootSize

        public boolean isRootSize()
        helper method to check request resource type
        Returns:
        true if type is TYPE.ROOT_SIZE
      • isDbSize

        public boolean isDbSize()
        helper method to check request resource type
        Returns:
        true if type is TYPE.DB_SIZE
      • isDbMeta

        public boolean isDbMeta()
        helper method to check request resource type
        Returns:
        true if type is TYPE.DB_META
      • isCollectionSize

        public boolean isCollectionSize()
        helper method to check request resource type
        Returns:
        true if type is TYPE.COLLECTION_SIZE
      • isCollectionMeta

        public boolean isCollectionMeta()
        helper method to check request resource type
        Returns:
        true if type is TYPE.COLLECTION_META
      • isFilesBucketSize

        public boolean isFilesBucketSize()
        helper method to check request resource type
        Returns:
        true if type is TYPE.FILES_BUCKET_SIZE
      • isFilesBucketMeta

        public boolean isFilesBucketMeta()
        helper method to check request resource type
        Returns:
        true if type is TYPE.FILES_BUCKET_META
      • isSchemaStoreSize

        public boolean isSchemaStoreSize()
        helper method to check request resource type
        Returns:
        true if type is TYPE.SCHEMA_STORE_SIZE
      • isSchemaStoreMeta

        public boolean isSchemaStoreMeta()
        helper method to check request resource type
        Returns:
        true if type is TYPE.SCHEMA_STORE_SIZE
      • isMetrics

        public boolean isMetrics()
        helper method to check request resource type
        Returns:
        true if type is TYPE.METRICS
      • isWriteDocument

        public boolean isWriteDocument()
        helper method to check if a request writes a document or a file or a schema
        Returns:
        true if the request writes a document or a file or a schema
      • isETagCheckRequired

        public boolean isETagCheckRequired()
        Returns:
        the isETagCheckRequired
      • setETagCheckRequired

        public void setETagCheckRequired​(boolean etagCheckRequired)
        Parameters:
        etagCheckRequired -
      • isForceEtagCheck

        public boolean isForceEtagCheck()
        Returns:
        the forceEtagCheck