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());
}
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();
}
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();
}
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);
}
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();
}
Aggregations