本文整理汇总了Java中javax.jcr.version.VersionIterator.hasNext方法的典型用法代码示例。如果您正苦于以下问题:Java VersionIterator.hasNext方法的具体用法?Java VersionIterator.hasNext怎么用?Java VersionIterator.hasNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.jcr.version.VersionIterator
的用法示例。
在下文中一共展示了VersionIterator.hasNext方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例2: 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)));
}
示例3: 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;
}
示例4: 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;
}
示例5: 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()]);
}