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


Java NodeTypeManager.createNodeTypeTemplate方法代码示例

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


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

示例1: registerMixinNodeType

import javax.jcr.nodetype.NodeTypeManager; //导入方法依赖的package包/类
private static void registerMixinNodeType( NodeTypeManager nodeTypeManager, String name )
    throws RepositoryException
{
    NodeTypeTemplate nodeType = nodeTypeManager.createNodeTypeTemplate();
    nodeType.setMixin( true );
    nodeType.setName( name );

    // for now just don't re-create - but in future if we change the definition, make sure to remove first as an
    // upgrade path
    if ( !nodeTypeManager.hasNodeType( name ) )
    {
        nodeTypeManager.registerNodeType( nodeType, false );
    }
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:15,代码来源:JcrMetadataRepository.java

示例2: registerMixinNodeType

import javax.jcr.nodetype.NodeTypeManager; //导入方法依赖的package包/类
private static void registerMixinNodeType( NodeTypeManager nodeTypeManager, String type )
    throws RepositoryException
{
    NodeTypeTemplate nodeType = nodeTypeManager.createNodeTypeTemplate();
    nodeType.setMixin( true );
    nodeType.setName( type );
    nodeTypeManager.registerNodeType( nodeType, false );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:9,代码来源:JcrRepositoryStatisticsGatheringTest.java

示例3: createMyCollabFolderType

import javax.jcr.nodetype.NodeTypeManager; //导入方法依赖的package包/类
private NodeTypeTemplate createMyCollabFolderType(NodeTypeManager manager) throws RepositoryException {
    // Create content node type
    NodeTypeTemplate contentTypeTemplate = manager.createNodeTypeTemplate();

    contentTypeTemplate.setAbstract(false);
    contentTypeTemplate.setMixin(false);
    contentTypeTemplate.setName("mycollab:folder");
    contentTypeTemplate.setPrimaryItemName("folder");
    contentTypeTemplate.setDeclaredSuperTypeNames(new String[]{NodeType.NT_FOLDER});
    contentTypeTemplate.setQueryable(true);
    contentTypeTemplate.setOrderableChildNodes(false);

    PropertyDefinitionTemplate createdPropertyTemplate = manager
            .createPropertyDefinitionTemplate();
    createdPropertyTemplate.setMultiple(false);
    createdPropertyTemplate.setName("mycollab:createdUser");
    createdPropertyTemplate.setMandatory(true);
    createdPropertyTemplate.setRequiredType(PropertyType.STRING);
    contentTypeTemplate.getPropertyDefinitionTemplates().add(createdPropertyTemplate);

    PropertyDefinitionTemplate descPropertyTemplate = manager
            .createPropertyDefinitionTemplate();
    descPropertyTemplate.setMultiple(false);
    descPropertyTemplate.setName("jcr:description");
    descPropertyTemplate.setMandatory(false);
    descPropertyTemplate.setRequiredType(PropertyType.STRING);
    contentTypeTemplate.getPropertyDefinitionTemplates().add(descPropertyTemplate);

    return contentTypeTemplate;
}
 
开发者ID:MyCollab,项目名称:mycollab,代码行数:31,代码来源:ContentSessionFactory.java

示例4: createWikiFolderType

import javax.jcr.nodetype.NodeTypeManager; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private NodeTypeTemplate createWikiFolderType(NodeTypeManager manager) throws RepositoryException {
    // Create content node type
    NodeTypeTemplate folderTypeTemplate = manager.createNodeTypeTemplate();

    folderTypeTemplate.setAbstract(false);
    folderTypeTemplate.setMixin(false);
    folderTypeTemplate.setName("wiki:folder");
    folderTypeTemplate.setPrimaryItemName("folder");
    folderTypeTemplate.setDeclaredSuperTypeNames(new String[]{NodeType.NT_FOLDER});
    folderTypeTemplate.setQueryable(true);
    folderTypeTemplate.setOrderableChildNodes(false);

    PropertyDefinitionTemplate createdPropertyTemplate = manager.createPropertyDefinitionTemplate();
    createdPropertyTemplate.setMultiple(false);
    createdPropertyTemplate.setName("wiki:createdUser");
    createdPropertyTemplate.setMandatory(true);
    createdPropertyTemplate.setRequiredType(PropertyType.STRING);
    folderTypeTemplate.getPropertyDefinitionTemplates().add(createdPropertyTemplate);

    PropertyDefinitionTemplate namePropertyTemplate = manager.createPropertyDefinitionTemplate();
    namePropertyTemplate.setMultiple(false);
    namePropertyTemplate.setName("wiki:name");
    namePropertyTemplate.setMandatory(true);
    namePropertyTemplate.setRequiredType(PropertyType.STRING);
    folderTypeTemplate.getPropertyDefinitionTemplates().add(namePropertyTemplate);

    PropertyDefinitionTemplate descPropertyTemplate = manager.createPropertyDefinitionTemplate();
    descPropertyTemplate.setMultiple(false);
    descPropertyTemplate.setName("wiki:description");
    descPropertyTemplate.setMandatory(true);
    descPropertyTemplate.setRequiredType(PropertyType.STRING);
    folderTypeTemplate.getPropertyDefinitionTemplates().add(descPropertyTemplate);
    return folderTypeTemplate;
}
 
开发者ID:MyCollab,项目名称:mycollab,代码行数:36,代码来源:PageSessionFactory.java

示例5: onLoaded

import javax.jcr.nodetype.NodeTypeManager; //导入方法依赖的package包/类
@Override
public void onLoaded(AbstractResourceModelContext modelContext) {
    try {
        final Session session= this.sessionFactory.getInternalSession();
        /* make sure that the scape namespace is available in fcrepo */
        final Dataset namespace =
                this.repositoryService.getNamespaceRegistryDataset(session, new DefaultIdentifierTranslator());
        UpdateAction.parseExecute(
                "INSERT {<http://scapeproject.eu/model#> <" +
                        RdfLexicon.HAS_NAMESPACE_PREFIX + "> \"scape\"} WHERE {}",
                namespace);
        session.save();
        // Get the node type manager ...
        final NodeTypeManager mgr =
                session.getWorkspace().getNodeTypeManager();

        // Create templates for the node types ...
        final NodeTypeTemplate planType = mgr.createNodeTypeTemplate();
        planType.setName("scape:plan");
        planType.setDeclaredSuperTypeNames(new String[] {
                "fedora:resource", "fedora:object"});
        planType.setMixin(true);
        planType.setQueryable(true);
        planType.setAbstract(false);
        planType.getPropertyDefinitionTemplates().add(createMultiPropertyDefTemplate(session, mgr, "scape:hasExecState"));


        // and register them
        mgr.registerNodeTypes(new NodeTypeDefinition[] {planType}, true);

    } catch (RepositoryException e) {
        LOG.error("Error while setting up scape namespace", e);
        throw new RuntimeException("Unable to setup scape on fedora");
    }
}
 
开发者ID:openpreserve,项目名称:scape-fcrepo4-planmanagement,代码行数:36,代码来源:ScapeNamespaceInitializer.java

示例6: addMixin

import javax.jcr.nodetype.NodeTypeManager; //导入方法依赖的package包/类
/**
 * Add a mixin to a node
 * @param resource the fedora resource
 * @param mixinResource the mixin resource
 * @param namespaces the namespace
 * @throws RepositoryException if repository exception occurred
 */
public void addMixin(final FedoraResource resource,
                     final Resource mixinResource,
                     final Map<String,String> namespaces)
        throws RepositoryException {

    final Node node = getJcrNode(resource);
    final Session session = node.getSession();
    final String mixinName = getPropertyNameFromPredicate(node, mixinResource, namespaces);
    if (!repositoryHasType(session, mixinName)) {
        final NodeTypeManager mgr = session.getWorkspace().getNodeTypeManager();
        final NodeTypeTemplate type = mgr.createNodeTypeTemplate();
        type.setName(mixinName);
        type.setMixin(true);
        type.setQueryable(true);
        mgr.registerNodeType(type, false);
    }

    if (node.isNodeType(mixinName)) {
        LOGGER.trace("Subject {} is already a {}; skipping", node, mixinName);
        return;
    }

    if (node.canAddMixin(mixinName)) {
        LOGGER.debug("Adding mixin: {} to node: {}.", mixinName, node.getPath());
        node.addMixin(mixinName);
    } else {
        throw new MalformedRdfException("Could not persist triple containing type assertion: "
                + mixinResource.toString()
                + " because no such mixin/type can be added to this node: "
                + node.getPath() + "!");
    }
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:40,代码来源:JcrRdfTools.java

示例7: testRdfTypeInheritance

import javax.jcr.nodetype.NodeTypeManager; //导入方法依赖的package包/类
@Test
public void testRdfTypeInheritance() throws RepositoryException {
    final Session jcrSession = getJcrSession(session);
    final NodeTypeManager mgr = jcrSession.getWorkspace().getNodeTypeManager();
    //create supertype mixin
    final NodeTypeTemplate type1 = mgr.createNodeTypeTemplate();
    type1.setName("test:aSupertype");
    type1.setMixin(true);
    final NodeTypeDefinition[] nodeTypes = new NodeTypeDefinition[]{type1};
    mgr.registerNodeTypes(nodeTypes, true);

    //create a type inheriting above supertype
    final NodeTypeTemplate type2 = mgr.createNodeTypeTemplate();
    type2.setName("test:testInher");
    type2.setMixin(true);
    type2.setDeclaredSuperTypeNames(new String[]{"test:aSupertype"});
    final NodeTypeDefinition[] nodeTypes2 = new NodeTypeDefinition[]{type2};
    mgr.registerNodeTypes(nodeTypes2, true);

    //create object with inheriting type
    FedoraResource object = containerService.findOrCreate(session, "/testNTTnheritanceObject");
    final javax.jcr.Node node = getJcrNode(object);
    node.addMixin("test:testInher");

    session.commit();
    session.expire();
    session = repo.login();

    object = containerService.findOrCreate(session, "/testNTTnheritanceObject");

    //test that supertype has been inherited as rdf:type
    final Node s = createGraphSubjectNode(object);
    final Node p = type.asNode();
    final Node o = createProperty("info:fedora/test/aSupertype").asNode();
    assertTrue("supertype test:aSupertype not found inherited in test:testInher!",
            object.getTriples(subjects, PROPERTIES).collect(toModel()).getGraph().contains(s, p, o));
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:38,代码来源:FedoraResourceImplIT.java

示例8: createMyCollabContentType

import javax.jcr.nodetype.NodeTypeManager; //导入方法依赖的package包/类
private NodeTypeTemplate createMyCollabContentType(NodeTypeManager manager) throws RepositoryException {
    LOG.info("Register mycollab content type");
    NodeType hierachyNode = manager.getNodeType(NodeType.NT_HIERARCHY_NODE);
    // Create content node type
    NodeTypeTemplate contentTypeTemplate = manager.createNodeTypeTemplate(hierachyNode);

    contentTypeTemplate.setAbstract(false);
    contentTypeTemplate.setMixin(false);
    contentTypeTemplate.setName("mycollab:content");
    contentTypeTemplate.setPrimaryItemName("content");
    contentTypeTemplate.setDeclaredSuperTypeNames(new String[]{NodeType.NT_HIERARCHY_NODE});
    contentTypeTemplate.setQueryable(true);
    contentTypeTemplate.setOrderableChildNodes(false);

    PropertyDefinitionTemplate createdUserPropertyTemplate = manager
            .createPropertyDefinitionTemplate();
    createdUserPropertyTemplate.setMultiple(false);
    createdUserPropertyTemplate.setName("mycollab:createdUser");
    createdUserPropertyTemplate.setMandatory(true);
    createdUserPropertyTemplate.setRequiredType(PropertyType.STRING);
    contentTypeTemplate.getPropertyDefinitionTemplates().add(createdUserPropertyTemplate);

    PropertyDefinitionTemplate contentPathPropertyTemplate = manager.createPropertyDefinitionTemplate();
    contentPathPropertyTemplate.setMultiple(false);
    contentPathPropertyTemplate.setName("mycollab:contentPath");
    contentPathPropertyTemplate.setMandatory(false);
    contentPathPropertyTemplate.setRequiredType(PropertyType.STRING);
    contentTypeTemplate.getPropertyDefinitionTemplates().add(contentPathPropertyTemplate);

    PropertyDefinitionTemplate thumbnailPathPropertyTemplate = manager.createPropertyDefinitionTemplate();
    thumbnailPathPropertyTemplate.setMultiple(false);
    thumbnailPathPropertyTemplate.setName("mycollab:thumbnailPath");
    thumbnailPathPropertyTemplate.setMandatory(false);
    thumbnailPathPropertyTemplate.setRequiredType(PropertyType.STRING);
    contentTypeTemplate.getPropertyDefinitionTemplates().add(
            thumbnailPathPropertyTemplate);

    PropertyDefinitionTemplate lastModifiedUserPropertyTemplate = manager.createPropertyDefinitionTemplate();
    lastModifiedUserPropertyTemplate.setMultiple(false);
    lastModifiedUserPropertyTemplate.setName("mycollab:lastModifiedUser");
    lastModifiedUserPropertyTemplate.setMandatory(true);
    lastModifiedUserPropertyTemplate.setRequiredType(PropertyType.STRING);
    contentTypeTemplate.getPropertyDefinitionTemplates().add(lastModifiedUserPropertyTemplate);

    PropertyDefinitionTemplate mimeTypePropertyTemplate = manager
            .createPropertyDefinitionTemplate();
    mimeTypePropertyTemplate.setMultiple(false);
    mimeTypePropertyTemplate.setName("mycollab:mimeType");
    mimeTypePropertyTemplate.setMandatory(false);
    mimeTypePropertyTemplate.setRequiredType(PropertyType.STRING);
    contentTypeTemplate.getPropertyDefinitionTemplates().add(
            mimeTypePropertyTemplate);

    PropertyDefinitionTemplate sizePropertyTemplate = manager.createPropertyDefinitionTemplate();
    sizePropertyTemplate.setMultiple(false);
    sizePropertyTemplate.setName("mycollab:size");
    sizePropertyTemplate.setMandatory(true);
    sizePropertyTemplate.setRequiredType(PropertyType.LONG);
    contentTypeTemplate.getPropertyDefinitionTemplates().add(sizePropertyTemplate);

    return contentTypeTemplate;
}
 
开发者ID:MyCollab,项目名称:mycollab,代码行数:63,代码来源:ContentSessionFactory.java

示例9: createWikiPageType

import javax.jcr.nodetype.NodeTypeManager; //导入方法依赖的package包/类
private NodeTypeTemplate createWikiPageType(NodeTypeManager manager) throws RepositoryException {
    LOG.info("Register mycollab content type");
    NodeType hierachyNode = manager.getNodeType(NodeType.NT_HIERARCHY_NODE);
    // Create content node type
    NodeTypeTemplate pageTypeTemplate = manager.createNodeTypeTemplate(hierachyNode);

    pageTypeTemplate.setAbstract(false);
    pageTypeTemplate.setMixin(false);
    pageTypeTemplate.setName("wiki:page");
    pageTypeTemplate.setPrimaryItemName("page");
    pageTypeTemplate.setDeclaredSuperTypeNames(new String[]{NodeType.NT_HIERARCHY_NODE});
    pageTypeTemplate.setQueryable(true);
    pageTypeTemplate.setOrderableChildNodes(false);
    LOG.debug("PROPERTY {} {}",
            pageTypeTemplate.getDeclaredPropertyDefinitions().length,
            pageTypeTemplate.getDeclaredChildNodeDefinitions().length);

    PropertyDefinitionTemplate subjectPropertyTemplate = manager.createPropertyDefinitionTemplate();
    subjectPropertyTemplate.setMultiple(false);
    subjectPropertyTemplate.setName("wiki:subject");
    subjectPropertyTemplate.setMandatory(true);
    subjectPropertyTemplate.setRequiredType(PropertyType.STRING);
    pageTypeTemplate.getPropertyDefinitionTemplates().add(subjectPropertyTemplate);

    PropertyDefinitionTemplate contentPropertyTemplate = manager.createPropertyDefinitionTemplate();
    contentPropertyTemplate.setMultiple(false);
    contentPropertyTemplate.setName("wiki:content");
    contentPropertyTemplate.setMandatory(true);
    contentPropertyTemplate.setRequiredType(PropertyType.STRING);
    pageTypeTemplate.getPropertyDefinitionTemplates().add(contentPropertyTemplate);

    PropertyDefinitionTemplate lockPropertyTemplate = manager.createPropertyDefinitionTemplate();
    lockPropertyTemplate.setMultiple(false);
    lockPropertyTemplate.setName("wiki:isLock");
    lockPropertyTemplate.setMandatory(false);
    lockPropertyTemplate.setRequiredType(PropertyType.BOOLEAN);
    pageTypeTemplate.getPropertyDefinitionTemplates().add(lockPropertyTemplate);

    PropertyDefinitionTemplate statusPropertyTemplate = manager.createPropertyDefinitionTemplate();
    statusPropertyTemplate.setMultiple(false);
    statusPropertyTemplate.setName("wiki:status");
    statusPropertyTemplate.setMandatory(true);
    statusPropertyTemplate.setRequiredType(PropertyType.STRING);
    pageTypeTemplate.getPropertyDefinitionTemplates().add(statusPropertyTemplate);

    PropertyDefinitionTemplate categoryPropertyTemplate = manager.createPropertyDefinitionTemplate();
    categoryPropertyTemplate.setMultiple(false);
    categoryPropertyTemplate.setName("wiki:category");
    categoryPropertyTemplate.setMandatory(false);
    categoryPropertyTemplate.setRequiredType(PropertyType.STRING);
    pageTypeTemplate.getPropertyDefinitionTemplates().add(categoryPropertyTemplate);

    PropertyDefinitionTemplate createdPropertyTemplate = manager.createPropertyDefinitionTemplate();
    createdPropertyTemplate.setMultiple(false);
    createdPropertyTemplate.setName("wiki:createdUser");
    createdPropertyTemplate.setMandatory(true);
    createdPropertyTemplate.setRequiredType(PropertyType.STRING);
    pageTypeTemplate.getPropertyDefinitionTemplates().add(createdPropertyTemplate);

    return pageTypeTemplate;
}
 
开发者ID:MyCollab,项目名称:mycollab,代码行数:62,代码来源:PageSessionFactory.java


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