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