use of org.liferay.jukebox.model.Song in project liferay-ide by liferay.
the class AlbumLocalServiceImpl method restoreDependentsFromTrash.
protected void restoreDependentsFromTrash(List<Song> songs, long trashEntryId) throws PortalException, SystemException {
for (Song song : songs) {
// Song
TrashEntry trashEntry = trashEntryLocalService.fetchEntry(Song.class.getName(), song.getSongId());
if (trashEntry != null) {
continue;
}
TrashVersion trashVersion = trashVersionLocalService.fetchVersion(trashEntryId, Song.class.getName(), song.getSongId());
int oldStatus = WorkflowConstants.STATUS_APPROVED;
if (trashVersion != null) {
oldStatus = trashVersion.getStatus();
}
song.setStatus(oldStatus);
songPersistence.update(song);
if (trashVersion != null) {
trashVersionLocalService.deleteTrashVersion(trashVersion);
}
if (oldStatus == WorkflowConstants.STATUS_APPROVED) {
assetEntryLocalService.updateVisible(Song.class.getName(), song.getSongId(), true);
}
// Indexer
Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(Song.class);
indexer.reindex(song);
}
}
use of org.liferay.jukebox.model.Song in project liferay-ide by liferay.
the class AlbumLocalServiceImpl method deleteAlbum.
@Indexable(type = IndexableType.DELETE)
public Album deleteAlbum(long albumId) throws PortalException, SystemException {
Album album = albumPersistence.findByPrimaryKey(albumId);
List<Song> songs = songLocalService.getSongsByAlbumId(albumId);
for (Song song : songs) {
songLocalService.deleteSong(song.getSongId());
}
try {
PortletFileRepositoryUtil.deletePortletFileEntry(album.getGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, String.valueOf(albumId));
} catch (Exception e) {
}
return albumPersistence.remove(albumId);
}
use of org.liferay.jukebox.model.Song in project liferay-ide by liferay.
the class SongLocalServiceImpl method addSong.
@Indexable(type = IndexableType.REINDEX)
public Song addSong(long userId, long albumId, String name, String songFileName, InputStream songInputStream, String lyricsFileName, InputStream lyricsInputStream, ServiceContext serviceContext) throws PortalException, SystemException {
long groupId = serviceContext.getScopeGroupId();
User user = userPersistence.findByPrimaryKey(userId);
Date now = new Date();
long songId = counterLocalService.increment();
Album album = albumPersistence.findByPrimaryKey(albumId);
validate(songId, groupId, album.getArtistId(), albumId, name);
Song song = songPersistence.create(songId);
song.setUuid(serviceContext.getUuid());
song.setGroupId(groupId);
song.setCompanyId(user.getCompanyId());
song.setUserId(user.getUserId());
song.setUserName(user.getFullName());
song.setCreateDate(serviceContext.getCreateDate(now));
song.setModifiedDate(serviceContext.getModifiedDate(now));
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(groupId, 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);
FileEntry fileEntry = PortletFileRepositoryUtil.addPortletFileEntry(groupId, userId, Song.class.getName(), song.getSongId(), Constants.JUKEBOX_PORTLET_REPOSITORY, songFolder.getFolderId(), songInputStream, songFileName, StringPool.BLANK, true);
DLProcessorRegistryUtil.trigger(fileEntry, null, true);
}
if (lyricsInputStream != null) {
Folder lyricsFolder = PortletFileRepositoryUtil.addPortletFolder(userId, repository.getRepositoryId(), folder.getFolderId(), Constants.LYRICS_FOLDER_NAME, serviceContext);
FileEntry fileEntry = PortletFileRepositoryUtil.addPortletFileEntry(groupId, userId, Song.class.getName(), song.getSongId(), Constants.JUKEBOX_PORTLET_REPOSITORY, lyricsFolder.getFolderId(), lyricsInputStream, lyricsFileName, StringPool.BLANK, true);
DLProcessorRegistryUtil.trigger(fileEntry, null, true);
}
}
if (serviceContext.isAddGroupPermissions() || serviceContext.isAddGuestPermissions()) {
addEntryResources(song, serviceContext.isAddGroupPermissions(), serviceContext.isAddGuestPermissions());
} else {
addEntryResources(song, serviceContext.getGroupPermissions(), serviceContext.getGuestPermissions());
}
// Message boards
mbMessageLocalService.addDiscussionMessage(userId, album.getUserName(), groupId, Song.class.getName(), songId, WorkflowConstants.ACTION_PUBLISH);
// Asset
updateAsset(userId, song, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), serviceContext.getAssetLinkEntryIds());
return song;
}
use of org.liferay.jukebox.model.Song 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;
}
use of org.liferay.jukebox.model.Song 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;
}
Aggregations