Apache Jackrabbit 内容存储版本控制

不多说,上代码:

/** * * @param session * @throws RepositoryException * @author 李晗 * 实现版本控制,修改记录版本号 */ public void versionControl(Session session) throws RepositoryException{ Node n = session.getRootNode(); n.checkout(); n.setProperty("lihan", "true"); session.save(); n.checkin(); VersionIterator vi = n.getVersionHistory().getAllVersions(); while(vi.hasNext()){ Version v = vi.nextVersion(); System.out.println("1:"+v.getCreated().getTimeInMillis()); } System.out.println("==============================================="); n.checkout(); n.setProperty("lihan", "false"); session.save(); n.checkin(); VersionIterator vi1 = n.getVersionHistory().getAllVersions(); while(vi1.hasNext()){ Version v1 = vi1.nextVersion(); System.out.println("2:"+v1.getCreated().getTimeInMillis()); } }

输出结果:

 

1:1247019892781
1:1247019894390
1:1247020513625
1:1247020514718
1:1247021126812
1:1247021127937
1:1247021201125
1:1247021203390
1:1247021352078
===============================================
2:1247019892781
2:1247019894390
2:1247020513625
2:1247020514718
2:1247021126812
2:1247021127937
2:1247021201125
2:1247021203390
2:1247021352078
2:1247021353265

 

注:最后一个是版本的修改时间,可做版本名称

你可能感兴趣的:(Apache Jackrabbit 内容存储版本控制)