Search in sources :

Example 11 with User

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

the class ArtistLocalServiceImpl method updateArtist.

@Indexable(type = IndexableType.REINDEX)
public Artist updateArtist(long userId, long artistId, String name, String bio, InputStream inputStream, ServiceContext serviceContext) throws PortalException, SystemException {
    // Event
    User user = userPersistence.findByPrimaryKey(userId);
    validate(name);
    Artist artist = artistPersistence.findByPrimaryKey(artistId);
    artist.setModifiedDate(serviceContext.getModifiedDate(null));
    artist.setName(name);
    artist.setBio(bio);
    artist.setExpandoBridgeAttributes(serviceContext);
    artistPersistence.update(artist);
    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(artist.getArtistId()));
            } catch (Exception e) {
                if (_log.isDebugEnabled()) {
                    _log.debug("Cannot delete artist image");
                }
            }
        }
        PortletFileRepositoryUtil.addPortletFileEntry(serviceContext.getScopeGroupId(), userId, Artist.class.getName(), artist.getArtistId(), Constants.JUKEBOX_PORTLET_REPOSITORY, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, inputStream, String.valueOf(artist.getArtistId()), StringPool.BLANK, true);
    }
    // Asset
    updateAsset(userId, artist, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), serviceContext.getAssetLinkEntryIds());
    return artist;
}
Also used : Artist(org.liferay.jukebox.model.Artist) Repository(com.liferay.portal.model.Repository) User(com.liferay.portal.model.User) PortalException(com.liferay.portal.kernel.exception.PortalException) SystemException(com.liferay.portal.kernel.exception.SystemException) ArtistNameException(org.liferay.jukebox.ArtistNameException) Indexable(com.liferay.portal.kernel.search.Indexable)

Example 12 with User

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

the class ArtistLocalServiceImpl method addArtist.

@Indexable(type = IndexableType.REINDEX)
public Artist addArtist(long userId, String name, String bio, InputStream inputStream, ServiceContext serviceContext) throws PortalException, SystemException {
    long groupId = serviceContext.getScopeGroupId();
    User user = userPersistence.findByPrimaryKey(userId);
    Date now = new Date();
    validate(name);
    long artistId = counterLocalService.increment();
    Artist artist = artistPersistence.create(artistId);
    artist.setUuid(serviceContext.getUuid());
    artist.setGroupId(groupId);
    artist.setCompanyId(user.getCompanyId());
    artist.setUserId(user.getUserId());
    artist.setUserName(user.getFullName());
    artist.setCreateDate(serviceContext.getCreateDate(now));
    artist.setModifiedDate(serviceContext.getModifiedDate(now));
    artist.setName(name);
    artist.setBio(bio);
    artist.setExpandoBridgeAttributes(serviceContext);
    artistPersistence.update(artist);
    if (inputStream != null) {
        PortletFileRepositoryUtil.addPortletFileEntry(groupId, userId, Artist.class.getName(), artist.getArtistId(), Constants.JUKEBOX_PORTLET_REPOSITORY, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, inputStream, String.valueOf(artist.getArtistId()), StringPool.BLANK, true);
    }
    if (serviceContext.isAddGroupPermissions() || serviceContext.isAddGuestPermissions()) {
        addEntryResources(artist, serviceContext.isAddGroupPermissions(), serviceContext.isAddGuestPermissions());
    } else {
        addEntryResources(artist, serviceContext.getGroupPermissions(), serviceContext.getGuestPermissions());
    }
    // Message boards
    mbMessageLocalService.addDiscussionMessage(userId, artist.getUserName(), groupId, Artist.class.getName(), artistId, WorkflowConstants.ACTION_PUBLISH);
    // Asset
    updateAsset(userId, artist, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), serviceContext.getAssetLinkEntryIds());
    return artist;
}
Also used : Artist(org.liferay.jukebox.model.Artist) User(com.liferay.portal.model.User) Date(java.util.Date) Indexable(com.liferay.portal.kernel.search.Indexable)

Example 13 with User

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

the class SongLocalServiceImpl method moveSongFromTrash.

@Override
public Song moveSongFromTrash(long userId, long songId, long albumId) throws PortalException, SystemException {
    Song song = getSong(songId);
    TrashEntry trashEntry = song.getTrashEntry();
    if (trashEntry.isTrashEntry(Song.class, songId)) {
        restoreSongFromTrash(userId, songId);
    } else {
        // Entry
        TrashVersion trashVersion = trashVersionLocalService.fetchVersion(trashEntry.getEntryId(), Song.class.getName(), songId);
        int status = WorkflowConstants.STATUS_APPROVED;
        if (trashVersion != null) {
            status = trashVersion.getStatus();
        }
        ServiceContext serviceContext = new ServiceContext();
        // Entry
        User user = userPersistence.findByPrimaryKey(userId);
        Date now = new Date();
        song.setModifiedDate(serviceContext.getModifiedDate(now));
        song.setStatus(status);
        song.setStatusByUserId(user.getUserId());
        song.setStatusByUserName(user.getFullName());
        song.setStatusDate(serviceContext.getModifiedDate(now));
        songPersistence.update(song);
        // Asset
        assetEntryLocalService.updateVisible(Song.class.getName(), song.getSongId(), false);
        // Indexer
        Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(Song.class);
        indexer.reindex(song);
        if (trashVersion != null) {
            trashVersionLocalService.deleteTrashVersion(trashVersion);
        }
    }
    return songLocalService.moveSong(songId, albumId);
}
Also used : Song(org.liferay.jukebox.model.Song) TrashEntry(com.liferay.portlet.trash.model.TrashEntry) User(com.liferay.portal.model.User) Indexer(com.liferay.portal.kernel.search.Indexer) ServiceContext(com.liferay.portal.service.ServiceContext) TrashVersion(com.liferay.portlet.trash.model.TrashVersion) Date(java.util.Date)

Example 14 with User

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

the class UserLocalServiceImpl method updateOpenId.

/**
 * Updates the user's OpenID.
 *
 * @param  userId the primary key of the user
 * @param  openId the new OpenID
 * @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 updateOpenId(long userId, String openId) throws PortalException, SystemException {
    openId = openId.trim();
    User user = userPersistence.findByPrimaryKey(userId);
    user.setOpenId(openId);
    userPersistence.update(user);
    return user;
}
Also used : User(com.liferay.portal.model.User)

Example 15 with User

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

the class UserLocalServiceImpl method updateCreateDate.

/**
 * Updates the user's creation date.
 *
 * @param  userId the primary key of the user
 * @param  createDate the new creation date
 * @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 updateCreateDate(long userId, Date createDate) throws PortalException, SystemException {
    User user = userPersistence.findByPrimaryKey(userId);
    user.setCreateDate(createDate);
    userPersistence.update(user);
    return user;
}
Also used : User(com.liferay.portal.model.User)

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