本文整理汇总了Java中org.apache.jackrabbit.commons.JcrUtils.getChildNodes方法的典型用法代码示例。如果您正苦于以下问题:Java JcrUtils.getChildNodes方法的具体用法?Java JcrUtils.getChildNodes怎么用?Java JcrUtils.getChildNodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jackrabbit.commons.JcrUtils
的用法示例。
在下文中一共展示了JcrUtils.getChildNodes方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: recurse
import org.apache.jackrabbit.commons.JcrUtils; //导入方法依赖的package包/类
private void recurse( List<String> facets, String prefix, Node node )
throws RepositoryException
{
for ( Node n : JcrUtils.getChildNodes( node ) )
{
String name = prefix + "/" + n.getName();
if ( n.hasNodes() )
{
recurse( facets, name, n );
}
else
{
// strip leading / first
facets.add( name.substring( 1 ) );
}
}
}
示例2: removeProjectVersion
import org.apache.jackrabbit.commons.JcrUtils; //导入方法依赖的package包/类
@Override
public void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion )
throws MetadataRepositoryException
{
try
{
String path = getProjectPath( repoId, namespace, projectId );
Node root = getJcrSession().getRootNode();
Node nodeAtPath = root.getNode( path );
for ( Node node : JcrUtils.getChildNodes( nodeAtPath ) )
{
if ( node.isNodeType( PROJECT_VERSION_NODE_TYPE ) && StringUtils.equals( projectVersion,
node.getName() ) )
{
node.remove();
}
}
}
catch ( RepositoryException e )
{
throw new MetadataRepositoryException( e.getMessage(), e );
}
}
示例3: removeArtifact
import org.apache.jackrabbit.commons.JcrUtils; //导入方法依赖的package包/类
@Override
public void removeArtifact( String repositoryId, String namespace, String projectId, String projectVersion,
String id )
throws MetadataRepositoryException
{
try
{
Node root = getJcrSession().getRootNode();
String path = getArtifactPath( repositoryId, namespace, projectId, projectVersion, id );
if ( root.hasNode( path ) )
{
root.getNode( path ).remove();
}
// remove version
path = getProjectPath( repositoryId, namespace, projectId );
Node nodeAtPath = root.getNode( path );
for ( Node node : JcrUtils.getChildNodes( nodeAtPath ) )
{
if ( node.isNodeType( PROJECT_VERSION_NODE_TYPE ) //
&& StringUtils.equals( node.getName(), projectVersion ) )
{
node.remove();
}
}
}
catch ( RepositoryException e )
{
throw new MetadataRepositoryException( e.getMessage(), e );
}
}
示例4: getArtifacts
import org.apache.jackrabbit.commons.JcrUtils; //导入方法依赖的package包/类
@Override
public Collection<ArtifactMetadata> getArtifacts( String repositoryId, String namespace, String projectId,
String projectVersion )
throws MetadataResolutionException
{
List<ArtifactMetadata> artifacts = new ArrayList<>();
try
{
Node root = getJcrSession().getRootNode();
String path = getProjectVersionPath( repositoryId, namespace, projectId, projectVersion );
if ( root.hasNode( path ) )
{
Node node = root.getNode( path );
for ( Node n : JcrUtils.getChildNodes( node ) )
{
if ( n.isNodeType( ARTIFACT_NODE_TYPE ) )
{
artifacts.add( getArtifactFromNode( repositoryId, n ) );
}
}
}
}
catch ( RepositoryException e )
{
throw new MetadataResolutionException( e.getMessage(), e );
}
return artifacts;
}
示例5: getArtifactFromNode
import org.apache.jackrabbit.commons.JcrUtils; //导入方法依赖的package包/类
private ArtifactMetadata getArtifactFromNode( String repositoryId, Node artifactNode )
throws RepositoryException
{
String id = artifactNode.getName();
ArtifactMetadata artifact = new ArtifactMetadata();
artifact.setId( id );
artifact.setRepositoryId( repositoryId == null ? artifactNode.getAncestor(2).getName() : repositoryId );
Node projectVersionNode = artifactNode.getParent();
Node projectNode = projectVersionNode.getParent();
Node namespaceNode = projectNode.getParent();
artifact.setNamespace( namespaceNode.getProperty( "namespace" ).getString() );
artifact.setProject( projectNode.getName() );
artifact.setProjectVersion( projectVersionNode.getName() );
artifact.setVersion( artifactNode.hasProperty( "version" )
? artifactNode.getProperty( "version" ).getString()
: projectVersionNode.getName() );
if ( artifactNode.hasProperty( JCR_LAST_MODIFIED ) )
{
artifact.setFileLastModified( artifactNode.getProperty( JCR_LAST_MODIFIED ).getDate().getTimeInMillis() );
}
if ( artifactNode.hasProperty( "whenGathered" ) )
{
artifact.setWhenGathered( artifactNode.getProperty( "whenGathered" ).getDate().getTime() );
}
if ( artifactNode.hasProperty( "size" ) )
{
artifact.setSize( artifactNode.getProperty( "size" ).getLong() );
}
if ( artifactNode.hasProperty( "md5" ) )
{
artifact.setMd5( artifactNode.getProperty( "md5" ).getString() );
}
if ( artifactNode.hasProperty( "sha1" ) )
{
artifact.setSha1( artifactNode.getProperty( "sha1" ).getString() );
}
for ( Node n : JcrUtils.getChildNodes( artifactNode ) )
{
if ( n.isNodeType( FACET_NODE_TYPE ) )
{
String name = n.getName();
MetadataFacetFactory factory = metadataFacetFactories.get( name );
if ( factory == null )
{
log.error( "Attempted to load unknown project version metadata facet: " + name );
}
else
{
MetadataFacet facet = factory.createMetadataFacet();
Map<String, String> map = new HashMap<>();
for ( Property p : JcrUtils.getProperties( n ) )
{
String property = p.getName();
if ( !property.startsWith( "jcr:" ) )
{
map.put( property, p.getString() );
}
}
facet.fromProperties( map );
artifact.addFacet( facet );
}
}
}
return artifact;
}
示例6: getArtifactFromNode
import org.apache.jackrabbit.commons.JcrUtils; //导入方法依赖的package包/类
private ArtifactMetadata getArtifactFromNode( String repositoryId, Node artifactNode )
throws RepositoryException
{
String id = artifactNode.getName();
ArtifactMetadata artifact = new ArtifactMetadata();
artifact.setId( id );
artifact.setRepositoryId( repositoryId == null ? artifactNode.getAncestor( 2 ).getName() : repositoryId );
Node projectVersionNode = artifactNode.getParent();
Node projectNode = projectVersionNode.getParent();
Node namespaceNode = projectNode.getParent();
artifact.setNamespace( namespaceNode.getProperty( "namespace" ).getString() );
artifact.setProject( projectNode.getName() );
artifact.setProjectVersion( projectVersionNode.getName() );
artifact.setVersion( artifactNode.hasProperty( "version" )
? artifactNode.getProperty( "version" ).getString()
: projectVersionNode.getName() );
if ( artifactNode.hasProperty( JCR_LAST_MODIFIED ) )
{
artifact.setFileLastModified( artifactNode.getProperty( JCR_LAST_MODIFIED ).getDate().getTimeInMillis() );
}
if ( artifactNode.hasProperty( "whenGathered" ) )
{
artifact.setWhenGathered( artifactNode.getProperty( "whenGathered" ).getDate().getTime() );
}
if ( artifactNode.hasProperty( "size" ) )
{
artifact.setSize( artifactNode.getProperty( "size" ).getLong() );
}
if ( artifactNode.hasProperty( "md5" ) )
{
artifact.setMd5( artifactNode.getProperty( "md5" ).getString() );
}
if ( artifactNode.hasProperty( "sha1" ) )
{
artifact.setSha1( artifactNode.getProperty( "sha1" ).getString() );
}
for ( Node n : JcrUtils.getChildNodes( artifactNode ) )
{
if ( n.isNodeType( FACET_NODE_TYPE ) )
{
String name = n.getName();
MetadataFacetFactory factory = metadataFacetFactories.get( name );
if ( factory == null )
{
log.error( "Attempted to load unknown project version metadata facet: {}", name );
}
else
{
MetadataFacet facet = factory.createMetadataFacet();
Map<String, String> map = new HashMap<>();
for ( Property p : JcrUtils.getProperties( n ) )
{
String property = p.getName();
if ( !property.startsWith( "jcr:" ) )
{
map.put( property, p.getString() );
}
}
facet.fromProperties( map );
artifact.addFacet( facet );
}
}
}
return artifact;
}