Search in sources :

Example 1 with ContentVersions

use of com.enonic.xp.content.ContentVersions 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();
}
Also used : ContentVersions(com.enonic.xp.content.ContentVersions) FindContentVersionsResult(com.enonic.xp.content.FindContentVersionsResult) NodeId(com.enonic.xp.node.NodeId) NodeVersionQueryResult(com.enonic.xp.node.NodeVersionQueryResult)

Example 2 with ContentVersions

use of com.enonic.xp.content.ContentVersions in project xp by enonic.

the class ContentVersionFactory method create.

public ContentVersions create(final NodeId nodeId, final NodeVersionsMetadata nodeVersionsMetadata) {
    final ContentVersions.Builder contentVersionsBuilder = ContentVersions.create().contentId(ContentId.from(nodeId.toString()));
    for (final NodeVersionMetadata nodeVersionMetadata : nodeVersionsMetadata) {
        final ContentVersion contentVersion = create(nodeVersionMetadata);
        contentVersionsBuilder.add(contentVersion);
    }
    return contentVersionsBuilder.build();
}
Also used : ContentVersions(com.enonic.xp.content.ContentVersions) NodeVersionMetadata(com.enonic.xp.node.NodeVersionMetadata) ContentVersion(com.enonic.xp.content.ContentVersion)

Aggregations

ContentVersions (com.enonic.xp.content.ContentVersions)2 ContentVersion (com.enonic.xp.content.ContentVersion)1 FindContentVersionsResult (com.enonic.xp.content.FindContentVersionsResult)1 NodeId (com.enonic.xp.node.NodeId)1 NodeVersionMetadata (com.enonic.xp.node.NodeVersionMetadata)1 NodeVersionQueryResult (com.enonic.xp.node.NodeVersionQueryResult)1