Search in sources :

Example 1 with ContentIds

use of com.enonic.xp.content.ContentIds in project xp by enonic.

the class GetOutboundDependenciesHandler method doExecute.

@Override
protected Object doExecute() {
    validate();
    ContentIds contentIds;
    if (this.key.startsWith("/")) {
        final Content content = contentService.getByPath(ContentPath.from(this.key));
        contentIds = contentService.getOutboundDependencies(content.getId());
    } else {
        contentIds = contentService.getOutboundDependencies(ContentId.from(key));
    }
    return contentIds.stream().map(ContentId::toString).collect(Collectors.toList());
}
Also used : Content(com.enonic.xp.content.Content) ContentIds(com.enonic.xp.content.ContentIds)

Example 2 with ContentIds

use of com.enonic.xp.content.ContentIds in project xp by enonic.

the class PublishContentHandlerTest 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);
    PushContentParams pushParams = PushContentParams.create().contentIds(ids).target(Branch.from("master")).includeDependencies(false).message("My first publish").build();
    Mockito.when(this.contentService.publish(pushParams)).thenReturn(exampleResult());
    runScript("/lib/xp/examples/content/publish.js");
}
Also used : Content(com.enonic.xp.content.Content) ContentIds(com.enonic.xp.content.ContentIds) PushContentParams(com.enonic.xp.content.PushContentParams) Test(org.junit.jupiter.api.Test)

Example 3 with ContentIds

use of com.enonic.xp.content.ContentIds in project xp by enonic.

the class PublishContentHandlerTest method publishWithoutChildrenOrDependencies.

@Test
public void publishWithoutChildrenOrDependencies() {
    Contents published = Contents.from(exampleContent(PUB_ID_3, "mycontent", "My Content", "/mysite/somepage", "myfield", "Hello World"));
    PublishContentResult exampleResult = PublishContentResult.create().setPushed(published.getIds()).build();
    ContentIds ids = ContentIds.from(PUB_ID_3);
    PushContentParams pushParams = PushContentParams.create().contentIds(ids).target(Branch.from("master")).excludeChildrenIds(ids).includeDependencies(false).build();
    Mockito.when(this.contentService.publish(pushParams)).thenReturn(exampleResult);
    runFunction("/test/PublishContentHandlerTest.js", "publishWithoutChildrenOrDependencies");
}
Also used : PublishContentResult(com.enonic.xp.content.PublishContentResult) Contents(com.enonic.xp.content.Contents) ContentIds(com.enonic.xp.content.ContentIds) PushContentParams(com.enonic.xp.content.PushContentParams) Test(org.junit.jupiter.api.Test)

Example 4 with ContentIds

use of com.enonic.xp.content.ContentIds in project xp by enonic.

the class QueryContentHandler method convert.

private ContentsResultMapper convert(final FindContentIdsByQueryResult findQueryResult) {
    final ContentIds contentIds = findQueryResult.getContentIds();
    final Contents contents;
    if (contentIds.isEmpty()) {
        contents = Contents.empty();
    } else {
        contents = this.contentService.getByIds(new GetContentByIdsParams(contentIds));
    }
    return new ContentsResultMapper(contents, findQueryResult.getTotalHits(), findQueryResult.getAggregations(), findQueryResult.getHighlight(), findQueryResult.getSort(), findQueryResult.getScore());
}
Also used : Contents(com.enonic.xp.content.Contents) GetContentByIdsParams(com.enonic.xp.content.GetContentByIdsParams) ContentsResultMapper(com.enonic.xp.lib.content.mapper.ContentsResultMapper) ContentIds(com.enonic.xp.content.ContentIds)

Example 5 with ContentIds

use of com.enonic.xp.content.ContentIds in project xp by enonic.

the class PublishContentHandlerTest method publishWithMessage.

@Test
public void publishWithMessage() {
    ContentIds ids = ContentIds.from(PUB_ID_2, DEL_ID, FAIL_ID);
    PushContentParams pushParams = PushContentParams.create().contentIds(ids).target(Branch.from("draft")).message("My first publish").build();
    Mockito.when(this.contentService.publish(pushParams)).thenReturn(exampleResult());
    runFunction("/test/PublishContentHandlerTest.js", "publishWithMessage");
}
Also used : ContentIds(com.enonic.xp.content.ContentIds) PushContentParams(com.enonic.xp.content.PushContentParams) Test(org.junit.jupiter.api.Test)

Aggregations

ContentIds (com.enonic.xp.content.ContentIds)38 Test (org.junit.jupiter.api.Test)27 Content (com.enonic.xp.content.Content)22 Contents (com.enonic.xp.content.Contents)11 GetContentByIdsParams (com.enonic.xp.content.GetContentByIdsParams)10 PropertyTree (com.enonic.xp.data.PropertyTree)8 ContentId (com.enonic.xp.content.ContentId)6 PushContentParams (com.enonic.xp.content.PushContentParams)6 UnpublishContentParams (com.enonic.xp.content.UnpublishContentParams)4 NodeIds (com.enonic.xp.node.NodeIds)4 DeleteContentsResult (com.enonic.xp.content.DeleteContentsResult)3 CreateContentParams (com.enonic.xp.content.CreateContentParams)2 DeleteContentParams (com.enonic.xp.content.DeleteContentParams)2 PublishContentResult (com.enonic.xp.content.PublishContentResult)2 UnpublishContentsResult (com.enonic.xp.content.UnpublishContentsResult)2 Context (com.enonic.xp.context.Context)2 PropertySet (com.enonic.xp.data.PropertySet)2 FindNodesByParentResult (com.enonic.xp.node.FindNodesByParentResult)2 Node (com.enonic.xp.node.Node)2 NodeId (com.enonic.xp.node.NodeId)2