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