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 aRole
by its name.protected IGenericDAO
<Role, UUID> getDAO()
Provides the generic DAO used by inherited service methods.protected String
Supplies 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, updateById
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:
getDAO
in classGenericServiceImpl<Role,
UUID> - Returns:
- the
IGenericDAO
implementation forRole
-
getEntityName
Supplies a user-friendly name representing the entity, used in exception messages and logs.- Specified by:
getEntityName
in 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:
getUserRoles
in interfaceIRoleService
- Returns:
- a
Set
containing the "USER"Role
- Throws:
BadRequestException
- if the default role cannot be found
-
findByRoleName
Finds aRole
by its name.- Specified by:
findByRoleName
in interfaceIRoleService
- Parameters:
roleName
- the name of the role to find; must not benull
or blank- Returns:
- the found
Role
instance - Throws:
BadRequestException
- if the provided role name isnull
or blankNotFoundException
- if no role is found with the given name
-