Package org.ametys.core.ui.right
Class ProfileAssignmentsToolClientSideElement
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.core.ui.StaticFileImportsClientSideElement
-
- org.ametys.core.ui.StaticClientSideElement
-
- org.ametys.core.ui.right.ProfileAssignmentsToolClientSideElement
-
- All Implemented Interfaces:
ClientSideElement
,LogEnabled
,PluginAware
,Configurable
,Serviceable
- Direct Known Subclasses:
CartProfileAssignmentsToolClientSideElement
,ExtractionProfileAssignmentsToolClientSideElement
,QueriesProfileAssignmentsToolClientSideElement
public class ProfileAssignmentsToolClientSideElement extends StaticClientSideElement
ClientSideElement
for the tool displaying the profile assignments
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ProfileAssignmentsToolClientSideElement.AccessType
Enumeration of all possible access typesstatic class
ProfileAssignmentsToolClientSideElement.TargetType
Enumeration of all possible target types-
Nested classes/interfaces inherited from interface org.ametys.core.ui.ClientSideElement
ClientSideElement.Script, ClientSideElement.ScriptFile
-
-
Field Summary
Fields Modifier and Type Field Description protected GroupDirectoryDAO
_groupDirectoryDAO
The DAO for group directoriesprotected GroupManager
_groupManager
The group managerprotected ObservationManager
_observationManager
The observation managerprotected ProfileAssignmentStorageExtensionPoint
_profileAssignmentStorageEP
The profile assignment storage componentprotected RightProfilesDAO
_profileDAO
The profile DAOprotected RightAssignmentContextExtensionPoint
_rightAssignmentContextEP
The extension point for right assignment contextsprotected UserHelper
_userHelper
The user helper-
Fields inherited from class org.ametys.core.ui.StaticFileImportsClientSideElement
_currentUserProvider, _dependencies, _featureName, _id, _pluginName, _rightManager, _rights, _rightsMode, _script
-
-
Constructor Summary
Constructors Constructor Description ProfileAssignmentsToolClientSideElement()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Map<String,Object>
_getEventParams(Object context, String contextIdentifier, Set<String> profileIds)
Get the event params for notification.protected void
_notifyObservers(Object context, String contextIdentifier, Set<String> profileIds)
Notify observers after modifying profile assignments.protected boolean
canDelegateRights(UserIdentity user, Set<GroupIdentity> groups, String profileId, String assignment, Object context)
Only allow user with right CMS_Rights_Delegate_Rights to add a profil that this user already have on this contextvoid
disallowInheritance(String rightAssignmentCtxId, Object jsContext, boolean disallow)
Allow or disallow the inheritance of assignments on the given contextString
getInheritedAssignment(String rightAssignmentCtxId, Object jsContext, String profileId, String targetType, Map<String,String> identity)
Get the first permission given by inheritance for a object context and a specific profileMap<String,String>
getInheritedAssignments(String rightAssignmentCtxId, Object jsContext, List<String> profileIds, String targetType, Map<String,String> identity)
Get the first permission given by inheritance for a object context and profilesList<ClientSideElement.Script>
getScripts(boolean ignoreRights, Map<String,Object> contextParameters)
This method return the scripts that will be used on client side.List<Map<String,Object>>
getUserGroups(String login, String populationId)
Gets the groups of a user as JSONboolean
isInheritanceDisallowed(String rightAssignmentCtxId, Object jsContext)
Determines if the inheritance of assignments is disallowed on the given contextMap<String,Object>
saveChanges(String rightAssignmentCtxId, Object jsContext, List<Map<String,Object>> assignmentsInfo)
Save some changes made client-side.void
service(ServiceManager smanager)
-
Methods inherited from class org.ametys.core.ui.StaticClientSideElement
_configureClass, _configureParameters, _configureScript, configureInitialParameters
-
Methods inherited from class org.ametys.core.ui.StaticFileImportsClientSideElement
_configureDependencies, _configureImports, _configureRights, _configureRightsMode, configure, getDependencies, getId, getPluginName, getRights, getScripts, hasRight, setPluginInfo, toString
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
_profileAssignmentStorageEP
protected ProfileAssignmentStorageExtensionPoint _profileAssignmentStorageEP
The profile assignment storage component
-
_rightAssignmentContextEP
protected RightAssignmentContextExtensionPoint _rightAssignmentContextEP
The extension point for right assignment contexts
-
_groupDirectoryDAO
protected GroupDirectoryDAO _groupDirectoryDAO
The DAO for group directories
-
_groupManager
protected GroupManager _groupManager
The group manager
-
_observationManager
protected ObservationManager _observationManager
The observation manager
-
_userHelper
protected UserHelper _userHelper
The user helper
-
_profileDAO
protected RightProfilesDAO _profileDAO
The profile DAO
-
-
Constructor Detail
-
ProfileAssignmentsToolClientSideElement
public ProfileAssignmentsToolClientSideElement()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classStaticFileImportsClientSideElement
- Throws:
ServiceException
-
getScripts
public List<ClientSideElement.Script> getScripts(boolean ignoreRights, Map<String,Object> contextParameters)
Description copied from interface:ClientSideElement
This method return the scripts that will be used on client side. This class will be parametrized by initial and current parameters.- Specified by:
getScripts
in interfaceClientSideElement
- Overrides:
getScripts
in classStaticFileImportsClientSideElement
- Parameters:
ignoreRights
- True to ignore the rights verification.contextParameters
- Contextuals parameters transmitted by the environment.- Returns:
- The list of scripts or an empty list.
-
getUserGroups
public List<Map<String,Object>> getUserGroups(String login, String populationId)
Gets the groups of a user as JSON- Parameters:
login
- The login of the userpopulationId
- The population of the user- Returns:
- the groups of a user as JSON
-
saveChanges
public Map<String,Object> saveChanges(String rightAssignmentCtxId, Object jsContext, List<Map<String,Object>> assignmentsInfo)
Save some changes made client-side.- Parameters:
rightAssignmentCtxId
- The id of the right assignment contextjsContext
- The JS object contextassignmentsInfo
- The list of all the changes to make. Each map in the list must contain the following keys:- profileId for the id of the profile (as a string)
- assignment for the kind of assignment (can be ACCESS_TYPE_ALLOW, ACCESS_TYPE_DENY...)
- assignmentType expects one of these four strings: "user", "group", "anonymous", "anyConnectedUser"
- identity Can be null if assignmentType is "anonymous" or "anyConnectedUser". If "user", must be a map with the keys "login" and "populationId". If "group", must be a map with the keys "groupId" and "groupDirectory"
- Returns:
- a map containing 3 objects : success : boolean, everything is saved successInfos : elements from assignmentsInfo that are saved errorInfos : elements from assignmentsInfo that are not saved
-
canDelegateRights
protected boolean canDelegateRights(UserIdentity user, Set<GroupIdentity> groups, String profileId, String assignment, Object context)
Only allow user with right CMS_Rights_Delegate_Rights to add a profil that this user already have on this context- Parameters:
user
- user that want to de an assignmentgroups
- groups of the userprofileId
- profil impactedassignment
- assignment seeProfileAssignmentsToolClientSideElement.AccessType
context
- context of the assignment- Returns:
true
if user can de this assignment
-
_notifyObservers
protected void _notifyObservers(Object context, String contextIdentifier, Set<String> profileIds)
Notify observers after modifying profile assignments.- Parameters:
context
- The contextcontextIdentifier
- The context identifierprofileIds
- The profiles
-
_getEventParams
protected Map<String,Object> _getEventParams(Object context, String contextIdentifier, Set<String> profileIds)
Get the event params for notification.- Parameters:
context
- The contextcontextIdentifier
- The context identifierprofileIds
- The profiles- Returns:
- the event params
-
isInheritanceDisallowed
public boolean isInheritanceDisallowed(String rightAssignmentCtxId, Object jsContext)
Determines if the inheritance of assignments is disallowed on the given context- Parameters:
rightAssignmentCtxId
- The id of the right assignment contextjsContext
- The JS object context- Returns:
true
if the inheritance is disallowed.
-
disallowInheritance
public void disallowInheritance(String rightAssignmentCtxId, Object jsContext, boolean disallow)
Allow or disallow the inheritance of assignments on the given context- Parameters:
rightAssignmentCtxId
- The id of the right assignment contextjsContext
- The JS object contextdisallow
- true to disallow the inheritance, false to allow.
-
getInheritedAssignments
public Map<String,String> getInheritedAssignments(String rightAssignmentCtxId, Object jsContext, List<String> profileIds, String targetType, Map<String,String> identity)
Get the first permission given by inheritance for a object context and profiles- Parameters:
rightAssignmentCtxId
- The id of the right assignment contextjsContext
- The JS object contextprofileIds
- The list of profilestargetType
- The type of target : anonymous, any connected users, a user or a groupidentity
- The identity of the target. Can be null if the target is anonymous or any connected users- Returns:
- The first access type given by inheritance for each profile
-
getInheritedAssignment
public String getInheritedAssignment(String rightAssignmentCtxId, Object jsContext, String profileId, String targetType, Map<String,String> identity)
Get the first permission given by inheritance for a object context and a specific profile- Parameters:
rightAssignmentCtxId
- The id of the right assignment contextjsContext
- The JS object contextprofileId
- The id of profiletargetType
- The type of target : anonymous, any connected users, a user or a groupidentity
- The identity of the target. Can be null if the target is anonymous or any connected users- Returns:
- The first access type given by inheritance
-
-