Example usage for com.liferay.portal.kernel.service UserLocalServiceUtil getOrganizationPrimaryKeys

List of usage examples for com.liferay.portal.kernel.service UserLocalServiceUtil getOrganizationPrimaryKeys

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.service UserLocalServiceUtil getOrganizationPrimaryKeys.

Prototype

public static long[] getOrganizationPrimaryKeys(long userId) 

Source Link

Document

Returns the organizationIds of the organizations associated with the user.

Usage

From source file:eu.gerhards.liferay.services.angular.service.impl.AngularUserServiceImpl.java

License:Open Source License

protected void updateOrganizations(long userId, long[] newOrganizationIds, boolean indexingEnabled)
        throws PortalException {

    if (newOrganizationIds == null) {
        return;//from   w ww  .  j a  v a 2  s. co m
    }

    long[] oldOrganizationIds = UserLocalServiceUtil.getOrganizationPrimaryKeys(userId);

    for (long oldOrganizationId : oldOrganizationIds) {
        if (!ArrayUtil.contains(newOrganizationIds, oldOrganizationId)) {
            unsetOrganizationUsers(oldOrganizationId, new long[] { userId });
        }
    }

    for (long newOrganizationId : newOrganizationIds) {
        if (!ArrayUtil.contains(oldOrganizationIds, newOrganizationId)) {
            addOrganizationUsers(newOrganizationId, new long[] { userId });
        }
    }

    if (indexingEnabled) {
        reindex(userId);
    }
}