Class WikiPermissionService

java.lang.Object
fr.paris.lutece.plugins.wiki.service.permission.WikiPermissionService

public final class WikiPermissionService extends Object
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 Details

    • ROLE_PRIVATE

      public static final String ROLE_PRIVATE
      Marker used by the item forms to mean "only the creator and the users explicitly listed".
      See Also:
    • ROLE_NONE

      public static final String 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 item
      strUserGuid - the user identifier, as returned by LuteceUser#getName
      strDisplayName - the user name to display, falls back to the identifier when null
      strPermissionType - VIEW or EDIT
    • revoke

      public static void revoke(AbstractWikiItem item, String strUserGuid, String strPermissionType)
      Revokes a permission held by a user on an item.
      Parameters:
      item - the wiki item
      strUserGuid - the user identifier
      strPermissionType - 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 item
      creator - 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 item
      strAttributeName - the directory attribute
      strAttributeValue - the value its holders must carry
      strAttributeLabel - the attribute label, as shown to whoever granted the rule
      strPermissionType - 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 item
      strAttributeName - the directory attribute
      strAttributeValue - the value
      strPermissionType - 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 item
      strPermissionType - 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 item
      strPermissionType - VIEW or EDIT
      Returns:
      the permissions, ordered by display name
    • isValidPermissionType

      public static boolean isValidPermissionType(String strPermissionType)
      Tells whether a permission type is supported.
      Parameters:
      strPermissionType - the permission type to check
      Returns:
      true when VIEW or EDIT