Class BaseSiteMembershipPolicy

Object
com.liferay.portal.kernel.security.membershippolicy.BaseSiteMembershipPolicy
All Implemented Interfaces:
SiteMembershipPolicy
Direct Known Subclasses:
DummySiteMembershipPolicy

public abstract class BaseSiteMembershipPolicy extends Object implements SiteMembershipPolicy
Author:
Roberto Díaz, Sergio González
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    checkRoles(List<UserGroupRole> addUserGroupRoles, List<UserGroupRole> removeUserGroupRoles)
    Checks if the site roles can be added to or removed from their users.
    boolean
    isMembershipAllowed(long userId, long groupId)
    Returns true if the user can be added to the site.
    boolean
    isMembershipProtected(PermissionChecker permissionChecker, long userId, long groupId)
    Returns true if the policy prevents the user from being removed from the site by the user associated with the permission checker.
    boolean
    isMembershipRequired(long userId, long groupId)
    Returns true if site membership for the user is mandatory.
    boolean
    isRoleAllowed(long userId, long groupId, long roleId)
    Returns true if the role can be added to the user on the site.
    boolean
    isRoleProtected(PermissionChecker permissionChecker, long userId, long groupId, long roleId)
    Returns true if the policy prevents the user from being removed from the role by the user associated with the permission checker.
    boolean
    isRoleRequired(long userId, long groupId, long roleId)
    Returns true if the role is mandatory for the user on the site.
    void
    propagateRoles(List<UserGroupRole> addUserGroupRoles, List<UserGroupRole> removeUserGroupRoles)
    Performs membership policy related actions after the respective site roles are added to and removed from the affected users.
    void
    Checks the integrity of the membership policy of each of the portal's sites and performs operations necessary for the compliance of each site and site role.
    void
    Checks the integrity of the membership policy of the site and performs operations necessary for the site's compliance.
    void
    Checks the integrity of the membership policy of the site role and performs operations necessary for the role's compliance.
    void
    verifyPolicy(Role role, Role oldRole, Map<String,Serializable> oldExpandoAttributes)
    Checks the integrity of the membership policy of the site role, with respect to its expando attributes, and performs operations necessary for the role's compliance.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.liferay.portal.kernel.security.membershippolicy.SiteMembershipPolicy

    checkMembership, propagateMembership, verifyPolicy
  • Constructor Details

    • BaseSiteMembershipPolicy

      public BaseSiteMembershipPolicy()
  • Method Details

    • checkRoles

      public void checkRoles(List<UserGroupRole> addUserGroupRoles, List<UserGroupRole> removeUserGroupRoles) throws PortalException
      Description copied from interface: SiteMembershipPolicy
      Checks if the site roles can be added to or removed from their users.

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

      Specified by:
      checkRoles in interface SiteMembershipPolicy
      Parameters:
      addUserGroupRoles - the user group roles to be added
      removeUserGroupRoles - the user group roles to be removed
      Throws:
      PortalException
    • isMembershipAllowed

      public boolean isMembershipAllowed(long userId, long groupId) throws PortalException
      Description copied from interface: SiteMembershipPolicy
      Returns true if the user can be added to the site. Liferay's UI calls this method.
      Specified by:
      isMembershipAllowed in interface SiteMembershipPolicy
      Parameters:
      userId - the primary key of the user
      groupId - the primary key of the site
      Returns:
      true if the user can be added to the site; false otherwise
      Throws:
      PortalException
    • isMembershipProtected

      public boolean isMembershipProtected(PermissionChecker permissionChecker, long userId, long groupId) throws PortalException
      Description copied from interface: SiteMembershipPolicy
      Returns true if the policy prevents the user from being removed from the site by the user associated with the permission checker.
      Specified by:
      isMembershipProtected in interface SiteMembershipPolicy
      Parameters:
      permissionChecker - the permission checker referencing a user
      userId - the primary key of the user to check for protection
      groupId - the primary key of the site
      Returns:
      true if the policy prevents the user from being removed from the site by the user associated with the permission checker; false otherwise
      Throws:
      PortalException
    • isMembershipRequired

      public boolean isMembershipRequired(long userId, long groupId) throws PortalException
      Description copied from interface: SiteMembershipPolicy
      Returns true if site membership for the user is mandatory. Liferay's UI, for example, calls this method in deciding whether to display the option to leave the site.
      Specified by:
      isMembershipRequired in interface SiteMembershipPolicy
      Parameters:
      userId - the primary key of the user
      groupId - the primary key of the site
      Returns:
      true if site membership for the user is mandatory; false otherwise
      Throws:
      PortalException
    • isRoleAllowed

      public boolean isRoleAllowed(long userId, long groupId, long roleId) throws PortalException
      Description copied from interface: SiteMembershipPolicy
      Returns true if the role can be added to the user on the site. Liferay's UI calls this method.
      Specified by:
      isRoleAllowed in interface SiteMembershipPolicy
      Parameters:
      userId - the primary key of the user
      groupId - the primary key of the site
      roleId - the primary key of the role
      Returns:
      true if the role can be added to the user on the site; false otherwise
      Throws:
      PortalException
    • isRoleProtected

      public boolean isRoleProtected(PermissionChecker permissionChecker, long userId, long groupId, long roleId) throws PortalException
      Description copied from interface: SiteMembershipPolicy
      Returns true if the policy prevents the user from being removed from the role by the user associated with the permission checker.
      Specified by:
      isRoleProtected in interface SiteMembershipPolicy
      Parameters:
      permissionChecker - the permission checker referencing a user
      userId - the primary key of the user to check for protection
      groupId - the primary key of the site
      roleId - the primary key of the role
      Returns:
      true if the policy prevents the user from being removed from the role by the user associated with the permission checker; false otherwise
      Throws:
      PortalException
    • isRoleRequired

      public boolean isRoleRequired(long userId, long groupId, long roleId)
      Description copied from interface: SiteMembershipPolicy
      Returns true if the role is mandatory for the user on the site. Liferay's UI calls this method.
      Specified by:
      isRoleRequired in interface SiteMembershipPolicy
      Parameters:
      userId - the primary key of the user
      groupId - the primary key of the site
      roleId - the primary key of the role
      Returns:
      true if the role is mandatory for the user on the site; false otherwise
    • propagateRoles

      public void propagateRoles(List<UserGroupRole> addUserGroupRoles, List<UserGroupRole> removeUserGroupRoles) throws PortalException
      Description copied from interface: SiteMembershipPolicy
      Performs membership policy related actions after the respective site roles are added to and removed from the affected users. Liferay's core services call this method after the roles are added to and removed from the users.

      The actions must ensure the membership policy of each site role. For example, some actions for implementations to consider performing are:

      • If the role A is added to a user, role B should be added too.
      • If the role A is removed from a user, role B should be removed too.
      Specified by:
      propagateRoles in interface SiteMembershipPolicy
      Parameters:
      addUserGroupRoles - the user group roles added
      removeUserGroupRoles - the user group roles removed
      Throws:
      PortalException
    • verifyPolicy

      public void verifyPolicy() throws PortalException
      Description copied from interface: SiteMembershipPolicy
      Checks the integrity of the membership policy of each of the portal's sites and performs operations necessary for the compliance of each site and site role. This method can be triggered manually from the Control Panel. If the membership.policy.auto.verify portal property is true this method is triggered when starting Liferay and every time a membership policy hook is deployed.
      Specified by:
      verifyPolicy in interface SiteMembershipPolicy
      Throws:
      PortalException
    • verifyPolicy

      public void verifyPolicy(Group group) throws PortalException
      Description copied from interface: SiteMembershipPolicy
      Checks the integrity of the membership policy of the site and performs operations necessary for the site's compliance.
      Specified by:
      verifyPolicy in interface SiteMembershipPolicy
      Parameters:
      group - the site to verify
      Throws:
      PortalException
    • verifyPolicy

      public void verifyPolicy(Role role)
      Description copied from interface: SiteMembershipPolicy
      Checks the integrity of the membership policy of the site role and performs operations necessary for the role's compliance.
      Specified by:
      verifyPolicy in interface SiteMembershipPolicy
      Parameters:
      role - the role to verify
    • verifyPolicy

      public void verifyPolicy(Role role, Role oldRole, Map<String,Serializable> oldExpandoAttributes)
      Description copied from interface: SiteMembershipPolicy
      Checks the integrity of the membership policy of the site role, with respect to its expando attributes, and performs operations necessary for the role's compliance. Liferay calls this method when adding and updating site roles.
      Specified by:
      verifyPolicy in interface SiteMembershipPolicy
      Parameters:
      role - the added or updated role to verify
      oldRole - the old role
      oldExpandoAttributes - the old expando attributes