Class DummyUserGroupMembershipPolicy

Object
com.liferay.portal.kernel.security.membershippolicy.BaseUserGroupMembershipPolicy
com.liferay.portal.kernel.security.membershippolicy.DummyUserGroupMembershipPolicy
All Implemented Interfaces:
UserGroupMembershipPolicy

public class DummyUserGroupMembershipPolicy extends BaseUserGroupMembershipPolicy
Author:
Roberto Díaz, Sergio González
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    checkMembership(long[] userIds, long[] addUserGroupIds, long[] removeUserGroupIds)
    Checks if the users can be added to and removed from the respective user groups.
    boolean
    isMembershipAllowed(long userId, long userGroupId)
    Returns true if the user can be added to the user group.
    boolean
    isMembershipRequired(long userId, long userGroupId)
    Returns true if user group membership for the user is mandatory.
    void
    propagateMembership(long[] userIds, long[] addUserGroupIds, long[] removeUserGroupIds)
    Performs membership policy related actions after the users are added to and removed from the respective user groups.
    void
    Checks the integrity of the membership policy of the user group and performs operations necessary for the user group's compliance.
    void
    verifyPolicy(UserGroup userGroup, UserGroup oldUserGroup, Map<String,Serializable> oldExpandoAttributes)
    Checks the integrity of the membership policy of the user group, with respect to the user group's new attribute values and expando attributes, and performs operations necessary for the compliance of the user group.

    Methods inherited from class com.liferay.portal.kernel.security.membershippolicy.BaseUserGroupMembershipPolicy

    verifyPolicy

    Methods inherited from class java.lang.Object

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

    • DummyUserGroupMembershipPolicy

      public DummyUserGroupMembershipPolicy()
  • Method Details

    • checkMembership

      public void checkMembership(long[] userIds, long[] addUserGroupIds, long[] removeUserGroupIds)
      Description copied from interface: UserGroupMembershipPolicy
      Checks if the users can be added to and removed from the respective user groups.

      Liferay's core services call this method before adding the users to and removing the users from the respective user groups. If this method throws an exception, the service foregoes making the changes.

      Parameters:
      userIds - the primary keys of the users to be added and removed from the user groups
      addUserGroupIds - the primary keys of the user groups to which the users are to be added (optionally null)
      removeUserGroupIds - the primary keys of the user groups from which the users are to be removed (optionally null)
    • isMembershipAllowed

      public boolean isMembershipAllowed(long userId, long userGroupId)
      Description copied from interface: UserGroupMembershipPolicy
      Returns true if the user can be added to the user group. Liferay's UI calls this method.
      Specified by:
      isMembershipAllowed in interface UserGroupMembershipPolicy
      Overrides:
      isMembershipAllowed in class BaseUserGroupMembershipPolicy
      Parameters:
      userId - the primary key of the user
      userGroupId - the primary key of the user group
      Returns:
      true if the user can be added to the user group; false otherwise
    • isMembershipRequired

      public boolean isMembershipRequired(long userId, long userGroupId)
      Description copied from interface: UserGroupMembershipPolicy
      Returns true if user group membership for the user is mandatory. Liferay's UI, for example, calls this method in deciding whether the checkbox to select the user group will be enable.
      Specified by:
      isMembershipRequired in interface UserGroupMembershipPolicy
      Overrides:
      isMembershipRequired in class BaseUserGroupMembershipPolicy
      Parameters:
      userId - the primary key of the user
      userGroupId - the primary key of the user group
      Returns:
      true if user group membership for the user is mandatory; false otherwise
    • propagateMembership

      public void propagateMembership(long[] userIds, long[] addUserGroupIds, long[] removeUserGroupIds)
      Description copied from interface: UserGroupMembershipPolicy
      Performs membership policy related actions after the users are added to and removed from the respective user groups. Liferay's core services call this method after adding and removing the users to and from the respective user groups.

      The actions must ensure the integrity of each user group's membership policy. For example, some actions for implementations to consider performing are:

      • If a user is added to user group A, he should be added to user group B too.
      • If a user is removed from user group A, he should be removed from user group B too.
      Parameters:
      userIds - the primary key of the users to be added or removed
      addUserGroupIds - the primary keys of the user groups to which the users were added (optionally null)
      removeUserGroupIds - the primary keys of the user groups from which the users were removed (optionally null)
    • verifyPolicy

      public void verifyPolicy(UserGroup userGroup)
      Description copied from interface: UserGroupMembershipPolicy
      Checks the integrity of the membership policy of the user group and performs operations necessary for the user group's compliance.
      Specified by:
      verifyPolicy in interface UserGroupMembershipPolicy
      Overrides:
      verifyPolicy in class BaseUserGroupMembershipPolicy
      Parameters:
      userGroup - the user group to verify
    • verifyPolicy

      public void verifyPolicy(UserGroup userGroup, UserGroup oldUserGroup, Map<String,Serializable> oldExpandoAttributes)
      Description copied from interface: UserGroupMembershipPolicy
      Checks the integrity of the membership policy of the user group, with respect to the user group's new attribute values and expando attributes, and performs operations necessary for the compliance of the user group. Liferay calls this method when adding and updating user groups.

      The actions must ensure the integrity of the user group's membership policy based on what has changed in the user group's attribute values and expando attributes.

      For example, if the membership policy is that user groups with the expando attribute A should only allow administrators, then this method could enforce that policy using the following logic:

      • If the oldExpandoAttributes include the expando attribute A and the new expando attributes include it too, then no action needs to be performed regarding the policy. Note, the new expando attributes can be obtained by calling assetTagLocalService.getTags(Group.class.getName(), group.getGroupId());.
      • If the oldExpandoAttributes include the expando attribute A and the new expando attributes don't include it, then no action needs to be performed regarding the policy, as non-administrator users need not be removed.
      • However, if the oldExpandoAttributes don't include the expando attribute A and the new expando attributes include it, any user group user that does not have the Administrator role must be removed from the user group.
      Parameters:
      userGroup - the added or updated user group to verify
      oldUserGroup - the old user group
      oldExpandoAttributes - the old expando attributes