检索以前版本的Alfresco NodeRef的内容

时间:2014-05-08 14:45:18

标签: version alfresco

我正在尝试检索以前版本的Alfresco NodeRef的内容。

String previousDeployedVersion = "1.3";
VersionHistory history = this.versionService.getVersionHistory(nodeRef);

// Retrieve and display all version labels 

ArrayList<Version> versions = (ArrayList<Version>) history.getAllVersions();

for (Version v1 : versions) 
{
  logger("version = " + v1.getVersionLabel());
}

//// In my test, it displays 1.4, 1.3, 1.2, 1.1, 1.0

Version version = history.getVersion(previousDeployedVersion);
NodeRef previousNode = version.getVersionedNodeRef();

ContentReader contentReader = contentService.getReader(previousNode,
    ContentModel.PROP_CONTENT);

String contentString = contentReader.getContentString();
logger("contentString = " + contentString);

/// At this point it display the content of the current version (1.4) of the NodeRef

有没有人对如何获取以前版本的内容有任何建议 或者我做错了什么?

由于

1 个答案:

答案 0 :(得分:2)

从版本获取冻结状态NodeRef。像这样:

VersionHistory vh = versionService.getVersionHistory(nodeRef);
Version version = vh.getHeadVersion();
NodeRef frozenNodeRef = version.getFrozenStateNodeRef();
// version = vh.getPredecessor(version); // Going  back in history
ContentReader contentReader = contentService.getReader(frozenNodeRef,
    ContentModel.PROP_CONTENT);