Class GroupPermissionProvider

java.lang.Object
de.murmelmeister.murmelapi.group.permission.GroupPermissionProvider
All Implemented Interfaces:
GroupPermission

public final class GroupPermissionProvider extends Object implements GroupPermission
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addPermission(int executorId, int groupId, String permission, long time)
    Adds a specific permission to a group along with an expiration time.
    void
    clearPermission(int groupId)
    Removes all permissions associated with the specified group.
    boolean
    existsPermission(int groupId, String permission)
    Checks if a specific permission exists for a given group.
    getAllPermissions(GroupParent groupParent, int groupId)
    Retrieves all permissions associated with a given group, including inherited permissions from its parent group if applicable.
    getCreatedAt(int groupId, String permission)
    Retrieves the timestamp of when the given permission was created for the specified group.
    int
    getCreatedBy(int groupId, String permission)
    Retrieves the ID of the user who created the specified permission for the given group.
    getExpiredDate(int groupId, String permission)
    Retrieves the expiration date of a specific permission for a given group.
    long
    getExpiredTime(int groupId, String permission)
    Retrieves the expiration time for a specific permission associated with a given group.
    getModifiedAt(int groupId, String permission)
    Retrieves the timestamp of the last modification made to a specific permission associated with a given group.
    int
    getModifiedBy(int groupId, String permission)
    Retrieves the user ID of the user who last modified the specified permission for a given group.
    getPermissions(int groupId)
    Retrieves a list of permissions associated with a specified group ID.
    boolean
    isExpired(int groupId, String permission)
    Determines whether a specified permission for a given group is expired.
    void
    Loads all expired permissions or entities associated with a given group into the system for further processing or cleanup.
    void
    removePermission(int groupId, String permission)
    Removes a specific permission from a group.
    setExpiredTime(int executorId, int groupId, String permission, long time)
    Sets the expiration time for a specific permission associated with a group.
    static void
    setup(Database database)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GroupPermissionProvider

      public GroupPermissionProvider(Database database)
  • Method Details

    • setup

      public static void setup(Database database)
    • existsPermission

      public boolean existsPermission(int groupId, String permission)
      Description copied from interface: GroupPermission
      Checks if a specific permission exists for a given group.
      Specified by:
      existsPermission in interface GroupPermission
      Parameters:
      groupId - The ID of the group to check the permission for.
      permission - The name of the permission to verify.
      Returns:
      true if the permission exists for the group, otherwise false.
    • addPermission

      public void addPermission(int executorId, int groupId, String permission, long time)
      Description copied from interface: GroupPermission
      Adds a specific permission to a group along with an expiration time.
      Specified by:
      addPermission in interface GroupPermission
      Parameters:
      executorId - The ID of the executor initiating the permission addition.
      groupId - The ID of the group to which the permission will be added.
      permission - The permission to add to the group.
      time - The expiration time in milliseconds. If set to -1, the permission will not expire.
    • removePermission

      public void removePermission(int groupId, String permission)
      Description copied from interface: GroupPermission
      Removes a specific permission from a group.
      Specified by:
      removePermission in interface GroupPermission
      Parameters:
      groupId - The ID of the group from which the permission is to be removed.
      permission - The permission to be removed from the group.
    • clearPermission

      public void clearPermission(int groupId)
      Description copied from interface: GroupPermission
      Removes all permissions associated with the specified group.
      Specified by:
      clearPermission in interface GroupPermission
      Parameters:
      groupId - The unique identifier of the group whose permissions are to be cleared.
    • getPermissions

      public List<String> getPermissions(int groupId)
      Description copied from interface: GroupPermission
      Retrieves a list of permissions associated with a specified group ID.
      Specified by:
      getPermissions in interface GroupPermission
      Parameters:
      groupId - The ID of the group whose permissions are to be retrieved.
      Returns:
      A list of permissions associated with the given group ID.
    • getAllPermissions

      public List<String> getAllPermissions(GroupParent groupParent, int groupId)
      Description copied from interface: GroupPermission
      Retrieves all permissions associated with a given group, including inherited permissions from its parent group if applicable.
      Specified by:
      getAllPermissions in interface GroupPermission
      Parameters:
      groupParent - The parent group entity, which may provide inherited permissions to the group.
      groupId - The unique identifier of the group for which permissions are being retrieved.
      Returns:
      A list of permissions associated with the group, including inherited permissions if present.
    • getExpiredTime

      public long getExpiredTime(int groupId, String permission)
      Description copied from interface: GroupPermission
      Retrieves the expiration time for a specific permission associated with a given group.
      Specified by:
      getExpiredTime in interface GroupPermission
      Parameters:
      groupId - The ID of the group for which the permission expiration time is being retrieved.
      permission - The permission whose expiration time is being retrieved.
      Returns:
      The expiration time in milliseconds since epoch. Returns -1 if the permission has no expiration time, or -2 if the permission does not exist.
    • getExpiredDate

      public String getExpiredDate(int groupId, String permission)
      Description copied from interface: GroupPermission
      Retrieves the expiration date of a specific permission for a given group. If the permission does not expire, the method will return "never".
      Specified by:
      getExpiredDate in interface GroupPermission
      Parameters:
      groupId - The ID of the group associated with the permission.
      permission - The specific permission to retrieve the expiration date for.
      Returns:
      A string representation of the expiration date. Returns "never" if the permission does not expire.
    • setExpiredTime

      public String setExpiredTime(int executorId, int groupId, String permission, long time)
      Description copied from interface: GroupPermission
      Sets the expiration time for a specific permission associated with a group. The expiration time can be specified to indicate when the permission should expire.
      Specified by:
      setExpiredTime in interface GroupPermission
      Parameters:
      executorId - The ID of the user or process making the change.
      groupId - The ID of the group associated with the permission.
      permission - The name of the permission whose expiration time is being set.
      time - The expiration time in milliseconds from the current time; use -1 for no expiration.
      Returns:
      A string representation of the new expiration date, or "never" if no expiration is set.
    • isExpired

      public boolean isExpired(int groupId, String permission)
      Description copied from interface: GroupPermission
      Determines whether a specified permission for a given group is expired.
      Specified by:
      isExpired in interface GroupPermission
      Parameters:
      groupId - The ID of the group to check the permission for.
      permission - The name of the permission to check for expiration.
      Returns:
      true if the specified permission is expired, otherwise false.
    • getCreatedBy

      public int getCreatedBy(int groupId, String permission)
      Description copied from interface: GroupPermission
      Retrieves the ID of the user who created the specified permission for the given group.
      Specified by:
      getCreatedBy in interface GroupPermission
      Parameters:
      groupId - The ID of the group for which the permission was created.
      permission - The name of the permission to retrieve the creator information for.
      Returns:
      The ID of the user who created the permission, or -2 if no such permission exists.
    • getCreatedAt

      public Timestamp getCreatedAt(int groupId, String permission)
      Description copied from interface: GroupPermission
      Retrieves the timestamp of when the given permission was created for the specified group.
      Specified by:
      getCreatedAt in interface GroupPermission
      Parameters:
      groupId - The ID of the group for which the permission was created.
      permission - The specific permission whose creation timestamp is to be retrieved.
      Returns:
      A Timestamp representing the creation time of the permission, or null if the permission does not exist or no creation time is available.
    • getModifiedBy

      public int getModifiedBy(int groupId, String permission)
      Description copied from interface: GroupPermission
      Retrieves the user ID of the user who last modified the specified permission for a given group.
      Specified by:
      getModifiedBy in interface GroupPermission
      Parameters:
      groupId - The ID of the group whose permission modification details are being queried.
      permission - The name of the permission for which the modifying user is being retrieved.
      Returns:
      The ID of the user who last modified the specified permission. If no modification was found, returns -2 as a fallback.
    • getModifiedAt

      public Timestamp getModifiedAt(int groupId, String permission)
      Description copied from interface: GroupPermission
      Retrieves the timestamp of the last modification made to a specific permission associated with a given group.
      Specified by:
      getModifiedAt in interface GroupPermission
      Parameters:
      groupId - The unique identifier of the group the permission belongs to.
      permission - The name of the permission whose modification timestamp is to be retrieved.
      Returns:
      A Timestamp object representing the last modification time of the specified permission, or null if no modification record exists.
    • loadExpired

      public void loadExpired(Group group)
      Description copied from interface: GroupPermission
      Loads all expired permissions or entities associated with a given group into the system for further processing or cleanup.
      Specified by:
      loadExpired in interface GroupPermission
      Parameters:
      group - The group for which expired permissions or entities will be loaded.