Search in sources :

Example 21 with ContentIds

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

the class ContentServiceImplTest_resolveRequiredDependencies method resolve_with_parent.

@Test
public void resolve_with_parent() throws Exception {
    Content content1 = createContent(ContentPath.ROOT);
    Content content2 = createContent(content1.getPath());
    refresh();
    final ContentIds result = this.contentService.resolveRequiredDependencies(ResolveRequiredDependenciesParams.create().contentIds(ContentIds.from(content1.getId(), content2.getId())).target(WS_OTHER).build());
    assertEquals(content1.getId(), result.first());
}
Also used : Content(com.enonic.xp.content.Content) ContentIds(com.enonic.xp.content.ContentIds) Test(org.junit.jupiter.api.Test)

Example 22 with ContentIds

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

the class ContentServiceImplTest_resolveRequiredDependencies method resolve_hierarchy.

@Test
public void resolve_hierarchy() throws Exception {
    Content content1 = createContent(ContentPath.ROOT);
    Content content2 = createContent(content1.getPath());
    Content content3 = createContent(content2.getPath());
    refresh();
    final ContentIds result = this.contentService.resolveRequiredDependencies(ResolveRequiredDependenciesParams.create().contentIds(ContentIds.from(content1.getId(), content2.getId(), content3.getId())).target(WS_OTHER).build());
    assertTrue(result.getSize() == 2);
    assertTrue(result.contains(content1.getId()));
    assertTrue(result.contains(content2.getId()));
}
Also used : Content(com.enonic.xp.content.Content) ContentIds(com.enonic.xp.content.ContentIds) Test(org.junit.jupiter.api.Test)

Example 23 with ContentIds

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

the class ContentServiceImplTest_resolveRequiredDependencies method resolve_empty.

@Test
public void resolve_empty() throws Exception {
    content1 = createContent(ContentPath.ROOT);
    content2 = createContent(content1.getPath());
    content3 = createContent(content2.getPath());
    refresh();
    final ContentIds result = this.contentService.resolveRequiredDependencies(ResolveRequiredDependenciesParams.create().contentIds(ContentIds.empty()).target(WS_OTHER).build());
    assertTrue(result.getSize() == 0);
}
Also used : ContentIds(com.enonic.xp.content.ContentIds) Test(org.junit.jupiter.api.Test)

Example 24 with ContentIds

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

the class UnpublishContentCommand method removePublishInfo.

private Void removePublishInfo(final ContentIds contentIds) {
    final Instant now = Instant.now();
    for (final ContentId contentId : contentIds) {
        this.nodeService.update(UpdateNodeParams.create().editor(toBeEdited -> {
            if (toBeEdited.data.getInstant(ContentPropertyNames.PUBLISH_INFO + PropertyPath.ELEMENT_DIVIDER + ContentPropertyNames.PUBLISH_FROM) != null) {
                PropertySet publishInfo = toBeEdited.data.getSet(ContentPropertyNames.PUBLISH_INFO);
                if (publishInfo.hasProperty(ContentPropertyNames.PUBLISH_FROM)) {
                    publishInfo.removeProperty(ContentPropertyNames.PUBLISH_FROM);
                }
                if (publishInfo.hasProperty(ContentPropertyNames.PUBLISH_TO)) {
                    publishInfo.removeProperty(ContentPropertyNames.PUBLISH_TO);
                }
                if (publishInfo.getInstant(ContentPropertyNames.PUBLISH_FIRST).compareTo(Instant.now()) > 0) {
                    publishInfo.removeProperty(ContentPropertyNames.PUBLISH_FIRST);
                }
            }
        }).id(NodeId.from(contentId)).build());
        commitUnpublishedNode(contentId);
    }
    return null;
}
Also used : RefreshMode(com.enonic.xp.node.RefreshMode) Nodes(com.enonic.xp.node.Nodes) ContentConstants(com.enonic.xp.content.ContentConstants) ContentPropertyNames(com.enonic.xp.content.ContentPropertyNames) ContentState(com.enonic.xp.content.ContentState) PropertySet(com.enonic.xp.data.PropertySet) Node(com.enonic.xp.node.Node) UnpublishContentParams(com.enonic.xp.content.UnpublishContentParams) Instant(java.time.Instant) Branch(com.enonic.xp.branch.Branch) NodeId(com.enonic.xp.node.NodeId) UpdateNodeParams(com.enonic.xp.node.UpdateNodeParams) ContentId(com.enonic.xp.content.ContentId) NodeCommitEntry(com.enonic.xp.node.NodeCommitEntry) ContentIds(com.enonic.xp.content.ContentIds) ContextAccessor(com.enonic.xp.context.ContextAccessor) FindNodesByParentResult(com.enonic.xp.node.FindNodesByParentResult) Preconditions(com.google.common.base.Preconditions) UnpublishContentsResult(com.enonic.xp.content.UnpublishContentsResult) Context(com.enonic.xp.context.Context) ContextBuilder(com.enonic.xp.context.ContextBuilder) PropertyPath(com.enonic.xp.data.PropertyPath) FindNodesByParentParams(com.enonic.xp.node.FindNodesByParentParams) NodeIds(com.enonic.xp.node.NodeIds) Instant(java.time.Instant) PropertySet(com.enonic.xp.data.PropertySet) ContentId(com.enonic.xp.content.ContentId)

Example 25 with ContentIds

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

the class ContentNodeHelperTest method toNodeIds.

@Test
public void toNodeIds() {
    final ContentIds contentIds = ContentIds.from("e1f57280-d672-4cd8-b674-98e26e5b69ae", "45d67001-7f2b-4093-99ae-639be9fdd1f6");
    final NodeIds nodeIds = ContentNodeHelper.toNodeIds(contentIds);
    assertEquals(NodeIds.from("e1f57280-d672-4cd8-b674-98e26e5b69ae", "45d67001-7f2b-4093-99ae-639be9fdd1f6"), nodeIds);
}
Also used : NodeIds(com.enonic.xp.node.NodeIds) ContentIds(com.enonic.xp.content.ContentIds) 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