Class ScopedEntityMongoUtils<T extends ScopedEntity>

java.lang.Object
org.graylog2.database.utils.ScopedEntityMongoUtils<T>

public class ScopedEntityMongoUtils<T extends ScopedEntity> extends Object
  • Constructor Details

    • ScopedEntityMongoUtils

      public ScopedEntityMongoUtils(com.mongodb.client.MongoCollection<T> delegate, EntityScopeService entityScopeService)
  • Method Details

    • update

      public T update(T entity)
      Performs a valid scope and mutability check before updating an existing entity.
      Parameters:
      entity - ScopedEntity to be updated
      Returns:
      the newly updated entity
    • create

      public String create(T entity)
      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

      public boolean deleteById(String id)
      Convenience method to delete a single document identified by its ID after performing mutability checks.
      Parameters:
      id - Hex string representation of the document's ObjectId.
      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

      public final long forceDelete(String id)
      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

      public final boolean isMutable(T scopedEntity)
    • isDeletable

      public final boolean isDeletable(T scopedEntity)
    • ensureValidScope

      public final void ensureValidScope(T entity)
    • ensureMutability

      public final void ensureMutability(T entity)
    • ensureDeletability

      public final void ensureDeletability(T entity)