本文整理了Java中javax.jcr.Node.getNode()
方法的一些代码示例,展示了Node.getNode()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.getNode()
方法的具体详情如下:
包路径:javax.jcr.Node
类名称:Node
方法名:getNode
[英]Returns the node at relPath
relative to this node.
If relPath
contains a path element that refers to a node with same-name sibling nodes without explicitly including an index using the array-style notation ([x]
), then the index [1] is assumed (indexing of same name siblings begins at 1, not 0, in order to preserve compatibility with XPath).
Within the scope of a single Session
object, if a Node
object has been acquired, any subsequent call of getNode
reacquiring the same node must return a Node
object reflecting the same state as the earlier Node
object. Whether this object is actually the same Node
instance, or simply one wrapping the same state, is up to the implementation.
[中]返回相对于此节点位于relPath
的节点。
如果relPath
包含一个path元素,该元素引用具有同名同级节点的节点,而没有使用数组样式表示法([x]
显式包含索引,则假定索引[1](同名同级节点的索引从1开始,而不是从0开始,以保持与XPath的兼容性)。
在单个Session
对象的范围内,如果已获取Node
对象,则任何后续调用getNode
重新获取同一节点时,都必须返回一个Node
对象,该对象反映的状态与之前的Node
对象相同。这个对象实际上是同一个Node
实例,还是仅仅是一个包装相同状态的实例,取决于实现。
代码示例来源:origin: exoplatform/platform
private Node getUserSettingHome(Session session) throws Exception {
Node settingNode = session.getRootNode().getNode(AbstractService.SETTING_NODE);
Node userHomeNode = null;
if (settingNode.hasNode(AbstractService.SETTING_USER_NODE) == false) {
userHomeNode = settingNode.addNode(AbstractService.SETTING_USER_NODE, AbstractService.STG_SUBCONTEXT);
session.save();
} else {
userHomeNode = settingNode.getNode(AbstractService.SETTING_USER_NODE);
}
return userHomeNode;
}
代码示例来源:origin: info.magnolia/magnolia-core
/**
* Get the Magnolia system node created under the given node.
*
* @throws RepositoryException if failed to create system node
*/
protected synchronized Node getSystemNode(Node node) throws RepositoryException {
if (node.hasNode(SYSTEM_NODE)) {
return node.getNode(SYSTEM_NODE);
}
return node.addNode(SYSTEM_NODE, NodeTypes.System.NAME);
}
}
代码示例来源:origin: org.onehippo.cms7/hippo-repository-deprecated-updater-module
@Override
protected void leaving(Node node, int level) throws RepositoryException {
if (node.hasNode("cms-pickers")) {
log.info("Removing the cms-pickers node from " + node.getPath());
node.getNode("cms-pickers").remove();
}
}
});
代码示例来源:origin: org.onehippo.cms7/hippo-repository-workflow
public void delete(String name) throws WorkflowException, MappingException, RepositoryException, RemoteException {
if (name.startsWith("/")) {
name = name.substring(1);
}
String path = subject.getPath().substring(1);
Node folder = (path.equals("") ? rootSession.getRootNode() : rootSession.getRootNode().getNode(path));
if (folder.hasNode(name)) {
Node offspring = folder.getNode(name);
delete(folder, offspring);
}
}
代码示例来源:origin: info.magnolia/magnolia-4-5-migration
/**
* Creating the logo and search area within the branding area.
*/
private void createLogoAndSearchInBranding(Node templateNode) throws RepositoryException {
if(templateNode.hasNode("areas") && templateNode.getNode("areas").hasNode("branding")) {
Node bandingNode = templateNode.getNode("areas").getNode("branding");
Node brandingAreasNode = MigrationUtil.getOrCreateNode(bandingNode, "areas", MgnlNodeType.NT_CONTENTNODE);
reportDebug("Adding areas logo and search to branding area " + brandingAreasNode.getPath());
MigrationUtil.createArea(brandingAreasNode, "logo", "/templating-kit/pages/global/logo.ftl", getPersistentMapService().getCustomMap(PersistentMapConstant.AREA_TYPE_FOR_STK).get("logo"), true, null, null, null, null, null);
MigrationUtil.createArea(brandingAreasNode, "search", "/templating-kit/pages/global/search.ftl", getPersistentMapService().getCustomMap(PersistentMapConstant.AREA_TYPE_FOR_STK).get("search"), true, null, null, null, null, null);
}
}
代码示例来源:origin: org.onehippo.cms7/hippo-repository-workflow
public RepositoryWorkflowImpl(Session userSession, Session rootSession, Node subject) throws RemoteException, RepositoryException {
this.session = rootSession;
if(subject.getDepth() == 0)
this.subject = rootSession.getRootNode();
else
this.subject = rootSession.getRootNode().getNode(subject.getPath().substring(1));
}
代码示例来源:origin: apache/jackrabbit
protected void setUp() throws Exception {
super.setUp();
nodeToMerge = testRootNodeW2.getNode(nodeName1);
// node has to be checked out while merging
VersionManager versionManager = nodeToMerge.getSession().getWorkspace().getVersionManager();
versionManager.checkout(nodeToMerge.getPath());
}
代码示例来源:origin: apache/jackrabbit-oak
private void addIgnoredChild(@NotNull Node node) throws Exception {
AccessControlManager acMgr = superuser.getAccessControlManager();
JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, node.getPath());
acl.addAccessControlEntry(EveryonePrincipal.getInstance(), AccessControlUtils.privilegesFromNames(acMgr, Privilege.JCR_READ));
acMgr.setPolicy(acl.getPath(), acl);
superuser.save();
Node c = node.getNode(AccessControlConstants.REP_POLICY);
assertEquals(OnParentVersionAction.IGNORE, c.getDefinition().getOnParentVersion());
}
代码示例来源:origin: apache/jackrabbit
public void testNodeAdded() throws RepositoryException {
Event[] events = getEvents(new Callable(){
public void call() throws RepositoryException {
testRootNode.addNode(nodeName1, testNodeType);
testRootNode.getSession().save();
}
}, Event.NODE_ADDED);
Node n = testRootNode.getNode(nodeName1);
assertEquals(n.getIdentifier(), getEventByPath(events, n.getPath()).getIdentifier());
}
代码示例来源:origin: apache/jackrabbit-oak
@Override
public void afterTest() throws RepositoryException {
session.getRootNode().getNode(ROOT_NODE_NAME).remove();
session.save();
}
}
代码示例来源:origin: info.magnolia/magnolia-core
@Override
protected Node doExec(Node context, ErrorHandler errorHandler) throws RepositoryException {
return (context.hasNode(name)) ? context.getNode(name) : context.addNode(name, nodeType);
}
};
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void getSiblings() throws RepositoryException {
for (String name : asList(SIBLING, SIBLINGS)) {
assertTrue(sns.hasNode(name));
Node sib = sns.getNode(name);
session.getNode(sns.getPath() + '/' + name);
}
}
代码示例来源:origin: org.onehippo.cms7/hippo-repository-workflow
public void delete(Document document) throws WorkflowException, MappingException, RepositoryException, RemoteException {
String path = subject.getPath().substring(1);
Node folderNode = (path.equals("") ? rootSession.getRootNode() : rootSession.getRootNode().getNode(path));
Node documentNode = document.getNode(rootSession);
if (documentNode.getPath().startsWith(folderNode.getPath()+"/")) {
delete(folderNode, documentNode);
}
}
代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons
private void setFolderTitle(Node child, String title) throws RepositoryException{
if (!child.getPath().equals(jcrBasePath)) {
if(child.hasNode(JcrConstants.JCR_CONTENT)){
child.getNode(JcrConstants.JCR_CONTENT).setProperty(JcrConstants.JCR_TITLE, title);
}else{
child.addNode(JcrConstants.JCR_CONTENT, JcrConstants.NT_UNSTRUCTURED).setProperty(JcrConstants.JCR_TITLE, title);
}
}
}
代码示例来源:origin: org.drools/guvnor-repository
/**
* Gets or creates a node.
*/
public static Node getNode(Node node, String name, String nodeType) throws RepositoryException {
Node permsNode;
if (!node.hasNode(name)) {
permsNode = node.addNode(name, nodeType);
} else {
permsNode = node.getNode(name);
}
return permsNode;
}
代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons
private void setFolderTitle(Node child, String title) throws RepositoryException {
if (child.hasNode(JcrConstants.JCR_CONTENT)) {
child.getNode(JcrConstants.JCR_CONTENT).setProperty(JcrConstants.JCR_TITLE, title);
} else {
child.addNode(JcrConstants.JCR_CONTENT, JcrConstants.NT_UNSTRUCTURED).setProperty(JcrConstants.JCR_TITLE, title);
}
}
代码示例来源:origin: apache/jackrabbit-oak
public static Node getOrAddNode(Node parent, String relPath) throws RepositoryException {
Node currentParent = parent;
for (final String name : PathUtils.elements(relPath)) {
if (!currentParent.hasNode(name)) {
currentParent.addNode(name, JcrConstants.NT_UNSTRUCTURED);
}
currentParent = currentParent.getNode(name);
}
return currentParent;
}
代码示例来源:origin: apache/jackrabbit-oak
@Override
public void afterSuite() throws RepositoryException {
session.getRootNode().getNode(testNodeName).remove();
session.save();
session.logout();
}
代码示例来源:origin: apache/jackrabbit-oak
@Override
protected void runTest() throws Exception {
final Session session = loginWriter(); // TODO: anonymous is slow
Node root = session.getRootNode().getNode(ROOT_NODE_NAME);
for (int i = 0; i < NODE_COUNT; i++) {
Node node = root.getNode("node" + i);
for (int j = 0; j < NODE_COUNT; j++) {
Node newNode = node.addNode("node" + j, "nt:unstructured");
session.save();
}
}
}
代码示例来源:origin: org.onehippo.cms7.essentials/hippo-essentials-plugin-api-implementation
public static Node createHippoNamespace(final Session session, final String prefix) throws RepositoryException {
if (StringUtils.isBlank(prefix)) {
throw new RepositoryException("Unable to create namespace for empty prefix");
}
final Node namespaces = session.getRootNode().getNode(HippoNodeType.NAMESPACES_PATH);
if (namespaces.hasNode(prefix)) {
log.info("Namespace '{}' already registered", prefix);
return namespaces.getNode(prefix);
}
return namespaces.addNode(prefix, HippoNodeType.NT_NAMESPACE);
}
内容来源于网络,如有侵权,请联系作者删除!