Package org.restheart.mongodb.utils
Class URLUtils
java.lang.Object
org.restheart.mongodb.utils.URLUtils
- Author:
- Andrea Di Cesare <andrea@softinstigate.com>
-
Method Summary
Modifier and TypeMethodDescriptionstatic ExchangeKeys.DOC_ID_TYPEcheckId(org.bson.BsonValue id)static StringdecodeQueryString(String qs)decode the percent encoded query stringstatic org.bson.BsonValuegetDocumentIdFromURI(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 StringgetIdString(org.bson.BsonValue id)static StringgetParentPath(String path)static StringgetQueryStringRemovingParams(io.undertow.server.HttpServerExchange exchange, String... paramsToRemove)static StringgetRemappedRequestURL(io.undertow.server.HttpServerExchange exchange)returns the request URL taking into account the instance-base-url configuration option.static StringgetUriWithDocId(MongoRequest request, String dbName, String collName, org.bson.BsonValue id)static StringgetUriWithFilterMany(MongoRequest request, String dbName, String collName, org.bson.BsonValue[] ids)static StringgetUriWithFilterManyInverse(MongoRequest request, String dbName, String collName, String referenceField, org.bson.BsonValue id)static StringgetUriWithFilterOne(MongoRequest request, String dbName, String collName, String referenceField, org.bson.BsonValue id)static Stringgiven string /ciao/this/has/trailings///// returns /ciao/this/has/trailings
-
Method Details
-
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 UnsupportedDocumentIdExceptionGets 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
given string /ciao/this/has/trailings///// returns /ciao/this/has/trailings- Parameters:
s-- Returns:
- the string s without the trailing slashes
-
decodeQueryString
decode the percent encoded query string- Parameters:
qs-- Returns:
- the undecoded string
-
getParentPath
- Parameters:
path-- Returns:
-
getRemappedRequestURL
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
- Parameters:
id-- Returns:
- Throws:
UnsupportedDocumentIdException
-