protected void restoreTrashEntries(ActionRequest actionRequest) throws Exception {

    long[] restoreTrashEntryIds =
        StringUtil.split(ParamUtil.getString(actionRequest, "restoreTrashEntryIds"), 0L);

    for (long restoreTrashEntryId : restoreTrashEntryIds) {
      TrashEntryServiceUtil.restoreEntry(restoreTrashEntryId);
    }
  }
Ejemplo n.º 2
0
  private void _trashWikiAttachments(boolean restore) throws Exception {
    int initialNotInTrashCount = _page.getAttachmentsFileEntriesCount();
    int initialTrashEntriesCount = _page.getDeletedAttachmentsFileEntriesCount();

    String fileName = RandomTestUtil.randomString() + ".docx";

    WikiTestUtil.addWikiAttachment(
        TestPropsValues.getUserId(), _node.getNodeId(), _page.getTitle(), fileName, getClass());

    Assert.assertEquals(initialNotInTrashCount + 1, _page.getAttachmentsFileEntriesCount());
    Assert.assertEquals(initialTrashEntriesCount, _page.getDeletedAttachmentsFileEntriesCount());

    FileEntry fileEntry =
        WikiPageLocalServiceUtil.movePageAttachmentToTrash(
            TestPropsValues.getUserId(), _page.getNodeId(), _page.getTitle(), fileName);

    Assert.assertEquals(initialNotInTrashCount, _page.getAttachmentsFileEntriesCount());
    Assert.assertEquals(
        initialTrashEntriesCount + 1, _page.getDeletedAttachmentsFileEntriesCount());

    if (restore) {
      TrashEntryServiceUtil.restoreEntry(
          DLFileEntryConstants.getClassName(), fileEntry.getFileEntryId());

      Assert.assertEquals(initialNotInTrashCount + 1, _page.getAttachmentsFileEntriesCount());
      Assert.assertEquals(initialTrashEntriesCount, _page.getDeletedAttachmentsFileEntriesCount());

      WikiPageLocalServiceUtil.deletePageAttachment(_page.getNodeId(), _page.getTitle(), fileName);
    } else {
      WikiPageLocalServiceUtil.deletePageAttachment(
          _page.getNodeId(), _page.getTitle(), fileEntry.getTitle());

      Assert.assertEquals(initialNotInTrashCount, _page.getAttachmentsFileEntriesCount());
      Assert.assertEquals(initialTrashEntriesCount, _page.getDeletedAttachmentsFileEntriesCount());
    }
  }