Search in sources :

Example 6 with Indexer

use of com.liferay.portal.kernel.search.Indexer in project liferay-ide by liferay.

the class UserLocalServiceImpl method unsetRoleUsers.

/**
 * Removes the users from the role.
 *
 * @param  roleId the primary key of the role
 * @param  users the users
 * @throws PortalException if a portal exception occurred
 * @throws SystemException if a system exception occurred
 */
@Override
public void unsetRoleUsers(long roleId, List<User> users) throws PortalException, SystemException {
    Role role = rolePersistence.findByPrimaryKey(roleId);
    String roleName = role.getName();
    if ((roleName.equals(RoleConstants.ADMINISTRATOR) && (getRoleUsersCount(role.getRoleId()) <= 1)) || roleName.equals(RoleConstants.USER)) {
        return;
    }
    rolePersistence.removeUsers(roleId, users);
    Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(User.class);
    indexer.reindex(users);
    PermissionCacheUtil.clearCache();
}
Also used : Role(com.liferay.portal.model.Role) UserGroupRole(com.liferay.portal.model.UserGroupRole) Indexer(com.liferay.portal.kernel.search.Indexer)

Example 7 with Indexer

use of com.liferay.portal.kernel.search.Indexer in project liferay-ide by liferay.

the class SongLocalServiceImpl method moveSongFromTrash.

@Override
public Song moveSongFromTrash(long userId, long songId, long albumId) throws PortalException, SystemException {
    Song song = getSong(songId);
    TrashEntry trashEntry = song.getTrashEntry();
    if (trashEntry.isTrashEntry(Song.class, songId)) {
        restoreSongFromTrash(userId, songId);
    } else {
        // Entry
        TrashVersion trashVersion = trashVersionLocalService.fetchVersion(trashEntry.getEntryId(), Song.class.getName(), songId);
        int status = WorkflowConstants.STATUS_APPROVED;
        if (trashVersion != null) {
            status = trashVersion.getStatus();
        }
        ServiceContext serviceContext = new ServiceContext();
        // Entry
        User user = userPersistence.findByPrimaryKey(userId);
        Date now = new Date();
        song.setModifiedDate(serviceContext.getModifiedDate(now));
        song.setStatus(status);
        song.setStatusByUserId(user.getUserId());
        song.setStatusByUserName(user.getFullName());
        song.setStatusDate(serviceContext.getModifiedDate(now));
        songPersistence.update(song);
        // Asset
        assetEntryLocalService.updateVisible(Song.class.getName(), song.getSongId(), false);
        // Indexer
        Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(Song.class);
        indexer.reindex(song);
        if (trashVersion != null) {
            trashVersionLocalService.deleteTrashVersion(trashVersion);
        }
    }
    return songLocalService.moveSong(songId, albumId);
}
Also used : Song(org.liferay.jukebox.model.Song) TrashEntry(com.liferay.portlet.trash.model.TrashEntry) User(com.liferay.portal.model.User) Indexer(com.liferay.portal.kernel.search.Indexer) ServiceContext(com.liferay.portal.service.ServiceContext) TrashVersion(com.liferay.portlet.trash.model.TrashVersion) Date(java.util.Date)

Example 8 with Indexer

use of com.liferay.portal.kernel.search.Indexer in project liferay-ide by liferay.

the class UserLocalServiceImpl method addOrganizationUsers.

/**
 * Adds the users to the organization.
 *
 * @param  organizationId the primary key of the organization
 * @param  userIds the primary keys of the users
 * @throws PortalException if an organization or user with the primary key
 *         could not be found
 * @throws SystemException if a system exception occurred
 */
@Override
public void addOrganizationUsers(long organizationId, long[] userIds) throws PortalException, SystemException {
    organizationPersistence.addUsers(organizationId, userIds);
    Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(User.class);
    indexer.reindex(userIds);
    PermissionCacheUtil.clearCache();
}
Also used : Indexer(com.liferay.portal.kernel.search.Indexer)

Example 9 with Indexer

use of com.liferay.portal.kernel.search.Indexer in project liferay-ide by liferay.

the class UserLocalServiceImpl method reindex.

protected void reindex(final User user) {
    final Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(User.class);
    Callable<Void> callable = new ShardCallable<Void>(user.getCompanyId()) {

        @Override
        protected Void doCall() throws Exception {
            indexer.reindex(user);
            return null;
        }
    };
    TransactionCommitCallbackRegistryUtil.registerCallback(callable);
}
Also used : Indexer(com.liferay.portal.kernel.search.Indexer) ShardCallable(com.liferay.portal.kernel.dao.shard.ShardCallable)

Example 10 with Indexer

use of com.liferay.portal.kernel.search.Indexer in project liferay-ide by liferay.

the class UserLocalServiceImpl method addTeamUsers.

/**
 * Adds the users to the team.
 *
 * @param  teamId the primary key of the team
 * @param  userIds the primary keys of the users
 * @throws PortalException if a team or user with the primary key could not
 *         be found
 * @throws SystemException if a system exception occurred
 */
@Override
public void addTeamUsers(long teamId, long[] userIds) throws PortalException, SystemException {
    teamPersistence.addUsers(teamId, userIds);
    Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(User.class);
    indexer.reindex(userIds);
    PermissionCacheUtil.clearCache();
}
Also used : Indexer(com.liferay.portal.kernel.search.Indexer)

Aggregations

Indexer (com.liferay.portal.kernel.search.Indexer)30 User (com.liferay.portal.model.User)5 Group (com.liferay.portal.model.Group)4 UserGroupRole (com.liferay.portal.model.UserGroupRole)4 Date (java.util.Date)4 ShardCallable (com.liferay.portal.kernel.dao.shard.ShardCallable)3 PortalException (com.liferay.portal.kernel.exception.PortalException)3 SystemException (com.liferay.portal.kernel.exception.SystemException)3 Role (com.liferay.portal.model.Role)3 UserGroup (com.liferay.portal.model.UserGroup)3 CompanyMaxUsersException (com.liferay.portal.CompanyMaxUsersException)2 ContactBirthdayException (com.liferay.portal.ContactBirthdayException)2 ContactFirstNameException (com.liferay.portal.ContactFirstNameException)2 ContactFullNameException (com.liferay.portal.ContactFullNameException)2 ContactLastNameException (com.liferay.portal.ContactLastNameException)2 DuplicateOpenIdException (com.liferay.portal.DuplicateOpenIdException)2 DuplicateUserEmailAddressException (com.liferay.portal.DuplicateUserEmailAddressException)2 DuplicateUserScreenNameException (com.liferay.portal.DuplicateUserScreenNameException)2 GroupFriendlyURLException (com.liferay.portal.GroupFriendlyURLException)2 ModelListenerException (com.liferay.portal.ModelListenerException)2