Enonic version: 6.0.0
OS: Debian Linux
I am writing av ScriptBean that fetches versions by contentId, this works fine. Is it possible to fetch content of previous versions ?
I’ve tried this:
public ContentsResultMapper getVersions(){
try{
FindContentVersionsResult versions = contentService.getVersions(FindContentVersionsParams.create().contentId(ContentId.from(contentId)).from(0).size(3).build());
List<String> contentIds = new ArrayList<>((int) versions.getHits());
versions.getContentVersions().forEach(contentVersion -> contentIds.add(contentVersion.getId().toString()));
return new ContentsResultMapper(contentService.getByIds(new GetContentByIdsParams(ContentIds.from(contentIds))), 10);
}catch (NodeNotFoundException ignored){
LOG.info("Found no versions for contentId: " + contentId);
return new ContentsResultMapper(Contents.empty(), 0);
}
}
But getByIds with the version id does not work, is this possible at all ?