Package org.restheart.mongodb.utils
Class URLUtils
- java.lang.Object
-
- org.restheart.mongodb.utils.URLUtils
-
public class URLUtils extends Object
- Author:
- Andrea Di Cesare <[email protected]>
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ExchangeKeys.DOC_ID_TYPE
checkId(org.bson.BsonValue id)
static String
decodeQueryString(String qs)
decode the percent encoded query stringstatic org.bson.BsonValue
getDocumentIdFromURI(String id, ExchangeKeys.DOC_ID_TYPE type)
Gets the id as object from its string representation in the document URI NOTE: for POST the special string id are checked by BodyInjectorHandler.checkSpecialStringId()static String
getIdString(org.bson.BsonValue id)
static String
getParentPath(String path)
static String
getQueryStringRemovingParams(io.undertow.server.HttpServerExchange exchange, String... paramsToRemove)
static String
getRemappedRequestURL(io.undertow.server.HttpServerExchange exchange)
returns the request URL taking into account the instance-base-url configuration option.static String
getUriWithDocId(MongoRequest request, String dbName, String collName, org.bson.BsonValue id)
static String
getUriWithFilterMany(MongoRequest request, String dbName, String collName, org.bson.BsonValue[] ids)
static String
getUriWithFilterManyInverse(MongoRequest request, String dbName, String collName, String referenceField, org.bson.BsonValue id)
static String
getUriWithFilterOne(MongoRequest request, String dbName, String collName, String referenceField, org.bson.BsonValue id)
static String
removeTrailingSlashes(String s)
given string /ciao/this/has/trailings///// returns /ciao/this/has/trailings
-
-
-
Method Detail
-
checkId
public static ExchangeKeys.DOC_ID_TYPE checkId(org.bson.BsonValue id) throws UnsupportedDocumentIdException
- Parameters:
id
-- Returns:
- Throws:
UnsupportedDocumentIdException
-
getDocumentIdFromURI
public static org.bson.BsonValue getDocumentIdFromURI(String id, ExchangeKeys.DOC_ID_TYPE type) throws UnsupportedDocumentIdException
Gets the id as object from its string representation in the document URI NOTE: for POST the special string id are checked by BodyInjectorHandler.checkSpecialStringId()- Parameters:
id
-type
-- Returns:
- Throws:
UnsupportedDocumentIdException
-
removeTrailingSlashes
public static String removeTrailingSlashes(String s)
given string /ciao/this/has/trailings///// returns /ciao/this/has/trailings- Parameters:
s
-- Returns:
- the string s without the trailing slashes
-
decodeQueryString
public static String decodeQueryString(String qs)
decode the percent encoded query string- Parameters:
qs
-- Returns:
- the undecoded string
-
getRemappedRequestURL
public static String getRemappedRequestURL(io.undertow.server.HttpServerExchange exchange)
returns the request URL taking into account the instance-base-url configuration option. When RESTHeart is exposed via a reverse-proxy or an API gateway it allows mapping the Location header correctly.- Parameters:
exchange
-- Returns:
-
getUriWithDocId
public static String getUriWithDocId(MongoRequest request, String dbName, String collName, org.bson.BsonValue id) throws UnsupportedDocumentIdException
- Parameters:
request
-dbName
-collName
-id
-- Returns:
- Throws:
UnsupportedDocumentIdException
-
getUriWithFilterMany
public static String getUriWithFilterMany(MongoRequest request, String dbName, String collName, org.bson.BsonValue[] ids) throws UnsupportedDocumentIdException
- Parameters:
request
-dbName
-collName
-ids
-- Returns:
- Throws:
UnsupportedDocumentIdException
-
getUriWithFilterOne
public static String getUriWithFilterOne(MongoRequest request, String dbName, String collName, String referenceField, org.bson.BsonValue id) throws UnsupportedDocumentIdException
- Parameters:
request
-dbName
-collName
-referenceField
-id
-- Returns:
- Throws:
UnsupportedDocumentIdException
-
getUriWithFilterManyInverse
public static String getUriWithFilterManyInverse(MongoRequest request, String dbName, String collName, String referenceField, org.bson.BsonValue id) throws UnsupportedDocumentIdException
- Parameters:
request
-dbName
-collName
-referenceField
-id
-- Returns:
- Throws:
UnsupportedDocumentIdException
-
getQueryStringRemovingParams
public static String getQueryStringRemovingParams(io.undertow.server.HttpServerExchange exchange, String... paramsToRemove)
- Parameters:
exchange
-paramsToRemove
-- Returns:
-
getIdString
public static String getIdString(org.bson.BsonValue id) throws UnsupportedDocumentIdException
- Parameters:
id
-- Returns:
- Throws:
UnsupportedDocumentIdException
-
-