Package org.graylog2.database.entities
Class ScopedDbService<E extends ScopedEntity>
java.lang.Object
org.graylog2.database.PaginatedDbService<E>
org.graylog2.database.entities.ScopedDbService<E>
- Type Parameters:
E
- type parameter for aScopedEntity
's subclass.
- Direct Known Subclasses:
DBCacheService
,DBDataAdapterService
,DBEventDefinitionService
,DBLookupTableService
A base database service to handle persistence and deletion of
ScopedEntity
instance.
Persistence and deletion is performed by the parent class, PaginatedDbService
,
this service simply performs mutability checks.
A EntityScopeService
is used to perform the actual mutability checks based on the entity's scope.
-
Field Summary
Fields inherited from class org.graylog2.database.PaginatedDbService
db
-
Constructor Summary
ConstructorDescriptionScopedDbService
(MongoConnection mongoConnection, MongoJackObjectMapperProvider mapper, Class<E> dtoClass, String collectionName, EntityScopeService entityScopeService) -
Method Summary
Modifier and TypeMethodDescriptionfinal int
Deletes thePaginatedDbService
for the given ID from the database.final void
ensureDeletability
(E entity) final void
ensureMutability
(E entity) final void
ensureValidScope
(E entity) final int
forceDelete
(String id) Deletes an entity without checking for deletability.final boolean
isDeletable
(ScopedEntity scopedEntity) final boolean
isMutable
(ScopedEntity scopedEntity) Stores the givenPaginatedDbService
in the database.Methods inherited from class org.graylog2.database.PaginatedDbService
asImmutableList, findPaginatedWithQueryAndSort, findPaginatedWithQueryFilterAndSort, findPaginatedWithQueryFilterAndSortWithGrandTotal, get, getMultiFieldSortBuilder, getPage, getSortBuilder, streamAll, streamByIds, streamQuery, streamQueryWithSort
-
Field Details
-
entityScopeService
-
-
Constructor Details
-
ScopedDbService
public ScopedDbService(MongoConnection mongoConnection, MongoJackObjectMapperProvider mapper, Class<E> dtoClass, String collectionName, EntityScopeService entityScopeService)
-
-
Method Details
-
isMutable
-
isDeletable
-
save
Description copied from class:PaginatedDbService
Stores the givenPaginatedDbService
in the database.- Overrides:
save
in classPaginatedDbService<E extends ScopedEntity>
- Parameters:
entity
- thePaginatedDbService
to save- Returns:
- the newly saved
PaginatedDbService
-
ensureValidScope
-
ensureMutability
-
ensureDeletability
-
delete
Description copied from class:PaginatedDbService
Deletes thePaginatedDbService
for the given ID from the database.- Overrides:
delete
in classPaginatedDbService<E extends ScopedEntity>
- Parameters:
id
- ID of thePaginatedDbService
to delete- Returns:
- the number of deleted documents
-
forceDelete
Deletes an entity without checking for deletability. Do not call this method for API requests for the user interface.
-