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()));
}
}
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;
}
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()));
}
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());
});
}
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"));
});
}
Aggregations