use of org.liferay.jukebox.model.Album in project liferay-ide by liferay.
the class AlbumIndexer method doReindex.
@Override
protected void doReindex(String className, long classPK) throws Exception {
Album album = AlbumLocalServiceUtil.getAlbum(classPK);
doReindex(album);
}
use of org.liferay.jukebox.model.Album 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.Album 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;
}
use of org.liferay.jukebox.model.Album in project liferay-ide by liferay.
the class AlbumServiceImpl method moveAlbumToTrash.
@Override
public Album moveAlbumToTrash(long albumId) throws PortalException, SystemException {
Album album = albumPersistence.findByPrimaryKey(albumId);
AlbumPermission.check(getPermissionChecker(), album, ActionKeys.DELETE);
return albumLocalService.moveAlbumToTrash(getUserId(), albumId);
}
use of org.liferay.jukebox.model.Album 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;
}
Aggregations