use of com.enonic.xp.content.UnpublishContentParams in project xp by enonic.
the class UnpublishContentHandler method execute.
public List<String> execute() {
final Branch targetBranch = ContentConstants.BRANCH_MASTER;
final Context context = ContextBuilder.from(ContextAccessor.current()).branch(targetBranch).build();
final List<ContentId> contentIds = context.callWith(this::resolveContentIds);
final UnpublishContentParams unpublishContentParams = UnpublishContentParams.create().contentIds(ContentIds.from(contentIds)).unpublishBranch(targetBranch).includeChildren(true).build();
final UnpublishContentsResult result = this.contentService.unpublishContent(unpublishContentParams);
return result.getUnpublishedContents().stream().map(ContentId::toString).collect(Collectors.toList());
}
use of com.enonic.xp.content.UnpublishContentParams in project xp by enonic.
the class UnpublishContentHandlerTest method unpublishById.
@Test
public void unpublishById() {
ContentIds ids = ContentIds.from(PUB_ID_2, DEL_ID, FAIL_ID);
UnpublishContentParams unpublishParams = UnpublishContentParams.create().contentIds(ids).unpublishBranch(ContentConstants.BRANCH_MASTER).includeChildren(true).build();
Mockito.when(this.contentService.unpublishContent(unpublishParams)).thenReturn(exampleResult());
runFunction("/test/UnpublishContentHandlerTest.js", "unpublishById");
}
use of com.enonic.xp.content.UnpublishContentParams in project xp by enonic.
the class UnpublishContentHandlerTest method testExample.
@Test
public void testExample() {
final Content content = exampleContent(PUB_ID_1, "mycontent", "My Content", "/mysite/somepage", "myfield", "Hello World");
Mockito.when(this.contentService.getByPath(ContentPath.from("/mysite/somepage"))).thenReturn(content);
ContentIds ids = ContentIds.from(PUB_ID_1, FAIL_ID);
UnpublishContentParams unpublishParams = UnpublishContentParams.create().contentIds(ids).unpublishBranch(ContentConstants.BRANCH_MASTER).includeChildren(true).build();
Mockito.when(this.contentService.unpublishContent(unpublishParams)).thenReturn(exampleResult());
runScript("/lib/xp/examples/content/unpublish.js");
}
use of com.enonic.xp.content.UnpublishContentParams in project xp by enonic.
the class UnpublishContentHandlerTest method unpublishByPath.
@Test
public void unpublishByPath() {
final Content myContent = exampleContent(PUB_ID_2, "mycontent", "My Content", "/myfolder/mycontent", "myfield", "Hello World");
Mockito.when(this.contentService.getByPath(ContentPath.from("/myfolder/mycontent"))).thenReturn(myContent);
final Content yourContent = exampleContent(PUB_ID_3, "yourcontent", "Your Content", "/yourfolder/yourcontent", "yourfield", "Hello Universe!");
Mockito.when(this.contentService.getByPath(ContentPath.from("/yourfolder/yourcontent"))).thenReturn(yourContent);
ContentIds ids = ContentIds.from(PUB_ID_2, PUB_ID_3);
UnpublishContentParams unpublishParams = UnpublishContentParams.create().contentIds(ids).unpublishBranch(ContentConstants.BRANCH_MASTER).includeChildren(true).build();
Mockito.when(this.contentService.unpublishContent(unpublishParams)).thenReturn(exampleResult());
runFunction("/test/UnpublishContentHandlerTest.js", "unpublishByPath");
}
Aggregations