Search in sources :

Example 6 with Organization

use of com.liferay.portal.model.Organization in project liferay-ide by liferay.

the class UserLocalServiceImpl method updateOrganizations.

protected void updateOrganizations(long userId, long[] newOrganizationIds, boolean indexingEnabled) throws PortalException, SystemException {
    if (newOrganizationIds == null) {
        return;
    }
    List<Organization> oldOrganizations = userPersistence.getOrganizations(userId);
    Set<Long> oldOrganizationIds = new HashSet<Long>(oldOrganizations.size());
    for (Organization oldOrganization : oldOrganizations) {
        long oldOrganizationId = oldOrganization.getOrganizationId();
        oldOrganizationIds.add(oldOrganizationId);
        if (!ArrayUtil.contains(newOrganizationIds, oldOrganizationId)) {
            unsetOrganizationUsers(oldOrganizationId, new long[] { userId });
        }
    }
    for (long newOrganizationId : newOrganizationIds) {
        if (!oldOrganizationIds.contains(newOrganizationId)) {
            addOrganizationUsers(newOrganizationId, new long[] { userId });
        }
    }
    if (indexingEnabled) {
        Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(User.class);
        indexer.reindex(new long[] { userId });
    }
    PermissionCacheUtil.clearCache();
}
Also used : Organization(com.liferay.portal.model.Organization) Indexer(com.liferay.portal.kernel.search.Indexer) HashSet(java.util.HashSet)

Example 7 with Organization

use of com.liferay.portal.model.Organization in project liferay-ide by liferay.

the class UserLocalServiceImpl method getOrganizationUsersCount.

/**
 * Returns the number of users with the status belonging to the
 * organization.
 *
 * @param  organizationId the primary key of the organization
 * @param  status the workflow status
 * @return the number of users with the status belonging to the organization
 * @throws PortalException if an organization with the primary key could not
 *         be found
 * @throws SystemException if a system exception occurred
 */
@Override
public int getOrganizationUsersCount(long organizationId, int status) throws PortalException, SystemException {
    Organization organization = organizationPersistence.findByPrimaryKey(organizationId);
    LinkedHashMap<String, Object> params = new LinkedHashMap<String, Object>();
    params.put("usersOrgs", new Long(organizationId));
    return searchCount(organization.getCompanyId(), null, status, params);
}
Also used : Organization(com.liferay.portal.model.Organization) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

Organization (com.liferay.portal.model.Organization)7 Indexer (com.liferay.portal.kernel.search.Indexer)2 Group (com.liferay.portal.model.Group)2 DuplicateUserEmailAddressException (com.liferay.portal.DuplicateUserEmailAddressException)1 NoSuchOrganizationException (com.liferay.portal.NoSuchOrganizationException)1 ShardCallable (com.liferay.portal.kernel.dao.shard.ShardCallable)1 Message (com.liferay.portal.kernel.messaging.Message)1 PasswordPolicy (com.liferay.portal.model.PasswordPolicy)1 User (com.liferay.portal.model.User)1 UserGroup (com.liferay.portal.model.UserGroup)1 UserGroupRole (com.liferay.portal.model.UserGroupRole)1 MBMessage (com.liferay.portlet.messageboards.model.MBMessage)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 Callable (java.util.concurrent.Callable)1 NameImpl (org.apache.shindig.social.core.model.NameImpl)1 PersonImpl (org.apache.shindig.social.core.model.PersonImpl)1 ListField (org.apache.shindig.social.opensocial.model.ListField)1 Name (org.apache.shindig.social.opensocial.model.Name)1 Person (org.apache.shindig.social.opensocial.model.Person)1