Search in sources :

Example 11 with Indexer

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();
}
Also used : Indexer(com.liferay.portal.kernel.search.Indexer)

Example 12 with Indexer

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);
}
Also used : 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 13 with Indexer

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;
}
Also used : Indexer(com.liferay.portal.kernel.search.Indexer) KBArticle(com.liferay.knowledgebase.model.KBArticle)

Example 14 with Indexer

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();
}
Also used : Indexer(com.liferay.portal.kernel.search.Indexer)

Example 15 with Indexer

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);
}
Also used : UserGroupRole(com.liferay.portal.model.UserGroupRole) Group(com.liferay.portal.model.Group) HashMap(java.util.HashMap) PermissionCheckerBag(com.liferay.portal.security.permission.PermissionCheckerBag) UniqueList(com.liferay.portal.kernel.util.UniqueList) UserGroupRole(com.liferay.portal.model.UserGroupRole) Role(com.liferay.portal.model.Role) Indexer(com.liferay.portal.kernel.search.Indexer) SearchPermissionChecker(com.liferay.portal.kernel.search.SearchPermissionChecker) PermissionChecker(com.liferay.portal.security.permission.PermissionChecker) AdvancedPermissionChecker(com.liferay.portal.security.permission.AdvancedPermissionChecker) AdvancedPermissionChecker(com.liferay.portal.security.permission.AdvancedPermissionChecker) ArrayList(java.util.ArrayList) UniqueList(com.liferay.portal.kernel.util.UniqueList) List(java.util.List)

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