Search in sources :

Example 1 with Message

use of com.liferay.portal.kernel.messaging.Message in project liferay-ide by liferay.

the class UserLocalServiceImpl method unsetOrganizationUsers.

/**
 * Removes the users from the organization.
 *
 * @param  organizationId the primary key of the organization
 * @param  userIds the primary keys of the users
 * @throws PortalException if a portal exception occurred
 * @throws SystemException if a system exception occurred
 */
@Override
public void unsetOrganizationUsers(long organizationId, final long[] userIds) throws PortalException, SystemException {
    Organization organization = organizationPersistence.findByPrimaryKey(organizationId);
    final Group group = organization.getGroup();
    userGroupRoleLocalService.deleteUserGroupRoles(userIds, group.getGroupId());
    organizationPersistence.removeUsers(organizationId, userIds);
    Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(User.class);
    indexer.reindex(userIds);
    PermissionCacheUtil.clearCache();
    Callable<Void> callable = new Callable<Void>() {

        @Override
        public Void call() throws Exception {
            Message message = new Message();
            message.put("groupId", group.getGroupId());
            message.put("userIds", userIds);
            MessageBusUtil.sendMessage(DestinationNames.SUBSCRIPTION_CLEAN_UP, message);
            return null;
        }
    };
    TransactionCommitCallbackRegistryUtil.registerCallback(callable);
}
Also used : Group(com.liferay.portal.model.Group) UserGroup(com.liferay.portal.model.UserGroup) Organization(com.liferay.portal.model.Organization) Indexer(com.liferay.portal.kernel.search.Indexer) MBMessage(com.liferay.portlet.messageboards.model.MBMessage) Message(com.liferay.portal.kernel.messaging.Message) ShardCallable(com.liferay.portal.kernel.dao.shard.ShardCallable) Callable(java.util.concurrent.Callable)

Example 2 with Message

use of com.liferay.portal.kernel.messaging.Message in project liferay-ide by liferay.

the class UserLocalServiceImpl method unsetGroupUsers.

/**
 * Removes the users from the group.
 *
 * @param  groupId the primary key of the group
 * @param  userIds the primary keys of the users
 * @param  serviceContext the service context to be applied (optionally
 *         <code>null</code>)
 * @throws PortalException if a portal exception occurred
 * @throws SystemException if a system exception occurred
 */
@Override
public void unsetGroupUsers(final long groupId, final long[] userIds, ServiceContext serviceContext) throws PortalException, SystemException {
    userGroupRoleLocalService.deleteUserGroupRoles(userIds, groupId, RoleConstants.TYPE_SITE);
    userLocalService.unsetGroupTeamsUsers(groupId, userIds);
    groupPersistence.removeUsers(groupId, userIds);
    Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(User.class);
    indexer.reindex(userIds);
    PermissionCacheUtil.clearCache();
    Callable<Void> callable = new Callable<Void>() {

        @Override
        public Void call() throws Exception {
            Message message = new Message();
            message.put("groupId", groupId);
            message.put("userIds", userIds);
            MessageBusUtil.sendMessage(DestinationNames.SUBSCRIPTION_CLEAN_UP, message);
            return null;
        }
    };
    TransactionCommitCallbackRegistryUtil.registerCallback(callable);
}
Also used : Indexer(com.liferay.portal.kernel.search.Indexer) MBMessage(com.liferay.portlet.messageboards.model.MBMessage) Message(com.liferay.portal.kernel.messaging.Message) ShardCallable(com.liferay.portal.kernel.dao.shard.ShardCallable) Callable(java.util.concurrent.Callable)

Aggregations

ShardCallable (com.liferay.portal.kernel.dao.shard.ShardCallable)2 Message (com.liferay.portal.kernel.messaging.Message)2 Indexer (com.liferay.portal.kernel.search.Indexer)2 MBMessage (com.liferay.portlet.messageboards.model.MBMessage)2 Callable (java.util.concurrent.Callable)2 Group (com.liferay.portal.model.Group)1 Organization (com.liferay.portal.model.Organization)1 UserGroup (com.liferay.portal.model.UserGroup)1