Package org.restheart.mongodb.exchange
Class BsonRequestContentInjector
- java.lang.Object
-
- org.restheart.mongodb.exchange.BsonRequestContentInjector
-
public class BsonRequestContentInjector extends Object
Injects the request content to MongoRequest from BufferedByteArrayRequest buffer also check the Content-Type header in case the content is not empty- Author:
- Andrea Di Cesare <andrea@softinstigate.com>
-
-
Constructor Summary
Constructors Constructor Description BsonRequestContentInjector()Creates a new instance of BodyInjectorHandler
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringcheckReservedId(org.bson.BsonValue content)Checks the _id in POST requests; it cannot be a string having a special meaning e.g _null, since the URI /db/coll/_null refers to the document with _id: nullstatic StringdetectMediaType(File file)Detect the file's mediatypeprotected static org.bson.BsonDocumentextractMetadata(io.undertow.server.handlers.form.FormData formData)Search the request for a field named 'metadata' (or 'properties') which must contain valid JSONstatic voidinject(io.undertow.server.HttpServerExchange exchange)
-
-
-
Method Detail
-
checkReservedId
public static String checkReservedId(org.bson.BsonValue content)
Checks the _id in POST requests; it cannot be a string having a special meaning e.g _null, since the URI /db/coll/_null refers to the document with _id: null- Parameters:
content-- Returns:
- null if ok, or the first not valid id
-
extractMetadata
protected static org.bson.BsonDocument extractMetadata(io.undertow.server.handlers.form.FormData formData) throws org.bson.json.JsonParseExceptionSearch the request for a field named 'metadata' (or 'properties') which must contain valid JSON- Parameters:
formData-- Returns:
- the parsed BsonDocument from the form data or an empty BsonDocument
- Throws:
org.bson.json.JsonParseException
-
detectMediaType
public static String detectMediaType(File file) throws IOException
Detect the file's mediatype- Parameters:
file- input file- Returns:
- the content-type as a String
- Throws:
IOException
-
inject
public static void inject(io.undertow.server.HttpServerExchange exchange)
- Parameters:
exchange-
-
-