當前位置: 首頁>>代碼示例>>Java>>正文


Java Node.isNodeType方法代碼示例

本文整理匯總了Java中javax.jcr.Node.isNodeType方法的典型用法代碼示例。如果您正苦於以下問題:Java Node.isNodeType方法的具體用法?Java Node.isNodeType怎麽用?Java Node.isNodeType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.jcr.Node的用法示例。


在下文中一共展示了Node.isNodeType方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isResourceType

import javax.jcr.Node; //導入方法依賴的package包/類
private boolean isResourceType(Resource resource, String resourceType) {
	if (StringUtils.isBlank(resourceType)) {
		return true;
	}
	if (resource.isResourceType(resourceType)) {
		return true;
	}
	if (!isValidType(resourceType)) {
		return false;
	}
	Node node = resource.adaptTo(Node.class);
	try {
		if (node != null) {
			return node.isNodeType(resourceType);
		}
	} catch (RepositoryException e) {
		LOG.error("Can't check node type", e);
	}
	return false;
}
 
開發者ID:apache,項目名稱:sling-org-apache-sling-query,代碼行數:21,代碼來源:ResourcePredicate.java

示例2: removeNamespace

import javax.jcr.Node; //導入方法依賴的package包/類
@Override
public void removeNamespace( String repositoryId, String projectId )
    throws MetadataRepositoryException
{
    try
    {
        Node root = getJcrSession().getRootNode();
        String path = getNamespacePath( repositoryId, projectId );
        if ( root.hasNode( path ) )
        {
            Node node = root.getNode( path );
            if ( node.isNodeType( NAMESPACE_NODE_TYPE ) )
            {
                node.remove();
            }
        }
    }
    catch ( RepositoryException e )
    {
        throw new MetadataRepositoryException( e.getMessage(), e );
    }
}
 
開發者ID:ruikom,項目名稱:apache-archiva,代碼行數:23,代碼來源:JcrMetadataRepository.java

示例3: removeProjectVersion

import javax.jcr.Node; //導入方法依賴的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 );
    }
}
 
開發者ID:ruikom,項目名稱:apache-archiva,代碼行數:27,代碼來源:JcrMetadataRepository.java

示例4: lockPath

import javax.jcr.Node; //導入方法依賴的package包/類
@Override
public void lockPath(String path,User user) throws Exception{
	path = processPath(path);
	int pos=path.indexOf(":");
	if(pos!=-1){
		path=path.substring(0,pos);
	}
	Node rootNode=getRootNode();
	if (!rootNode.hasNode(path)) {
		throw new RuleException("File [" + path + "] not exist.");
	}
	Node fileNode = rootNode.getNode(path);
	String topAbsPath=fileNode.getPath();
	if(lockManager.isLocked(topAbsPath)){
		String owner=lockManager.getLock(topAbsPath).getLockOwner();
		throw new NodeLockException("【"+path+"】已被"+owner+"鎖定,您不能進行再次鎖定!");
	}
	List<Node> nodeList=new ArrayList<Node>();
	unlockAllChildNodes(fileNode, user, nodeList, path);
	for(Node node:nodeList){
		if(!lockManager.isLocked(node.getPath())){
			continue;
		}
		Lock lock=lockManager.getLock(node.getPath());
		lockManager.unlock(lock.getNode().getPath());
	}
	if(!fileNode.isNodeType(NodeType.MIX_LOCKABLE)){
		if (!fileNode.isCheckedOut()) {
			versionManager.checkout(fileNode.getPath());
		}
		fileNode.addMixin("mix:lockable");
		session.save();
	}
	lockManager.lock(topAbsPath, true, true, Long.MAX_VALUE, user.getUsername());				
}
 
開發者ID:youseries,項目名稱:urule,代碼行數:36,代碼來源:RepositoryServiceImpl.java

示例5: removeProject

import javax.jcr.Node; //導入方法依賴的package包/類
@Override
public void removeProject( String repositoryId, String namespace, String projectId )
    throws MetadataRepositoryException
{
    try
    {
        Node root = getJcrSession().getRootNode();
        String namespacePath = getNamespacePath( repositoryId, namespace );

        if ( root.hasNode( namespacePath ) )
        {
            Iterator<Node> nodeIterator = JcrUtils.getChildNodes( root.getNode( namespacePath ) ).iterator();
            while ( nodeIterator.hasNext() )
            {
                Node node = nodeIterator.next();
                if ( node.isNodeType( PROJECT_NODE_TYPE ) && projectId.equals( node.getName() ) )
                {
                    node.remove();
                }
            }

        }
    }
    catch ( RepositoryException e )
    {
        throw new MetadataRepositoryException( e.getMessage(), e );
    }

}
 
開發者ID:ruikom,項目名稱:apache-archiva,代碼行數:30,代碼來源:JcrMetadataRepository.java

示例6: getArtifacts

import javax.jcr.Node; //導入方法依賴的package包/類
@Override
public List<ArtifactMetadata> getArtifacts( String repositoryId )
    throws MetadataRepositoryException
{
    List<ArtifactMetadata> artifacts;

    String q = getArtifactQuery( repositoryId );

    try
    {
        Query query = getJcrSession().getWorkspace().getQueryManager().createQuery( q, Query.JCR_SQL2 );
        QueryResult result = query.execute();

        artifacts = new ArrayList<>();
        for ( Node n : JcrUtils.getNodes( result ) )
        {
            if ( n.isNodeType( ARTIFACT_NODE_TYPE ) )
            {
                artifacts.add( getArtifactFromNode( repositoryId, n ) );
            }
        }
    }
    catch ( RepositoryException e )
    {
        throw new MetadataRepositoryException( e.getMessage(), e );
    }
    return artifacts;
}
 
開發者ID:ruikom,項目名稱:apache-archiva,代碼行數:29,代碼來源:JcrMetadataRepository.java

示例7: removeArtifact

import javax.jcr.Node; //導入方法依賴的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 );
    }
}
 
開發者ID:ruikom,項目名稱:apache-archiva,代碼行數:35,代碼來源:JcrMetadataRepository.java

示例8: 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;
}
 
開發者ID:ruikom,項目名稱:apache-archiva,代碼行數:75,代碼來源:JcrMetadataRepository.java

示例9: isNodeTypeWithNullThrowsException

import javax.jcr.Node; //導入方法依賴的package包/類
@Test(expected = NullPointerException.class)
public void isNodeTypeWithNullThrowsException() throws Exception {
	Node target = aNode("/content");
	
	target.isNodeType(null);
}
 
開發者ID:quatico-solutions,項目名稱:aem-testing,代碼行數:7,代碼來源:NodeTest.java


注:本文中的javax.jcr.Node.isNodeType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。