Class JsonSchemaBeforeWriteChecker
- java.lang.Object
-
- org.restheart.mongodb.interceptors.JsonSchemaBeforeWriteChecker
-
- All Implemented Interfaces:
ConfigurablePlugin,ExchangeTypeResolver<MongoRequest,MongoResponse>,Interceptor<MongoRequest,MongoResponse>,MongoInterceptor,Plugin
- Direct Known Subclasses:
JsonSchemaAfterWriteChecker
public class JsonSchemaBeforeWriteChecker extends Object implements MongoInterceptor
Checks documents according to the specified JSON schema This intercetor is able to check PUT and POST requests that don't use update operators. PATCH requests are checked by jsonSchemaAfterWrite
Note that checking bulk PATCH, i.e. PATCH /coll/*, is not supported. In this case the optional metadata property 'skipNotSuppored' controls the behaviour: if true, the request is not checked and executed, if false the request fails. It checks the request content against the JSON schema specified by the 'jsonSchema' collection metadata:
{ "jsonSchema": { "schemaId": <schemaId> "schemaStoreDb": <schemaStoreDb>, "skipNotSupported": <boolean> } }
schemaStoreDb is optional, default value is same db, skipNotSuppored is optional, defaul value is false- Author:
- Andrea Di Cesare <andrea@softinstigate.com>
-
-
Field Summary
Fields Modifier and Type Field Description static StringSCHEMA_ID_PROPERTYstatic StringSCHEMA_STORE_DB_PROPERTYstatic StringSKIP_NOT_SUPPORTED_PROPERTY
-
Constructor Summary
Constructors Constructor Description JsonSchemaBeforeWriteChecker()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidhandle(MongoRequest request, MongoResponse response)booleanresolve(MongoRequest request, MongoResponse response)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.restheart.plugins.ExchangeTypeResolver
requestType, responseType
-
-
-
-
Field Detail
-
SCHEMA_STORE_DB_PROPERTY
public static final String SCHEMA_STORE_DB_PROPERTY
- See Also:
- Constant Field Values
-
SCHEMA_ID_PROPERTY
public static final String SCHEMA_ID_PROPERTY
- See Also:
- Constant Field Values
-
SKIP_NOT_SUPPORTED_PROPERTY
public static final String SKIP_NOT_SUPPORTED_PROPERTY
- See Also:
- Constant Field Values
-
-
Method Detail
-
handle
public void handle(MongoRequest request, MongoResponse response) throws Exception
- Specified by:
handlein interfaceInterceptor<MongoRequest,MongoResponse>- Throws:
Exception
-
resolve
public boolean resolve(MongoRequest request, MongoResponse response)
- Specified by:
resolvein interfaceInterceptor<MongoRequest,MongoResponse>
-
-