Search in sources :

Example 66 with ContentId

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

the class ResolveContentsToBePublishedCommand method resolveDependencies.

private void resolveDependencies() {
    for (final ContentId contentId : this.contentIds) {
        final ResolveSyncWorkResult syncWorkResult = getWorkResult(contentId);
        this.resultBuilder.addAll(CompareResultTranslator.translate(syncWorkResult.getNodeComparisons()));
    }
}
Also used : ContentId(com.enonic.xp.content.ContentId) ResolveSyncWorkResult(com.enonic.xp.node.ResolveSyncWorkResult)

Example 67 with ContentId

use of com.enonic.xp.content.ContentId 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 68 with ContentId

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

the class ProjectContentEventListenerTest method testUpdatedLocally.

@Test
public void testUpdatedLocally() throws InterruptedException {
    final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT, "name"));
    handleEvents();
    final Content updatedInChild = targetContext.callWith(() -> contentService.update(new UpdateContentParams().contentId(sourceContent.getId()).editor((edit -> edit.data = new PropertyTree()))));
    assertEquals(2, updatedInChild.getInherit().size());
    assertFalse(updatedInChild.getInherit().contains(ContentInheritType.CONTENT));
    assertFalse(updatedInChild.getInherit().contains(ContentInheritType.NAME));
    final Content updatedInParent = sourceContext.callWith(() -> contentService.update(new UpdateContentParams().contentId(sourceContent.getId()).editor((edit -> edit.displayName = "new source display name"))));
    handleEvents();
    assertNotEquals(updatedInParent.getDisplayName(), targetContext.callWith(() -> contentService.getById(updatedInChild.getId()).getDisplayName()));
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) FindContentByParentResult(com.enonic.xp.content.FindContentByParentResult) WorkflowInfo(com.enonic.xp.content.WorkflowInfo) DuplicateContentParams(com.enonic.xp.content.DuplicateContentParams) Assertions.assertNotEquals(org.junit.jupiter.api.Assertions.assertNotEquals) Page(com.enonic.xp.page.Page) ContentName(com.enonic.xp.content.ContentName) ParentContentSynchronizer(com.enonic.xp.core.impl.content.ParentContentSynchronizer) Region(com.enonic.xp.region.Region) ContentId(com.enonic.xp.content.ContentId) MEDIA_INFO_BYTE_SIZE(com.enonic.xp.media.MediaInfo.MEDIA_INFO_BYTE_SIZE) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) FindContentByParentParams(com.enonic.xp.content.FindContentByParentParams) Locale(java.util.Locale) PageRegions(com.enonic.xp.page.PageRegions) ContextBuilder(com.enonic.xp.context.ContextBuilder) XDataName(com.enonic.xp.schema.xdata.XDataName) IMAGE_INFO_PIXEL_SIZE(com.enonic.xp.media.MediaInfo.IMAGE_INFO_PIXEL_SIZE) ImmutableMap(com.google.common.collect.ImmutableMap) PageTemplateKey(com.enonic.xp.page.PageTemplateKey) Set(java.util.Set) IMAGE_INFO_IMAGE_WIDTH(com.enonic.xp.media.MediaInfo.IMAGE_INFO_IMAGE_WIDTH) ExtraDatas(com.enonic.xp.content.ExtraDatas) ContentNotFoundException(com.enonic.xp.content.ContentNotFoundException) Test(org.junit.jupiter.api.Test) List(java.util.List) PushContentParams(com.enonic.xp.content.PushContentParams) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) PartComponent(com.enonic.xp.region.PartComponent) ArchiveContentParams(com.enonic.xp.archive.ArchiveContentParams) IMAGE_INFO_IMAGE_HEIGHT(com.enonic.xp.media.MediaInfo.IMAGE_INFO_IMAGE_HEIGHT) Assertions.assertDoesNotThrow(org.junit.jupiter.api.Assertions.assertDoesNotThrow) ProjectContentEventListener(com.enonic.xp.core.impl.content.ProjectContentEventListener) ChildOrder(com.enonic.xp.index.ChildOrder) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) ContentConstants(com.enonic.xp.content.ContentConstants) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) WorkflowState(com.enonic.xp.content.WorkflowState) PartDescriptor(com.enonic.xp.region.PartDescriptor) Sets(org.assertj.core.util.Sets) DeleteContentParams(com.enonic.xp.content.DeleteContentParams) RestoreContentParams(com.enonic.xp.archive.RestoreContentParams) ReorderChildParams(com.enonic.xp.content.ReorderChildParams) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) ArgumentCaptor(org.mockito.ArgumentCaptor) ExtraData(com.enonic.xp.content.ExtraData) Event(com.enonic.xp.event.Event) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) PropertyTree(com.enonic.xp.data.PropertyTree) Iterator(java.util.Iterator) ContentPath(com.enonic.xp.content.ContentPath) ContentInheritType(com.enonic.xp.content.ContentInheritType) Content(com.enonic.xp.content.Content) ContentPublishInfo(com.enonic.xp.content.ContentPublishInfo) UpdateContentParams(com.enonic.xp.content.UpdateContentParams) Form(com.enonic.xp.form.Form) Mockito(org.mockito.Mockito) PrincipalKey(com.enonic.xp.security.PrincipalKey) ContentIds(com.enonic.xp.content.ContentIds) DescriptorKey(com.enonic.xp.page.DescriptorKey) RenameContentParams(com.enonic.xp.content.RenameContentParams) MoveContentParams(com.enonic.xp.content.MoveContentParams) ReorderChildContentsParams(com.enonic.xp.content.ReorderChildContentsParams) SetContentChildOrderParams(com.enonic.xp.content.SetContentChildOrderParams) UpdateContentParams(com.enonic.xp.content.UpdateContentParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) Test(org.junit.jupiter.api.Test)

Example 69 with ContentId

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

the class ProjectContentEventListenerTest method testDuplicateInheritedWithChildren.

@Test
public void testDuplicateInheritedWithChildren() throws InterruptedException {
    final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT, "localContent"));
    final Content sourceChild1 = sourceContext.callWith(() -> createContent(sourceContent.getPath(), "localChild1"));
    final Content sourceChild2 = sourceContext.callWith(() -> createContent(sourceChild1.getPath(), "localChild2"));
    handleEvents();
    final ContentId duplicatedContentId = targetContext.callWith(() -> contentService.duplicate(DuplicateContentParams.create().contentId(sourceContent.getId()).build()).getDuplicatedContents().first());
    targetContext.runWith(() -> {
        final Content duplicatedTargetContent = contentService.getById(duplicatedContentId);
        final Content duplicatedTargetChild1 = contentService.getByPath(ContentPath.from("/localContent-copy/localChild1"));
        final Content duplicatedTargetChild2 = contentService.getByPath(ContentPath.from("/localContent-copy/localChild1/localChild2"));
        assertTrue(duplicatedTargetContent.getInherit().isEmpty());
        assertEquals("localContent-copy", duplicatedTargetContent.getName().toString());
        assertEquals("localChild1", duplicatedTargetChild1.getName().toString());
        assertEquals("localChild2", duplicatedTargetChild2.getName().toString());
    });
}
Also used : Content(com.enonic.xp.content.Content) ContentId(com.enonic.xp.content.ContentId) Test(org.junit.jupiter.api.Test)

Example 70 with ContentId

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

the class SyncContentServiceImplTest method testWorkflowInfo.

@Test
public void testWorkflowInfo() throws Exception {
    final Content source = sourceContext.callWith(() -> createContent(ContentPath.ROOT));
    syncCreated(source.getId());
    targetContext.runWith(() -> {
        contentService.update(new UpdateContentParams().contentId(source.getId()).editor(edit -> {
            edit.workflowInfo = WorkflowInfo.ready();
            edit.data = new PropertyTree();
        }));
    });
    syncContentService.resetInheritance(ResetContentInheritParams.create().contentId(source.getId()).inherit(EnumSet.of(ContentInheritType.CONTENT)).projectName(targetProject.getName()).build());
    targetContext.runWith(() -> {
        final Content changed = contentService.getById(source.getId());
        assertTrue(changed.getInherit().contains(ContentInheritType.CONTENT));
        assertTrue(changed.getData().hasProperty("stringField"));
    });
}
Also used : ChildOrder(com.enonic.xp.index.ChildOrder) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) BeforeEach(org.junit.jupiter.api.BeforeEach) WorkflowInfo(com.enonic.xp.content.WorkflowInfo) ContentPath(com.enonic.xp.content.ContentPath) ProjectSyncParams(com.enonic.xp.content.ProjectSyncParams) ContentInheritType(com.enonic.xp.content.ContentInheritType) Content(com.enonic.xp.content.Content) DeleteContentParams(com.enonic.xp.content.DeleteContentParams) UpdateContentParams(com.enonic.xp.content.UpdateContentParams) ContentSyncEventType(com.enonic.xp.core.impl.content.ContentSyncEventType) Test(org.junit.jupiter.api.Test) ParentContentSynchronizer(com.enonic.xp.core.impl.content.ParentContentSynchronizer) SyncContentServiceImpl(com.enonic.xp.core.impl.content.SyncContentServiceImpl) ContentId(com.enonic.xp.content.ContentId) ResetContentInheritParams(com.enonic.xp.content.ResetContentInheritParams) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) ProjectName(com.enonic.xp.project.ProjectName) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) SetContentChildOrderParams(com.enonic.xp.content.SetContentChildOrderParams) ContentEventsSyncParams(com.enonic.xp.core.impl.content.ContentEventsSyncParams) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) EnumSet(java.util.EnumSet) PropertyTree(com.enonic.xp.data.PropertyTree) UpdateContentParams(com.enonic.xp.content.UpdateContentParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) Test(org.junit.jupiter.api.Test)

Aggregations

ContentId (com.enonic.xp.content.ContentId)83 Content (com.enonic.xp.content.Content)34 Test (org.junit.jupiter.api.Test)33 PropertyTree (com.enonic.xp.data.PropertyTree)16 ContentPath (com.enonic.xp.content.ContentPath)14 ContentNotFoundException (com.enonic.xp.content.ContentNotFoundException)13 ContentIds (com.enonic.xp.content.ContentIds)11 PropertySet (com.enonic.xp.data.PropertySet)10 NodeId (com.enonic.xp.node.NodeId)9 BeforeEach (org.junit.jupiter.api.BeforeEach)8 ContentInheritType (com.enonic.xp.content.ContentInheritType)7 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)7 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)7 UpdateContentParams (com.enonic.xp.content.UpdateContentParams)6 Context (com.enonic.xp.context.Context)6 DeleteContentParams (com.enonic.xp.content.DeleteContentParams)5 Node (com.enonic.xp.node.Node)5 Branch (com.enonic.xp.branch.Branch)4 ContentConstants (com.enonic.xp.content.ContentConstants)4 ContextBuilder (com.enonic.xp.context.ContextBuilder)4