本文整理了Java中javax.jcr.version.Version.getLinearPredecessor()
方法的一些代码示例,展示了Version.getLinearPredecessor()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Version.getLinearPredecessor()
方法的具体详情如下:
包路径:javax.jcr.version.Version
类名称:Version
方法名:getLinearPredecessor
[英]Assuming that this Version
object was acquired through a Workspace``W
and is within the VersionHistory``H
, this method returns the predecessor of this version along the same line of descent as is returned by H.getAllLinearVersions()
where H
was also acquired through W
.
Note that under simple versioning the behavior of this method is equivalent to getting the unique predecessor (if any) of this version.
[中]假设此Version
对象是通过Workspace``W
获取的,并且在VersionHistory``H
范围内,此方法将沿着H.getAllLinearVersions()
返回的相同下降线返回此版本的前一个对象,其中H
也是通过[$7$]获取的。
请注意,在简单版本控制下,此方法的行为相当于获取此版本的唯一前置版本(如果有)。
代码示例来源:origin: info.magnolia/magnolia-core
@Override
public Version getLinearPredecessor() throws RepositoryException {
return version.getLinearPredecessor();
}
代码示例来源:origin: org.onehippo.cms7/hippo-repository-connector
public Version getLinearPredecessor() throws RepositoryException {
return version.getLinearPredecessor();
}
代码示例来源:origin: net.adamcin.oakpal/oakpal-core
@Override
public Version getLinearPredecessor() throws RepositoryException {
Version internalVersion = delegate.getLinearPredecessor();
return new VersionFacade<>(internalVersion, session);
}
代码示例来源:origin: com.adobe.acs/acs-aem-commons-bundle
@Override
public boolean isAdded() {
try {
if (isResource()) {
Node node = version.getLinearPredecessor().getFrozenNode().getNode(relativePath);
return node == null;
} else {
Property prop = version.getLinearPredecessor().getFrozenNode().getProperty(relativePath);
return prop == null;
}
} catch (Exception e) {
}
return true;
}
代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons
@Override
public boolean isAdded() {
try {
if (isResource()) {
Node node = version.getLinearPredecessor().getFrozenNode().getNode(relativePath);
return node == null;
} else {
Property prop = version.getLinearPredecessor().getFrozenNode().getProperty(relativePath);
return prop == null;
}
} catch (Exception e) {
// no-op
}
return true;
}
代码示例来源:origin: info.magnolia/magnolia-core
@Override
public Version getLinearPredecessor() throws RepositoryException {
Version linearPredecessor = getWrappedVersion().getLinearPredecessor();
return linearPredecessor != null ? wrapVersion(linearPredecessor) : null;
}
代码示例来源:origin: com.adobe.acs/acs-aem-commons-bundle
@Override
public boolean isChanged() {
try {
if (isResource()) {
return false;
}
Property prop = version.getLinearPredecessor().getFrozenNode().getProperty(relativePath);
String currentValue = config.printProperty(prop);
String oldValue = config.printProperty(property);
return !currentValue.equals(oldValue);
} catch (Exception e) {
log.error("Unable to check changed status", e);
}
return false;
}
代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons
@Override
public boolean isChanged() {
try {
if (isResource()) {
return false;
}
Property prop = version.getLinearPredecessor().getFrozenNode().getProperty(relativePath);
String currentValue = config.printProperty(prop);
String oldValue = config.printProperty(property);
return !currentValue.equals(oldValue);
} catch (Exception e) {
log.error("Unable to check changed status", e);
}
return false;
}
代码示例来源:origin: brix-cms/brix-cms
public JcrVersion execute() throws Exception {
return JcrVersion.Wrapper.wrap(getDelegate().getLinearPredecessor(),
getJcrSession());
}
});
代码示例来源:origin: brix-cms/brix-cms
public Version getLinearPredecessor() throws RepositoryException {
return VersionWrapper.wrap(getDelegate().getLinearPredecessor(), getSessionWrapper());
}
代码示例来源:origin: apache/jackrabbit
/** {@inheritDoc} */
public RemoteVersion getLinearPredecessor() throws RepositoryException,
RemoteException {
try {
Version linearPredecessor = version.getLinearPredecessor();
if (linearPredecessor == null) {
return null;
} else {
return getFactory().getRemoteVersion(linearPredecessor);
}
} catch (RepositoryException ex) {
throw getRepositoryException(ex);
}
}
代码示例来源:origin: apache/jackrabbit
/**
* @see VersionHistory#getAllLinearVersions()
*/
public VersionIterator getAllLinearVersions() throws RepositoryException {
checkStatus();
// TODO: improve and use lazy loading of versions as needed.
// TODO: change session.getNodeByUUID to Session.getNodeByIdentifier as soon as implemented
List<Version> versions = new ArrayList<Version>();
Version rootV = getRootVersion();
Node vn = session.getNodeByUUID(getVersionableUUID());
Version v = vn.getBaseVersion();
while (v != null && !rootV.isSame(v)) {
versions.add(0, v);
v = v.getLinearPredecessor();
}
versions.add(0, rootV);
return new VersionIteratorAdapter(versions);
}
代码示例来源:origin: org.apache.jackrabbit/jackrabbit-jcr2spi
/**
* @see VersionHistory#getAllLinearVersions()
*/
public VersionIterator getAllLinearVersions() throws RepositoryException {
checkStatus();
// TODO: improve and use lazy loading of versions as needed.
// TODO: change session.getNodeByUUID to Session.getNodeByIdentifier as soon as implemented
List<Version> versions = new ArrayList<Version>();
Version rootV = getRootVersion();
Node vn = session.getNodeByUUID(getVersionableUUID());
Version v = vn.getBaseVersion();
while (v != null && !rootV.isSame(v)) {
versions.add(0, v);
v = v.getLinearPredecessor();
}
versions.add(0, rootV);
return new VersionIteratorAdapter(versions);
}
代码示例来源:origin: org.apache.jackrabbit/jackrabbit-jcr2spi
/**
* @see Version#getLinearSuccessor()
*/
public Version getLinearSuccessor() throws RepositoryException {
// TODO: improve.
VersionHistory vh = getContainingHistory();
for (VersionIterator it = vh.getAllLinearVersions(); it.hasNext();) {
Version v = it.nextVersion();
if (isSame(v.getLinearPredecessor())) {
return v;
}
}
// no linear successor found
return null;
}
代码示例来源:origin: apache/jackrabbit
/**
* @see Version#getLinearSuccessor()
*/
public Version getLinearSuccessor() throws RepositoryException {
// TODO: improve.
VersionHistory vh = getContainingHistory();
for (VersionIterator it = vh.getAllLinearVersions(); it.hasNext();) {
Version v = it.nextVersion();
if (isSame(v.getLinearPredecessor())) {
return v;
}
}
// no linear successor found
return null;
}
代码示例来源:origin: apache/jackrabbit
/**
* Checks obtaining the linear predecessor.
* @since JCR 2.0
*/
public void testGetLinearPredecessorSuccessor() throws RepositoryException {
String path = versionableNode.getPath();
VersionManager vm = versionableNode.getSession().getWorkspace().getVersionManager();
// get the previous version
Version pred = vm.getBaseVersion(path);
// shouldn't have a predecessor
assertNull(pred.getLinearPredecessor());
// shouldn't have a successor yet
assertNull(pred.getLinearSuccessor());
// check root version
Version root = vm.getVersionHistory(path).getRootVersion();
assertNull(root.getLinearSuccessor());
// create a new version
vm.checkout(path);
Version version = vm.checkin(path);
// refresh the predecessor
pred = (Version)versionableNode.getSession().getNode(pred.getPath());
assertTrue("linear predecessor of new version should be previous version",
version.getLinearPredecessor().isSame(pred));
assertTrue("linear successor of previous version should be new version",
pred.getLinearSuccessor().isSame(version));
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void testGetPreviousVersion() throws RepositoryException {
// GIVEN
Session session = MgnlContext.getJCRSession(RepositoryConstants.WEBSITE);
Node node = session.getRootNode().addNode("pageTestGetPreviousVersion", NodeTypes.Content.NAME);
node.addNode("paragraph", NodeTypes.Content.NAME);
session.save();
Version version1_0 = versionManager.addVersion(node);
node.addNode("area", NodeTypes.Content.NAME);
session.save();
Version version1_1 = versionManager.addVersion(node);
// WHEN
Version previousVersion1_0 = VersionUtil.getPreviousVersion(version1_0);
Version previousVersion1_1 = VersionUtil.getPreviousVersion(version1_1);
// THEN
assertTrue(version1_0.isSame(previousVersion1_1));
assertEquals(version1_0.getLinearPredecessor().getIdentifier(), previousVersion1_0.getIdentifier());
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void testLinearPredecessorIsWrapped() throws Exception {
// GIVEN
Session session = MgnlContext.getJCRSession(RepositoryConstants.WEBSITE);
VersionManager versionMan = Components.getComponent(VersionManager.class);
Node node = session.getRootNode().addNode( "page", NodeTypes.Page.NAME);
session.save();
Version createdVersion_1 = versionMan.addVersion(node);
Version createdVersion_2 = versionMan.addVersion(node);
// WHEN
Version version = createdVersion_2.getLinearPredecessor();
// THEN
assertTrue(version instanceof ContentDecoratorVersionWrapper);
assertTrue(version.isSame(createdVersion_1));
}
内容来源于网络,如有侵权,请联系作者删除!