Class WikiPermissionService
java.lang.Object
fr.paris.lutece.plugins.wiki.service.permission.WikiPermissionService
Grants and revokes permissions held by named users on wiki items.
Permissions are stored as wiki data, so a grant or a revoke takes effect on the very next
request of the target user, without them having to sign in again.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic List<WikiItemAttributePermission>getAttributesWithPermission(AbstractWikiItem item, String strPermissionType) Returns the populations holding a permission on an item, as attribute rules.static List<WikiItemUserPermission>getUsersWithPermission(AbstractWikiItem item, String strPermissionType) Returns the users holding a permission on an item.static voidgrant(AbstractWikiItem item, String strUserGuid, String strDisplayName, String strPermissionType) Grants a permission to a user on an item.static voidgrantCreatorPermissions(AbstractWikiItem item, fr.paris.lutece.portal.service.security.LuteceUser creator) Grants the creator the right to edit the item they just created, when that item is private.static booleangrantToAttribute(AbstractWikiItem item, String strAttributeName, String strAttributeValue, String strAttributeLabel, String strPermissionType) Grants a permission to everyone carrying a directory attribute value, rather than to named users.static booleanisValidPermissionType(String strPermissionType) Tells whether a permission type is supported.static voidrevoke(AbstractWikiItem item, String strUserGuid, String strPermissionType) Revokes a permission held by a user on an item.static voidrevokeFromAttribute(AbstractWikiItem item, String strAttributeName, String strAttributeValue, String strPermissionType) Revokes a permission granted to the holders of an attribute value.
-
Field Details
-
ROLE_PRIVATE
Marker used by the item forms to mean "only the creator and the users explicitly listed".- See Also:
-
ROLE_NONE
Marker used by the item forms to mean "no restriction".- See Also:
-
-
Method Details
-
grant
public static void grant(AbstractWikiItem item, String strUserGuid, String strDisplayName, String strPermissionType) Grants a permission to a user on an item. Does nothing when the permission type is unknown or when the permission is already granted.- Parameters:
item- the wiki itemstrUserGuid- the user identifier, as returned by LuteceUser#getNamestrDisplayName- the user name to display, falls back to the identifier when nullstrPermissionType- VIEW or EDIT
-
revoke
Revokes a permission held by a user on an item.- Parameters:
item- the wiki itemstrUserGuid- the user identifierstrPermissionType- VIEW or EDIT
-
grantCreatorPermissions
public static void grantCreatorPermissions(AbstractWikiItem item, fr.paris.lutece.portal.service.security.LuteceUser creator) Grants the creator the right to edit the item they just created, when that item is private. Without it a creator without the wiki administrator role would lose access to their own item.- Parameters:
item- the wiki itemcreator- the user creating the item
-
grantToAttribute
public static boolean grantToAttribute(AbstractWikiItem item, String strAttributeName, String strAttributeValue, String strAttributeLabel, String strPermissionType) Grants a permission to everyone carrying a directory attribute value, rather than to named users. A population such as everyone in a direction changes as people join and leave, so listing its members would go stale the day it is written. Does nothing when the permission type is unknown, when the attribute holds no such value in the directory, or when the rule already exists.- Parameters:
item- the wiki itemstrAttributeName- the directory attributestrAttributeValue- the value its holders must carrystrAttributeLabel- the attribute label, as shown to whoever granted the rulestrPermissionType- VIEW or EDIT- Returns:
- true when the rule was applied
-
revokeFromAttribute
public static void revokeFromAttribute(AbstractWikiItem item, String strAttributeName, String strAttributeValue, String strPermissionType) Revokes a permission granted to the holders of an attribute value.- Parameters:
item- the wiki itemstrAttributeName- the directory attributestrAttributeValue- the valuestrPermissionType- VIEW or EDIT
-
getAttributesWithPermission
public static List<WikiItemAttributePermission> getAttributesWithPermission(AbstractWikiItem item, String strPermissionType) Returns the populations holding a permission on an item, as attribute rules.- Parameters:
item- the wiki itemstrPermissionType- VIEW or EDIT- Returns:
- the rules, ordered by label
-
getUsersWithPermission
public static List<WikiItemUserPermission> getUsersWithPermission(AbstractWikiItem item, String strPermissionType) Returns the users holding a permission on an item.- Parameters:
item- the wiki itemstrPermissionType- VIEW or EDIT- Returns:
- the permissions, ordered by display name
-
isValidPermissionType
Tells whether a permission type is supported.- Parameters:
strPermissionType- the permission type to check- Returns:
- true when VIEW or EDIT
-