use of com.enonic.xp.content.UpdateContentParams in project xp by enonic.
the class ParentContentSynchronizerTest method updateThumbnailCreated.
@Test
public void updateThumbnailCreated() throws Exception {
final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT, "content"));
final Content targetContent = syncCreated(sourceContent.getId());
sourceContext.runWith(() -> {
try {
final UpdateContentParams updateContentParams = new UpdateContentParams();
updateContentParams.contentId(targetContent.getId()).editor(edit -> {
edit.displayName = "new display name";
}).createAttachments(CreateAttachments.from(CreateAttachment.create().byteSource(loadImage("darth-small.jpg")).name(AttachmentNames.THUMBNAIL).mimeType("image/jpeg").build()));
this.contentService.update(updateContentParams);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
final Content targetContentUpdated = syncUpdated(sourceContent.getId());
assertNotNull(targetContentUpdated.getThumbnail());
}
use of com.enonic.xp.content.UpdateContentParams in project xp by enonic.
the class ParentContentSynchronizerTest method updateThumbnailUpdated.
@Test
public void updateThumbnailUpdated() throws Exception {
final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT, "content"));
final Content targetContent = syncCreated(sourceContent.getId());
sourceContext.runWith(() -> {
try {
final UpdateContentParams updateContentParams = new UpdateContentParams();
updateContentParams.contentId(targetContent.getId()).editor(edit -> {
edit.displayName = "new display name";
}).createAttachments(CreateAttachments.from(CreateAttachment.create().byteSource(loadImage("darth-small.jpg")).name(AttachmentNames.THUMBNAIL).mimeType("image/jpeg").build()));
this.contentService.update(updateContentParams);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
final Content thumbnailCreated = syncUpdated(sourceContent.getId());
sourceContext.runWith(() -> {
try {
final UpdateContentParams updateContentParams = new UpdateContentParams();
updateContentParams.contentId(targetContent.getId()).editor(edit -> {
edit.displayName = "new display name";
}).createAttachments(CreateAttachments.from(CreateAttachment.create().byteSource(loadImage("cat-small.jpg")).name(AttachmentNames.THUMBNAIL).mimeType("image/jpeg").build()));
this.contentService.update(updateContentParams);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
final Content thumbnailUpdated = syncUpdated(sourceContent.getId());
assertNotEquals(thumbnailCreated.getThumbnail().getSize(), thumbnailUpdated.getThumbnail().getSize());
}
use of com.enonic.xp.content.UpdateContentParams in project xp by enonic.
the class ContentServiceImplTest_update method update_content_modified_time_updated.
@Test
public void update_content_modified_time_updated() throws Exception {
final CreateContentParams createContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("This is my content").parent(ContentPath.ROOT).type(ContentTypeName.folder()).build();
final Content content = this.contentService.create(createContentParams);
final UpdateContentParams updateContentParams = new UpdateContentParams();
updateContentParams.contentId(content.getId()).editor(edit -> {
edit.displayName = "new display name";
});
this.contentService.update(updateContentParams);
final Content updatedContent = this.contentService.getById(content.getId());
assertEquals("new display name", updatedContent.getDisplayName());
assertNotNull(updatedContent.getCreator());
assertNotNull(updatedContent.getCreatedTime());
assertNotNull(updatedContent.getModifier());
assertNotNull(updatedContent.getModifiedTime());
assertTrue(updatedContent.getModifiedTime().isAfter(content.getModifiedTime()));
}
use of com.enonic.xp.content.UpdateContentParams in project xp by enonic.
the class ContentServiceImplTest_update method update_publish_info.
@Test
public void update_publish_info() throws Exception {
final CreateContentParams createContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("This is my content").parent(ContentPath.ROOT).type(ContentTypeName.folder()).build();
final Content content = this.contentService.create(createContentParams);
final UpdateContentParams updateContentParams = new UpdateContentParams();
updateContentParams.contentId(content.getId()).editor(edit -> {
edit.publishInfo = ContentPublishInfo.create().from(Instant.parse("2016-11-03T10:43:44Z")).to(Instant.parse("2016-11-23T10:43:44Z")).build();
});
this.contentService.update(updateContentParams);
final Content storedContent = this.contentService.getById(content.getId());
assertNotNull(storedContent.getPublishInfo());
assertNotNull(storedContent.getPublishInfo().getFrom());
assertNotNull(storedContent.getPublishInfo().getTo());
assertEquals(storedContent.getPublishInfo().getFrom(), Instant.parse("2016-11-03T10:43:44Z"));
assertEquals(storedContent.getPublishInfo().getTo(), Instant.parse("2016-11-23T10:43:44Z"));
}
use of com.enonic.xp.content.UpdateContentParams in project xp by enonic.
the class ModifyContentHandler method doExecute.
@Override
protected Object doExecute() {
final Content existingContent = getExistingContent(this.key);
if (existingContent == null) {
return null;
}
final UpdateContentParams params = new UpdateContentParams();
params.contentId(existingContent.getId());
params.editor(newContentEditor(existingContent));
params.requireValid(this.requireValid);
final Content result = this.contentService.update(params);
return result != null ? new ContentMapper(result) : null;
}
Aggregations