Search in sources :

Example 6 with ContentVersion

use of com.enonic.xp.content.ContentVersion 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)

Example 7 with ContentVersion

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

the class ContentServiceImplTest_versions method get_archived_versions.

@Test
public void get_archived_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.archive(ArchiveContentParams.create().contentId(content.getId()).build());
    this.contentService.restore(RestoreContentParams.create().contentId(content.getId()).build());
    final FindContentVersionsResult result = this.contentService.getVersions(FindContentVersionsParams.create().contentId(content.getId()).build());
    assertEquals(5, result.getHits());
    assertEquals(5, result.getTotalHits());
    final ImmutableList<ContentVersion> versions = ImmutableList.copyOf(result.getContentVersions().iterator());
    assertEquals(ContentVersionPublishInfo.CommitType.RESTORED, versions.get(0).getPublishInfo().getType());
    assertEquals(ContentVersionPublishInfo.CommitType.ARCHIVED, versions.get(2).getPublishInfo().getType());
}
Also used : Content(com.enonic.xp.content.Content) ContentVersion(com.enonic.xp.content.ContentVersion) PropertyTree(com.enonic.xp.data.PropertyTree) FindContentVersionsResult(com.enonic.xp.content.FindContentVersionsResult) Test(org.junit.jupiter.api.Test)

Aggregations

ContentVersion (com.enonic.xp.content.ContentVersion)7 FindContentVersionsResult (com.enonic.xp.content.FindContentVersionsResult)6 Content (com.enonic.xp.content.Content)5 Test (org.junit.jupiter.api.Test)5 PropertyTree (com.enonic.xp.data.PropertyTree)3 ContentVersions (com.enonic.xp.content.ContentVersions)1 WorkflowCheckState (com.enonic.xp.content.WorkflowCheckState)1 WorkflowInfo (com.enonic.xp.content.WorkflowInfo)1 NodeVersionMetadata (com.enonic.xp.node.NodeVersionMetadata)1 Instant (java.time.Instant)1