Search in sources :

Example 96 with Album

use of org.liferay.jukebox.model.Album in project liferay-ide by liferay.

the class SongLocalServiceImpl method updateSong.

@Indexable(type = IndexableType.REINDEX)
public Song updateSong(long userId, long songId, long albumId, String name, String songFileName, InputStream songInputStream, String lyricsFileName, InputStream lyricsInputStream, ServiceContext serviceContext) throws PortalException, SystemException {
    // Event
    User user = userPersistence.findByPrimaryKey(userId);
    Song song = songPersistence.findByPrimaryKey(songId);
    Album album = albumPersistence.findByPrimaryKey(albumId);
    validate(songId, song.getGroupId(), album.getArtistId(), albumId, name);
    song.setModifiedDate(serviceContext.getModifiedDate(null));
    song.setArtistId(album.getArtistId());
    song.setAlbumId(albumId);
    song.setName(name);
    song.setExpandoBridgeAttributes(serviceContext);
    songPersistence.update(song);
    if ((songInputStream != null) || (lyricsInputStream != null)) {
        Repository repository = PortletFileRepositoryUtil.addPortletRepository(serviceContext.getScopeGroupId(), Constants.JUKEBOX_PORTLET_REPOSITORY, serviceContext);
        Folder folder = PortletFileRepositoryUtil.addPortletFolder(userId, repository.getRepositoryId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, String.valueOf(song.getSongId()), serviceContext);
        if (songInputStream != null) {
            Folder songFolder = PortletFileRepositoryUtil.addPortletFolder(userId, repository.getRepositoryId(), folder.getFolderId(), Constants.SONGS_FOLDER_NAME, serviceContext);
            List<FileEntry> fileEntries = PortletFileRepositoryUtil.getPortletFileEntries(serviceContext.getScopeGroupId(), songFolder.getFolderId());
            for (FileEntry fileEntry : fileEntries) {
                PortletFileRepositoryUtil.deletePortletFileEntry(fileEntry.getFileEntryId());
                DLProcessorRegistryUtil.cleanUp(fileEntry);
            }
            FileEntry fileEntry = PortletFileRepositoryUtil.addPortletFileEntry(serviceContext.getScopeGroupId(), userId, Song.class.getName(), song.getSongId(), Constants.JUKEBOX_PORTLET_REPOSITORY, songFolder.getFolderId(), songInputStream, songFileName, StringPool.BLANK, true);
            triggerDLProcessors(fileEntry);
        }
        if (lyricsInputStream != null) {
            Folder lyricsFolder = PortletFileRepositoryUtil.addPortletFolder(userId, repository.getRepositoryId(), folder.getFolderId(), Constants.LYRICS_FOLDER_NAME, serviceContext);
            List<FileEntry> fileEntries = PortletFileRepositoryUtil.getPortletFileEntries(serviceContext.getScopeGroupId(), lyricsFolder.getFolderId());
            for (FileEntry fileEntry : fileEntries) {
                PortletFileRepositoryUtil.deletePortletFileEntry(fileEntry.getFileEntryId());
                DLProcessorRegistryUtil.cleanUp(fileEntry);
            }
            FileEntry fileEntry = PortletFileRepositoryUtil.addPortletFileEntry(serviceContext.getScopeGroupId(), userId, Song.class.getName(), song.getSongId(), Constants.JUKEBOX_PORTLET_REPOSITORY, lyricsFolder.getFolderId(), lyricsInputStream, lyricsFileName, StringPool.BLANK, true);
            triggerDLProcessors(fileEntry);
        }
    }
    // Asset
    updateAsset(userId, song, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), serviceContext.getAssetLinkEntryIds());
    return song;
}
Also used : Song(org.liferay.jukebox.model.Song) Repository(com.liferay.portal.model.Repository) User(com.liferay.portal.model.User) Album(org.liferay.jukebox.model.Album) FileEntry(com.liferay.portal.kernel.repository.model.FileEntry) Folder(com.liferay.portal.kernel.repository.model.Folder) Indexable(com.liferay.portal.kernel.search.Indexable)

Example 97 with Album

use of org.liferay.jukebox.model.Album in project liferay-ide by liferay.

the class AlbumTrashHandler method getRestoreURL.

protected PortletURL getRestoreURL(PortletRequest portletRequest, long classPK) throws PortalException, SystemException {
    String portletId = PortletKeys.ALBUMS;
    Album album = AlbumLocalServiceUtil.getAlbum(classPK);
    long plid = PortalUtil.getPlidFromPortletId(album.getGroupId(), PortletKeys.ALBUMS);
    PortletURL portletURL = PortletURLFactoryUtil.create(portletRequest, portletId, plid, PortletRequest.RENDER_PHASE);
    portletURL.setParameter("jspPage", "/html/albums/view_album.jsp");
    return portletURL;
}
Also used : Album(org.liferay.jukebox.model.Album) PortletURL(javax.portlet.PortletURL)

Aggregations

Album (org.liferay.jukebox.model.Album)97 NoSuchAlbumException (org.liferay.jukebox.NoSuchAlbumException)55 StringBundler (com.liferay.portal.kernel.util.StringBundler)53 SystemException (com.liferay.portal.kernel.exception.SystemException)37 Session (com.liferay.portal.kernel.dao.orm.Session)34 SQLQuery (com.liferay.portal.kernel.dao.orm.SQLQuery)32 QueryPos (com.liferay.portal.kernel.dao.orm.QueryPos)31 Query (com.liferay.portal.kernel.dao.orm.Query)22 AlbumImpl (org.liferay.jukebox.model.impl.AlbumImpl)18 UnmodifiableList (com.liferay.portal.kernel.util.UnmodifiableList)17 ArrayList (java.util.ArrayList)17 List (java.util.List)17 FinderPath (com.liferay.portal.kernel.dao.orm.FinderPath)11 Indexable (com.liferay.portal.kernel.search.Indexable)8 User (com.liferay.portal.model.User)6 Song (org.liferay.jukebox.model.Song)6 ServiceContext (com.liferay.portal.service.ServiceContext)4 Date (java.util.Date)4 Artist (org.liferay.jukebox.model.Artist)4 PortalException (com.liferay.portal.kernel.exception.PortalException)3