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


Java Workspace.getNodeTypeManager方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: initialize

import javax.jcr.Workspace; //导入方法依赖的package包/类
public 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:apache,项目名称:archiva,代码行数:29,代码来源:JcrMetadataRepository.java

示例5: createNodeTypes

import javax.jcr.Workspace; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void createNodeTypes() throws RepositoryException {
   	Session session = SessionFactoryUtils.getSession(getTemplate().getSessionFactory(), false);
   	Workspace workspace = session.getWorkspace();
   	
   	LOG.info("Registering namespace 'next' -> http://nextreports.ro/jcr/2.0");
       NamespaceRegistry namespaceRegistry = workspace.getNamespaceRegistry();
       namespaceRegistry.registerNamespace("next", "http://nextreports.ro/jcr/2.0");

   	/*
       // check if the node type is registered already
	if (nodeTypeManager.hasNodeType(NEXT_REPORT_MIXIN)) {
		return;
	}
	*/

   	LOG.info("Creating node type mixin '" + StorageConstants.NEXT_REPORT_MIXIN + "'");
   	NodeTypeManagerImpl nodeTypeManager = (NodeTypeManagerImpl) workspace.getNodeTypeManager();
   	NodeTypeTemplate nodeTypeTemplate = nodeTypeManager.createNodeTypeTemplate();
   	nodeTypeTemplate.setName(StorageConstants.NEXT_REPORT_MIXIN);
   	nodeTypeTemplate.setMixin(true);
   	nodeTypeTemplate.setOrderableChildNodes(false);
   	nodeTypeTemplate.setPrimaryItemName("nt:unstructured");
   	nodeTypeTemplate.setDeclaredSuperTypeNames(new String[] { "mix:referenceable", "mix:versionable" });

   	/*
   	PropertyDefinitionTemplate propertyDefinitionTemplate = nodeTypeManager.createPropertyDefinitionTemplate();
   	propertyDefinitionTemplate.setName("*");
   	propertyDefinitionTemplate.setRequiredType(PropertyType.UNDEFINED);
   	propertyDefinitionTemplate.setAutoCreated(false);
   	propertyDefinitionTemplate.setMandatory(false);
   	propertyDefinitionTemplate.setOnParentVersion(OnParentVersionAction.COPY);
   	propertyDefinitionTemplate.setProtected(false);
   	propertyDefinitionTemplate.setMultiple(false);

   	nodeTypeTemplate.getPropertyDefinitionTemplates().add(propertyDefinitionTemplate);
   	*/

   	NodeDefinitionTemplate nodeDefinitionTemplate = nodeTypeManager.createNodeDefinitionTemplate();
   	nodeDefinitionTemplate.setName("runHistory");
   	nodeDefinitionTemplate.setDefaultPrimaryTypeName("nt:unstructured");
   	nodeDefinitionTemplate.setRequiredPrimaryTypeNames(new String[] { "nt:unstructured" });
   	nodeDefinitionTemplate.setAutoCreated(true);
   	nodeDefinitionTemplate.setMandatory(false);
   	nodeDefinitionTemplate.setOnParentVersion(OnParentVersionAction.IGNORE);
   	nodeDefinitionTemplate.setProtected(false);
   	nodeDefinitionTemplate.setSameNameSiblings(false);

   	nodeTypeTemplate.getNodeDefinitionTemplates().add(nodeDefinitionTemplate);

   	LOG.info("Registering node type mixin '" + StorageConstants.NEXT_REPORT_MIXIN + "'");
   	nodeTypeManager.registerNodeType(nodeTypeTemplate, true);

   	getTemplate().save();
}
 
开发者ID:nextreports,项目名称:nextreports-server,代码行数:56,代码来源:StorageUpdate0.java

示例6: createNodeTemplates

import javax.jcr.Workspace; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
	private void createNodeTemplates() throws RepositoryException {
		Session session = SessionFactoryUtils.getSession(getTemplate().getSessionFactory(), false);
    	Workspace workspace = session.getWorkspace();
    	    	
    	NodeTypeManagerImpl nodeTypeManager = (NodeTypeManagerImpl) workspace.getNodeTypeManager();
//    	nodeTypeManager.unregisterNodeType(StorageConstants.NEXT_REPORT_MIXIN);
    	    	
    	NodeTypeTemplate nodeTypeTemplate = nodeTypeManager.createNodeTypeTemplate();
    	nodeTypeTemplate.setName(StorageConstants.NEXT_REPORT_MIXIN);
    	nodeTypeTemplate.setMixin(true);
    	nodeTypeTemplate.setOrderableChildNodes(false);
    	nodeTypeTemplate.setPrimaryItemName("nt:unstructured");
    	nodeTypeTemplate.setDeclaredSuperTypeNames(new String[] { "mix:referenceable", "mix:versionable" });   
    	
    	NodeDefinitionTemplate nodeDefinitionTemplate = nodeTypeManager.createNodeDefinitionTemplate();
    	nodeDefinitionTemplate.setName("runHistory");
    	nodeDefinitionTemplate.setDefaultPrimaryTypeName("nt:unstructured");
    	nodeDefinitionTemplate.setRequiredPrimaryTypeNames(new String[] { "nt:unstructured" });
    	nodeDefinitionTemplate.setAutoCreated(true);
    	nodeDefinitionTemplate.setMandatory(false);
    	nodeDefinitionTemplate.setOnParentVersion(OnParentVersionAction.IGNORE);
    	nodeDefinitionTemplate.setProtected(false);
    	nodeDefinitionTemplate.setSameNameSiblings(false);

    	nodeTypeTemplate.getNodeDefinitionTemplates().add(nodeDefinitionTemplate);
    	    	
    	NodeDefinitionTemplate nodeDefinitionTemplate2 = nodeTypeManager.createNodeDefinitionTemplate();
    	nodeDefinitionTemplate2.setName("templates");
    	nodeDefinitionTemplate2.setDefaultPrimaryTypeName("nt:unstructured");
    	nodeDefinitionTemplate2.setRequiredPrimaryTypeNames(new String[] { "nt:unstructured" });
    	nodeDefinitionTemplate2.setAutoCreated(true);
    	nodeDefinitionTemplate2.setMandatory(false);
    	nodeDefinitionTemplate2.setOnParentVersion(OnParentVersionAction.IGNORE);
    	nodeDefinitionTemplate2.setProtected(false);
    	nodeDefinitionTemplate2.setSameNameSiblings(false);
    	
    	nodeTypeTemplate.getNodeDefinitionTemplates().add(nodeDefinitionTemplate2);

    	LOG.info("Registering node type mixin '" + StorageConstants.NEXT_REPORT_MIXIN + "'");
    	nodeTypeManager.registerNodeType(nodeTypeTemplate, true);
    	
    	// add templates node to all existing reports
    	String statement = 
				"/jcr:root" + ISO9075.encodePath(StorageConstants.REPORTS_ROOT) + 
				"//*[@className='ro.nextreports.server.domain.Report']";
		  
		QueryResult queryResult = getTemplate().query(statement);
		NodeIterator nodes = queryResult.getNodes();
		
		LOG.info("Create templates nodes : Found " + nodes.getSize() + " report nodes");
		while (nodes.hasNext()) {			
			Node node = nodes.nextNode();
			node.addNode("templates");
		}					

    	getTemplate().save();
	}
 
开发者ID:nextreports,项目名称:nextreports-server,代码行数:59,代码来源:StorageUpdate13.java


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