use of com.liferay.portal.kernel.search.Indexer in project liferay-ide by liferay.
the class UserLocalServiceImpl method unsetTeamUsers.
/**
* Removes the users from the team.
*
* @param teamId the primary key of the team
* @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 unsetTeamUsers(long teamId, long[] userIds) throws PortalException, SystemException {
teamPersistence.removeUsers(teamId, 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 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);
}
use of com.liferay.portal.kernel.search.Indexer in project liferay-ide by liferay.
the class KBArticleLocalServiceImpl method deleteKBArticle.
@Override
public KBArticle deleteKBArticle(KBArticle kbArticle) throws PortalException, SystemException {
// Child KB articles
deleteKBArticles(kbArticle.getGroupId(), kbArticle.getResourcePrimKey());
// Resources
resourceLocalService.deleteResource(kbArticle.getCompanyId(), KBArticle.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL, kbArticle.getResourcePrimKey());
// KB articles
kbArticlePersistence.removeByResourcePrimKey(kbArticle.getResourcePrimKey());
// KB comments
kbCommentLocalService.deleteKBComments(KBArticle.class.getName(), kbArticle.getResourcePrimKey());
// Asset
deleteAssets(kbArticle);
// Ratings
ratingsStatsLocalService.deleteStats(KBArticle.class.getName(), kbArticle.getResourcePrimKey());
// Social
socialActivityLocalService.deleteActivities(KBArticle.class.getName(), kbArticle.getResourcePrimKey());
// Indexer
Indexer indexer = IndexerRegistryUtil.getIndexer(KBArticle.class);
indexer.delete(kbArticle);
// Attachments
PortletFileRepositoryUtil.deleteFolder(kbArticle.getAttachmentsFolderId());
// Subscriptions
deleteSubscriptions(kbArticle);
// Workflow
workflowInstanceLinkLocalService.deleteWorkflowInstanceLinks(kbArticle.getCompanyId(), kbArticle.getGroupId(), KBArticle.class.getName(), kbArticle.getResourcePrimKey());
return kbArticle;
}
use of com.liferay.portal.kernel.search.Indexer in project liferay-ide by liferay.
the class UserLocalServiceImpl method addUserGroupUsers.
/**
* Adds the users to the user group.
*
* @param userGroupId the primary key of the user group
* @param userIds the primary keys of the users
* @throws PortalException if a user group or user with the primary could
* could not be found
* @throws SystemException if a system exception occurred
*/
@Override
@SuppressWarnings("deprecation")
public void addUserGroupUsers(long userGroupId, long[] userIds) throws PortalException, SystemException {
if (PropsValues.USER_GROUPS_COPY_LAYOUTS_TO_USER_PERSONAL_SITE) {
userGroupLocalService.copyUserGroupLayouts(userGroupId, userIds);
}
userGroupPersistence.addUsers(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 SearchPermissionCheckerImpl method doGetPermissionQuery.
protected Query doGetPermissionQuery(long companyId, long[] groupIds, long userId, String className, Query query, SearchContext searchContext) throws Exception {
Indexer indexer = IndexerRegistryUtil.getIndexer(className);
if (!indexer.isPermissionAware()) {
return query;
}
PermissionChecker permissionChecker = PermissionThreadLocal.getPermissionChecker();
AdvancedPermissionChecker advancedPermissionChecker = null;
if ((permissionChecker != null) && (permissionChecker instanceof AdvancedPermissionChecker)) {
advancedPermissionChecker = (AdvancedPermissionChecker) permissionChecker;
}
if (advancedPermissionChecker == null) {
return query;
}
PermissionCheckerBag permissionCheckerBag = getPermissionCheckerBag(advancedPermissionChecker, userId);
if (permissionCheckerBag == null) {
return query;
}
List<Group> groups = new UniqueList<Group>();
List<Role> roles = new UniqueList<Role>();
List<UserGroupRole> userGroupRoles = new UniqueList<UserGroupRole>();
Map<Long, List<Role>> groupIdsToRoles = new HashMap<Long, List<Role>>();
roles.addAll(permissionCheckerBag.getRoles());
if (ArrayUtil.isEmpty(groupIds)) {
groups.addAll(GroupLocalServiceUtil.getUserGroups(userId, true));
groups.addAll(permissionCheckerBag.getGroups());
userGroupRoles = UserGroupRoleLocalServiceUtil.getUserGroupRoles(userId);
} else {
groups.addAll(permissionCheckerBag.getGroups());
for (long groupId : groupIds) {
if (GroupLocalServiceUtil.hasUserGroup(userId, groupId)) {
Group group = GroupLocalServiceUtil.getGroup(groupId);
groups.add(group);
}
userGroupRoles.addAll(UserGroupRoleLocalServiceUtil.getUserGroupRoles(userId, groupId));
userGroupRoles.addAll(UserGroupRoleLocalServiceUtil.getUserGroupRolesByUserUserGroupAndGroup(userId, groupId));
}
}
if (advancedPermissionChecker.isSignedIn()) {
roles.add(RoleLocalServiceUtil.getRole(companyId, RoleConstants.GUEST));
}
for (Group group : groups) {
PermissionCheckerBag userBag = advancedPermissionChecker.getUserBag(userId, group.getGroupId());
List<Role> groupRoles = userBag.getRoles();
groupIdsToRoles.put(group.getGroupId(), groupRoles);
roles.addAll(groupRoles);
}
return doGetPermissionQuery_6(companyId, groupIds, userId, className, query, searchContext, advancedPermissionChecker, groups, roles, userGroupRoles, groupIdsToRoles);
}
Aggregations