use of com.enonic.xp.archive.RestoreContentsResult in project xp by enonic.
the class ContentServiceImplTest_restore method restore_to_tree.
@Test
public void restore_to_tree() throws Exception {
final Content parent = createContent(ContentPath.ROOT, "archive");
final Content child1 = createContent(parent.getPath(), "child1");
createContent(child1.getPath(), "child1_1");
createContent(child1.getPath(), "child2_1");
this.contentService.archive(ArchiveContentParams.create().contentId(child1.getId()).build());
RestoreContentsResult result = this.contentService.restore(RestoreContentParams.create().contentId(child1.getId()).restoreContentListener(listener).build());
assertEquals(3, listener.getRestored());
assertEquals("/archive", result.getParentPath().toString());
}
use of com.enonic.xp.archive.RestoreContentsResult in project xp by enonic.
the class ContentServiceImpl method restore.
@Override
public RestoreContentsResult restore(final RestoreContentParams params) {
final RestoreContentsResult result = RestoreContentCommand.create(params).nodeService(nodeService).translator(translator).eventPublisher(eventPublisher).contentTypeService(contentTypeService).restoreListener(params.getRestoreContentListener()).build().execute();
contentAuditLogSupport.restore(params, result);
return result;
}
use of com.enonic.xp.archive.RestoreContentsResult in project xp by enonic.
the class RestoreContentCommand method execute.
RestoreContentsResult execute() {
params.validate();
try {
final RestoreContentsResult restoredContents = doExecute();
this.nodeService.refresh(RefreshMode.ALL);
return restoredContents;
} catch (MoveNodeException e) {
throw new RestoreContentException(e.getMessage(), ContentNodeHelper.translateNodePathToContentPath(e.getPath()));
} catch (NodeAccessException e) {
throw new ContentAccessException(e);
}
}
use of com.enonic.xp.archive.RestoreContentsResult in project xp by enonic.
the class RestoreContentHandler method restore.
private List<String> restore(final ContentId sourceId, final ContentPath pathToRestore) {
final RestoreContentParams restoreParams = RestoreContentParams.create().contentId(sourceId).path(pathToRestore).build();
final RestoreContentsResult result = contentService.restore(restoreParams);
return result.getRestoredContents().stream().map(ContentId::toString).collect(Collectors.toList());
}
Aggregations