本文整理了Java中javax.jcr.version.Version.getSession()
方法的一些代码示例,展示了Version.getSession()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Version.getSession()
方法的具体详情如下:
包路径:javax.jcr.version.Version
类名称:Version
方法名:getSession
暂无
代码示例来源:origin: apache/jackrabbit
/**
* Tests if <code>Version.getSession()</code> returns the right session
*/
public void testGetSession() throws Exception {
assertSame("Version.getSession() did not return the right session", superuser, version.getSession());
}
代码示例来源:origin: apache/jackrabbit
/**
* Tests if <code>Version.addNode(String)</code> and
* <code>Version.addNode(String, String)</code> throw a {@link
* javax.jcr.nodetype.ConstraintViolationException}
*/
public void testAddNode() throws Exception {
try {
version.addNode(nodeName4);
version.getSession().save();
fail("Version should be read-only: Version.addNode(String) did not throw a ConstraintViolationException");
} catch (ConstraintViolationException success) {
}
try {
version.addNode(nodeName4, ntBase);
version.getSession().save();
fail("Version should be read-only: Version.addNode(String,String) did not throw a ConstraintViolationException");
} catch (ConstraintViolationException success) {
}
}
代码示例来源:origin: com.thinkbiganalytics.kylo/kylo-metadata-modeshape
public static void restore(Version version) {
try {
getVersionManager(version.getSession()).restore(version, true);
} catch (RepositoryException e) {
throw new MetadataRepositoryException("Failed to restore version: " + version, e);
}
}
代码示例来源:origin: apache/jackrabbit
/**
* Tests if <code>Version.unlock()</code> throws a {@link
* javax.jcr.lock.LockException}
*/
public void testUnlockJcr2() throws Exception {
ensureLockingSupported();
try {
version.getSession().getWorkspace().getLockManager().unlock(version.getPath());
fail("Version should not be lockable: Version.unlock() did not throw a LockException");
} catch (LockException success) {
}
}
代码示例来源:origin: apache/jackrabbit
/**
* Tests if <code>Version.holdsLock()</code> returns <code>false</code>
*/
public void testHoldsLockJcr2() throws Exception {
ensureLockingSupported();
assertFalse("Version.holdsLock() did not return false", version.getSession().getWorkspace().getLockManager().holdsLock(version.getPath()));
}
代码示例来源:origin: apache/jackrabbit
/**
* Tests if <code>Version.isLocked()</code> returns <code>false</code>
*/
public void testIsLockedJcr2() throws Exception {
ensureLockingSupported();
assertFalse("Version.isLocked() did not return false", version.getSession().getWorkspace().getLockManager().isLocked(version.getPath()));
}
代码示例来源:origin: apache/jackrabbit
/**
* Tests if <code>Version.getLock()</code> throws a {@link
* javax.jcr.lock.LockException}
*/
public void testGetLockJcr2() throws Exception {
ensureLockingSupported();
try {
version.getSession().getWorkspace().getLockManager().getLock(version.getPath());
fail("Version should not be lockable: Version.getLock() did not throw a LockException");
} catch (LockException success) {
}
}
代码示例来源:origin: apache/jackrabbit
version.getSession().save();
fail("Version should be read-only: Version.setProperty(String,String[]) did not throw a ConstraintViolationException");
} catch (ConstraintViolationException success) {
version.getSession().save();
fail("Version should be read-only: Version.setProperty(String,String[],int) did not throw a ConstraintViolationException");
} catch (ConstraintViolationException success) {
version.getSession().save();
fail("Version should be read-only: Version.setProperty(String,Value[]) did not throw a ConstraintViolationException");
} catch (ConstraintViolationException success) {
version.getSession().save();
fail("Version should be read-only: Version.setProperty(String,Value[],int]) did not throw a ConstraintViolationException");
} catch (ConstraintViolationException success) {
version.getSession().save();
fail("Version should be read-only: Version.setProperty(String,boolean) did not throw a ConstraintViolationException");
} catch (ConstraintViolationException success) {
version.getSession().save();
fail("Version should be read-only: Version.setProperty(String,double) did not throw a ConstraintViolationException");
} catch (ConstraintViolationException success) {
InputStream inpStream = new ByteArrayInputStream(bytes);
version.setProperty(propertyName1, inpStream);
version.getSession().save();
fail("Version should be read-only: Version.setProperty(String,InputStream) did not throw a ConstraintViolationException");
} catch (ConstraintViolationException success) {
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void getVersionForALabel() throws RepositoryException {
// GIVEN
String label = "label";
VersionManager versionManager = VersionManager.getInstance();
// Create node structure
Node node = MgnlContext.getJCRSession(RepositoryConstants.WEBSITE).getRootNode().addNode("test", NodeTypes.Content.NAME);
Node firstLevel = node.addNode("first-level", NodeTypes.Content.NAME);
firstLevel.setProperty("text", " firstLevel V1");
Node secondLevel = firstLevel.addNode("second-level", NodeTypes.Content.NAME);
secondLevel.setProperty("text", " secondLevel V1");
node.getSession().save();
// Create version
Version v1 = versionManager.addVersion(node);
// Add label
v1.getContainingHistory().addVersionLabel(v1.getName(), label, true);
Version v2 = versionManager.addVersion(node);
assertEquals("magnolia-mgnlVersion", v2.getSession().getWorkspace().getName());
// WHEN
Version baseVersion = versionManager.getBaseVersion(node);
assertEquals("magnolia-mgnlVersion", baseVersion.getSession().getWorkspace().getName());
VersionHistory versionHistory = versionManager.getVersionHistory(node);
assertEquals("magnolia-mgnlVersion", versionHistory.getSession().getWorkspace().getName());
// WHEN
boolean haveLabel = versionHistory.hasVersionLabel(v1, label);
// THEN
assertTrue(haveLabel);
}
代码示例来源:origin: apache/jackrabbit
/**
* Tests if <code>Version.lock(boolean, boolean)</code> throws a {@link
* LockException}
*/
public void testLockJcr2() throws Exception {
ensureLockingSupported();
LockManager lockManager = version.getSession().getWorkspace().getLockManager();
String path = version.getPath();
try {
lockManager.lock(path, true, true, 60, "");
fail("Version should not be lockable: Version.lock(true,true) did not throw a LockException");
} catch (LockException success) {
}
try {
lockManager.lock(path, true, false, 60, "");
fail("Version should not be lockable: Version.lock(true,false) did not throw a LockException");
} catch (LockException success) {
}
try {
lockManager.lock(path, false, true, 60, "");
fail("Version should not be lockable: Version.lock(false,true) did not throw a LockException");
} catch (LockException success) {
}
try {
lockManager.lock(path, false, false, 60, "");
fail("Version should not be lockable: Version.lock(false,false) did not throw a LockException");
} catch (LockException success) {
}
}
代码示例来源:origin: apache/jackrabbit
/**
* Returns the NodeState of the given Node and asserts that the state is
* listed in the hierarchy built by this Session. If the version
* was obtained from a different session, the 'corresponding' version
* state for this session is retrieved.
*
* @param version
* @return the NodeState associated with the specified version.
*/
NodeState getVersionState(Version version) throws RepositoryException {
NodeState nodeState;
if (version.getSession() == this) {
nodeState = (NodeState) ((NodeImpl) version).getItemState();
} else {
Path p = getQPath(version.getPath());
Path parentPath = p.getAncestor(1);
HierarchyEntry parentEntry = getHierarchyManager().lookup(parentPath);
if (parentEntry != null) {
// make sure the parent entry is up to date
parentEntry.invalidate(false);
}
nodeState = getHierarchyManager().getNodeState(p);
}
return nodeState;
}
//------------------------------------------------------< check methods >---
代码示例来源:origin: org.apache.jackrabbit/jackrabbit-jcr2spi
/**
* Returns the NodeState of the given Node and asserts that the state is
* listed in the hierarchy built by this Session. If the version
* was obtained from a different session, the 'corresponding' version
* state for this session is retrieved.
*
* @param version
* @return the NodeState associated with the specified version.
*/
NodeState getVersionState(Version version) throws RepositoryException {
NodeState nodeState;
if (version.getSession() == this) {
nodeState = (NodeState) ((NodeImpl) version).getItemState();
} else {
Path p = getQPath(version.getPath());
Path parentPath = p.getAncestor(1);
HierarchyEntry parentEntry = getHierarchyManager().lookup(parentPath);
if (parentEntry != null) {
// make sure the parent entry is up to date
parentEntry.invalidate(false);
}
nodeState = getHierarchyManager().getNodeState(p);
}
return nodeState;
}
//------------------------------------------------------< check methods >---
代码示例来源:origin: org.onehippo.cms7/hippo-cms-api
protected WorkflowDescriptor load() {
try {
Session session = UserSession.get().getJcrSession();
WorkflowManager workflowManager = ((HippoWorkspace) session.getWorkspace()).getWorkflowManager();
Node node = getNode(session);
if (node.isNodeType(JcrConstants.NT_FROZEN_NODE)) {
Version version = (Version) node.getParent();
String docId = version.getContainingHistory().getVersionableIdentifier();
Node docNode = version.getSession().getNodeByIdentifier(docId);
if (docNode.getParent().isNodeType(HippoNodeType.NT_HANDLE)) {
Node handle = docNode.getParent();
return workflowManager.getWorkflowDescriptor(category, handle);
} else {
return workflowManager.getWorkflowDescriptor(category, docNode);
}
} else {
return workflowManager.getWorkflowDescriptor(category, node);
}
} catch (RepositoryException ex) {
return null;
}
}
代码示例来源:origin: org.exoplatform.jcr/exo.jcr.component.core
if (!v.getSession().getWorkspace().getName().equals(session.getWorkspace().getName()))
((SessionImpl)v.getSession()).getTransientNodesManager().getTransactManager();
corrNode = (NodeData)vDataManager.getItemData(versionableIdentifier);
if (corrNode != null)
内容来源于网络,如有侵权,请联系作者删除!