use of com.enonic.xp.content.UpdateContentParams in project xp by enonic.
the class ProjectContentEventListenerTest method testUpdated.
@Test
public void testUpdated() throws InterruptedException {
final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT, "name"));
final Content updatedContent = sourceContext.callWith(() -> {
final Content updated = contentService.update(new UpdateContentParams().contentId(sourceContent.getId()).editor((edit -> {
edit.data = new PropertyTree();
edit.displayName = "newDisplayName";
edit.extraDatas = ExtraDatas.create().add(createExtraData()).build();
edit.owner = PrincipalKey.from("user:system:newOwner");
edit.language = Locale.forLanguageTag("no");
edit.page = createPage();
})));
return updated;
});
handleEvents();
final Content targetContent = targetContext.callWith(() -> contentService.getById(sourceContent.getId()));
compareSynched(updatedContent, targetContent);
assertEquals(4, targetContent.getInherit().size());
}
use of com.enonic.xp.content.UpdateContentParams 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.UpdateContentParams in project xp by enonic.
the class ProjectContentEventListenerTest method testArchivedNotInherited.
@Test
public void testArchivedNotInherited() throws InterruptedException {
final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT, "content"));
handleEvents();
targetContext.runWith(() -> contentService.update(new UpdateContentParams().contentId(sourceContent.getId()).editor(edit -> edit.data = new PropertyTree())));
handleEvents();
sourceContext.runWith(() -> contentService.archive(ArchiveContentParams.create().contentId(sourceContent.getId()).build()));
handleEvents();
final Content targetContent = targetContext.callWith(() -> contentService.getById(sourceContent.getId()));
assertEquals("/content", targetContent.getPath().toString());
}
use of com.enonic.xp.content.UpdateContentParams in project xp by enonic.
the class ProjectContentEventListenerTest method testUpdatedFromReadyToInProgress.
@Test
public void testUpdatedFromReadyToInProgress() throws InterruptedException {
final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT, "name"));
sourceContext.callWith(() -> {
contentService.update(new UpdateContentParams().contentId(sourceContent.getId()).editor((edit -> edit.workflowInfo = WorkflowInfo.create().state(WorkflowState.READY).build())));
handleEvents();
final Content sourceContentReady = contentService.update(new UpdateContentParams().contentId(sourceContent.getId()).editor((edit -> edit.workflowInfo = WorkflowInfo.create().state(WorkflowState.IN_PROGRESS).build())));
handleEvents();
return sourceContentReady;
});
final Content targetContent = targetContext.callWith(() -> contentService.getById(sourceContent.getId()));
assertEquals(WorkflowState.READY, targetContent.getWorkflowInfo().getState());
}
use of com.enonic.xp.content.UpdateContentParams in project xp by enonic.
the class RemoveAttachmentHandler method execute.
public void execute() {
UpdateContentParams updateContent = new UpdateContentParams();
if (!this.key.startsWith("/")) {
updateContent.contentId(ContentId.from(this.key));
} else {
final Content contentByPath = this.contentService.getByPath(ContentPath.from(key));
updateContent.contentId(contentByPath.getId());
}
BinaryReferences binaryRefs = BinaryReferences.from(Arrays.stream(this.names).map(BinaryReference::from).collect(toList()));
updateContent.removeAttachments(binaryRefs);
contentService.update(updateContent);
}
Aggregations