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);
}
use of com.enonic.xp.content.UpdateContentParams in project xp by enonic.
the class ContentServiceImplTest_publish_update_publishedTime method keep_original_published_time.
@Test
public void keep_original_published_time() throws Exception {
final Content content = doCreateContent();
doPublishContent(content);
assertVersions(content.getId(), 2);
final ContentPublishInfo publishInfo = this.contentService.getById(content.getId()).getPublishInfo();
assertNotNull(publishInfo);
assertNotNull(publishInfo.getFirst());
assertNotNull(publishInfo.getFrom());
final UpdateContentParams updateContentParams = new UpdateContentParams();
updateContentParams.contentId(content.getId()).editor(edit -> edit.displayName = "new display name");
this.contentService.update(updateContentParams);
doPublishContent(content);
assertVersions(content.getId(), 3);
final ContentPublishInfo unUpdatedPublishInfo = this.contentService.getById(content.getId()).getPublishInfo();
assertEquals(publishInfo, unUpdatedPublishInfo);
}
use of com.enonic.xp.content.UpdateContentParams in project xp by enonic.
the class ContentServiceImplTest_publish_update_publishedTime method set_publish_time_again_if_reset.
@Test
public void set_publish_time_again_if_reset() throws Exception {
final Content content = doCreateContent();
doPublishContent(content);
final ContentPublishInfo publishInfo = this.contentService.getById(content.getId()).getPublishInfo();
final UpdateContentParams updateContentParams = new UpdateContentParams();
updateContentParams.contentId(content.getId()).editor(edit -> edit.publishInfo = null);
this.contentService.update(updateContentParams);
doPublishContent(content);
final ContentPublishInfo updatedPublishInfo = this.contentService.getById(content.getId()).getPublishInfo();
assertTrue(updatedPublishInfo.getFrom().isAfter(publishInfo.getFrom()));
}
use of com.enonic.xp.content.UpdateContentParams in project xp by enonic.
the class ModifyContentHandlerTest method modifyNotMappedXDataFieldNameStricted.
@Test
public void modifyNotMappedXDataFieldNameStricted() throws Exception {
final Content content = TestDataFixtures.newSmallContent();
when(this.contentService.getByPath(content.getPath())).thenReturn(content);
when(this.contentService.update(Mockito.isA(UpdateContentParams.class))).thenAnswer(invocationOnMock -> invokeUpdate((UpdateContentParams) invocationOnMock.getArguments()[0], TestDataFixtures.newSmallContent()));
mockXData();
runFunction("/test/ModifyContentHandlerTest.js", "modifyNotMappedXDataFieldName_stricted");
}
use of com.enonic.xp.content.UpdateContentParams in project xp by enonic.
the class ModifyContentHandlerTest method modifyById.
@Test
public void modifyById() throws Exception {
when(this.contentService.update(Mockito.isA(UpdateContentParams.class))).thenAnswer(invocationOnMock -> invokeUpdate((UpdateContentParams) invocationOnMock.getArguments()[0], TestDataFixtures.newSmallContent()));
final Content content = TestDataFixtures.newSmallContent();
when(this.contentService.getById(content.getId())).thenReturn(content);
mockXData();
runFunction("/test/ModifyContentHandlerTest.js", "modifyById");
}
Aggregations