Class DummyOrganizationMembershipPolicy
- All Implemented Interfaces:
OrganizationMembershipPolicy
- Author:
- Roberto Díaz, Sergio González
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckMembership(long[] userIds, long[] addOrganizationIds, long[] removeOrganizationIds) Checks if the users can be added to and removed from the respective organizations.booleanisMembershipAllowed(long userId, long groupId) Returnstrueif the user can be added to the organization.booleanisMembershipRequired(long userId, long groupId) Returnstrueif organization membership for the user is mandatory.booleanisRoleAllowed(long userId, long groupId, long roleId) Returnstrueif the role can be added to the user on the organization.booleanisRoleRequired(long userId, long groupId, long roleId) Returnstrueif the role is mandatory for the user on the organization.voidpropagateMembership(long[] userIds, long[] addOrganizationIds, long[] removeOrganizationIds) Performs membership policy related actions after the users are added to and removed from the respective organizations.voidverifyPolicy(Organization organization) Checks the integrity of the membership policy of the organization and performs operations necessary for the organization's compliance.voidverifyPolicy(Organization organization, Organization oldOrganization, List<AssetCategory> oldAssetCategories, List<AssetTag> oldAssetTags, Map<String, Serializable> oldExpandoAttributes) Checks the integrity of the membership policy of the organization, with respect to the organization's new attribute values, categories, tags, and expando attributes, and performs operations necessary for the compliance of the organization and its organization roles.Methods inherited from class com.liferay.portal.kernel.security.membershippolicy.BaseOrganizationMembershipPolicy
checkRoles, isMembershipProtected, isRoleProtected, propagateRoles, verifyPolicy, verifyPolicy, verifyPolicy
-
Constructor Details
-
DummyOrganizationMembershipPolicy
public DummyOrganizationMembershipPolicy()
-
-
Method Details
-
checkMembership
public void checkMembership(long[] userIds, long[] addOrganizationIds, long[] removeOrganizationIds) Description copied from interface:OrganizationMembershipPolicyChecks if the users can be added to and removed from the respective organizations.Liferay's core services call this method before adding the users to and removing the users from the respective organizations. 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 organizationsaddOrganizationIds- the primary keys of the organizations to which the users are to be added (optionallynull)removeOrganizationIds- the primary keys of the organizations from which the users are to be removed (optionallynull)
-
isMembershipAllowed
public boolean isMembershipAllowed(long userId, long groupId) Description copied from interface:OrganizationMembershipPolicyReturnstrueif the user can be added to the organization. Liferay's UI calls this method.- Specified by:
isMembershipAllowedin interfaceOrganizationMembershipPolicy- Overrides:
isMembershipAllowedin classBaseOrganizationMembershipPolicy- Parameters:
userId- the primary key of the usergroupId- the primary key of the organization- Returns:
trueif the user can be added to the organization;falseotherwise
-
isMembershipRequired
public boolean isMembershipRequired(long userId, long groupId) Description copied from interface:OrganizationMembershipPolicyReturnstrueif organization membership for the user is mandatory. Liferay's UI, for example, calls this method in deciding whether to enable the checkbox for removing the user from the organization.- Specified by:
isMembershipRequiredin interfaceOrganizationMembershipPolicy- Overrides:
isMembershipRequiredin classBaseOrganizationMembershipPolicy- Parameters:
userId- the primary key of the usergroupId- the primary key of the organization- Returns:
trueif organization membership for the user is mandatory;falseotherwise
-
isRoleAllowed
public boolean isRoleAllowed(long userId, long groupId, long roleId) Description copied from interface:OrganizationMembershipPolicyReturnstrueif the role can be added to the user on the organization. Liferay's UI calls this method.- Specified by:
isRoleAllowedin interfaceOrganizationMembershipPolicy- Overrides:
isRoleAllowedin classBaseOrganizationMembershipPolicy- Parameters:
userId- the primary key of the usergroupId- the primary key of the organizationroleId- the primary key of the role- Returns:
trueif the role can be added to the user on the organization;falseotherwise
-
isRoleRequired
public boolean isRoleRequired(long userId, long groupId, long roleId) Description copied from interface:OrganizationMembershipPolicyReturnstrueif the role is mandatory for the user on the organization. Liferay's UI calls this method.- Specified by:
isRoleRequiredin interfaceOrganizationMembershipPolicy- Overrides:
isRoleRequiredin classBaseOrganizationMembershipPolicy- Parameters:
userId- the primary key of the usergroupId- the primary key of the organizationroleId- the primary key of the role- Returns:
trueif the role is mandatory for the user on the organization;falseotherwise
-
propagateMembership
public void propagateMembership(long[] userIds, long[] addOrganizationIds, long[] removeOrganizationIds) Description copied from interface:OrganizationMembershipPolicyPerforms membership policy related actions after the users are added to and removed from the respective organizations. Liferay's core services call this method after adding and removing the users to and from the respective organizations.The actions must ensure the integrity of each organization's membership policy. For example, some actions for implementations to consider performing are:
- Adding the users to the child organizations of each organization to which the users were added.
- Removing the users from the child organizations of each organization from which the users were removed.
- Parameters:
userIds- the primary key of the users to be added or removedaddOrganizationIds- the primary keys of the organizations to which the users were added (optionallynull)removeOrganizationIds- the primary keys of the organizations from which the users were removed (optionallynull)
-
verifyPolicy
Description copied from interface:OrganizationMembershipPolicyChecks the integrity of the membership policy of the organization and performs operations necessary for the organization's compliance.- Specified by:
verifyPolicyin interfaceOrganizationMembershipPolicy- Overrides:
verifyPolicyin classBaseOrganizationMembershipPolicy- Parameters:
organization- the organization to verify
-
verifyPolicy
public void verifyPolicy(Organization organization, Organization oldOrganization, List<AssetCategory> oldAssetCategories, List<AssetTag> oldAssetTags, Map<String, Serializable> oldExpandoAttributes) Description copied from interface:OrganizationMembershipPolicyChecks the integrity of the membership policy of the organization, with respect to the organization's new attribute values, categories, tags, and expando attributes, and performs operations necessary for the compliance of the organization and its organization roles. Liferay calls this method when adding and updating organizations.The actions must ensure the integrity of the organization's membership policy based on what has changed in the organization's attribute values, categories, tags, and expando attributes.
For example, if the membership policy is that organizations 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 organization user that does not have the Administrator role must be removed from the organization.
- Parameters:
organization- the added or updated organization to verifyoldOrganization- the old organizationoldAssetCategories- the old categoriesoldAssetTags- the old tagsoldExpandoAttributes- the old expando attributes
-
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
-