Search in sources :

Example 1 with ArchiveContentsResult

use of com.enonic.xp.archive.ArchiveContentsResult in project xp by enonic.

the class ArchiveContentCommand method execute.

ArchiveContentsResult execute() {
    params.validate();
    try {
        final ArchiveContentsResult archivedContents = doExecute();
        this.nodeService.refresh(RefreshMode.ALL);
        return archivedContents;
    } catch (MoveNodeException e) {
        throw new ArchiveContentException(e.getMessage(), ContentNodeHelper.translateNodePathToContentPath(e.getPath()));
    } catch (NodeAccessException e) {
        throw new ContentAccessException(e);
    }
}
Also used : MoveNodeException(com.enonic.xp.node.MoveNodeException) NodeAccessException(com.enonic.xp.node.NodeAccessException) ArchiveContentException(com.enonic.xp.archive.ArchiveContentException) ArchiveContentsResult(com.enonic.xp.archive.ArchiveContentsResult) ContentAccessException(com.enonic.xp.content.ContentAccessException)

Example 2 with ArchiveContentsResult

use of com.enonic.xp.archive.ArchiveContentsResult in project xp by enonic.

the class ContentServiceImpl method archive.

@Override
public ArchiveContentsResult archive(final ArchiveContentParams params) {
    final ArchiveContentsResult result = ArchiveContentCommand.create(params).nodeService(nodeService).translator(translator).eventPublisher(eventPublisher).contentTypeService(contentTypeService).archiveListener(params.getArchiveContentListener()).build().execute();
    contentAuditLogSupport.archive(params, result);
    return result;
}
Also used : ArchiveContentsResult(com.enonic.xp.archive.ArchiveContentsResult)

Example 3 with ArchiveContentsResult

use of com.enonic.xp.archive.ArchiveContentsResult in project xp by enonic.

the class ContentServiceImplTest_archive method archive_tree.

@Test
public void archive_tree() throws Exception {
    final Content parent = createContent(ContentPath.ROOT, "archive");
    final Content child1 = createContent(parent.getPath(), "child1");
    final Content child1_1 = createContent(child1.getPath(), "child1_1");
    final Content child1_2 = createContent(child1.getPath(), "child2_1");
    final ArchiveContentParams params = ArchiveContentParams.create().contentId(parent.getId()).archiveContentListener(listener).build();
    final ArchiveContentsResult result = this.contentService.archive(params);
    assertEquals(1, result.getArchivedContents().getSize());
    assertEquals(4, listener.getArchived());
    assertFalse(this.contentService.contentExists(child1.getId()));
    assertFalse(this.contentService.contentExists(child1.getPath()));
    assertFalse(this.contentService.contentExists(child1_1.getId()));
    assertFalse(this.contentService.contentExists(child1_1.getPath()));
    assertFalse(this.contentService.contentExists(child1_2.getId()));
    assertFalse(this.contentService.contentExists(child1_2.getPath()));
    archiveContext().runWith(() -> {
        assertTrue(this.contentService.contentExists(child1.getId()));
        assertTrue(this.contentService.contentExists(child1.getPath()));
        assertTrue(this.contentService.contentExists(child1_1.getId()));
        assertTrue(this.contentService.contentExists(child1_1.getPath()));
        assertTrue(this.contentService.contentExists(child1_2.getId()));
        assertTrue(this.contentService.contentExists(child1_2.getPath()));
    });
}
Also used : ArchiveContentParams(com.enonic.xp.archive.ArchiveContentParams) Content(com.enonic.xp.content.Content) ArchiveContentsResult(com.enonic.xp.archive.ArchiveContentsResult) Test(org.junit.jupiter.api.Test)

Example 4 with ArchiveContentsResult

use of com.enonic.xp.archive.ArchiveContentsResult in project xp by enonic.

the class ArchiveContentHandler method archive.

private List<String> archive(final ContentId sourceId) {
    final ArchiveContentParams archiveParams = ArchiveContentParams.create().contentId(sourceId).build();
    final ArchiveContentsResult result = contentService.archive(archiveParams);
    return result.getArchivedContents().stream().map(ContentId::toString).collect(Collectors.toList());
}
Also used : ArchiveContentParams(com.enonic.xp.archive.ArchiveContentParams) ArchiveContentsResult(com.enonic.xp.archive.ArchiveContentsResult)

Aggregations

ArchiveContentsResult (com.enonic.xp.archive.ArchiveContentsResult)4 ArchiveContentParams (com.enonic.xp.archive.ArchiveContentParams)2 ArchiveContentException (com.enonic.xp.archive.ArchiveContentException)1 Content (com.enonic.xp.content.Content)1 ContentAccessException (com.enonic.xp.content.ContentAccessException)1 MoveNodeException (com.enonic.xp.node.MoveNodeException)1 NodeAccessException (com.enonic.xp.node.NodeAccessException)1 Test (org.junit.jupiter.api.Test)1