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
FieldsFields inherited from class org.graylog2.database.PaginatedDbService
db -
Constructor Summary
ConstructorsConstructorDescriptionScopedDbService(MongoConnection mongoConnection, MongoJackObjectMapperProvider mapper, Class<E> dtoClass, String collectionName, EntityScopeService entityScopeService) -
Method Summary
Modifier and TypeMethodDescriptionfinal intDeletes thePaginatedDbServicefor the given ID from the database.final voidensureDeletability(E entity) final voidensureMutability(E entity) final voidensureValidScope(E entity) final intforceDelete(String id) Deletes an entity without checking for deletability.final booleanisDeletable(ScopedEntity scopedEntity) final booleanisMutable(ScopedEntity scopedEntity) Stores the givenPaginatedDbServicein 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:PaginatedDbServiceStores the givenPaginatedDbServicein the database.- Overrides:
savein classPaginatedDbService<E extends ScopedEntity>- Parameters:
entity- thePaginatedDbServiceto save- Returns:
- the newly saved
PaginatedDbService
-
ensureValidScope
-
ensureMutability
-
ensureDeletability
-
delete
Description copied from class:PaginatedDbServiceDeletes thePaginatedDbServicefor the given ID from the database.- Overrides:
deletein classPaginatedDbService<E extends ScopedEntity>- Parameters:
id- ID of thePaginatedDbServiceto 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.
-