Search in sources :

Example 11 with Indexable

use of com.liferay.portal.kernel.search.Indexable in project liferay-ide by liferay.

the class SongLocalServiceImpl method moveSongToTrash.

@Indexable(type = IndexableType.REINDEX)
public Song moveSongToTrash(long userId, Song song) throws PortalException, SystemException {
    ServiceContext serviceContext = new ServiceContext();
    // Entry
    User user = userPersistence.findByPrimaryKey(userId);
    Date now = new Date();
    int oldStatus = song.getStatus();
    song.setModifiedDate(serviceContext.getModifiedDate(now));
    song.setStatus(WorkflowConstants.STATUS_IN_TRASH);
    song.setStatusByUserId(user.getUserId());
    song.setStatusByUserName(user.getFullName());
    song.setStatusDate(serviceContext.getModifiedDate(now));
    // Asset
    assetEntryLocalService.updateVisible(Song.class.getName(), song.getSongId(), false);
    // Trash
    UnicodeProperties typeSettingsProperties = new UnicodeProperties();
    typeSettingsProperties.put("title", song.getName());
    TrashEntry trashEntry = trashEntryLocalService.addTrashEntry(userId, song.getGroupId(), Song.class.getName(), song.getSongId(), song.getUuid(), null, oldStatus, null, typeSettingsProperties);
    song.setName(TrashUtil.getTrashTitle(trashEntry.getEntryId()));
    songPersistence.update(song);
    return song;
}
Also used : Song(org.liferay.jukebox.model.Song) User(com.liferay.portal.model.User) TrashEntry(com.liferay.portlet.trash.model.TrashEntry) UnicodeProperties(com.liferay.portal.kernel.util.UnicodeProperties) ServiceContext(com.liferay.portal.service.ServiceContext) Date(java.util.Date) Indexable(com.liferay.portal.kernel.search.Indexable)

Example 12 with Indexable

use of com.liferay.portal.kernel.search.Indexable 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 13 with Indexable

use of com.liferay.portal.kernel.search.Indexable in project liferay-ide by liferay.

the class SongLocalServiceImpl method deleteSong.

@Indexable(type = IndexableType.DELETE)
public Song deleteSong(long songId) throws PortalException, SystemException {
    Song song = songPersistence.findByPrimaryKey(songId);
    Repository repository = PortletFileRepositoryUtil.fetchPortletRepository(song.getGroupId(), Constants.JUKEBOX_PORTLET_REPOSITORY);
    if (repository != null) {
        try {
            Folder folder = PortletFileRepositoryUtil.getPortletFolder(0, repository.getRepositoryId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, String.valueOf(songId), null);
            PortletFileRepositoryUtil.deleteFolder(folder.getFolderId());
        } catch (Exception e) {
        }
    }
    return songPersistence.remove(songId);
}
Also used : Song(org.liferay.jukebox.model.Song) Repository(com.liferay.portal.model.Repository) Folder(com.liferay.portal.kernel.repository.model.Folder) SongNameException(org.liferay.jukebox.SongNameException) PortalException(com.liferay.portal.kernel.exception.PortalException) SystemException(com.liferay.portal.kernel.exception.SystemException) DuplicatedSongException(org.liferay.jukebox.DuplicatedSongException) Indexable(com.liferay.portal.kernel.search.Indexable)

Example 14 with Indexable

use of com.liferay.portal.kernel.search.Indexable in project liferay-ide by liferay.

the class SongLocalServiceImpl method restoreSongFromTrash.

@Indexable(type = IndexableType.REINDEX)
@Override
public Song restoreSongFromTrash(long userId, long songId) throws PortalException, SystemException {
    ServiceContext serviceContext = new ServiceContext();
    // Entry
    User user = userPersistence.findByPrimaryKey(userId);
    Date now = new Date();
    TrashEntry trashEntry = trashEntryLocalService.getEntry(Song.class.getName(), songId);
    Song song = songPersistence.findByPrimaryKey(songId);
    song.setName(TrashUtil.getOriginalTitle(song.getName()));
    song.setModifiedDate(serviceContext.getModifiedDate(now));
    song.setStatus(trashEntry.getStatus());
    song.setStatusByUserId(user.getUserId());
    song.setStatusByUserName(user.getFullName());
    song.setStatusDate(serviceContext.getModifiedDate(now));
    songPersistence.update(song);
    assetEntryLocalService.updateVisible(Song.class.getName(), song.getSongId(), true);
    trashEntryLocalService.deleteEntry(Song.class.getName(), songId);
    return song;
}
Also used : Song(org.liferay.jukebox.model.Song) User(com.liferay.portal.model.User) TrashEntry(com.liferay.portlet.trash.model.TrashEntry) ServiceContext(com.liferay.portal.service.ServiceContext) Date(java.util.Date) Indexable(com.liferay.portal.kernel.search.Indexable)

Aggregations

Indexable (com.liferay.portal.kernel.search.Indexable)14 User (com.liferay.portal.model.User)10 Song (org.liferay.jukebox.model.Song)9 Album (org.liferay.jukebox.model.Album)8 Date (java.util.Date)7 PortalException (com.liferay.portal.kernel.exception.PortalException)5 SystemException (com.liferay.portal.kernel.exception.SystemException)5 Repository (com.liferay.portal.model.Repository)5 ServiceContext (com.liferay.portal.service.ServiceContext)4 TrashEntry (com.liferay.portlet.trash.model.TrashEntry)4 Folder (com.liferay.portal.kernel.repository.model.Folder)3 Artist (org.liferay.jukebox.model.Artist)3 FileEntry (com.liferay.portal.kernel.repository.model.FileEntry)2 AlbumNameException (org.liferay.jukebox.AlbumNameException)2 ArtistNameException (org.liferay.jukebox.ArtistNameException)2 UnicodeProperties (com.liferay.portal.kernel.util.UnicodeProperties)1 DuplicatedSongException (org.liferay.jukebox.DuplicatedSongException)1 SongNameException (org.liferay.jukebox.SongNameException)1