use of com.enonic.xp.content.UpdateContentParams in project xp by enonic.
the class CreateFragmentCommand method execute.
public Content execute() {
final String displayName = generateDisplayName(params.getComponent());
final String name = generateUniqueContentName(params.getParent(), "fragment-" + displayName);
final CreateContentParams createContent = CreateContentParams.create().parent(params.getParent()).displayName(displayName).name(name).type(ContentTypeName.fragment()).contentData(new PropertyTree()).workflowInfo(params.getWorkflowInfo()).build();
final Content content = contentService.create(createContent);
final Page page = Page.create().config(this.params.getConfig()).fragment(this.params.getComponent()).build();
final UpdateContentParams params = new UpdateContentParams().contentId(content.getId()).modifier(getCurrentUser().getKey()).editor(edit -> edit.page = page);
return this.contentService.update(params);
}
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 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 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"));
});
}
use of com.enonic.xp.content.UpdateContentParams in project xp by enonic.
the class ParentContentSynchronizerTest method updateBinaryChanged.
@Test
public void updateBinaryChanged() throws Exception {
final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT, "content1"));
syncCreated(sourceContent.getId());
sourceContext.runWith(() -> {
contentService.update(new UpdateContentParams().contentId(sourceContent.getId()).createAttachments(CreateAttachments.create().add(CreateAttachment.create().name(AttachmentNames.THUMBNAIL).byteSource(ByteSource.wrap("this is image".getBytes())).mimeType("image/png").text("This is the image").build()).build()).editor(edit -> {
}));
});
final Content targetContentWithThumbnail = syncUpdated(sourceContent.getId());
assertTrue(targetContentWithThumbnail.hasThumbnail());
sourceContext.runWith(() -> {
contentService.update(new UpdateContentParams().contentId(sourceContent.getId()).removeAttachments(BinaryReferences.from(AttachmentNames.THUMBNAIL)).editor(edit -> {
}));
});
final Content targetContentWithoutThumbnail = syncUpdated(sourceContent.getId());
assertFalse(targetContentWithoutThumbnail.hasThumbnail());
}
Aggregations