本文整理汇总了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 );
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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" );
}
示例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);
}
}
示例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.");
}
}