Package org.ametys.core.right
Class RightProfilesDAO
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.core.datasource.AbstractMyBatisDAO
-
- org.ametys.core.right.RightProfilesDAO
-
- All Implemented Interfaces:
LogEnabled
,PluginAware
,Component
,Configurable
,Contextualizable
,Serviceable
public class RightProfilesDAO extends AbstractMyBatisDAO
Manages registration of profiles
-
-
Field Summary
Fields Modifier and Type Field Description private CurrentUserProvider
_currentUserProvider
private ObservationManager
_observationManager
private Map<String,List<String>>
_profileRightsCache
private Map<String,Profile>
_profilesCache
private ServiceManager
_smanager
static String
ROLE
The component role.-
Fields inherited from class org.ametys.core.datasource.AbstractMyBatisDAO
_manager
-
-
Constructor Summary
Constructors Constructor Description RightProfilesDAO()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
_addRight(org.apache.ibatis.session.SqlSession session, Profile profile, String rightId)
private String
_generateUniqueId(String label)
private Map<String,List<String>>
_getProfileRightsCache()
private Map<String,Profile>
_getProfiles()
private void
_notifyEvent(Profile profile, String eventId)
Profile
addProfile(String label)
Creates a new profile with null context.Profile
addProfile(String label, String context)
Creates a new profile.Profile
addProfile(String id, String label, String context)
Creates a new profilevoid
addProfile(Profile profile)
Add a new profilevoid
addProfile(Profile profile, boolean silent)
Add a new profilevoid
addRight(Profile profile, String rightId)
Add a right to a profilevoid
addRights(Profile profile, List<String> rightIds)
Add a right to a profilevoid
clearCache()
Clear the profiles cachevoid
deleteProfile(Profile profile)
Delete a profilevoid
deleteProfile(Profile profile, boolean silent)
Delete a profileProfile
getProfile(String id)
Get the profile with given identifierList<Profile>
getProfiles()
Get all existing profilesList<Profile>
getProfiles(String context)
Get the profiles on a given contextSet<String>
getProfilesWithRight(String rightId)
Get all profiles containing the right with given idList<String>
getRights(String profileId)
Get the rights of a profileList<String>
getRights(Profile profile)
Get the rights of a profilevoid
removeRights(Profile profile)
Add a right to a profilevoid
removeRights(Profile profile, boolean silent)
Add a right to a profilevoid
renameProfile(Profile profile, String newLabel)
Rename a profilevoid
renameProfile(Profile profile, String newLabel, boolean silent)
Rename a profilevoid
service(ServiceManager smanager)
void
updateRights(Profile profile, List<String> rights)
Update the rights of a profilevoid
updateRights(Profile profile, List<String> rights, boolean silent)
Update the rights of a profile-
Methods inherited from class org.ametys.core.datasource.AbstractMyBatisDAO
_configureDatasource, _getDataSourceId, _getMyBatisConfiguration, configure, contextualize, getSession, getSession, reload, setPluginInfo
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
_profilesCache
private Map<String,Profile> _profilesCache
-
_profileRightsCache
private Map<String,List<String>> _profileRightsCache
-
_smanager
private ServiceManager _smanager
-
_observationManager
private ObservationManager _observationManager
-
_currentUserProvider
private CurrentUserProvider _currentUserProvider
-
-
Constructor Detail
-
RightProfilesDAO
public RightProfilesDAO()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classAbstractMyBatisDAO
- Throws:
ServiceException
-
clearCache
public void clearCache()
Clear the profiles cache
-
_getProfiles
private Map<String,Profile> _getProfiles()
-
_getProfileRightsCache
private Map<String,List<String>> _getProfileRightsCache()
-
getProfiles
public List<Profile> getProfiles()
Get all existing profiles- Returns:
- The list for profiles
-
getProfiles
public List<Profile> getProfiles(String context)
Get the profiles on a given context- Parameters:
context
- The context. Can be null. If null, the profiles with no context are returned.- Returns:
- The list for profiles for this context
-
getProfile
public Profile getProfile(String id)
Get the profile with given identifier- Parameters:
id
- The id of profile to retrieve- Returns:
- The profile
-
getProfilesWithRight
public Set<String> getProfilesWithRight(String rightId)
Get all profiles containing the right with given id- Parameters:
rightId
- The id of right- Returns:
- The id of profiles with this right
-
addProfile
public Profile addProfile(String label)
Creates a new profile with null context. The identifier of the profile will be automatically generated from label.- Parameters:
label
- The label of profile- Returns:
- The create profile
-
addProfile
public Profile addProfile(String label, String context)
Creates a new profile. The identifier of the profile will be automatically generated from label.- Parameters:
label
- The label of profilecontext
- The context. Can be null- Returns:
- The create profile
-
_generateUniqueId
private String _generateUniqueId(String label)
-
addProfile
public Profile addProfile(String id, String label, String context)
Creates a new profile- Parameters:
id
- The unique identifier of profilelabel
- The label of profilecontext
- The context. Can be null- Returns:
- The create profile
-
addProfile
public void addProfile(Profile profile, boolean silent)
Add a new profile- Parameters:
profile
- The profile to addsilent
- Set to true to not notify observer of this update
-
addProfile
public void addProfile(Profile profile)
Add a new profile- Parameters:
profile
- The profile to add
-
renameProfile
public void renameProfile(Profile profile, String newLabel)
Rename a profile- Parameters:
profile
- The profile to renamenewLabel
- The updated label
-
renameProfile
public void renameProfile(Profile profile, String newLabel, boolean silent)
Rename a profile- Parameters:
profile
- The profile to renamenewLabel
- The updated labelsilent
- Set to true to not notify observer of this update
-
getRights
public List<String> getRights(String profileId)
Get the rights of a profile- Parameters:
profileId
- The profile id- Returns:
- The rights
-
getRights
public List<String> getRights(Profile profile)
Get the rights of a profile- Parameters:
profile
- The profile- Returns:
- The rights
-
addRight
public void addRight(Profile profile, String rightId)
Add a right to a profile- Parameters:
profile
- The profilerightId
- The id of right to add
-
addRights
public void addRights(Profile profile, List<String> rightIds)
Add a right to a profile- Parameters:
profile
- The profilerightIds
- The id of rights to add
-
updateRights
public void updateRights(Profile profile, List<String> rights)
Update the rights of a profile- Parameters:
profile
- The profilerights
- The rights of the profile
-
updateRights
public void updateRights(Profile profile, List<String> rights, boolean silent)
Update the rights of a profile- Parameters:
profile
- The profilerights
- The rights of the profilesilent
- Set to true to not notify observer of this update
-
_addRight
private void _addRight(org.apache.ibatis.session.SqlSession session, Profile profile, String rightId)
-
removeRights
public void removeRights(Profile profile)
Add a right to a profile- Parameters:
profile
- The profile
-
removeRights
public void removeRights(Profile profile, boolean silent)
Add a right to a profile- Parameters:
profile
- The profilesilent
- Set to true to not notify observer of this update
-
deleteProfile
public void deleteProfile(Profile profile)
Delete a profile- Parameters:
profile
- The profile to delete
-
deleteProfile
public void deleteProfile(Profile profile, boolean silent)
Delete a profile- Parameters:
profile
- The profile to deletesilent
- Set to true to not notify observer of this update
-
_notifyEvent
private void _notifyEvent(Profile profile, String eventId)
-
-