Package org.graylog2.database.utils
Class ScopedEntityMongoUtils<T extends ScopedEntity>
java.lang.Object
org.graylog2.database.utils.ScopedEntityMongoUtils<T>
-
Constructor Summary
ConstructorsConstructorDescriptionScopedEntityMongoUtils(com.mongodb.client.MongoCollection<T> delegate, EntityScopeService entityScopeService) -
Method Summary
Modifier and TypeMethodDescriptionPerforms a valid scope check before inserting the entity into the DB.booleandeleteById(String id) Convenience method to delete a single document identified by its ID after performing mutability checks.booleandeleteById(org.bson.types.ObjectId id) Convenience method to delete a single document identified by its ID after performing mutability checks.final voidensureDeletability(T entity) final voidensureMutability(T entity) final voidensureValidScope(T entity) final longforceDelete(String id) Deletes an entity without checking for deletability.final booleanisDeletable(T scopedEntity) final booleanPerforms a valid scope and mutability check before updating an existing entity.
-
Constructor Details
-
ScopedEntityMongoUtils
public ScopedEntityMongoUtils(com.mongodb.client.MongoCollection<T> delegate, EntityScopeService entityScopeService)
-
-
Method Details
-
update
Performs a valid scope and mutability check before updating an existing entity.- Parameters:
entity- ScopedEntity to be updated- Returns:
- the newly updated entity
-
create
Performs a valid scope check before inserting the entity into the DB.- Parameters:
entity- ScopedEntity to be created- Returns:
- the ID of the newly created ScopedEntity
-
deleteById
Convenience method to delete a single document identified by its ID after performing mutability checks.- Parameters:
id- Hex string representation of the document'sObjectId.- Returns:
- true if a document was deleted, false otherwise.
-
deleteById
public boolean deleteById(org.bson.types.ObjectId id) Convenience method to delete a single document identified by its ID after performing mutability checks.- Parameters:
id- the document's id.- Returns:
- true if a document was deleted, false otherwise.
-
forceDelete
Deletes an entity without checking for deletability. Do not call this method for API requests for the user interface.- Parameters:
id- ID of the ScopedEntity to be deleted
-
isMutable
-
isDeletable
-
ensureValidScope
-
ensureMutability
-
ensureDeletability
-