use of com.liferay.portal.NoSuchImageException 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;
}
Aggregations