当前位置: 首页>>代码示例>>Java>>正文


Java Session.getRootNode方法代码示例

本文整理汇总了Java中javax.jcr.Session.getRootNode方法的典型用法代码示例。如果您正苦于以下问题:Java Session.getRootNode方法的具体用法?Java Session.getRootNode怎么用?Java Session.getRootNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.jcr.Session的用法示例。


在下文中一共展示了Session.getRootNode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import javax.jcr.Session; //导入方法依赖的package包/类
@Override
public void execute(final InstallContext installContext) throws TaskExecutionException {
    try {
        final Session session = MgnlContext.getJCRSession(NewsRepositoryConstants.COLLABORATION);

        final Node rootNode = session.getRootNode();
        final int numberOfMovedNodes = processNewsItems(installContext, rootNode, 0);

        if (numberOfMovedNodes > 0) {
            installContext.info("Nested news items were found and have been un-nested.");
            installContext.info("Note: If present, duplicate news items now have a name that ends with '-duplicate'.");
            installContext.info("Please check all news items and re-publish if needed.");
        }
    } catch (RepositoryException e) {
        throw new TaskExecutionException("Error while un-nesting event nodes", e);
    }
}
 
开发者ID:tricode,项目名称:magnolia-news,代码行数:18,代码来源:FindAndMoveNestedNewsTask.java

示例2: getJcrFromFixture

import javax.jcr.Session; //导入方法依赖的package包/类
public Session getJcrFromFixture(InputStream fixture) {
    Repository repository = null;
    Session session = null;
    try {
        repository = MockJcr.newRepository();
        session = repository.login();
        Node rootNode = session.getRootNode();

        Yaml parser = new Yaml();
        List<Map<String, Object>> nodes = (ArrayList<Map<String, Object>>) parser.load(fixture);

        for (Map object: nodes) {
            NodeYaml node = new NodeYaml(
                (String) object.get("path"),
                (String) object.get("primaryType"),
                (Map<String, Object>) object.getOrDefault("properties", emptyMap())
            );
            Node n = rootNode.addNode(node.path, node.primaryType);
            for (Map.Entry<String, Object> entry : node.properties.entrySet()) {
                if (entry.getValue() instanceof Boolean) {
                    n.setProperty(entry.getKey(), (Boolean) entry.getValue());
                } else {
                    n.setProperty(entry.getKey(), entry.getValue().toString());
                }
            }
        }

        session.save();
    } catch (RepositoryException e) {
        throw new RuntimeException("Failed to set property on JCR node", e);
    }

    return session;
}
 
开发者ID:NHS-digital-website,项目名称:hippo,代码行数:35,代码来源:JcrProvider.java

示例3: initialise

import javax.jcr.Session; //导入方法依赖的package包/类
public void initialise(Session session) throws LoginException, RepositoryException {
	final NamespaceRegistry registry = session.getWorkspace().getNamespaceRegistry();
	
	if (!Arrays.asList(registry.getPrefixes()).contains("ocm")) {
		session.getWorkspace().getNamespaceRegistry().registerNamespace("ocm", "http://jackrabbit.apache.org/ocm");
	}
	
	Node rootNode = session.getRootNode();
	for( String nodeName : this.mainNodes){
		if(!rootNode.hasNode(nodeName)){
			rootNode.addNode(nodeName);
		}
	}
	session.save();
}
 
开发者ID:cheetah100,项目名称:gravity,代码行数:16,代码来源:OcmMapperFactory.java

示例4: testJcrConsumer

import javax.jcr.Session; //导入方法依赖的package包/类
@Test
public void testJcrConsumer() throws Exception {
    // start consumer thread first
    JcrConsumerThread consumerThread = new JcrConsumerThread();
    consumerThread.start();
    // wait until the consumer thread has tried to receive event at least once
    while (consumerThread.getReceiveTrialTimes() < 1) {
        Thread.sleep(10L);
    }

    // now create a node under the specified event node path

    Session session = openSession();

    try {
        Node folderNode = session.getRootNode();

        for (String folderNodeName : absPath.split("\\/")) {
            if (!"".equals(folderNodeName)) {
                if (folderNode.hasNode(folderNodeName)) {
                    folderNode.getNode(folderNodeName).remove();
                }

                folderNode = folderNode.addNode(folderNodeName, "nt:unstructured");
            }
        }

        folderNode.addNode("node", "nt:unstructured");
        session.save();
    } finally {
        if (session != null && session.isLive()) {
            session.logout();
        }
    }

    // wait until the consumer thread captures an event
    consumerThread.join();

    Exchange exchange = consumerThread.getExchange();
    assertNotNull(exchange);

    Message message = exchange.getIn();
    assertNotNull(message);
    assertTrue(message instanceof JcrMessage);
    EventIterator eventIterator = ((JcrMessage)message).getEventIterator();
    assertNotNull(eventIterator);
    assertEquals(1, eventIterator.getSize());

    List<?> eventList = message.getBody(List.class);
    assertEquals(1, eventList.size());
    Event event = (Event) eventList.get(0);
    assertEquals(Event.NODE_ADDED, event.getType());
    assertNotNull(event.getPath());
    assertTrue(event.getPath().startsWith(absPath));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:56,代码来源:JcrConsumerTest.java


注:本文中的javax.jcr.Session.getRootNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。