Package org.restheart.exchange
Class MongoRequest
java.lang.Object
org.restheart.exchange.Exchange<T>
org.restheart.exchange.Request<T>
org.restheart.exchange.ServiceRequest<org.bson.BsonValue>
org.restheart.exchange.BsonRequest
org.restheart.exchange.MongoRequest
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 <[email protected]>
-
Field Summary
Fields inherited from class org.restheart.exchange.ServiceRequest
content
Fields inherited from class org.restheart.exchange.Request
PATCH, SLASH, UNDERSCORE
Fields inherited from class org.restheart.exchange.Exchange
APP_FORM_URLENCODED_TYPE, APPLICATION_PDF_TYPE, FORM_URLENCODED, HAL_JSON_MEDIA_TYPE, IN_ERROR_KEY, JSON_MEDIA_TYPE, LOGGER, MAX_BUFFERS, MAX_CONTENT_SIZE, MULTIPART, MULTIPART_FORM_DATA_TYPE, wrapped
-
Constructor Summary
ModifierConstructorDescriptionprotected
MongoRequest
(io.undertow.server.HttpServerExchange exchange, String requestUri, String resourceUri) -
Method Summary
Modifier and TypeMethodDescriptionorg.bson.BsonDocument
org.bson.BsonDocument
org.bson.BsonDocument
org.bson.BsonValue
getETag()
org.bson.BsonDocument
getHint()
org.bson.BsonDocument
org.bson.json.JsonMode
getKeys()
The mapped uri is the exchange request uri.int
getPage()
int
if mongo-mounts specifies a path template (i.e.org.bson.BsonDocument
long
org.bson.BsonDocument
getSid()
org.bson.BsonDocument
long
getTxnId()
getType()
The unmapped uri is the cononical uri of a mongodb resource (e.g.getUri()
static MongoRequest
boolean
helper method to check request resource typeboolean
helper method to check request resource typeboolean
helper method to check request resource typeboolean
helper method to check request resource typeboolean
helper method to check request resource typeboolean
Seehttps://docs.mongodb.org/v3.2/reference/limits/#naming-restrictionsboolean
isCollectionNameInvalid
(String collectionName) boolean
helper method to check request resource typeboolean
isCount()
boolean
isDb()
helper method to check request resource typeboolean
isDbMeta()
helper method to check request resource typeboolean
Seehttps://docs.mongodb.org/v3.2/reference/limits/#naming-restrictionsboolean
isDbNameInvalid
(String dbName) boolean
Seehttps://docs.mongodb.org/v3.2/reference/limits/#naming-restrictionsboolean
isDbNameInvalidOnWindows
(String dbName) boolean
isDbSize()
helper method to check request resource typeboolean
helper method to check request resource typeboolean
boolean
isFile()
helper method to check request resource typeboolean
helper method to check request resource typeboolean
helper method to check request resource typeboolean
helper method to check request resource typeboolean
helper method to check request resource typeboolean
boolean
boolean
isIndex()
helper method to check request resource typeboolean
helper method to check request resource typeboolean
boolean
boolean
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)static boolean
isReservedCollectionName
(String collectionName) static boolean
isReservedDbName
(String dbName) static boolean
isReservedDocumentId
(ExchangeKeys.TYPE type, org.bson.BsonValue documentId) boolean
boolean
isRoot()
helper method to check request resource typeboolean
helper method to check request resource typeboolean
isSchema()
helper method to check request resource typeboolean
helper method to check request resource typeboolean
helper method to check request resource typeboolean
helper method to check request resource typeboolean
helper method to check request resource typeboolean
isTxn()
helper method to check request resource typeboolean
isTxns()
helper method to check request resource typeboolean
helper method to check if a request writes a document or a file or a schemagiven a canonical uri (/db/coll) returns the mapped uri (/some/mapping/uri) relative to this context.static MongoRequest
of
(io.undertow.server.HttpServerExchange exchange) rsOps()
ReplicaSet connection otpionsvoid
setAggregationVars
(org.bson.BsonDocument aggregationVars) void
setClientSession
(ClientSessionImpl clientSession) void
setCollectionProps
(org.bson.BsonDocument collectionProps) void
setCount
(boolean count) void
setCursorAllocationPolicy
(ExchangeKeys.EAGER_CURSOR_ALLOCATION_POLICY cursorAllocationPolicy) void
setDbProps
(org.bson.BsonDocument dbProps) void
setDocIdType
(ExchangeKeys.DOC_ID_TYPE docIdType) void
setDocumentId
(org.bson.BsonValue documentId) void
setETagCheckRequired
(boolean etagCheckRequired) void
setFilePath
(Path filePath) void
void
setHalMode
(ExchangeKeys.HAL_MODE halMode) void
void
void
setNoProps
(boolean noProps) void
setPage
(int page) void
setPagesize
(int pagesize) void
setRepresentationFormat
(ExchangeKeys.REPRESENTATION_FORMAT representationFormat) sets representationFormatvoid
setShardKey
(org.bson.BsonDocument shardKey) void
void
setWriteMode
(ExchangeKeys.WRITE_MODE writeMode) static Type
type()
Methods inherited from class org.restheart.exchange.BsonRequest
init, injectContent
Methods inherited from class org.restheart.exchange.ServiceRequest
getContent, isHandledBy, of, setContent
Methods inherited from class org.restheart.exchange.Request
addXForwardedHeader, blockForTooManyRequests, getAuthenticatedAccount, getContentType, getContentType, getCookie, getHeader, getHeaders, getMethod, getPath, getPathParam, getPathParams, getPipelineInfo, getQueryParameterOfDefault, getQueryParameters, getQueryString, getRequestContentLength, getStartTime, getURL, getXForwardedHeaders, isBlockForTooManyRequests, isDelete, isGet, isOptions, isPatch, isPost, isPut, pipelineInfo, setContentLength, setContentType, setContentTypeAsJson, setHeader, setHeader, setPipelineInfo, setPipelineInfo, setStartTime
Methods 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
-
MongoRequest
-
-
Method Details
-
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 URIresourceUri
- the resource URI identifying a resource in the DB- Returns:
- the MongoRequest
-
of
-
type
-
isReservedDbName
- Parameters:
dbName
-- Returns:
- true if the dbName is a reserved resource
-
isReservedCollectionName
- Parameters:
collectionName
-- Returns:
- true if the collectionName is a reserved resource
-
isReservedDocumentId
- Parameters:
type
-documentId
-- Returns:
- true if the documentIdRaw is a reserved resource
-
getType
- Returns:
- type
-
mapUri
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
- Returns:
- DB Name
-
getCollectionName
- Returns:
- collection name
-
getDocumentIdRaw
- Returns:
- document id
-
getIndexId
- Returns:
- index id
-
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
- Returns:
- collection name
-
getChangeStreamOperation
- Returns:
- change stream operation name
-
getUri
- Returns:
- URI
- Throws:
URISyntaxException
-
isReservedResource
public boolean isReservedResource()- Returns:
- isReservedResource
-
getUriPrefix
- Returns:
- the whereUri
-
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
-
getRepresentationFormat
- Returns:
- the representationFormat
-
setRepresentationFormat
sets representationFormat- Parameters:
representationFormat
-
-
isCount
public boolean isCount()- Returns:
- the count
-
setCount
public void setCount(boolean count) - Parameters:
count
- the count to set
-
getFilter
- Returns:
- the filter
-
setFilter
- Parameters:
filter
- the filter to set
-
getHint
- Returns:
- the hint
-
setHint
- 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
-
getAggregationVars
public org.bson.BsonDocument getAggregationVars()- Returns:
- the aggregationVars
-
setAggregationVars
public void setAggregationVars(org.bson.BsonDocument aggregationVars) - Parameters:
aggregationVars
- the aggregationVars to set
-
getSortBy
- Returns:
- the sortBy
-
setSortBy
- 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
The unmapped uri is the cononical uri of a mongodb resource (e.g. /db/coll).- Returns:
- the unmappedUri
-
getMappedRequestUri
The mapped uri is the exchange request uri. This is "mapped" by the mongo-mounts mapping paramenters.- Returns:
- the mappedUri
-
getPathTemplateParamenters
if mongo-mounts specifies a path template (i.e. /{foo}/*) this returns the request template parameters (/x/y => foo=x, *=y)- Returns:
-
getCursorAllocationPolicy
- Returns:
- the cursorAllocationPolicy
-
setCursorAllocationPolicy
public void setCursorAllocationPolicy(ExchangeKeys.EAGER_CURSOR_ALLOCATION_POLICY cursorAllocationPolicy) - Parameters:
cursorAllocationPolicy
- the cursorAllocationPolicy to set
-
getDocIdType
- Returns:
- the docIdType
-
setDocIdType
- 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
- Returns:
- the clientSession
-
setClientSession
- Parameters:
clientSession
- the clientSession to set
-
getJsonMode
public org.bson.json.JsonMode getJsonMode()- Returns:
- the jsonMode as specified by jsonMode query paramter
-
getFilePath
- Returns:
- the filePath
-
setFilePath
- Parameters:
filePath
- the filePath to set
-
getKeys
- Returns:
- keys
-
setKeys
- Parameters:
keys
- keys to set
-
getHalMode
- Returns:
- the halMode
-
isFullHalMode
public boolean isFullHalMode()- Returns:
-
setHalMode
- Parameters:
halMode
- the halMode to set
-
isDbNameInvalid
public boolean isDbNameInvalid()Seehttps://docs.mongodb.org/v3.2/reference/limits/#naming-restrictions- Returns:
-
getRequestStartTime
public long getRequestStartTime()- Returns:
-
isDbNameInvalid
- Parameters:
dbName
- Seehttps://docs.mongodb.org/v3.2/reference/limits/#naming-restrictions- Returns:
-
isDbNameInvalidOnWindows
public boolean isDbNameInvalidOnWindows()Seehttps://docs.mongodb.org/v3.2/reference/limits/#naming-restrictions- Returns:
-
isDbNameInvalidOnWindows
- Parameters:
dbName
- Seehttps://docs.mongodb.org/v3.2/reference/limits/#naming-restrictions- Returns:
-
isCollectionNameInvalid
public boolean isCollectionNameInvalid()Seehttps://docs.mongodb.org/v3.2/reference/limits/#naming-restrictions- Returns:
-
isCollectionNameInvalid
- Parameters:
collectionName
- Seehttps://docs.mongodb.org/v3.2/reference/limits/#naming-restrictions- Returns:
-
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
-
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
-
-
getWriteMode
- Returns:
- the write mode
-
setWriteMode
- Parameters:
writeMode
- the write mode to set
-
isForceEtagCheck
public boolean isForceEtagCheck()- Returns:
- the forceEtagCheck
-
isNoCache
public boolean isNoCache()- Returns:
- the noCache
-
rsOps
ReplicaSet connection otpions- Returns:
- the rsOps
-