本文整理汇总了Java中javax.jcr.version.VersionIterator类的典型用法代码示例。如果您正苦于以下问题:Java VersionIterator类的具体用法?Java VersionIterator怎么用?Java VersionIterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VersionIterator类属于javax.jcr.version包,在下文中一共展示了VersionIterator类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getVersionList
import javax.jcr.version.VersionIterator; //导入依赖的package包/类
protected List<T> getVersionList(Node node, NodeFilter nodeFilter) {
try {
List<T> versionList = new ArrayList<T>();
//VersionHistory versionHistory = node.getVersionHistory();
VersionHistory versionHistory = JcrUtils.getVersionManager(node.getSession()).getVersionHistory(node.getPath());
VersionIterator versionIterator = versionHistory.getAllVersions();
versionIterator.skip(1);
while (versionIterator.hasNext()) {
Version version = versionIterator.nextVersion();
NodeIterator nodeIterator = version.getNodes();
while (nodeIterator.hasNext()) {
T entityVersion = getJcrom().fromNode(getEntityClass(), nodeIterator.nextNode(), nodeFilter);
//Version baseVersion = node.getBaseVersion();
Version baseVersion = JcrUtils.getVersionManager(node.getSession()).getBaseVersion(node.getPath());
getJcrom().setBaseVersionInfo(entityVersion, baseVersion.getName(), baseVersion.getCreated());
versionList.add(entityVersion);
}
}
return versionList;
} catch (RepositoryException e) {
throw new JcrMappingException("Could not get version list", e);
}
}
开发者ID:dooApp,项目名称:jcromfx,代码行数:24,代码来源:AbstractJcrDAO.java
示例2: getPageVersions
import javax.jcr.version.VersionIterator; //导入依赖的package包/类
@Override
public List<PageVersion> getPageVersions(final String path) {
return jcrTemplate.execute(session -> {
Node rootNode = session.getRootNode();
Node node = JcrUtils.getNodeIfExists(rootNode, path);
if (node != null) {
VersionManager vm = session.getWorkspace().getVersionManager();
VersionHistory history = vm.getVersionHistory("/" + path);
List<PageVersion> versions = new ArrayList<>();
for (VersionIterator it = history.getAllVersions(); it.hasNext(); ) {
Version version = (Version) it.next();
if (!"jcr:rootVersion".equals(version.getName())) {
versions.add(convertNodeToPageVersion(version));
}
}
return versions;
} else {
return null;
}
});
}
开发者ID:MyCollab,项目名称:mycollab,代码行数:22,代码来源:PageServiceImpl.java
示例3: initialize
import javax.jcr.version.VersionIterator; //导入依赖的package包/类
private void initialize() throws RepositoryException {
if (versionName.equals("latest")) {
populate(resource, resource.getPath(), 0);
versionDate = Properties.lastModified(resource);
}
VersionManager versionManager = resource.getResourceResolver().adaptTo(Session.class).getWorkspace().getVersionManager();
try {
VersionHistory history = versionManager.getVersionHistory(this.resource.getPath());
VersionIterator versionIterator = history.getAllVersions();
while (versionIterator.hasNext()) {
Version next = versionIterator.nextVersion();
versionSelection.add(new VersionSelectionImpl(next.getName(), next.getCreated().getTime()));
if (next.getName().equalsIgnoreCase(versionName)) {
String versionPath = next.getFrozenNode().getPath();
Resource versionResource = resource.getResourceResolver().resolve(versionPath);
populate(versionResource, versionPath, 0);
versionDate = next.getCreated().getTime();
}
}
} catch (javax.jcr.UnsupportedRepositoryOperationException e) {
log.debug(String.format("node %s not versionable", this.resource.getPath()));
}
versionSelection.add(new VersionSelectionImpl("latest", Properties.lastModified(resource)));
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:26,代码来源:PageCompareDataImpl.java
示例4: lastVersion_oneVersion_returnVersion
import javax.jcr.version.VersionIterator; //导入依赖的package包/类
@Test
public void lastVersion_oneVersion_returnVersion() throws Exception {
// given
VersionIterator versionIterator = mock(VersionIterator.class, withSettings().extraInterfaces(Iterator.class));
when(versionIterator.hasNext()).thenReturn(true, false);
Version last = mock(Version.class);
when(versionIterator.next()).thenReturn(last);
Resource resource = mockResource(versionIterator);
// when
Version result = underTest.lastVersion(resource);
// then
assertThat(result, is(last));
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:18,代码来源:VersionServiceImplTest.java
示例5: lastVersion_listOfVersion_returnLast
import javax.jcr.version.VersionIterator; //导入依赖的package包/类
@Test
public void lastVersion_listOfVersion_returnLast() throws Exception {
// given
VersionIterator versionIterator = mock(VersionIterator.class, withSettings().extraInterfaces(Iterator.class));
when(versionIterator.hasNext()).thenReturn(true, true, true, false);
Version one = mock(Version.class);
Version two = mock(Version.class);
Version three = mock(Version.class);
when(versionIterator.next()).thenReturn(one, two, three);
Resource resource = mockResource(versionIterator);
// when
Version result = underTest.lastVersion(resource);
// then
assertThat(result, is(three));
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:20,代码来源:VersionServiceImplTest.java
示例6: testGetVersionLabels
import javax.jcr.version.VersionIterator; //导入依赖的package包/类
@Test
public void testGetVersionLabels() throws RepositoryException {
when(mockNode.isNodeType(FROZEN_NODE)).thenReturn(true);
final VersionHistory mockVersionHistory = mock(VersionHistory.class);
final Version mockVersion = mock(Version.class);
when(mockVersion.getName()).thenReturn("uuid");
final Workspace mockWorkspace = mock(Workspace.class);
when(mockSession.getWorkspace()).thenReturn(mockWorkspace);
final VersionManager mockVersionManager = mock(VersionManager.class);
when(mockWorkspace.getVersionManager()).thenReturn(mockVersionManager);
final VersionIterator mockVersionIterator = mock(VersionIterator.class);
when(mockVersionHistory.getAllVersions()).thenReturn(mockVersionIterator);
when(mockVersionIterator.hasNext()).thenReturn(false);
when(mockVersionManager.getVersionHistory(anyString())).thenReturn(
mockVersionHistory);
testObj.getVersions();
verify(mockVersionManager).getVersionHistory(anyString());
}
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:22,代码来源:FedoraResourceImplTest.java
示例7: getVersionFiles
import javax.jcr.version.VersionIterator; //导入依赖的package包/类
@Override
public List<VersionFile> getVersionFiles(String path) throws Exception{
path = processPath(path);
Node rootNode=getRootNode();
if (!rootNode.hasNode(path)) {
throw new RuleException("File [" + path + "] not exist.");
}
List<VersionFile> files = new ArrayList<VersionFile>();
Node fileNode = rootNode.getNode(path);
VersionHistory versionHistory = versionManager.getVersionHistory(fileNode.getPath());
VersionIterator iterator = versionHistory.getAllVersions();
while (iterator.hasNext()) {
Version version = iterator.nextVersion();
String versionName = version.getName();
if (versionName.startsWith("jcr:")) {
continue; // skip root version
}
Node fnode = version.getFrozenNode();
VersionFile file = new VersionFile();
file.setName(version.getName());
file.setPath(fileNode.getPath());
Property prop = fnode.getProperty(CRATE_USER);
file.setCreateUser(prop.getString());
prop = fnode.getProperty(CRATE_DATE);
file.setCreateDate(prop.getDate().getTime());
if(fnode.hasProperty(VERSION_COMMENT)){
prop=fnode.getProperty(VERSION_COMMENT);
file.setComment(prop.getString());
}
files.add(file);
}
return files;
}
开发者ID:youseries,项目名称:urule,代码行数:34,代码来源:BaseRepositoryService.java
示例8: updateVersion
import javax.jcr.version.VersionIterator; //导入依赖的package包/类
protected String updateVersion(Session session, Node nodeByUUID) throws RepositoryException, OleDocStoreException {
session.save();
String currentVersion = null;
if (isVersioningEnabled()) {
VersionManager versionManager = getVersionManager(session);
versionManager.checkpoint(nodeByUUID.getPath());
VersionHistory versionHistory = versionManager.getVersionHistory(nodeByUUID.getPath());
VersionIterator allVersions = versionHistory.getAllVersions();
while (allVersions.hasNext()) {
currentVersion = allVersions.nextVersion().getName();
}
logger.info("Version updated for UUID:" + nodeByUUID.getIdentifier() + " ==== version:" + currentVersion);
}
return currentVersion;
}
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:16,代码来源:JcrAbstractDocumentManager.java
示例9: getVersions
import javax.jcr.version.VersionIterator; //导入依赖的package包/类
private List<Version> getVersions(String nodePath, Session session) throws RepositoryException {
List<Version> versions = new ArrayList<Version>();
for (VersionIterator iter = session.getWorkspace()
.getVersionManager().getVersionHistory(nodePath)
.getAllVersions(); iter.hasNext();) {
Version v = iter.nextVersion();
versions.add(v);
}
return versions;
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:13,代码来源:ReplicateVersionImpl.java
示例10: lastVersion_noElement_returnNull
import javax.jcr.version.VersionIterator; //导入依赖的package包/类
@Test
public void lastVersion_noElement_returnNull() throws Exception {
// given
VersionIterator versionIterator = mock(VersionIterator.class, withSettings().extraInterfaces(Iterator.class));
when(versionIterator.hasNext()).thenReturn(false);
Resource resource = mockResource(versionIterator);
// when
Version result = underTest.lastVersion(resource);
// then
assertNull(result);
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:15,代码来源:VersionServiceImplTest.java
示例11: lastVersion_error_returnNull
import javax.jcr.version.VersionIterator; //导入依赖的package包/类
@Test
public void lastVersion_error_returnNull() throws Exception {
// given
VersionIterator versionIterator = mock(VersionIterator.class, withSettings().extraInterfaces(Iterator.class));
when(versionIterator.hasNext()).thenThrow(RepositoryException.class);
Resource resource = mockResource(versionIterator);
// when
Version result = underTest.lastVersion(resource);
// then
assertNull(result);
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:15,代码来源:VersionServiceImplTest.java
示例12: mockResource
import javax.jcr.version.VersionIterator; //导入依赖的package包/类
private Resource mockResource(VersionIterator versionIterator) throws RepositoryException {
Resource resource = mock(Resource.class, RETURNS_DEEP_STUBS.get());
Session session = mock(Session.class, RETURNS_DEEP_STUBS.get());
when(resource.getResourceResolver().adaptTo(Session.class)).thenReturn(session);
when(session.getWorkspace().getVersionManager().getVersionHistory(anyString()).getAllVersions()).thenReturn(versionIterator);
return resource;
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:8,代码来源:VersionServiceImplTest.java
示例13: mockResource
import javax.jcr.version.VersionIterator; //导入依赖的package包/类
static Resource mockResource(String path, String versionName, Date date) throws RepositoryException {
Resource resource = mock(Resource.class, Answers.RETURNS_DEEP_STUBS.get());
when(resource.getPath()).thenReturn(path);
when(resource.getValueMap()).thenReturn(mock(ValueMap.class));
Node node = mock(Node.class, Answers.RETURNS_DEEP_STUBS.get());
when(resource.adaptTo(Node.class)).thenReturn(node);
ResourceResolver resourceResolver = mock(ResourceResolver.class);
when(resource.getResourceResolver()).thenReturn(resourceResolver);
when(resourceResolver.resolve(path)).thenReturn(resource);
Session session = mock(Session.class, Answers.RETURNS_DEEP_STUBS.get());
when(resourceResolver.adaptTo(Session.class)).thenReturn(session);
VersionManager versionManager = mock(VersionManager.class);
when(session.getWorkspace().getVersionManager()).thenReturn(versionManager);
VersionHistory history = mock(VersionHistory.class);
when(versionManager.getVersionHistory(path)).thenReturn(history);
Version version = mock(Version.class, Answers.RETURNS_DEEP_STUBS.get());
when(version.getName()).thenReturn(versionName);
final GregorianCalendar calendar = new GregorianCalendar();
calendar.setTime(date);
when(version.getCreated()).thenReturn(calendar);
when(version.getFrozenNode().getPath()).thenReturn(path);
VersionIterator versionIterator = mock(VersionIterator.class);
when(versionIterator.hasNext()).thenReturn(true, false);
when(versionIterator.nextVersion()).thenReturn(version);
when(history.getAllVersions()).thenReturn(versionIterator);
return resource;
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:36,代码来源:PageCompareDataImplTest.java
示例14: testRevertToUnknownVersion
import javax.jcr.version.VersionIterator; //导入依赖的package包/类
@Test(expected = RepositoryRuntimeException.class)
public void testRevertToUnknownVersion() throws RepositoryException {
final String versionUUID = "uuid";
final VersionManager mockVersionManager = mock(VersionManager.class);
final VersionHistory mockHistory = mock(VersionHistory.class);
when(mockHistory.getVersionByLabel(versionUUID)).thenThrow(new VersionException());
final VersionIterator mockVersionIterator = mock(VersionIterator.class);
when(mockHistory.getAllVersions()).thenReturn(mockVersionIterator);
when(mockVersionIterator.hasNext()).thenReturn(false);
when(mockWorkspace.getVersionManager()).thenReturn(mockVersionManager);
when(mockVersionManager.getVersionHistory(EXAMPLE_VERSIONED_PATH)).thenReturn(mockHistory);
testObj.revertToVersion(testSession, EXAMPLE_VERSIONED_PATH, versionUUID);
}
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:16,代码来源:VersionServiceImplTest.java
示例15: testRemoveUnknownVersion
import javax.jcr.version.VersionIterator; //导入依赖的package包/类
@Test(expected = RepositoryRuntimeException.class)
public void testRemoveUnknownVersion() throws RepositoryException {
final String versionUUID = "uuid";
final VersionManager mockVersionManager = mock(VersionManager.class);
final VersionHistory mockHistory = mock(VersionHistory.class);
when(mockHistory.getVersionByLabel(versionUUID)).thenThrow(new VersionException());
final VersionIterator mockVersionIterator = mock(VersionIterator.class);
when(mockHistory.getAllVersions()).thenReturn(mockVersionIterator);
when(mockVersionIterator.hasNext()).thenReturn(false);
when(mockWorkspace.getVersionManager()).thenReturn(mockVersionManager);
when(mockVersionManager.getVersionHistory("/example")).thenReturn(mockHistory);
testObj.removeVersion(testSession, "/example", versionUUID);
}
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:16,代码来源:VersionServiceImplTest.java
示例16: testReplicate
import javax.jcr.version.VersionIterator; //导入依赖的package包/类
@Test
public final void testReplicate() throws Exception {
final String[] agents = new String[]{"agent1"};
final String[] rootPaths = new String[]{"/content/geometrixx/en"};
final Date date = getDate("2013-12-21T00:00:00");
final Date vDate = getDate("2013-12-01T00:00:00");
final Date vDate1 = getDate("2013-12-22T00:00:00");
final Calendar cal = GregorianCalendar.getInstance();
cal.setTime(vDate);
final Calendar cal1 = GregorianCalendar.getInstance();
cal1.setTime(vDate1);
final ResourceResolver resourceResolver = mock(ResourceResolver.class);
final Session session = mock(Session.class);
final Workspace wk = mock(Workspace.class);
final VersionManager vm = mock(VersionManager.class);
final VersionHistory vh = mock(VersionHistory.class);
final VersionIterator vi = mock(VersionIterator.class);
final Version v = mock(Version.class);
final Version v1 = mock(Version.class);
when(v.getCreated()).thenReturn(cal);
when(v1.getCreated()).thenReturn(cal1);
when(v.getName()).thenReturn("version1");
when(vi.nextVersion()).thenReturn(v, v1);
when(vi.hasNext()).thenReturn(true, true, false);
when(session.getWorkspace()).thenReturn(wk);
when(wk.getVersionManager()).thenReturn(vm);
when(resourceResolver.adaptTo(Session.class)).thenReturn(session);
when(vm.getVersionHistory(rootPaths[0])).thenReturn(vh);
when(vh.getAllVersions()).thenReturn(vi);
final Resource res = mock(Resource.class);
when(res.getPath()).thenReturn(rootPaths[0]);
final Node node = mock(Node.class);
when(resourceResolver.getResource(rootPaths[0])).thenReturn(res);
when(res.adaptTo(Node.class)).thenReturn(node);
when(session.getNode(rootPaths[0])).thenReturn(node);
when(node.hasNode(NameConstants.NN_CONTENT)).thenReturn(true);
final Node node1 = mock(Node.class);
when(node1.getPath()).thenReturn(rootPaths[0]);
when(node.getNode(NameConstants.NN_CONTENT)).thenReturn(node1);
when(node1.isNodeType(JcrConstants.MIX_VERSIONABLE)).thenReturn(true);
when(node.isNodeType("nt:hierarchyNode")).thenReturn(true);
final Resource res1 = mock(Resource.class);
final Resource res2 = mock(Resource.class);
@SuppressWarnings("unchecked")
final Iterator<Resource> itr = mock(Iterator.class);
when(resourceResolver.listChildren(res)).thenReturn(itr);
when(itr.hasNext()).thenReturn(true, true, false);
when(itr.next()).thenReturn(res1, res2);
when(res1.adaptTo(Node.class)).thenReturn(node1);
when(res2.adaptTo(Node.class)).thenReturn(node1);
when(node1.isNodeType("nt:hierarchyNode")).thenReturn(false);
List<ReplicationResult> list = rpvs.replicate(resourceResolver, rootPaths, agents, date);
Assert.assertEquals("/content/geometrixx/en", list.get(0).getPath());
Assert.assertEquals(Status.replicated, list.get(0).getStatus());
Assert.assertEquals("version1", list.get(0).getVersion());
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:61,代码来源:ReplicateVersionImplTest.java
示例17: getVersionInfos
import javax.jcr.version.VersionIterator; //导入依赖的package包/类
public VersionInfo[] getVersionInfos(String id) throws NotFoundException {
// checkPath(path);
Node node = getNodeById(id);
if (!isVersionable(node)) {
// TODO throws an custom exception
return new VersionInfo[0];
}
List<VersionInfo> versionInfos = new ArrayList<VersionInfo>();
try {
VersionHistory versionHistory = getSession().getWorkspace().getVersionManager()
.getVersionHistory(node.getPath());
Version baseVersion = getSession().getWorkspace().getVersionManager().getBaseVersion(node.getPath());
VersionIterator versions = versionHistory.getAllVersions();
versions.skip(1);
while (versions.hasNext()) {
Version version = versions.nextVersion();
NodeIterator nodes = version.getNodes();
while (nodes.hasNext()) {
VersionInfo versionInfo = new VersionInfo();
versionInfo.setName(version.getName());
try {
Entity entity = getEntity(nodes.nextNode());
// after StorageUpdate20 when com.asf.nextserver package
// was renamed with ro.nextreports.server
// all version nodes remained with older className (they
// cannot be changed because they are protected)
// so they cannot be accessed anymore!
if (entity == null) {
continue;
}
String createdBy = entity.getLastUpdatedBy();
if (createdBy == null) {
createdBy = entity.getCreatedBy();
}
versionInfo.setCreatedBy(createdBy);
versionInfo.setCreatedDate(version.getCreated().getTime());
versionInfo.setBaseVersion(baseVersion.getName().equals(version.getName()));
versionInfos.add(versionInfo);
} catch (JcrMappingException ex) {
// getEntity version is not found???
// @todo why?
}
}
}
} catch (RepositoryException e) {
throw convertJcrAccessException(e);
}
return versionInfos.toArray(new VersionInfo[versionInfos.size()]);
}
开发者ID:nextreports,项目名称:nextreports-server,代码行数:53,代码来源:JcrStorageDao.java
注:本文中的javax.jcr.version.VersionIterator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论