Search in sources :

Example 6 with RestoreContentsResult

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());
}
Also used : RestoreContentsResult(com.enonic.xp.archive.RestoreContentsResult) Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 7 with RestoreContentsResult

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;
}
Also used : RestoreContentsResult(com.enonic.xp.archive.RestoreContentsResult)

Example 8 with RestoreContentsResult

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);
    }
}
Also used : RestoreContentsResult(com.enonic.xp.archive.RestoreContentsResult) MoveNodeException(com.enonic.xp.node.MoveNodeException) NodeAccessException(com.enonic.xp.node.NodeAccessException) RestoreContentException(com.enonic.xp.archive.RestoreContentException) ContentAccessException(com.enonic.xp.content.ContentAccessException)

Example 9 with RestoreContentsResult

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());
}
Also used : RestoreContentsResult(com.enonic.xp.archive.RestoreContentsResult) RestoreContentParams(com.enonic.xp.archive.RestoreContentParams)

Aggregations

RestoreContentsResult (com.enonic.xp.archive.RestoreContentsResult)9 Content (com.enonic.xp.content.Content)5 Test (org.junit.jupiter.api.Test)5 RestoreContentException (com.enonic.xp.archive.RestoreContentException)1 RestoreContentParams (com.enonic.xp.archive.RestoreContentParams)1 ContentAccessException (com.enonic.xp.content.ContentAccessException)1 MoveNodeException (com.enonic.xp.node.MoveNodeException)1 MoveNodeParams (com.enonic.xp.node.MoveNodeParams)1 Node (com.enonic.xp.node.Node)1 NodeAccessException (com.enonic.xp.node.NodeAccessException)1 NodePath (com.enonic.xp.node.NodePath)1