Package com.alpaca.service.impl
Class RoleServiceImpl
- All Implemented Interfaces:
IGenericService<Role,,UUID> IRoleService
Service layer implementation for managing
Role entities and encapsulating business logic
specific to roles while inheriting basic CRUD operations from IGenericService.
Includes specialized methods for fetching user-default roles and retrieving roles by name, with validation and error handling for invalid inputs or missing entities.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindByRoleName(String roleName) Finds aRoleby its name.protected IGenericDAO<Role, UUID> getDAO()Provides the generic DAO used by inherited service methods.protected StringSupplies a user-friendly name representing the entity, used in exception messages and logs.Retrieves the default set of roles assigned to users.Methods inherited from class com.alpaca.service.impl.GenericServiceImpl
deleteById, existsAllByIds, existsById, existsByUniqueProperties, findAll, findAllByIds, findAllByIdsToSet, findAllPage, findById, save, saveAll, updateByIdMethods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.alpaca.service.IGenericService
deleteById, existsAllByIds, existsById, existsByUniqueProperties, findAll, findAllByIds, findAllByIdsToSet, findAllPage, findById, save, saveAll, updateById
-
Field Details
-
dao
-
-
Constructor Details
-
RoleServiceImpl
public RoleServiceImpl()
-
-
Method Details
-
getDAO
Provides the generic DAO used by inherited service methods.- Specified by:
getDAOin classGenericServiceImpl<Role,UUID> - Returns:
- the
IGenericDAOimplementation forRole
-
getEntityName
Supplies a user-friendly name representing the entity, used in exception messages and logs.- Specified by:
getEntityNamein classGenericServiceImpl<Role,UUID> - Returns:
- the string literal "Role"
-
getUserRoles
Retrieves the default set of roles assigned to users. Currently configured to always return a set containing the "USER" role.- Specified by:
getUserRolesin interfaceIRoleService- Returns:
- a
Setcontaining the "USER"Role - Throws:
BadRequestException- if the default role cannot be found
-
findByRoleName
Finds aRoleby its name.- Specified by:
findByRoleNamein interfaceIRoleService- Parameters:
roleName- the name of the role to find; must not benullor blank- Returns:
- the found
Roleinstance - Throws:
BadRequestException- if the provided role name isnullor blankNotFoundException- if no role is found with the given name
-