use of com.enonic.xp.content.FindContentVersionsResult in project xp by enonic.
the class FindContentVersionsCommand method doGetContentVersions.
private FindContentVersionsResult doGetContentVersions() {
this.nodeService.refresh(RefreshMode.STORAGE);
final NodeId nodeId = NodeId.from(this.contentId);
final NodeVersionQueryResult nodeVersionQueryResult = nodeService.findVersions(GetNodeVersionsParams.create().nodeId(nodeId).from(this.from).size(this.size).build());
final FindContentVersionsResult.Builder findContentVersionsResultBuilder = FindContentVersionsResult.create().hits(nodeVersionQueryResult.getHits()).totalHits(nodeVersionQueryResult.getTotalHits()).from(nodeVersionQueryResult.getFrom()).size(nodeVersionQueryResult.getSize());
final ContentVersionFactory contentVersionFactory = new ContentVersionFactory(this.nodeService);
final ContentVersions contentVersions = contentVersionFactory.create(nodeId, nodeVersionQueryResult.getNodeVersionsMetadata());
findContentVersionsResultBuilder.contentVersions(contentVersions);
return findContentVersionsResultBuilder.build();
}
use of com.enonic.xp.content.FindContentVersionsResult in project xp by enonic.
the class AbstractContentServiceTest method assertVersions.
protected void assertVersions(final ContentId contentId, final int expected) {
FindContentVersionsResult versions = this.contentService.getVersions(FindContentVersionsParams.create().contentId(contentId).build());
assertEquals(expected, versions.getHits());
final Iterator<ContentVersion> iterator = versions.getContentVersions().iterator();
Instant lastModified = null;
while (iterator.hasNext()) {
final ContentVersion next = iterator.next();
if (lastModified != null) {
assertFalse(next.getModified().isAfter(lastModified));
}
lastModified = next.getModified();
}
}
use of com.enonic.xp.content.FindContentVersionsResult in project xp by enonic.
the class ContentServiceImplTest_publish method publish_with_message_no_message.
@Test
public void publish_with_message_no_message() {
final Content content = createContent(ContentPath.ROOT, "a");
this.contentService.publish(PushContentParams.create().contentIds(ContentIds.from(content.getId())).target(WS_OTHER).message(null).build());
FindContentVersionsResult versions = this.contentService.getVersions(FindContentVersionsParams.create().contentId(content.getId()).build());
Iterator<ContentVersion> iterator = versions.getContentVersions().iterator();
assertTrue(iterator.hasNext());
ContentVersion version = iterator.next();
assertNotNull(version.getPublishInfo().getTimestamp());
assertEquals("user:system:test-user", version.getPublishInfo().getPublisher().toString());
assertNull(version.getPublishInfo().getMessage());
}
use of com.enonic.xp.content.FindContentVersionsResult in project xp by enonic.
the class ContentServiceImplTest_versions method get_versions.
@Test
public void get_versions() throws Exception {
final Content content = this.contentService.create(CreateContentParams.create().contentData(new PropertyTree()).displayName("content").parent(ContentPath.ROOT).name("myContent").type(ContentTypeName.folder()).build());
final UpdateContentParams updateContentParams = new UpdateContentParams();
updateContentParams.contentId(content.getId()).editor(edit -> {
edit.displayName = "new display name";
});
this.contentService.update(updateContentParams);
final FindContentVersionsResult result = this.contentService.getVersions(FindContentVersionsParams.create().contentId(content.getId()).build());
assertEquals(2, result.getHits());
assertEquals(2, result.getTotalHits());
}
use of com.enonic.xp.content.FindContentVersionsResult in project xp by enonic.
the class ContentServiceImplTest_versions method get_published_versions.
@Test
public void get_published_versions() throws Exception {
final Content content = this.contentService.create(CreateContentParams.create().contentData(new PropertyTree()).displayName("content").parent(ContentPath.ROOT).name("myContent").type(ContentTypeName.folder()).build());
this.contentService.publish(PushContentParams.create().contentIds(ContentIds.from(content.getId())).target(WS_OTHER).build());
this.contentService.unpublishContent(UnpublishContentParams.create().contentIds(ContentIds.from(content.getId())).unpublishBranch(WS_OTHER).build());
final FindContentVersionsResult result = this.contentService.getVersions(FindContentVersionsParams.create().contentId(content.getId()).build());
assertEquals(3, result.getHits());
assertEquals(3, result.getTotalHits());
final Iterator<ContentVersion> versions = result.getContentVersions().iterator();
assertNotNull(versions.next().getPublishInfo());
assertNotNull(versions.next().getPublishInfo());
assertNull(versions.next().getPublishInfo());
}
Aggregations