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


Java Session.logout方法代码示例

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


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

示例1: testReadNode

import javax.jcr.Session; //导入方法依赖的package包/类
/** Create a node via Sling's http interface and verify that admin can
 *  read it via davex remote access.
 */
public void testReadNode() throws Exception {
    final String path = "/DavExNodeTest_1_" + System.currentTimeMillis();
    final String url = HTTP_BASE_URL + path;

    // add some properties to the node
    final Map<String, String> props = new HashMap<String, String>();
    props.put("name1", "value1");
    props.put("name2", "value2");

    testClient.createNode(url, props);

    // Oak does not support login without credentials, so to
    // verify that davex access works we do need valid repository credentials.
    final Credentials creds = new SimpleCredentials("admin", "admin".toCharArray());
    Session session = repository.login(creds);

    try {
        final Node node = session.getNode(path);
        assertNotNull(node);
        assertEquals("value1", node.getProperty("name1").getString());
        assertEquals("value2", node.getProperty("name2").getString());
    } finally {
        session.logout();
    }
}
 
开发者ID:apache,项目名称:sling-org-apache-sling-launchpad-integration-tests,代码行数:29,代码来源:DavExIntegrationTest.java

示例2: testJcrProducer

import javax.jcr.Session; //导入方法依赖的package包/类
@Test
public void testJcrProducer() throws Exception {
    Exchange exchange = createExchangeWithBody("<hello>world!</hello>");
    exchange.getIn().setHeader(JcrConstants.JCR_NODE_NAME, "node");
    exchange.getIn().setHeader("my.contents.property", exchange.getIn().getBody());
    Exchange out = template.send("direct:a", exchange);
    assertNotNull(out);
    String uuid = out.getOut().getBody(String.class);
    Session session = openSession();
    try {
        Node node = session.getNodeByIdentifier(uuid);
        assertNotNull(node);
        assertEquals("/home/test/node", node.getPath());
        assertEquals("<hello>world!</hello>", node.getProperty("my.contents.property").getString());
    } finally {
        if (session != null && session.isLive()) {
            session.logout();
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:JcrProducerTest.java

示例3: testNodeTypeIsSpecified

import javax.jcr.Session; //导入方法依赖的package包/类
@Test
public void testNodeTypeIsSpecified() throws Exception {
    Exchange exchange = createExchangeWithBody("Test");
    exchange.getIn().removeHeader("testClass"); //there is no definition of such property in nt:resource
    exchange.getIn().setHeader(JcrConstants.JCR_NODE_NAME, "typedNode");
    exchange.getIn().setHeader(JcrConstants.JCR_NODE_TYPE, "nt:folder");
    Exchange out = template.send("direct:a", exchange);
    assertNotNull(out);
    String uuid = out.getOut().getBody(String.class);
    Session session = openSession();
    try {
        Node node = session.getNodeByIdentifier(uuid);
        assertNotNull(node);
        assertEquals("/home/test/typedNode", node.getPath());
        assertEquals("nt:folder", node.getPrimaryNodeType().getName());
    } finally {
        if (session != null && session.isLive()) {
            session.logout();
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:JcrProducerTest.java

示例4: testCreateNodeWithAuthentication

import javax.jcr.Session; //导入方法依赖的package包/类
@Test
public void testCreateNodeWithAuthentication() throws Exception {
    Exchange exchange = createExchangeWithBody("<message>hello!</message>");
    Exchange out = template.send("direct:a", exchange);
    assertNotNull(out);
    String uuid = out.getOut().getBody(String.class);
    assertNotNull("Out body was null; expected JCR node UUID", uuid);
    Session session = getRepository().login(
            new SimpleCredentials("admin", "admin".toCharArray()));
    try {
        Node node = session.getNodeByIdentifier(uuid);
        assertNotNull(node);
        assertEquals(BASE_REPO_PATH + "/node", node.getPath());
    } finally {
        if (session != null && session.isLive()) {
            session.logout();
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:JcrAuthLoginTest.java

示例5: testJcrNodePathCreation

import javax.jcr.Session; //导入方法依赖的package包/类
@Test
public void testJcrNodePathCreation() throws Exception {
    Exchange exchange = createExchangeWithBody("<body/>");
    Exchange out = template.send("direct:a", exchange);
    assertNotNull(out);
    String uuid = out.getOut().getBody(String.class);
    assertNotNull("Out body was null; expected JCR node UUID", uuid);
    Session session = openSession();
    try {
        Node node = session.getNodeByIdentifier(uuid);
        assertNotNull(node);
        assertEquals("/home/test/node/with/path", node.getPath());
    } finally {
        if (session != null && session.isLive()) {
            session.logout();
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:JcrNodePathCreationTest.java

示例6: testJcrNodePathCreationMultiValued

import javax.jcr.Session; //导入方法依赖的package包/类
@Test
public void testJcrNodePathCreationMultiValued() throws Exception {
    Exchange exchange = createExchangeWithBody(multiValued);
    Exchange out = template.send("direct:a", exchange);
    assertNotNull(out);
    String uuid = out.getOut().getBody(String.class);
    assertNotNull("Out body was null; expected JCR node UUID", uuid);
    Session session = openSession();
    try {
        Node node = session.getNodeByIdentifier(uuid);
        assertNotNull(node);
        assertEquals("/home/test/node/with/path", node.getPath());
        assertTrue(node.getProperty("my.contents.property").isMultiple());
        assertArrayEquals(multiValued, node.getProperty("my.contents.property").getValues());
    } finally {
        if (session != null && session.isLive()) {
            session.logout();
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:JcrNodePathCreationTest.java

示例7: testJcrProducer

import javax.jcr.Session; //导入方法依赖的package包/类
@Test
public void testJcrProducer() throws Exception {
    Exchange exchange = createExchangeWithBody("<hello>world!</hello>");
    Exchange out = template.send("direct:a", exchange);
    assertNotNull(out);
    String uuid = out.getOut().getBody(String.class);
    Session session = openSession(CUSTOM_WORKSPACE_NAME);
    try {
        Node node = session.getNodeByIdentifier(uuid);
        Workspace workspace = session.getWorkspace();
        assertEquals(CUSTOM_WORKSPACE_NAME, workspace.getName());
        assertNotNull(node);
        assertEquals("/home/test/node", node.getPath());
        assertEquals("<hello>world!</hello>", node.getProperty("my.contents.property").getString());
    } finally {
        if (session != null && session.isLive()) {
            session.logout();
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:JcrProducerDifferentWorkspaceTest.java

示例8: setUp

import javax.jcr.Session; //导入方法依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
    super.setUp();

    Session session = openSession();
    Node node = session.getRootNode().addNode("home").addNode("test");
    node.setProperty("content.approved", APPROVED);
    node.setProperty("my.contents.property", CONTENT);
    
    
    ValueFactory valFact = session.getValueFactory();
    Value[] vals = new Value[] {valFact.createValue("value-1"), valFact.createValue("value-2")};
    node.setProperty("my.multi.valued", vals);
    
    identifier = node.getIdentifier();

    session.save();
    session.logout();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:JcrGetNodeByIdTest.java

示例9: get

import javax.jcr.Session; //导入方法依赖的package包/类
private byte[] get(final String path) throws LoginException, RepositoryException, IOException {
	byte[] ret = null;
	Session session = null;
	try {
		session = repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
		Binary b = session.getRootNode().getProperty(path).getBinary();
		ret = IOUtils.toByteArray(b.getStream());
		b.dispose();
	} catch (Exception e) {
		e.printStackTrace();
	} finally {
		if (session != null) {
			session.logout();
		}
	}
	return ret;
}
 
开发者ID:justcoke,项目名称:dropwizard-jcr-module,代码行数:18,代码来源:JcrDAO.java

示例10: examinePhase

import javax.jcr.Session; //导入方法依赖的package包/类
@PreAuthorize("hasPermission(#boardId, 'BOARD', 'WRITE,ADMIN')")
@RequestMapping(value = "/{phaseId}/examine", method=RequestMethod.GET)
public @ResponseBody Boolean examinePhase(@PathVariable String boardId, 
									  		@PathVariable String phaseId) throws Exception {
	
	Session session = ocmFactory.getOcm().getSession();
	try {
		Map<String,String> result = listTools.list(String.format(URI.CARDS_URI, boardId, phaseId, ""), "id", session);
		for( Entry<String,String> entry : result.entrySet()){
			CardHolder cardHolder = new CardHolder();
			cardHolder.setBoardId(boardId);
			cardHolder.setCardId(entry.getKey());
			cardListener.addCardHolder(cardHolder);
			Thread.sleep(3500);
		}
	} finally {
		session.logout();
	}
	return true;
}
 
开发者ID:cheetah100,项目名称:gravity,代码行数:21,代码来源:PhaseController.java

示例11: curePhase

import javax.jcr.Session; //导入方法依赖的package包/类
/**
 * The purpose of this method is to check for some conditions which may break Phases.
 * 
 * @param boardId
 * @param phaseId
 * @return
 * @throws Exception
 */
@PreAuthorize("hasPermission(#boardId, 'BOARD', 'ADMIN')")
@RequestMapping(value = "/{phaseId}/cure", method=RequestMethod.GET)
public @ResponseBody Boolean curePhase(@PathVariable String boardId, 
									  		@PathVariable String phaseId) throws Exception {
	
	Session session = ocmFactory.getOcm().getSession();

	try{
		Node node = session.getNode(String.format(URI.PHASES_URI, boardId, phaseId));
		Property property = node.getProperty("cards");
		// If there is a property we need to kill it.
		property.remove();
		session.save();
	} catch (PathNotFoundException e){
		// This is expected - there should be no property.
	} finally {
		session.logout();	
	}
	
	this.cacheInvalidationManager.invalidate(BoardController.BOARD, boardId);
	
	return true;
}
 
开发者ID:cheetah100,项目名称:gravity,代码行数:32,代码来源:PhaseController.java

示例12: pathExists

import javax.jcr.Session; //导入方法依赖的package包/类
@Test
public void pathExists() throws RepositoryException {
    final SlingRepository repo = teleporter.getService(SlingRepository.class);
    final Session s = repo.loginAdministrative(null);
    try {
        assertTrue(s.nodeExists("/repoinit/provisioningModelTest"));
    } finally { 
        s.logout();
    }
}
 
开发者ID:apache,项目名称:sling-org-apache-sling-launchpad-integration-tests,代码行数:11,代码来源:RepoinitPathTest.java

示例13: assertSystemUser

import javax.jcr.Session; //导入方法依赖的package包/类
private void assertSystemUser(String name) throws RepositoryException {
    final SlingRepository repo = teleporter.getService(SlingRepository.class);
    final Session s = repo.loginAdministrative(null);
    try {
        final Credentials creds = new SimpleCredentials(name, new char[] {});
        try {
            s.impersonate(creds);
        } catch(RepositoryException rex) {
            fail("Impersonation as " + name + " failed: " + rex.toString());
        }
    } finally { 
        s.logout();
    }
}
 
开发者ID:apache,项目名称:sling-org-apache-sling-launchpad-integration-tests,代码行数:15,代码来源:SystemUsersTest.java

示例14: pathExists

import javax.jcr.Session; //导入方法依赖的package包/类
private boolean pathExists(String path){
    boolean nodeExists = false;
    try {
        Session session = newSession();
        nodeExists = session.nodeExists(path);
        session.logout();
    } catch (RepositoryException e) {
        log.warn("Error occurred while accessing repository", e);
    }
    return nodeExists;
}
 
开发者ID:bdelacretaz,项目名称:sling-adaptto-2016,代码行数:12,代码来源:RenditionJobConsumer.java

示例15: process

import javax.jcr.Session; //导入方法依赖的package包/类
private void process(HttpServletRequest request) throws RepositoryException, IOException {
    String imagePath = request.getParameter("path");
    //TODO Use service user
    Session session = repository.loginAdministrative(null);
    RenditionGenerator generator = new RenditionGenerator(session, imagePath);
    try{
        generator.generate();
    } finally {
        IOUtils.closeQuietly(generator);
        session.logout();
    }
}
 
开发者ID:bdelacretaz,项目名称:sling-adaptto-2016,代码行数:13,代码来源:RenditionGeneratorServlet.java


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