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


Java JcrUtils.getOrAddNode方法代码示例

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


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

示例1: addMetadataFacet

import org.apache.jackrabbit.commons.JcrUtils; //导入方法依赖的package包/类
@Override
public void addMetadataFacet( String repositoryId, MetadataFacet metadataFacet )
    throws MetadataRepositoryException
{
    try
    {
        Node repo = getOrAddRepositoryNode( repositoryId );
        Node facets = JcrUtils.getOrAddNode( repo, "facets" );

        String id = metadataFacet.getFacetId();
        Node facetNode = JcrUtils.getOrAddNode( facets, id );

        Node node = getOrAddNodeByPath( facetNode, metadataFacet.getName() );

        for ( Map.Entry<String, String> entry : metadataFacet.toProperties().entrySet() )
        {
            node.setProperty( entry.getKey(), entry.getValue() );
        }
    }
    catch ( RepositoryException e )
    {
        throw new MetadataRepositoryException( e.getMessage(), e );
    }
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:25,代码来源:JcrMetadataRepository.java

示例2: getOrAddNodeByPath

import org.apache.jackrabbit.commons.JcrUtils; //导入方法依赖的package包/类
private Node getOrAddNodeByPath( Node baseNode, String name, String nodeType )
    throws RepositoryException
{
    Node node = baseNode;
    for ( String n : name.split( "/" ) )
    {
        node = JcrUtils.getOrAddNode( node, n );
        if ( nodeType != null )
        {
            node.addMixin( nodeType );
        }
    }
    return node;
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:15,代码来源:JcrMetadataRepository.java

示例3: getOrAddRepositoryNode

import org.apache.jackrabbit.commons.JcrUtils; //导入方法依赖的package包/类
private Node getOrAddRepositoryNode( String repositoryId )
    throws RepositoryException
{
    Node root = getJcrSession().getRootNode();
    Node node = JcrUtils.getOrAddNode( root, "repositories" );
    node = JcrUtils.getOrAddNode( node, repositoryId );
    return node;
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:9,代码来源:JcrMetadataRepository.java

示例4: getOrAddProjectNode

import org.apache.jackrabbit.commons.JcrUtils; //导入方法依赖的package包/类
private Node getOrAddProjectNode( String repositoryId, String namespace, String projectId )
    throws RepositoryException
{
    Node namespaceNode = getOrAddNamespaceNode( repositoryId, namespace );
    Node node = JcrUtils.getOrAddNode( namespaceNode, projectId );
    node.addMixin( PROJECT_NODE_TYPE );
    return node;
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:9,代码来源:JcrMetadataRepository.java

示例5: getOrAddProjectVersionNode

import org.apache.jackrabbit.commons.JcrUtils; //导入方法依赖的package包/类
private Node getOrAddProjectVersionNode( String repositoryId, String namespace, String projectId,
                                         String projectVersion )
    throws RepositoryException
{
    Node projectNode = getOrAddProjectNode( repositoryId, namespace, projectId );
    Node node = JcrUtils.getOrAddNode( projectNode, projectVersion );
    node.addMixin( PROJECT_VERSION_NODE_TYPE );
    return node;
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:10,代码来源:JcrMetadataRepository.java

示例6: getOrAddArtifactNode

import org.apache.jackrabbit.commons.JcrUtils; //导入方法依赖的package包/类
private Node getOrAddArtifactNode( String repositoryId, String namespace, String projectId, String projectVersion,
                                   String id )
    throws RepositoryException
{
    Node versionNode = getOrAddProjectVersionNode( repositoryId, namespace, projectId, projectVersion );
    Node node = JcrUtils.getOrAddNode( versionNode, id );
    node.addMixin( ARTIFACT_NODE_TYPE );
    return node;
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:10,代码来源:JcrMetadataRepository.java

示例7: loadContentIntoRepo

import org.apache.jackrabbit.commons.JcrUtils; //导入方法依赖的package包/类
private void loadContentIntoRepo( String repoId )
    throws RepositoryException, IOException
{
    Node n = JcrUtils.getOrAddNode( session.getRootNode(), "repositories" );
    n = JcrUtils.getOrAddNode( n, repoId );
    n = JcrUtils.getOrAddNode( n, "content" );
    n = JcrUtils.getOrAddNode( n, "org" );
    n = JcrUtils.getOrAddNode( n, "apache" );

    GZIPInputStream inputStream = new GZIPInputStream( getClass().getResourceAsStream( "/artifacts.xml.gz" ) );
    session.importXML( n.getPath(), inputStream, ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW );
    session.save();
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:14,代码来源:JcrRepositoryStatisticsGatheringTest.java

示例8: getOrAddNodeByPath

import org.apache.jackrabbit.commons.JcrUtils; //导入方法依赖的package包/类
private Node getOrAddNodeByPath( Node baseNode, String name, String nodeType )
    throws RepositoryException
{
    log.debug( "getOrAddNodeByPath" + baseNode + " " + name + " " + nodeType );
    Node node = baseNode;
    for ( String n : name.split( "/" ) )
    {
        node = JcrUtils.getOrAddNode( node, n );
        if ( nodeType != null )
        {
            node.addMixin( nodeType );
        }
    }
    return node;
}
 
开发者ID:apache,项目名称:archiva,代码行数:16,代码来源:JcrMetadataRepository.java

示例9: getOrAddRepositoryNode

import org.apache.jackrabbit.commons.JcrUtils; //导入方法依赖的package包/类
private Node getOrAddRepositoryNode( String repositoryId )
    throws RepositoryException
{
    log.debug( "getOrAddRepositoryNode " + repositoryId );
    Node root = getJcrSession().getRootNode();
    Node node = JcrUtils.getOrAddNode( root, "repositories" );
    log.debug( "Repositories " + node );
    node = JcrUtils.getOrAddNode( node, repositoryId );
    return node;
}
 
开发者ID:apache,项目名称:archiva,代码行数:11,代码来源:JcrMetadataRepository.java

示例10: getOrAddRepositoryContentNode

import org.apache.jackrabbit.commons.JcrUtils; //导入方法依赖的package包/类
private Node getOrAddRepositoryContentNode( String repositoryId )
    throws RepositoryException
{
    Node node = getOrAddRepositoryNode( repositoryId );
    return JcrUtils.getOrAddNode( node, "content" );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:7,代码来源:JcrMetadataRepository.java

示例11: productRolloutHook

import org.apache.jackrabbit.commons.JcrUtils; //导入方法依赖的package包/类
@Override
public void productRolloutHook(Product productData, Page productPage, Product product) throws CommerceException {
    try {
        boolean changed = false;

        //
        // The out-of-the-box commerce components (such as commerce/components/product) support
        // two variant axes: "size", plus one (optional) user-defined axis.
        // The user-defined axis, if required, is specified using the "variationAxis" and
        // "variationTitle" properties.
        //
        // In the sample product set, the optional axis is always "color".
        //
        Node productNode = product.adaptTo(Node.class);
        if (productData.axisIsVariant("color")) {
            if (!productNode.hasProperty("variationAxis")) {
                productNode.setProperty("variationAxis", "color");
                productNode.setProperty("variationTitle", "Color");
                changed = true;
            }
        } else {
            if (productNode.hasProperty("variationAxis") && productNode.getProperty("variationAxis").getString().equals("color")) {
                productNode.setProperty("variationAxis", "");
                productNode.setProperty("variationTitle", "");
                changed = true;
            }
        }

        //
        // Copy we-retail namespaced tags from the product to the product page.
        //
        if (CommerceHelper.copyTags(productData, productPage.getContentResource(),
                new Predicate() {
                    public boolean evaluate(Object o) {
                        return ((Tag) o).getNamespace().getName().equals("we-retail");
                    }
                })) {
            changed = true;
        }

        //
        // Give product pages a product-specific thumbnail so they don't have to fall back to
        // the (generic) page_product template's thumbnail.  This greatly improves the usability
        // of the pages content finder tab.
        //
        if (!ResourceUtil.isA(productPage.getContentResource(), CommerceConstants.RT_PRODUCT_PAGE_PROXY)) {
            String productImageRef = "";
            Resource productImage = productData.getImage();
            if (productImage != null) {
                productImageRef = ResourceUtil.getValueMap(productImage).get("fileReference", "");
            }
            Node contentNode = productPage.getContentResource().adaptTo(Node.class);
            Node pageImageNode = JcrUtils.getOrAddNode(contentNode, "image", "nt:unstructured");
            pageImageNode.setProperty("fileReference", productImageRef);
        }

        if (changed) {
            productPage.getPageManager().touch(productPage.adaptTo(Node.class), true, Calendar.getInstance(), false);
        }
    } catch(Exception e) {
        throw new CommerceException("Product rollout hook failed: ", e);
    }
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-sample-we-retail,代码行数:64,代码来源:WeRetailCommerceServiceImpl.java

示例12: initialize

import org.apache.jackrabbit.commons.JcrUtils; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void initialize(QueryHelper queryHelper, Config config) throws
        PersistenceException, RepositoryException {

    // Query for all candidate resources
    final ResourceResolver resourceResolver = config.getResourceResolver();
    final List<Resource> resources = queryHelper.findResources(resourceResolver,
            config.getQueryType(),
            config.getQueryStatement(),
            config.getRelativePath());

    int total = 0;

    // Create Workspace Node
    Node workspace = JcrUtils.getOrAddNode(config.getResource().adaptTo(Node.class), Workspace.NN_WORKSPACE, Workspace.NT_UNORDERED);
    // Create the PayloadGroups Launchpad node; this simply points to the first to process
    Node currentPayloadGroup = JcrUtils.getOrCreateByPath(workspace, Workspace.NN_PAYLOADS_LAUNCHPAD, true, Workspace.NT_UNORDERED, Workspace.NT_UNORDERED, false);
    // Set the first Payload Group to be the launchpad node
    JcrUtil.setProperty(workspace, Workspace.PN_ACTIVE_PAYLOAD_GROUPS, new String[]{PayloadGroup.dereference(currentPayloadGroup.getPath())});


    // No begin populating the actual PayloadGroup nodes
    ListIterator<Resource> itr = resources.listIterator();

    while (itr.hasNext()) {
        // Increment to a new PayloadGroup as needed
        if (total % config.getBatchSize() == 0 && itr.hasNext()) {
            // payload group is complete; save...
            Node nextPayloadGroup = JcrUtils.getOrCreateByPath(workspace, Workspace.NN_PAYLOADS, true, Workspace.NT_UNORDERED, Workspace.NT_UNORDERED, false);
            JcrUtil.setProperty(currentPayloadGroup, PayloadGroup.PN_NEXT, PayloadGroup.dereference(nextPayloadGroup.getPath()));
            currentPayloadGroup = nextPayloadGroup;
        }

        // Process the payload
        Resource payload = itr.next();
        Node payloadNode = JcrUtils.getOrCreateByPath(currentPayloadGroup, Payload.NN_PAYLOAD, true, Workspace.NT_UNORDERED, Workspace.NT_UNORDERED, false);
        JcrUtil.setProperty(payloadNode, "path", Payload.dereference(payload.getPath()));
        log.debug("Created payload with search result [ {} ]", payload.getPath());

        if (++total % SAVE_THRESHOLD == 0 || !itr.hasNext()) {
            resourceResolver.commit();
        }
    } // while

    if (total > 0) {
        config.getWorkspace().getRunner().initialize(config.getWorkspace(), total);
        config.commit();

        log.info("Completed initialization of Bulk Workflow Manager");
    } else {
        throw new IllegalArgumentException("Query returned zero results.");
    }
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:57,代码来源:AbstractWorkflowRunner.java


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