/** * Adds the song to the database. Also notifies the appropriate model listeners. * * @param song the song * @return the song that was added */ @Indexable(type = IndexableType.REINDEX) @Override public Song addSong(Song song) { song.setNew(true); return songPersistence.update(song); }
protected void restoreDependentsFromTrash(List<Song> songs, long trashEntryId) throws PortalException { 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); // Trash if (trashVersion != null) { trashVersionLocalService.deleteTrashVersion(trashVersion); } // Asset if (oldStatus == WorkflowConstants.STATUS_APPROVED) { assetEntryLocalService.updateVisible(Song.class.getName(), song.getSongId(), true); } // Indexer Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(Song.class); indexer.reindex(song); } }
@Indexable(type = IndexableType.DELETE) public Album deleteAlbum(long albumId) throws PortalException { 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); }
protected void moveDependentsToTrash(List<Song> songs, long trashEntryId) throws PortalException { for (Song song : songs) { // Entry if (song.isInTrash()) { continue; } int oldStatus = song.getStatus(); song.setStatus(WorkflowConstants.STATUS_IN_TRASH); songPersistence.update(song); // Trash int status = oldStatus; if (oldStatus == WorkflowConstants.STATUS_PENDING) { status = WorkflowConstants.STATUS_DRAFT; } if (oldStatus != WorkflowConstants.STATUS_APPROVED) { trashVersionLocalService.addTrashVersion( trashEntryId, Song.class.getName(), song.getSongId(), status, null); } // Asset assetEntryLocalService.updateVisible(Song.class.getName(), song.getSongId(), false); // Indexer Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(Song.class); indexer.reindex(song); } }