Search in sources :

Example 1 with RestoreContentParams

use of com.enonic.xp.archive.RestoreContentParams 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)

Example 2 with RestoreContentParams

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

the class RestoreContentHandlerTest method testExample.

@Test
public void testExample() {
    final Content content = TestDataFixtures.newExampleContent();
    when(this.contentService.getByPath(ContentPath.from("/path/to/mycontent"))).thenReturn(content);
    when(this.contentService.restore(Mockito.isA(RestoreContentParams.class))).thenAnswer(invocationOnMock -> invokeRestore((RestoreContentParams) invocationOnMock.getArguments()[0], content));
    runScript("/lib/xp/examples/content/restore.js");
}
Also used : Content(com.enonic.xp.content.Content) RestoreContentParams(com.enonic.xp.archive.RestoreContentParams) Test(org.junit.jupiter.api.Test)

Aggregations

RestoreContentParams (com.enonic.xp.archive.RestoreContentParams)2 RestoreContentsResult (com.enonic.xp.archive.RestoreContentsResult)1 Content (com.enonic.xp.content.Content)1 Test (org.junit.jupiter.api.Test)1