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;
}
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;
}
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);
}
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;
}
Aggregations