Search in sources :

Example 1 with RequiredUserException

use of com.liferay.portal.RequiredUserException in project liferay-ide by liferay.

the class UserLocalServiceImpl method deleteUser.

/**
 * Deletes the user.
 *
 * @param  user the user
 * @return the deleted user
 * @throws PortalException if a portal exception occurred
 * @throws SystemException if a system exception occurred
 */
@Override
public User deleteUser(User user) throws PortalException, SystemException {
    if (!PropsValues.USERS_DELETE) {
        throw new RequiredUserException();
    }
    // Browser tracker
    browserTrackerLocalService.deleteUserBrowserTracker(user.getUserId());
    // Group
    Group group = null;
    if (!user.isDefaultUser()) {
        group = user.getGroup();
    }
    if (group != null) {
        groupLocalService.deleteGroup(group);
    }
    try {
        imageLocalService.deleteImage(user.getPortraitId());
    } catch (NoSuchImageException nsie) {
        if (_log.isWarnEnabled()) {
            _log.warn("Unable to delete image " + user.getPortraitId());
        }
    }
    // Password policy relation
    passwordPolicyRelLocalService.deletePasswordPolicyRel(User.class.getName(), user.getUserId());
    // Old passwords
    passwordTrackerLocalService.deletePasswordTrackers(user.getUserId());
    // Subscriptions
    subscriptionLocalService.deleteSubscriptions(user.getUserId());
    // External user ids
    userIdMapperLocalService.deleteUserIdMappers(user.getUserId());
    // Announcements
    announcementsDeliveryLocalService.deleteDeliveries(user.getUserId());
    // Asset
    assetEntryLocalService.deleteEntry(User.class.getName(), user.getUserId());
    // Blogs
    blogsStatsUserLocalService.deleteStatsUserByUserId(user.getUserId());
    // Document library
    dlFileRankLocalService.deleteFileRanksByUserId(user.getUserId());
    // Expando
    expandoRowLocalService.deleteRows(user.getUserId());
    // Message boards
    mbBanLocalService.deleteBansByBanUserId(user.getUserId());
    mbStatsUserLocalService.deleteStatsUsersByUserId(user.getUserId());
    mbThreadFlagLocalService.deleteThreadFlagsByUserId(user.getUserId());
    // Membership requests
    membershipRequestLocalService.deleteMembershipRequestsByUserId(user.getUserId());
    // Shopping cart
    shoppingCartLocalService.deleteUserCarts(user.getUserId());
    // Social
    socialActivityLocalService.deleteUserActivities(user.getUserId());
    socialRequestLocalService.deleteReceiverUserRequests(user.getUserId());
    socialRequestLocalService.deleteUserRequests(user.getUserId());
    // Mail
    mailService.deleteUser(user.getCompanyId(), user.getUserId());
    // Contact
    Contact contact = contactLocalService.fetchContact(user.getContactId());
    if (contact != null) {
        contactLocalService.deleteContact(contact);
    }
    // Group roles
    userGroupRoleLocalService.deleteUserGroupRolesByUserId(user.getUserId());
    // Resources
    resourceLocalService.deleteResource(user.getCompanyId(), User.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL, user.getUserId());
    // User
    userPersistence.remove(user);
    // Permission cache
    PermissionCacheUtil.clearCache();
    // Workflow
    workflowInstanceLinkLocalService.deleteWorkflowInstanceLinks(user.getCompanyId(), 0, User.class.getName(), user.getUserId());
    return user;
}
Also used : Group(com.liferay.portal.model.Group) UserGroup(com.liferay.portal.model.UserGroup) User(com.liferay.portal.model.User) RequiredUserException(com.liferay.portal.RequiredUserException) NoSuchImageException(com.liferay.portal.NoSuchImageException) Contact(com.liferay.portal.model.Contact)

Aggregations

NoSuchImageException (com.liferay.portal.NoSuchImageException)1 RequiredUserException (com.liferay.portal.RequiredUserException)1 Contact (com.liferay.portal.model.Contact)1 Group (com.liferay.portal.model.Group)1 User (com.liferay.portal.model.User)1 UserGroup (com.liferay.portal.model.UserGroup)1