Package de.terrestris.shoguncore.service
Class PermissionAwareCrudService<E extends PersistentObject,D extends GenericHibernateDao<E,Integer>>
- java.lang.Object
-
- de.terrestris.shoguncore.service.AbstractDaoService<E,D>
-
- de.terrestris.shoguncore.service.AbstractCrudService<E,D>
-
- de.terrestris.shoguncore.service.PermissionAwareCrudService<E,D>
-
- Direct Known Subclasses:
AbstractTokenService,ApplicationService,ButtonService,ExtentService,FileService,InterceptorRuleService,LayerAppearanceService,LayerDataSourceService,LayerService,LayoutService,MapConfigService,MapControlService,ModuleService,PersonService,PluginService,RoleService,TileGridService,TreeFolderService,TreeNodeService,UserGroupService,WpsParameterService
@Service("permissionAwareCrudService") public class PermissionAwareCrudService<E extends PersistentObject,D extends GenericHibernateDao<E,Integer>> extends AbstractCrudService<E,D>- Author:
- Nils Bühner
- See Also:
AbstractCrudService
-
-
Field Summary
Fields Modifier and Type Field Description protected PermissionCollectionService<PermissionCollection,PermissionCollectionDao<PermissionCollection>>permissionCollectionService-
Fields inherited from class de.terrestris.shoguncore.service.AbstractDaoService
dao, logger
-
-
Constructor Summary
Constructors Modifier Constructor Description PermissionAwareCrudService()Default constructor, which calls the type-constructorprotectedPermissionAwareCrudService(Class<E> entityClass)Constructor that sets the concrete entity class for the service.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAndSaveGroupPermissions(E entity, UserGroup userGroup, Permission... permissions)This method adds (user) permissions to the passed entity and persists (!) the permission collection! If no permissions have been set before, they will be created.voidaddAndSaveUserPermissions(E entity, User user, Permission... permissions)This method adds (user) permissions to the passed entity and persists (!) the permission collection! If no permissions have been set before, they will be created.Map<PersistentObject,PermissionCollection>findAllUserGroupPermissionsOfUserGroup(UserGroup userGroup)This method returns aMapthat mapsPersistentObjects to PermissionCollections for the passedUserGroup.Map<PersistentObject,PermissionCollection>findAllUserPermissionsOfUser(User user)PermissionCollectionService<PermissionCollection,PermissionCollectionDao<PermissionCollection>>getPermissionCollectionService()voidremoveAndSaveGroupPermissions(E entity, UserGroup userGroup, Permission... permissions)This method removes (group) permissions from the passed entity and persists (!) the permission collection!voidremoveAndSaveUserPermissions(E entity, User user, Permission... permissions)This method removes (user) permissions from the passed entity and persists (!) the permission collection!voidsetDao(D dao)Subclasses must implement this class and annotate it withAutowiredandQualifier! This is necessary as there may be multiple candidates to autowire (due to hierarchy) and we have to configure the correct ones.voidsetPermissionCollectionService(PermissionCollectionService<PermissionCollection,PermissionCollectionDao<PermissionCollection>> permissionCollectionService)-
Methods inherited from class de.terrestris.shoguncore.service.AbstractCrudService
delete, findAll, findAllRestricted, findAllWhereFieldEquals, findAllWithCollectionContaining, findById, findBySimpleFilter, loadById, saveOrUpdate, updatePartialWithJsonNode
-
Methods inherited from class de.terrestris.shoguncore.service.AbstractDaoService
getDao, getEntityClass
-
-
-
-
Field Detail
-
permissionCollectionService
@Autowired @Qualifier("permissionCollectionService") protected PermissionCollectionService<PermissionCollection,PermissionCollectionDao<PermissionCollection>> permissionCollectionService
-
-
Method Detail
-
setDao
@Autowired @Qualifier("genericDao") public void setDao(D dao)Description copied from class:AbstractDaoServiceSubclasses must implement this class and annotate it withAutowiredandQualifier! This is necessary as there may be multiple candidates to autowire (due to hierarchy) and we have to configure the correct ones.- Specified by:
setDaoin classAbstractDaoService<E extends PersistentObject,D extends GenericHibernateDao<E,Integer>>- Parameters:
dao- the dao to set
-
addAndSaveUserPermissions
public void addAndSaveUserPermissions(E entity, User user, Permission... permissions)
This method adds (user) permissions to the passed entity and persists (!) the permission collection! If no permissions have been set before, they will be created. Otherwise the passed permissions will be added to the existing permission collection.- Parameters:
entity- The secured entityuser- The user that gets permissions for the entitypermissions- The permissions the user gets for the entity
-
removeAndSaveUserPermissions
public void removeAndSaveUserPermissions(E entity, User user, Permission... permissions)
This method removes (user) permissions from the passed entity and persists (!) the permission collection!- Parameters:
entity- The secured entityuser- The user from which the permissions for the entity will be removedpermissions- The permissions to remove
-
addAndSaveGroupPermissions
public void addAndSaveGroupPermissions(E entity, UserGroup userGroup, Permission... permissions)
This method adds (user) permissions to the passed entity and persists (!) the permission collection! If no permissions have been set before, they will be created. Otherwise the passed permissions will be added to the existing permission collection.- Parameters:
entity- The secured entityuserGroup- The user group that gets permissions for the entitypermissions- The permissions the user group gets for the entity
-
removeAndSaveGroupPermissions
public void removeAndSaveGroupPermissions(E entity, UserGroup userGroup, Permission... permissions)
This method removes (group) permissions from the passed entity and persists (!) the permission collection!- Parameters:
entity- The secured entityuserGroup- The user group from which the permissions for the entity will be removedpermissions- The permissions to remove
-
findAllUserPermissionsOfUser
@PreAuthorize("hasRole(@configHolder.getSuperAdminRoleName()) or hasPermission(#user, \'READ\')") @Transactional(readOnly=true) public Map<PersistentObject,PermissionCollection> findAllUserPermissionsOfUser(User user)This method returns aMapthat mapsPersistentObjects to PermissionCollections for the passedUser. I.e. the keySet of the map is the collection of allPersistentObjects where the user has at least one permission and the corresponding value contains thePermissionCollectionfor the passed user on the entity.- Parameters:
user-- Returns:
-
findAllUserGroupPermissionsOfUserGroup
@PreAuthorize("hasRole(@configHolder.getSuperAdminRoleName()) or hasPermission(#userGroup, \'READ\')") @Transactional(readOnly=true) public Map<PersistentObject,PermissionCollection> findAllUserGroupPermissionsOfUserGroup(UserGroup userGroup)This method returns aMapthat mapsPersistentObjects to PermissionCollections for the passedUserGroup. I.e. the keySet of the map is the collection of allPersistentObjects where the user group has at least one permission and the corresponding value contains thePermissionCollectionfor the passed user group on the entity.- Parameters:
userGroup-- Returns:
-
getPermissionCollectionService
public PermissionCollectionService<PermissionCollection,PermissionCollectionDao<PermissionCollection>> getPermissionCollectionService()
- Returns:
- the permissionCollectionService
-
setPermissionCollectionService
public void setPermissionCollectionService(PermissionCollectionService<PermissionCollection,PermissionCollectionDao<PermissionCollection>> permissionCollectionService)
- Parameters:
permissionCollectionService- the permissionCollectionService to set
-
-