コード例 #1
0
  @Indexable(type = IndexableType.REINDEX)
  @Override
  public Album moveAlbumToTrash(long userId, long albumId) throws PortalException {

    ServiceContext serviceContext = new ServiceContext();

    // Folder

    User user = userPersistence.findByPrimaryKey(userId);
    Date now = new Date();

    Album album = albumPersistence.findByPrimaryKey(albumId);

    int oldStatus = album.getStatus();

    album.setModifiedDate(serviceContext.getModifiedDate(now));
    album.setStatus(WorkflowConstants.STATUS_IN_TRASH);
    album.setStatusByUserId(user.getUserId());
    album.setStatusByUserName(user.getFullName());
    album.setStatusDate(serviceContext.getModifiedDate(now));

    albumPersistence.update(album);

    // Asset

    assetEntryLocalService.updateVisible(Album.class.getName(), album.getAlbumId(), false);

    // Trash

    TrashEntry trashEntry =
        trashEntryLocalService.addTrashEntry(
            userId,
            album.getGroupId(),
            Album.class.getName(),
            album.getAlbumId(),
            album.getUuid(),
            null,
            oldStatus,
            null,
            null);

    // Folders and entries

    List<Song> songs = songLocalService.getSongsByAlbumId(album.getAlbumId());

    moveDependentsToTrash(songs, trashEntry.getEntryId());

    return album;
  }
コード例 #2
0
  @Indexable(type = IndexableType.REINDEX)
  @Override
  public Album restoreAlbumFromTrash(long userId, long albumId) throws PortalException {

    ServiceContext serviceContext = new ServiceContext();

    // Folder

    User user = userPersistence.findByPrimaryKey(userId);
    Date now = new Date();

    Album album = albumPersistence.findByPrimaryKey(albumId);

    TrashEntry trashEntry = trashEntryLocalService.getEntry(Album.class.getName(), albumId);

    album.setModifiedDate(serviceContext.getModifiedDate(now));
    album.setStatus(trashEntry.getStatus());
    album.setStatusByUserId(user.getUserId());
    album.setStatusByUserName(user.getFullName());
    album.setStatusDate(serviceContext.getModifiedDate(now));

    albumPersistence.update(album);

    assetEntryLocalService.updateVisible(Album.class.getName(), album.getAlbumId(), true);

    // Songs

    List<Song> songs =
        songLocalService.getSongsByAlbumId(
            album.getGroupId(), album.getAlbumId(), WorkflowConstants.STATUS_IN_TRASH);

    restoreDependentsFromTrash(songs, trashEntry.getEntryId());

    // Trash

    trashEntryLocalService.deleteEntry(trashEntry.getEntryId());

    return album;
  }