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


Java Workspace类代码示例

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


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

示例1: addListeners

import javax.jcr.Workspace; //导入依赖的package包/类
/**
 * Hook for adding listeners to the newly returned session. We have to treat exceptions manually and can't
 * reply on the template.
 * @param session JCR session
 * @return the listened session
 * @throws javax.jcr.RepositoryException
 */
private Session addListeners(Session session) throws RepositoryException {
    if (getRepository() == null) {
        throw new IllegalArgumentException("repository is required");
    }

    if (eventListeners != null && eventListeners.length > 0) {
        if (!supportsObservation(getRepository())) {
            throw new IllegalArgumentException("repository " + getRepositoryInfo() + " does NOT support Observation; remove Listener definitions");
        }
        Workspace ws = session.getWorkspace();
        ObservationManager manager = ws.getObservationManager();

        for (EventListenerDefinition eventListener : eventListeners) {
            manager.addEventListener(eventListener.getListener(), eventListener.getEventTypes(), eventListener.getAbsPath(), eventListener.isDeep(), eventListener.getUuid(), eventListener.getNodeTypeName(), eventListener.isNoLocal());
        }
    }
    return session;
}
 
开发者ID:dooApp,项目名称:jcromfx,代码行数:26,代码来源:SessionFactoryImpl.java

示例2: testJcrProducer

import javax.jcr.Workspace; //导入依赖的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

示例3: registerNodeTypes

import javax.jcr.Workspace; //导入依赖的package包/类
@Override
protected void registerNodeTypes() throws Exception {
    if (!ObjectUtils.isEmpty(nodeDefinitions)) {

        Session session = getBareSession();
        Workspace ws = session.getWorkspace();

        NodeTypeManagerImpl jackrabbitNodeTypeManager = (NodeTypeManagerImpl) ws.getNodeTypeManager();

        boolean debug = LOG.isDebugEnabled();
        for (int i = 0; i < nodeDefinitions.length; i++) {
            Resource resource = nodeDefinitions[i];
            if (debug) {
                LOG.debug("adding node type definitions from " + resource.getDescription());
            }
            try {
                //                    ws.getNodeTypeManager().registerNodeType(ntd, allowUpdate)
                jackrabbitNodeTypeManager.registerNodeTypes(resource.getInputStream(), contentType);
            } catch (RepositoryException ex) {
                LOG.error("Error registering nodetypes ", ex.getCause());
            }
        }
        session.logout();
    }
}
 
开发者ID:MyCollab,项目名称:mycollab,代码行数:26,代码来源:JackrabbitSessionFactory.java

示例4: addListeners

import javax.jcr.Workspace; //导入依赖的package包/类
/**
 * Hook for adding listeners to the newly returned session. We have to treat
 * exceptions manually and can't reply on the template.
 * 
 * @param session
 *            JCR session
 * @return the listened session
 * @throws javax.jcr.RepositoryException
 */
protected Session addListeners(Session session) throws RepositoryException {
	if (eventListeners != null && eventListeners.length > 0) {
		Workspace ws = session.getWorkspace();
		ObservationManager manager = ws.getObservationManager();

		LOG.debug("adding listeners "
				+ Arrays.asList(eventListeners).toString()
				+ " for session " + session);

		for (int i = 0; i < eventListeners.length; i++) {
			manager.addEventListener(eventListeners[i].getListener(),
					eventListeners[i].getEventTypes(),
					eventListeners[i].getAbsPath(),
					eventListeners[i].isDeep(),
					eventListeners[i].getUuid(),
					eventListeners[i].getNodeTypeName(),
					eventListeners[i].isNoLocal());
		}
	}
	return session;
}
 
开发者ID:MyCollab,项目名称:mycollab,代码行数:31,代码来源:JcrSessionFactory.java

示例5: removeVersion

import javax.jcr.Workspace; //导入依赖的package包/类
@Override
public void removeVersion(final FedoraSession session, final String absPath, final String label) {
    final Session jcrSession = getJcrSession(session);
    final Workspace workspace = jcrSession.getWorkspace();
    try {
        final Version v = getVersionForLabel(workspace, absPath, label);
        if (v == null) {
            throw new PathNotFoundException("Unknown version \"" + label + "\"!");
        } else if (workspace.getVersionManager().getBaseVersion(absPath).equals(v) ) {
            throw new VersionException("Cannot remove most recent version snapshot.");
        } else {
            // remove labels
            final VersionHistory history = v.getContainingHistory();
            final String[] versionLabels = history.getVersionLabels(v);
            for ( final String versionLabel : versionLabels ) {
                LOGGER.debug("Removing label: {}", versionLabel);
                history.removeVersionLabel( versionLabel );
            }
            history.removeVersion( v.getName() );
        }
    } catch (final RepositoryException e) {
        throw new RepositoryRuntimeException(e);
    }
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:25,代码来源:VersionServiceImpl.java

示例6: checkpoint

import javax.jcr.Workspace; //导入依赖的package包/类
private static String checkpoint(final Session session, final String absPath, final String label)
        throws RepositoryException {
    if (!validLabel(label)) {
        throw new VersionException("Invalid label: " + label);
    }

    LOGGER.trace("Setting version checkpoint for {}", absPath);
    final Workspace workspace = session.getWorkspace();
    final VersionManager versionManager = workspace.getVersionManager();
    final VersionHistory versionHistory = versionManager.getVersionHistory(absPath);
    if (versionHistory.hasVersionLabel(label)) {
        throw new LabelExistsVersionException("The specified label \"" + label
                + "\" is already assigned to another version of this resource!");
    }
    final Version v = versionManager.checkpoint(absPath);
    if (v == null) {
        return null;
    }
    versionHistory.addVersionLabel(v.getName(), label, false);
    return v.getFrozenNode().getIdentifier();
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:22,代码来源:VersionServiceImpl.java

示例7: testGetBaseVersion

import javax.jcr.Workspace; //导入依赖的package包/类
@Test
public void testGetBaseVersion() throws RepositoryException {

    final Version mockVersion = mock(Version.class);
    when(mockVersion.getName()).thenReturn("uuid");
    final Workspace mockWorkspace = mock(Workspace.class);
    when(mockSession.getWorkspace()).thenReturn(mockWorkspace);
    final VersionManager mockVersionManager = mock(VersionManager.class);
    when(mockWorkspace.getVersionManager()).thenReturn(mockVersionManager);

    when(mockVersionManager.getBaseVersion(anyString())).thenReturn(
            mockVersion);

    testObj.getBaseVersion();

    verify(mockVersionManager).getBaseVersion(anyString());
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:18,代码来源:FedoraResourceImplTest.java

示例8: testGetVersionLabels

import javax.jcr.Workspace; //导入依赖的package包/类
@Test
public void testGetVersionLabels() throws RepositoryException {
    when(mockNode.isNodeType(FROZEN_NODE)).thenReturn(true);
    final VersionHistory mockVersionHistory = mock(VersionHistory.class);
    final Version mockVersion = mock(Version.class);
    when(mockVersion.getName()).thenReturn("uuid");
    final Workspace mockWorkspace = mock(Workspace.class);
    when(mockSession.getWorkspace()).thenReturn(mockWorkspace);
    final VersionManager mockVersionManager = mock(VersionManager.class);
    when(mockWorkspace.getVersionManager()).thenReturn(mockVersionManager);
    final VersionIterator mockVersionIterator = mock(VersionIterator.class);
    when(mockVersionHistory.getAllVersions()).thenReturn(mockVersionIterator);
    when(mockVersionIterator.hasNext()).thenReturn(false);

    when(mockVersionManager.getVersionHistory(anyString())).thenReturn(
            mockVersionHistory);

    testObj.getVersions();

    verify(mockVersionManager).getVersionHistory(anyString());
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:22,代码来源:FedoraResourceImplTest.java

示例9: getSessionMock

import javax.jcr.Workspace; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static Session getSessionMock() throws RepositoryException {
    final String[] mockPrefixes = {MOCK_PREFIX};
    final Session mockSession = mock(Session.class);
    final Workspace mockWorkspace = mock(Workspace.class);
    final NamespaceRegistry mockNameReg = mock(NamespaceRegistry.class);
    final NodeTypeManager mockNTM = mock(NodeTypeManager.class);
    final NodeTypeIterator mockNTI = mock(NodeTypeIterator.class);
    final NodeType mockNodeType = mock(NodeType.class);
    when(mockSession.getWorkspace()).thenReturn(mockWorkspace);
    when(mockWorkspace.getNamespaceRegistry()).thenReturn(mockNameReg);
    when(mockNameReg.getPrefixes()).thenReturn(mockPrefixes);
    when(mockNameReg.getURI(MOCK_PREFIX)).thenReturn(MOCK_URI_STRING);
    when(mockWorkspace.getNodeTypeManager()).thenReturn(mockNTM);
    when(mockNodeType.getName()).thenReturn("mockName");
    when(mockNodeType.toString()).thenReturn("mockString");
    when(mockNTM.getAllNodeTypes()).thenReturn(mockNTI);
    when(mockNTI.hasNext()).thenReturn(true, false);
    when(mockNTI.nextNodeType()).thenReturn(mockNodeType).thenThrow(
            ArrayIndexOutOfBoundsException.class);
    return mockSession;
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:23,代码来源:TestHelpers.java

示例10: setAclManagementCallback

import javax.jcr.Workspace; //导入依赖的package包/类
/**
 * Create a {@linkplain JcrCallback} for setting up ACL management in test repository
 * 
 * @return acl management callback
 */
static JcrCallback setAclManagementCallback() {
  return new JcrCallback() {
    @Override
    public Object doInJcr( Session session ) throws IOException, RepositoryException {
      PentahoJcrConstants pentahoJcrConstants = new PentahoJcrConstants( session );
      Workspace workspace = session.getWorkspace();
      PrivilegeManager privilegeManager = ( (JackrabbitWorkspace) workspace ).getPrivilegeManager();
      try {
        privilegeManager.getPrivilege( pentahoJcrConstants.getPHO_ACLMANAGEMENT_PRIVILEGE() );
      } catch ( AccessControlException ace ) {
        privilegeManager.registerPrivilege( pentahoJcrConstants.getPHO_ACLMANAGEMENT_PRIVILEGE(), false,
            new String[0] );
      }
      session.save();
      return null;
    }
  };
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:24,代码来源:PurRepositoryTestingUtils.java

示例11: setAclManagement

import javax.jcr.Workspace; //导入依赖的package包/类
private void setAclManagement() {
  testJcrTemplate.execute( new JcrCallback() {
    @Override
    public Object doInJcr( Session session ) throws IOException, RepositoryException {
      PentahoJcrConstants pentahoJcrConstants = new PentahoJcrConstants( session );
      Workspace workspace = session.getWorkspace();
      PrivilegeManager privilegeManager = ( (JackrabbitWorkspace) workspace ).getPrivilegeManager();
      try {
        privilegeManager.getPrivilege( pentahoJcrConstants.getPHO_ACLMANAGEMENT_PRIVILEGE() );
      } catch ( AccessControlException ace ) {
        privilegeManager.registerPrivilege( pentahoJcrConstants.getPHO_ACLMANAGEMENT_PRIVILEGE(), false,
            new String[0] );
      }
      session.save();
      return null;
    }
  } );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:19,代码来源:UIEERepositoryDirectoryIT.java

示例12: initialize

import javax.jcr.Workspace; //导入依赖的package包/类
static void initialize( Session session )
        throws RepositoryException
    {

        // TODO: consider using namespaces for facets instead of the current approach:
        // (if used, check if actually called by normal injection)
//        for ( String facetId : metadataFacetFactories.keySet() )
//        {
//            session.getWorkspace().getNamespaceRegistry().registerNamespace( facetId, facetId );
//        }
        Workspace workspace = session.getWorkspace();
        NamespaceRegistry registry = workspace.getNamespaceRegistry();

        if ( !Arrays.asList( registry.getPrefixes() ).contains( "archiva" ) )
        {
            registry.registerNamespace( "archiva", "http://archiva.apache.org/jcr/" );
        }

        NodeTypeManager nodeTypeManager = workspace.getNodeTypeManager();
        registerMixinNodeType( nodeTypeManager, JcrMetadataRepository.NAMESPACE_NODE_TYPE );
        registerMixinNodeType( nodeTypeManager, JcrMetadataRepository.PROJECT_NODE_TYPE );
        registerMixinNodeType( nodeTypeManager, JcrMetadataRepository.PROJECT_VERSION_NODE_TYPE );
        registerMixinNodeType( nodeTypeManager, JcrMetadataRepository.ARTIFACT_NODE_TYPE );
        registerMixinNodeType( nodeTypeManager, JcrMetadataRepository.FACET_NODE_TYPE );
        registerMixinNodeType( nodeTypeManager, JcrMetadataRepository.DEPENDENCY_NODE_TYPE );

    }
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:28,代码来源:JcrMetadataRepository.java

示例13: setUp

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

    File confFile = new File( "src/test/repository.xml" );
    File dir = new File( "target/jcr" );
    FileUtils.deleteDirectory( dir );

    assertTrue( confFile.exists() );
    assertFalse( dir.exists() );

    TransientRepository repository = new TransientRepository( confFile, dir );
    session = repository.login( new SimpleCredentials( "username", "password".toCharArray() ) );

    // TODO: perhaps have an archiva-jcr-utils module shared by these plugins that does this and can contain
    //      structure information
    Workspace workspace = session.getWorkspace();
    NamespaceRegistry registry = workspace.getNamespaceRegistry();
    registry.registerNamespace( "archiva", "http://archiva.apache.org/jcr/" );

    NodeTypeManager nodeTypeManager = workspace.getNodeTypeManager();
    registerMixinNodeType( nodeTypeManager, "archiva:namespace" );
    registerMixinNodeType( nodeTypeManager, "archiva:project" );
    registerMixinNodeType( nodeTypeManager, "archiva:projectVersion" );
    registerMixinNodeType( nodeTypeManager, "archiva:artifact" );
    registerMixinNodeType( nodeTypeManager, "archiva:facet" );

    metadataRepository = mock( MetadataRepository.class );
    when( metadataRepository.canObtainAccess( Session.class ) ).thenReturn( true );
    when( metadataRepository.obtainAccess( Session.class ) ).thenReturn( session );

    repositoryStatisticsManager = new DefaultRepositoryStatisticsManager();
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:37,代码来源:JcrRepositoryStatisticsGatheringTest.java

示例14: setUp

import javax.jcr.Workspace; //导入依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
    deleteDirectory(REPO_PATH);
    super.setUp();
    Session session = getRepository().login(new SimpleCredentials("user", "pass".toCharArray()));
    Workspace workspace = session.getWorkspace();
    workspace.createWorkspace(CUSTOM_WORKSPACE_NAME);
    session.save();
    session.logout();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:JcrRouteDifferentWorkspaceTestSupport.java

示例15: executeMockQuery

import javax.jcr.Workspace; //导入依赖的package包/类
private void executeMockQuery(String workspace, String expectedQuery, List<Node> results) throws Exception {
    Session mockSession = mock(Session.class);
    Workspace mockWorkspace = mock(Workspace.class);
    QueryManager mockQueryManager = mock(QueryManager.class);
    Query mockQuery = mock(Query.class);
    QueryResult mockQueryResult = mock(QueryResult.class);

    doReturn(mockSession).when(mockWebContext).getJCRSession(workspace);
    doReturn(mockWorkspace).when(mockSession).getWorkspace();
    doReturn(mockQueryManager).when(mockWorkspace).getQueryManager();

    doReturn(mockQuery).when(mockQueryManager).createQuery(expectedQuery, Query.JCR_SQL2);
    doReturn(mockQueryResult).when(mockQuery).execute();
    doReturn(new NodeIteratorAdapter(results)).when(mockQueryResult).getNodes();
}
 
开发者ID:tricode,项目名称:magnolia-blog,代码行数:16,代码来源:BlogRenderableDefinitionTest.java


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