Search in sources :

Example 1 with Indexer

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

the class AssetEntriesFacet method doGetFacetClause.

@Override
protected BooleanClause doGetFacetClause() {
    SearchContext searchContext = getSearchContext();
    String[] entryClassNames = searchContext.getEntryClassNames();
    BooleanQuery facetQuery = BooleanQueryFactoryUtil.create(searchContext);
    for (String entryClassName : entryClassNames) {
        Indexer indexer = IndexerRegistryUtil.getIndexer(entryClassName);
        if (indexer == null) {
            continue;
        }
        String searchEngineId = searchContext.getSearchEngineId();
        if (!searchEngineId.equals(indexer.getSearchEngineId())) {
            continue;
        }
        try {
            BooleanQuery indexerBooleanQuery = indexer.getFacetQuery(entryClassName, searchContext);
            if ((indexerBooleanQuery == null) || !indexerBooleanQuery.hasClauses()) {
                continue;
            }
            BooleanQuery entityQuery = BooleanQueryFactoryUtil.create(searchContext);
            entityQuery.add(indexerBooleanQuery, BooleanClauseOccur.MUST);
            indexer.postProcessContextQuery(entityQuery, searchContext);
            for (IndexerPostProcessor indexerPostProcessor : indexer.getIndexerPostProcessors()) {
                indexerPostProcessor.postProcessContextQuery(entityQuery, searchContext);
            }
            if (indexer.isStagingAware()) {
                if (!searchContext.isIncludeLiveGroups() && searchContext.isIncludeStagingGroups()) {
                    entityQuery.addRequiredTerm(Field.STAGING_GROUP, true);
                } else if (searchContext.isIncludeLiveGroups() && !searchContext.isIncludeStagingGroups()) {
                    entityQuery.addRequiredTerm(Field.STAGING_GROUP, false);
                }
            }
            if (entityQuery.hasClauses()) {
                facetQuery.add(entityQuery, BooleanClauseOccur.SHOULD);
            }
        } catch (Exception e) {
            _log.error(e, e);
        }
    }
    if (!facetQuery.hasClauses()) {
        return null;
    }
    return BooleanClauseFactoryUtil.create(searchContext, facetQuery, BooleanClauseOccur.MUST.getName());
}
Also used : BooleanQuery(com.liferay.portal.kernel.search.BooleanQuery) Indexer(com.liferay.portal.kernel.search.Indexer) SearchContext(com.liferay.portal.kernel.search.SearchContext) IndexerPostProcessor(com.liferay.portal.kernel.search.IndexerPostProcessor)

Example 2 with Indexer

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

the class UserLocalServiceImpl method setUserGroupUsers.

/**
 * Sets the users in the user group, removing and adding users to the user
 * group as necessary.
 *
 * @param  userGroupId the primary key of the user group
 * @param  userIds the primary keys of the users
 * @throws PortalException if a portal exception occurred
 * @throws SystemException if a system exception occurred
 */
@Override
@SuppressWarnings("deprecation")
public void setUserGroupUsers(long userGroupId, long[] userIds) throws PortalException, SystemException {
    if (PropsValues.USER_GROUPS_COPY_LAYOUTS_TO_USER_PERSONAL_SITE) {
        userGroupLocalService.copyUserGroupLayouts(userGroupId, userIds);
    }
    userGroupPersistence.setUsers(userGroupId, userIds);
    Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(User.class);
    indexer.reindex(userIds);
    PermissionCacheUtil.clearCache();
}
Also used : Indexer(com.liferay.portal.kernel.search.Indexer)

Example 3 with Indexer

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

the class UserLocalServiceImpl method setRoleUsers.

/**
 * Sets the users in the role, removing and adding users to the role as
 * necessary.
 *
 * @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 setRoleUsers(long roleId, long[] userIds) throws PortalException, SystemException {
    rolePersistence.setUsers(roleId, userIds);
    Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(User.class);
    indexer.reindex(userIds);
    PermissionCacheUtil.clearCache();
}
Also used : Indexer(com.liferay.portal.kernel.search.Indexer)

Example 4 with Indexer

use of com.liferay.portal.kernel.search.Indexer 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 5 with Indexer

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

the class UserLocalServiceImpl method deleteUserGroupUser.

/**
 * Removes the user from the user group.
 *
 * @param  userGroupId the primary key of the user group
 * @param  userId the primary key of the user
 * @throws PortalException if a portal exception occurred
 * @throws SystemException if a system exception occurred
 */
@Override
public void deleteUserGroupUser(long userGroupId, long userId) throws PortalException, SystemException {
    userGroupPersistence.removeUser(userGroupId, userId);
    Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(User.class);
    indexer.reindex(userId);
    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