use of com.enonic.xp.content.ActiveContentVersionEntry in project xp by enonic.
the class ContentServiceImpl method getActiveVersion.
@Override
public ContentVersion getActiveVersion(final GetActiveContentVersionParams params) {
final GetActiveContentVersionsResult activeVersions = getActiveVersions(GetActiveContentVersionsParams.create().branches(Branches.from(params.getBranch())).contentId(params.getContentId()).build());
final UnmodifiableIterator<ActiveContentVersionEntry> activeVersionIterator = activeVersions.getActiveContentVersions().iterator();
return activeVersionIterator.hasNext() ? activeVersionIterator.next().getContentVersion() : null;
}
use of com.enonic.xp.content.ActiveContentVersionEntry in project xp by enonic.
the class ContentServiceImplTest_versions method get_active_versions.
@Test
public void get_active_versions() throws Exception {
final Content content = this.contentService.create(CreateContentParams.create().contentData(new PropertyTree()).displayName("This is my test content").parent(ContentPath.ROOT).name("myContent").type(ContentTypeName.folder()).build());
this.contentService.publish(PushContentParams.create().contentIds(ContentIds.from(content.getId())).target(WS_OTHER).build());
// Two versions, since publish adds one version
assertVersions(content.getId(), 2);
final UpdateContentParams updateContentParams = new UpdateContentParams();
updateContentParams.contentId(content.getId()).editor(edit -> {
edit.displayName = "new display name";
});
this.contentService.update(updateContentParams);
assertVersions(content.getId(), 3);
final GetActiveContentVersionsResult activeVersions = this.contentService.getActiveVersions(GetActiveContentVersionsParams.create().contentId(content.getId()).branches(Branches.from(WS_DEFAULT, WS_OTHER)).build());
final ImmutableList<ActiveContentVersionEntry> activeContentVersions = activeVersions.getActiveContentVersions();
assertEquals(2, activeContentVersions.size());
final UnmodifiableIterator<ActiveContentVersionEntry> iterator = activeContentVersions.iterator();
assertTrue(iterator.next().getContentVersion() != iterator.next().getContentVersion());
}
Aggregations