Class DummySiteMembershipPolicy
Object
com.liferay.portal.kernel.security.membershippolicy.BaseSiteMembershipPolicy
com.liferay.portal.kernel.security.membershippolicy.DummySiteMembershipPolicy
- All Implemented Interfaces:
SiteMembershipPolicy
- Author:
- Roberto Díaz, Sergio González
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckMembership(long[] userIds, long[] addGroupIds, long[] removeGroupIds) Checks if the users can be added to and removed from the respective sites.booleanisMembershipAllowed(long userId, long groupId) Returnstrueif the user can be added to the site.booleanisMembershipRequired(long userId, long groupId) Returnstrueif site membership for the user is mandatory.booleanisRoleAllowed(long userId, long groupId, long roleId) Returnstrueif the role can be added to the user on the site.booleanisRoleRequired(long userId, long groupId, long roleId) Returnstrueif the role is mandatory for the user on the site.voidpropagateMembership(long[] userIds, long[] addGroupIds, long[] removeGroupIds) Performs membership policy related actions after the users are added to and removed from the respective sites.voidverifyPolicy(Group group) Checks the integrity of the membership policy of the site and performs operations necessary for the site's compliance.voidverifyPolicy(Group group, Group oldGroup, List<AssetCategory> oldAssetCategories, List<AssetTag> oldAssetTags, Map<String, Serializable> oldExpandoAttributes, UnicodeProperties oldTypeSettingsUnicodeProperties) Checks the integrity of the membership policy of the site, with respect to the site's new attribute values, categories, tags, expando attributes, and type settings properties, and performs operations necessary for the compliance of the site and its site roles.Methods inherited from class com.liferay.portal.kernel.security.membershippolicy.BaseSiteMembershipPolicy
checkRoles, isMembershipProtected, isRoleProtected, propagateRoles, verifyPolicy, verifyPolicy, verifyPolicy
-
Constructor Details
-
DummySiteMembershipPolicy
public DummySiteMembershipPolicy()
-
-
Method Details
-
checkMembership
public void checkMembership(long[] userIds, long[] addGroupIds, long[] removeGroupIds) Description copied from interface:SiteMembershipPolicyChecks if the users can be added to and removed from the respective sites.Liferay's core services call this method before adding the users to and removing the users from the respective sites. 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 sitesaddGroupIds- the primary keys of the sites to which the users are to be added (optionallynull)removeGroupIds- the primary keys of the sites from which the users are to be removed (optionallynull)
-
isMembershipAllowed
public boolean isMembershipAllowed(long userId, long groupId) Description copied from interface:SiteMembershipPolicyReturnstrueif the user can be added to the site. Liferay's UI calls this method.- Specified by:
isMembershipAllowedin interfaceSiteMembershipPolicy- Overrides:
isMembershipAllowedin classBaseSiteMembershipPolicy- Parameters:
userId- the primary key of the usergroupId- the primary key of the site- Returns:
trueif the user can be added to the site;falseotherwise
-
isMembershipRequired
public boolean isMembershipRequired(long userId, long groupId) Description copied from interface:SiteMembershipPolicyReturnstrueif 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:
isMembershipRequiredin interfaceSiteMembershipPolicy- Overrides:
isMembershipRequiredin classBaseSiteMembershipPolicy- Parameters:
userId- the primary key of the usergroupId- the primary key of the site- Returns:
trueif site membership for the user is mandatory;falseotherwise
-
isRoleAllowed
public boolean isRoleAllowed(long userId, long groupId, long roleId) Description copied from interface:SiteMembershipPolicyReturnstrueif the role can be added to the user on the site. Liferay's UI calls this method.- Specified by:
isRoleAllowedin interfaceSiteMembershipPolicy- Overrides:
isRoleAllowedin classBaseSiteMembershipPolicy- Parameters:
userId- the primary key of the usergroupId- the primary key of the siteroleId- the primary key of the role- Returns:
trueif the role can be added to the user on the site;falseotherwise
-
isRoleRequired
public boolean isRoleRequired(long userId, long groupId, long roleId) Description copied from interface:SiteMembershipPolicyReturnstrueif the role is mandatory for the user on the site. Liferay's UI calls this method.- Specified by:
isRoleRequiredin interfaceSiteMembershipPolicy- Overrides:
isRoleRequiredin classBaseSiteMembershipPolicy- Parameters:
userId- the primary key of the usergroupId- the primary key of the siteroleId- the primary key of the role- Returns:
trueif the role is mandatory for the user on the site;falseotherwise
-
propagateMembership
public void propagateMembership(long[] userIds, long[] addGroupIds, long[] removeGroupIds) Description copied from interface:SiteMembershipPolicyPerforms membership policy related actions after the users are added to and removed from the respective sites. Liferay's core services call this method after adding and removing the users to and from the respective sites.The actions must ensure the integrity of each site's membership policy. For example, some actions for implementations to consider performing are:
- Adding the users to the child sites of each site to which the users were added.
- Removing the users from the child sites of each site from which the users were removed.
- Parameters:
userIds- the primary key of the users that have been added or removedaddGroupIds- the primary keys of the sites to which the users were added (optionallynull)removeGroupIds- the primary keys of the sites from which the users were removed (optionallynull)
-
verifyPolicy
Description copied from interface:SiteMembershipPolicyChecks the integrity of the membership policy of the site and performs operations necessary for the site's compliance.- Specified by:
verifyPolicyin interfaceSiteMembershipPolicy- Overrides:
verifyPolicyin classBaseSiteMembershipPolicy- Parameters:
group- the site to verify
-
verifyPolicy
public void verifyPolicy(Group group, Group oldGroup, List<AssetCategory> oldAssetCategories, List<AssetTag> oldAssetTags, Map<String, Serializable> oldExpandoAttributes, UnicodeProperties oldTypeSettingsUnicodeProperties) Description copied from interface:SiteMembershipPolicyChecks the integrity of the membership policy of the site, with respect to the site's new attribute values, categories, tags, expando attributes, and type settings properties, and performs operations necessary for the compliance of the site and its site roles. Liferay calls this method when adding and updating sites.The actions must ensure the integrity of the site's membership policy based on what has changed in the site's attribute values, categories, tags, expando attributes, and type settings properties.
For example, if the membership policy is that sites with the "admnistrator" tag should only allow administrators as users, then this method could enforce that policy using the following logic:
-
If the old tags include the "administrator" tag and the new tags include
it too, then no action needs to be performed regarding the
policy. Note, the new tags can be obtained by calling
assetTagLocalService.getTags(Group.class.getName(), group.getGroupId());. - If the old tags include the "administrator" tag and the new tags 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 old tags don't include the "administrator" tag, but the new tags include it, any site user that does not have the Administrator role must be removed from the site.
- Parameters:
group- the added or updated site to verifyoldGroup- the old siteoldAssetCategories- the old categoriesoldAssetTags- the old tagsoldExpandoAttributes- the old expando attributesoldTypeSettingsUnicodeProperties- the old type settings properties
-
If the old tags include the "administrator" tag and the new tags include
it too, then no action needs to be performed regarding the
policy. Note, the new tags can be obtained by calling
-