Search in sources :

Example 26 with Indexer

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

the class AlbumLocalServiceImpl method moveDependentsToTrash.

protected void moveDependentsToTrash(List<Song> songs, long trashEntryId) throws PortalException, SystemException {
    for (Song song : songs) {
        if (song.isInTrash()) {
            continue;
        }
        int oldStatus = song.getStatus();
        song.setStatus(WorkflowConstants.STATUS_IN_TRASH);
        songPersistence.update(song);
        // Trash
        int status = oldStatus;
        if (oldStatus == WorkflowConstants.STATUS_PENDING) {
            status = WorkflowConstants.STATUS_DRAFT;
        }
        if (oldStatus != WorkflowConstants.STATUS_APPROVED) {
            trashVersionLocalService.addTrashVersion(trashEntryId, Song.class.getName(), song.getSongId(), status, null);
        }
        // Asset
        assetEntryLocalService.updateVisible(Song.class.getName(), song.getSongId(), false);
        // Indexer
        Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(Song.class);
        indexer.reindex(song);
    }
}
Also used : Song(org.liferay.jukebox.model.Song) Indexer(com.liferay.portal.kernel.search.Indexer)

Example 27 with Indexer

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

the class AlbumLocalServiceImpl method restoreDependentsFromTrash.

protected void restoreDependentsFromTrash(List<Song> songs, long trashEntryId) throws PortalException, SystemException {
    for (Song song : songs) {
        // Song
        TrashEntry trashEntry = trashEntryLocalService.fetchEntry(Song.class.getName(), song.getSongId());
        if (trashEntry != null) {
            continue;
        }
        TrashVersion trashVersion = trashVersionLocalService.fetchVersion(trashEntryId, Song.class.getName(), song.getSongId());
        int oldStatus = WorkflowConstants.STATUS_APPROVED;
        if (trashVersion != null) {
            oldStatus = trashVersion.getStatus();
        }
        song.setStatus(oldStatus);
        songPersistence.update(song);
        if (trashVersion != null) {
            trashVersionLocalService.deleteTrashVersion(trashVersion);
        }
        if (oldStatus == WorkflowConstants.STATUS_APPROVED) {
            assetEntryLocalService.updateVisible(Song.class.getName(), song.getSongId(), true);
        }
        // Indexer
        Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(Song.class);
        indexer.reindex(song);
    }
}
Also used : Song(org.liferay.jukebox.model.Song) TrashEntry(com.liferay.portlet.trash.model.TrashEntry) Indexer(com.liferay.portal.kernel.search.Indexer) TrashVersion(com.liferay.portlet.trash.model.TrashVersion)

Example 28 with Indexer

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

the class UserLocalServiceImpl method addGroupUsers.

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

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

Example 30 with Indexer

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

the class SearchPermissionCheckerImpl method addPermissionFields.

@Override
public void addPermissionFields(long companyId, Document document) {
    try {
        long groupId = GetterUtil.getLong(document.get(Field.GROUP_ID));
        String className = document.get(Field.ENTRY_CLASS_NAME);
        boolean relatedEntry = GetterUtil.getBoolean(document.get(Field.RELATED_ENTRY));
        if (relatedEntry) {
            long classNameId = GetterUtil.getLong(document.get(Field.CLASS_NAME_ID));
            className = PortalUtil.getClassName(classNameId);
        }
        if (Validator.isNull(className)) {
            return;
        }
        String classPK = document.get(Field.ROOT_ENTRY_CLASS_PK);
        if (Validator.isNull(classPK)) {
            classPK = document.get(Field.ENTRY_CLASS_PK);
        }
        if (relatedEntry) {
            classPK = document.get(Field.CLASS_PK);
        }
        if (Validator.isNull(classPK)) {
            return;
        }
        Indexer indexer = IndexerRegistryUtil.getIndexer(className);
        if (!indexer.isPermissionAware()) {
            return;
        }
        doAddPermissionFields_6(companyId, groupId, className, classPK, document);
    } catch (NoSuchResourceException nsre) {
    } catch (Exception e) {
        _log.error(e, e);
    }
}
Also used : NoSuchResourceException(com.liferay.portal.NoSuchResourceException) Indexer(com.liferay.portal.kernel.search.Indexer) NoSuchResourceException(com.liferay.portal.NoSuchResourceException)

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