本文整理汇总了Java中javax.jcr.Node.getParent方法的典型用法代码示例。如果您正苦于以下问题:Java Node.getParent方法的具体用法?Java Node.getParent怎么用?Java Node.getParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.jcr.Node
的用法示例。
在下文中一共展示了Node.getParent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeMetadataFacet
import javax.jcr.Node; //导入方法依赖的package包/类
@Override
public void removeMetadataFacet( String repositoryId, String facetId, String name )
throws MetadataRepositoryException
{
try
{
Node root = getJcrSession().getRootNode();
String path = getFacetPath( repositoryId, facetId, name );
if ( root.hasNode( path ) )
{
Node node = root.getNode( path );
do
{
// also remove empty container nodes
Node parent = node.getParent();
node.remove();
node = parent;
}
while ( !node.hasNodes() );
}
}
catch ( RepositoryException e )
{
throw new MetadataRepositoryException( e.getMessage(), e );
}
}
示例2: findParentPublication
import javax.jcr.Node; //导入方法依赖的package包/类
private Node findParentPublication(Node node) {
Node publication = null;
try {
Node folder = node.getParent();
publication = findPublicationInFolder(folder);
} catch (RepositoryException ex) {
log.error("Repository exception during read operation", ex);
}
return publication;
}
示例3: getProjectReferences
import javax.jcr.Node; //导入方法依赖的package包/类
@Override
public Collection<ProjectVersionReference> getProjectReferences( String repositoryId, String namespace,
String projectId, String projectVersion )
throws MetadataResolutionException
{
List<ProjectVersionReference> references = new ArrayList<>();
// TODO: bind variables instead
String q = "SELECT * FROM [archiva:dependency] WHERE ISDESCENDANTNODE([/repositories/" + repositoryId +
"/content]) AND [groupId]='" + namespace + "' AND [artifactId]='" + projectId + "'";
if ( projectVersion != null )
{
q += " AND [version]='" + projectVersion + "'";
}
try
{
Query query = getJcrSession().getWorkspace().getQueryManager().createQuery( q, Query.JCR_SQL2 );
QueryResult result = query.execute();
for ( Node n : JcrUtils.getNodes( result ) )
{
n = n.getParent(); // dependencies grouping element
n = n.getParent(); // project version
String usedByProjectVersion = n.getName();
n = n.getParent(); // project
String usedByProject = n.getName();
n = n.getParent(); // namespace
String usedByNamespace = n.getProperty( "namespace" ).getString();
ProjectVersionReference ref = new ProjectVersionReference();
ref.setNamespace( usedByNamespace );
ref.setProjectId( usedByProject );
ref.setProjectVersion( usedByProjectVersion );
ref.setReferenceType( ProjectVersionReference.ReferenceType.DEPENDENCY );
references.add( ref );
}
}
catch ( RepositoryException e )
{
throw new MetadataResolutionException( e.getMessage(), e );
}
return references;
}
示例4: getArtifactFromNode
import javax.jcr.Node; //导入方法依赖的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;
}
示例5: getParentWithRootThrowsException
import javax.jcr.Node; //导入方法依赖的package包/类
@Test(expected = NullPointerException.class)
public void getParentWithRootThrowsException() throws Exception {
Node testObj = aNode("/");
testObj.getParent();
}