Search in sources :

Example 81 with User

use of com.liferay.portal.model.User in project liferay-ide by liferay.

the class UserLocalServiceImpl method updateEmailAddressVerified.

/**
 * Updates whether the user has verified email address.
 *
 * @param  userId the primary key of the user
 * @param  emailAddressVerified whether the user has verified email address
 * @return the user
 * @throws PortalException if a user with the primary key could not be found
 * @throws SystemException if a system exception occurred
 */
@Override
public User updateEmailAddressVerified(long userId, boolean emailAddressVerified) throws PortalException, SystemException {
    User user = userPersistence.findByPrimaryKey(userId);
    user.setEmailAddressVerified(emailAddressVerified);
    userPersistence.update(user);
    return user;
}
Also used : User(com.liferay.portal.model.User)

Example 82 with User

use of com.liferay.portal.model.User in project liferay-ide by liferay.

the class UserLocalServiceImpl method deletePortrait.

/**
 * Deletes the user's portrait image.
 *
 * @param  userId the primary key of the user
 * @throws PortalException if a user with the primary key could not be found
 *         or if the user's portrait could not be found
 * @throws SystemException if a system exception occurred
 */
@Override
public void deletePortrait(long userId) throws PortalException, SystemException {
    User user = userPersistence.findByPrimaryKey(userId);
    long portraitId = user.getPortraitId();
    if (portraitId > 0) {
        user.setPortraitId(0);
        userPersistence.update(user);
        imageLocalService.deleteImage(portraitId);
    }
}
Also used : User(com.liferay.portal.model.User)

Example 83 with User

use of com.liferay.portal.model.User in project liferay-ide by liferay.

the class WebServerServlet method _getGroupId.

private static long _getGroupId(long companyId, String name) throws Exception {
    try {
        Group group = GroupLocalServiceUtil.getFriendlyURLGroup(companyId, StringPool.SLASH + name);
        return group.getGroupId();
    } catch (NoSuchGroupException nsge) {
    }
    User user = UserLocalServiceUtil.getUserByScreenName(companyId, name);
    Group group = user.getGroup();
    return group.getGroupId();
}
Also used : Group(com.liferay.portal.model.Group) User(com.liferay.portal.model.User) NoSuchGroupException(com.liferay.portal.NoSuchGroupException)

Example 84 with User

use of com.liferay.portal.model.User in project liferay-ide by liferay.

the class WebServerServlet method _getUser.

private static User _getUser(HttpServletRequest request) throws Exception {
    HttpSession session = request.getSession();
    if (PortalSessionThreadLocal.getHttpSession() == null) {
        PortalSessionThreadLocal.setHttpSession(session);
    }
    User user = PortalUtil.getUser(request);
    if (user != null) {
        return user;
    }
    String userIdString = (String) session.getAttribute("j_username");
    String password = (String) session.getAttribute("j_password");
    if ((userIdString != null) && (password != null)) {
        long userId = GetterUtil.getLong(userIdString);
        user = UserLocalServiceUtil.getUser(userId);
    } else {
        long companyId = PortalUtil.getCompanyId(request);
        Company company = CompanyLocalServiceUtil.getCompany(companyId);
        user = company.getDefaultUser();
    }
    return user;
}
Also used : Company(com.liferay.portal.model.Company) User(com.liferay.portal.model.User) HttpSession(javax.servlet.http.HttpSession)

Example 85 with User

use of com.liferay.portal.model.User in project liferay-ide by liferay.

the class AlbumLocalServiceImpl method updateAlbum.

@Indexable(type = IndexableType.REINDEX)
public Album updateAlbum(long userId, long albumId, long artistId, String name, int year, InputStream inputStream, ServiceContext serviceContext) throws PortalException, SystemException {
    // Event
    User user = userPersistence.findByPrimaryKey(userId);
    validate(name);
    Album album = albumPersistence.findByPrimaryKey(albumId);
    album.setModifiedDate(serviceContext.getModifiedDate(null));
    album.setArtistId(artistId);
    album.setName(name);
    album.setYear(year);
    album.setExpandoBridgeAttributes(serviceContext);
    albumPersistence.update(album);
    if (inputStream != null) {
        Repository repository = PortletFileRepositoryUtil.fetchPortletRepository(serviceContext.getScopeGroupId(), Constants.JUKEBOX_PORTLET_REPOSITORY);
        if (repository != null) {
            try {
                PortletFileRepositoryUtil.deletePortletFileEntry(repository.getRepositoryId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, String.valueOf(album.getAlbumId()));
            } catch (Exception e) {
                if (_log.isDebugEnabled()) {
                    _log.debug("Cannot delete album cover");
                }
            }
        }
        PortletFileRepositoryUtil.addPortletFileEntry(serviceContext.getScopeGroupId(), userId, Album.class.getName(), album.getAlbumId(), Constants.JUKEBOX_PORTLET_REPOSITORY, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, inputStream, String.valueOf(album.getAlbumId()), StringPool.BLANK, true);
    }
    // Asset
    updateAsset(userId, album, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), serviceContext.getAssetLinkEntryIds());
    return album;
}
Also used : Repository(com.liferay.portal.model.Repository) User(com.liferay.portal.model.User) Album(org.liferay.jukebox.model.Album) PortalException(com.liferay.portal.kernel.exception.PortalException) SystemException(com.liferay.portal.kernel.exception.SystemException) AlbumNameException(org.liferay.jukebox.AlbumNameException) Indexable(com.liferay.portal.kernel.search.Indexable)

Aggregations

User (com.liferay.portal.model.User)97 Date (java.util.Date)22 SystemException (com.liferay.portal.kernel.exception.SystemException)17 Group (com.liferay.portal.model.Group)15 PortalException (com.liferay.portal.kernel.exception.PortalException)13 Company (com.liferay.portal.model.Company)11 ServiceContext (com.liferay.portal.service.ServiceContext)11 Indexable (com.liferay.portal.kernel.search.Indexable)10 UserGroup (com.liferay.portal.model.UserGroup)10 IOException (java.io.IOException)9 DuplicateUserEmailAddressException (com.liferay.portal.DuplicateUserEmailAddressException)8 EncryptorException (com.liferay.util.EncryptorException)7 Song (org.liferay.jukebox.model.Song)7 Contact (com.liferay.portal.model.Contact)6 PrincipalException (com.liferay.portal.security.auth.PrincipalException)6 Album (org.liferay.jukebox.model.Album)6 DuplicateUserScreenNameException (com.liferay.portal.DuplicateUserScreenNameException)5 GroupFriendlyURLException (com.liferay.portal.GroupFriendlyURLException)5 NoSuchImageException (com.liferay.portal.NoSuchImageException)5 NoSuchOrganizationException (com.liferay.portal.NoSuchOrganizationException)5