本文整理了Java中javax.jcr.Session.getNodeByIdentifier()
方法的一些代码示例,展示了Session.getNodeByIdentifier()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Session.getNodeByIdentifier()
方法的具体详情如下:
包路径:javax.jcr.Session
类名称:Session
方法名:getNodeByIdentifier
[英]Returns the node specified by the given identifier. Applies to both referenceable and non-referenceable nodes.
[中]返回给定标识符指定的节点。适用于可引用和不可引用节点。
代码示例来源:origin: info.magnolia/magnolia-core
/**
* Get node from version store.
*/
protected Node getVersionedNode(Session session, String uuid) throws RepositoryException {
try {
return session.getNodeByIdentifier(uuid);
} catch (ItemNotFoundException e) {
// node is not versioned yet
return null;
}
}
代码示例来源:origin: org.apache.jackrabbit/jackrabbit-core
static Node getTokenNode(String token, Session session) throws RepositoryException {
int pos = token.indexOf(DELIM);
String id = (pos == -1) ? token : token.substring(0, pos);
return session.getNodeByIdentifier(id);
}
代码示例来源:origin: org.apache.jackrabbit/jackrabbit-core
static Node getTokenNode(String token, Session session) throws RepositoryException {
int pos = token.indexOf(DELIM);
String id = (pos == -1) ? token : token.substring(0, pos);
return session.getNodeByIdentifier(id);
}
代码示例来源:origin: info.magnolia/magnolia-core
@Override
public User exec(Session session) throws RepositoryException {
Node priviledgedUserNode = session.getNodeByIdentifier(id);
return newUserInstance(priviledgedUserNode);
}
代码示例来源:origin: info.magnolia/magnolia-core
/**
* Get a Node by identifier.
*/
public static Node getNodeByIdentifier(String workspace, String identifier) throws RepositoryException {
if (workspace == null || identifier == null) {
return null;
}
final Session jcrSession = MgnlContext.getJCRSession(workspace);
return (jcrSession == null) ? null : jcrSession.getNodeByIdentifier(identifier);
}
代码示例来源:origin: pentaho/pentaho-platform
@Override
public Object doInJcr( final Session session ) throws RepositoryException, IOException {
Node fileNode = session.getNodeByIdentifier( fileId.toString() );
session.getWorkspace().getVersionManager().restore( fileNode.getPath(), versionId.toString(), true );
return null;
}
} );
代码示例来源:origin: info.magnolia/magnolia-core
@Override
public synchronized Node getWrappedNode() {
try {
if (node == null || !node.getSession().isLive()) {
Session session = getSessionForWrappedNode(this.workspace);
node = session.getNodeByIdentifier(this.nodeIdentifier);
}
} catch (RepositoryException e) {
throw new RuntimeException(e);
}
return node;
}
代码示例来源:origin: pentaho/pentaho-platform
public static Serializable getParentId( final Session session, final Serializable fileId )
throws RepositoryException {
Node node = session.getNodeByIdentifier( fileId.toString() );
return node.getParent().getIdentifier();
}
代码示例来源:origin: pentaho/pentaho-platform
public static Serializable getBaseVersionId( final Session session, final Serializable fileId )
throws RepositoryException {
Node node = session.getNodeByIdentifier( fileId.toString() );
return session.getWorkspace().getVersionManager().getBaseVersion( node.getPath() ).getName();
}
代码示例来源:origin: info.magnolia/magnolia-core
/**
* Creates link guessing best possible link format from current site and provided content.
*
* @param uuid UUID of content to create link to.
* @param workspaceName Name of the repository where content is located.
* @return Absolute link to the provided content.
* @see info.magnolia.cms.i18n.AbstractI18nContentSupport
*/
public static String createLink(String workspaceName, String uuid) throws RepositoryException {
Node node = MgnlContext.getJCRSession(workspaceName).getNodeByIdentifier(uuid);
return createLink(node);
}
代码示例来源:origin: info.magnolia/magnolia-core
protected String getResourceName(final String resourceId) {
try {
return MgnlContext.getJCRSession(getRepositoryName()).getNodeByIdentifier(resourceId).getName();
} catch (ItemNotFoundException e) {
// referenced node doesn't exist
return null;
} catch (RepositoryException e) {
log.error(e.getMessage(), e);
}
return null;
}
代码示例来源:origin: info.magnolia/magnolia-core
/**
* Creates absolute link including context path to the provided content and performing all URI2Repository mappings and applying locales.
*
* @param uuid UUID of content to create link to.
* @param workspaceName Name of the repository where content is located.
* @return Absolute link to the provided content.
* @see info.magnolia.cms.i18n.AbstractI18nContentSupport
*/
public static String createAbsoluteLink(String workspaceName, String uuid) throws RepositoryException {
Node jcrNode = MgnlContext.getJCRSession(workspaceName).getNodeByIdentifier(uuid);
return createAbsoluteLink(jcrNode);
}
代码示例来源:origin: pentaho/pentaho-platform
private static void preventLostUpdate( final Session session, final PentahoJcrConstants pentahoJcrConstants,
final RepositoryFile file ) throws RepositoryException {
Node fileNode = session.getNodeByIdentifier( file.getId().toString() );
// guard against using a file retrieved from a more lenient session inside a more strict session
Assert.notNull( fileNode );
if ( isVersioned( session, pentahoJcrConstants, fileNode ) ) {
Assert.notNull( file.getVersionId(), "updating a versioned file requires a non-null version id" ); //$NON-NLS-1$
Assert.state( session.getWorkspace().getVersionManager().getBaseVersion( fileNode.getPath() ).getName().equals(
file.getVersionId().toString() ), "update to this file has occurred since its last read" ); //$NON-NLS-1$
}
}
代码示例来源:origin: pentaho/pentaho-platform
public static RepositoryFile getFileAtVersion( final Session session, final PentahoJcrConstants pentahoJcrConstants,
final IPathConversionHelper pathConversionHelper, final ILockHelper lockHelper, final Serializable fileId,
final Serializable versionId ) throws RepositoryException {
Node fileNode = session.getNodeByIdentifier( fileId.toString() );
Version version =
session.getWorkspace().getVersionManager().getVersionHistory( fileNode.getPath() ).getVersion( versionId
.toString() );
return nodeToFile( session, pentahoJcrConstants, pathConversionHelper, lockHelper, getNodeAtVersion(
pentahoJcrConstants, version ) );
}
代码示例来源:origin: pentaho/pentaho-platform
public static String getAbsolutePath( final Session session, final PentahoJcrConstants pentahoJcrConstants,
final Node node ) throws RepositoryException {
if ( node.isNodeType( pentahoJcrConstants.getNT_FROZENNODE() ) ) {
return JcrStringHelper.pathDecode( session.getNodeByIdentifier( node.getProperty( pentahoJcrConstants
.getJCR_FROZENUUID() ).getString() ).getPath() );
}
return JcrStringHelper.pathDecode( node.getPath() );
}
代码示例来源:origin: pentaho/pentaho-platform
public static RepositoryFileAcl createAcl( Session session, PentahoJcrConstants pentahoJcrConstants,
Serializable fileId, RepositoryFileAcl acl ) throws ItemNotFoundException, RepositoryException {
Node node = session.getNodeByIdentifier( fileId.toString() );
String absPath = node.getPath();
AccessControlManager acMgr = session.getAccessControlManager();
AccessControlList acList = getAccessControlList( acMgr, absPath );
acMgr.setPolicy( absPath, acList );
return internalUpdateAcl( session, pentahoJcrConstants, fileId, acl );
}
代码示例来源:origin: info.magnolia/magnolia-core
private Node doImport(Node source) throws RepositoryException {
try {
this.importNode(getVersionSessionFor(source).getRootNode(), source);
} catch (IOException ioe) {
throw new RepositoryException("Failed to import node in magnolia version store : " + ioe.getMessage(), ioe);
}
Node root = getVersionSessionFor(source).getNodeByIdentifier(source.getIdentifier());
// save parent node since this node is newly created
saveSessionWithoutPropertySessionWrapper(root.getSession());
return root;
}
代码示例来源:origin: pentaho/pentaho-platform
public Object doInJcr( final Session session ) throws RepositoryException, IOException {
PentahoJcrConstants pentahoJcrConstants = new PentahoJcrConstants( session );
Node node = session.getNodeByIdentifier( id.toString() );
if ( !node.getParent().isSame( session.getRootNode() ) ) {
return toAcl( session, pentahoJcrConstants, node.getParent().getIdentifier() );
} else {
return null;
}
}
} );
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void copyToNewVersionKeepTheLastModifiedBy() throws Exception {
// GIVEN
Node testNode = websiteSession.getRootNode().addNode("test", NodeTypes.Page.NAME);
NodeTypes.LastModified.update(testNode, "testName", Calendar.getInstance());
testNode.getSession().save();
// WHEN
copyUtil.copyToVersion(testNode, new RuleBasedNodePredicate(new Rule()));
// THEN
Node versionNode = versionSession.getNodeByIdentifier(testNode.getIdentifier());
assertEquals("testName", NodeTypes.LastModified.getLastModifiedBy(versionNode));
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void copyToVersionWithNewStructure() throws Exception {
// GIVEN
Node testNode = websiteSession.getRootNode().addNode("test", NodeTypes.Page.NAME);
// WHEN
copyUtil.copyToVersion(testNode, new RuleBasedNodePredicate(new Rule()));
// THEN
Node versionNode = versionSession.getNodeByIdentifier(testNode.getIdentifier());
assertThat(versionNode.getParent().getPath(), matchesRegex("/\\w{2}/\\w{2}/\\w{2}"));
assertThat(versionSession.getRootNode(), hasNode(CopyUtil.getSavePath(versionNode) + "/" + testNode.getIdentifier()));
}
内容来源于网络,如有侵权,请联系作者删除!