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


Java Node.hasNode方法代碼示例

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


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

示例1: setUpdateScriptJcrNode

import javax.jcr.Node; //導入方法依賴的package包/類
/**
 * do the update or create a node of the groovy file
 * this will not save the session
 *
 * @param parent parentnode of the Node te be
 * @param file file to transform into a Node
 * @return success
 * @throws RepositoryException
 */
public static boolean setUpdateScriptJcrNode(Node parent, File file) throws RepositoryException {
    ScriptClass scriptClass = getInterpretingClass(file);
    if(!scriptClass.isValid()){
        return false;
    }
    final Updater updater = scriptClass.getUpdater();
    String name = updater.name();
    if(parent.hasNode(name)){
        parent.getNode(name).remove();
    }
    Node scriptNode = parent.addNode(name, HIPPOSYS_UPDATERINFO);

    scriptNode.setProperty(HIPPOSYS_BATCHSIZE, updater.batchSize());
    scriptNode.setProperty(HIPPOSYS_DESCRIPTION, updater.description());
    scriptNode.setProperty(HIPPOSYS_PARAMETERS, updater.parameters());
    scriptNode.setProperty(updater.xpath().isEmpty() ? HIPPOSYS_PATH : HIPPOSYS_QUERY,
            updater.xpath().isEmpty() ? updater.path() : updater.xpath());
    scriptNode.setProperty(HIPPOSYS_SCRIPT, scriptClass.getContent());
    scriptNode.setProperty(HIPPOSYS_THROTTLE, updater.throttle());
    return true;
}
 
開發者ID:openweb-nl,項目名稱:hippo-groovy-updater,代碼行數:31,代碼來源:GroovyFilesServiceImpl.java

示例2: readFile

import javax.jcr.Node; //導入方法依賴的package包/類
@Override
public InputStream readFile(String path,String version) throws Exception{
	if(StringUtils.isNotBlank(version)){
		repositoryInteceptor.readFile(path+":"+version);
		return readVersionFile(path, version);
	}
	repositoryInteceptor.readFile(path);
	Node rootNode=getRootNode();
	int colonPos = path.lastIndexOf(":");
	if (colonPos > -1) {
		version = path.substring(colonPos + 1, path.length());
		path = path.substring(0, colonPos);
		return readFile(path, version);
	}
	path = processPath(path);
	if (!rootNode.hasNode(path)) {
		throw new RuleException("File [" + path + "] not exist.");
	}
	Node fileNode = rootNode.getNode(path);
	Property property = fileNode.getProperty(DATA);
	Binary fileBinary = property.getBinary();
	return fileBinary.getStream();
}
 
開發者ID:youseries,項目名稱:urule,代碼行數:24,代碼來源:BaseRepositoryService.java

示例3: unlockPath

import javax.jcr.Node; //導入方法依賴的package包/類
@Override
public void unlockPath(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 absPath=fileNode.getPath();
	if(!lockManager.isLocked(absPath)){
		throw new NodeLockException("當前文件未鎖定,不需要解鎖!");
	}
	Lock lock=lockManager.getLock(absPath);
	String owner=lock.getLockOwner();
	if(!owner.equals(user.getUsername())){
		throw new NodeLockException("當前文件由【"+owner+"】鎖定,您無權解鎖!");
	}
	lockManager.unlock(lock.getNode().getPath());
}
 
開發者ID:youseries,項目名稱:urule,代碼行數:24,代碼來源:RepositoryServiceImpl.java

示例4: createProject

import javax.jcr.Node; //導入方法依賴的package包/類
@Override
public RepositoryFile createProject(String projectName, User user,boolean classify) throws Exception{
	if(!permissionService.isAdmin()){
		throw new NoPermissionException();
	}
	repositoryInteceptor.createProject(projectName);
	Node rootNode=getRootNode();
	if(rootNode.hasNode(projectName)){
		throw new RuleException("Project ["+projectName+"] already exist.");
	}
	Node projectNode=rootNode.addNode(projectName);
	projectNode.addMixin("mix:versionable");
	projectNode.setProperty(FILE, true);
	projectNode.setProperty(CRATE_USER,user.getUsername());
	projectNode.setProperty(COMPANY_ID, user.getCompanyId());
	Calendar calendar = Calendar.getInstance();
	calendar.setTime(new Date());
	DateValue dateValue = new DateValue(calendar);
	projectNode.setProperty(CRATE_DATE, dateValue);
	session.save();
	createResourcePackageFile(projectName,user);
	createClientConfigFile(projectName, user);
	RepositoryFile projectFileInfo=buildProjectFile(projectNode, null ,classify,null);
	return projectFileInfo;
}
 
開發者ID:youseries,項目名稱:urule,代碼行數:26,代碼來源:RepositoryServiceImpl.java

示例5: 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

示例6: removeMetadataFacets

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

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

示例8: removeRepository

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

示例9: getProject

import javax.jcr.Node; //導入方法依賴的package包/類
@Override
public ProjectMetadata getProject( String repositoryId, String namespace, String projectId )
    throws MetadataResolutionException
{
    ProjectMetadata metadata = null;

    try
    {
        Node root = getJcrSession().getRootNode();

        // basically just checking it exists
        String path = getProjectPath( repositoryId, namespace, projectId );
        if ( root.hasNode( path ) )
        {
            metadata = new ProjectMetadata();
            metadata.setId( projectId );
            metadata.setNamespace( namespace );
        }
    }
    catch ( RepositoryException e )
    {
        throw new MetadataResolutionException( e.getMessage(), e );
    }

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

示例10: findOrCreateNode

import javax.jcr.Node; //導入方法依賴的package包/類
private Node findOrCreateNode(Node parent, String path, String nodeType) throws RepositoryException {
    Node result = parent;
    for (String component : path.split("/")) {
        component = Text.escapeIllegalJcrChars(component);
        if (component.length() > 0) {
            if (result.hasNode(component)) {
                result = result.getNode(component);
            } else {
                if (ObjectHelper.isNotEmpty(nodeType)) {
                    result = result.addNode(component, nodeType);
                } else {
                    result = result.addNode(component);
                }
            }
        }
    }
    return result;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:19,代碼來源:JcrProducer.java

示例11: doGet

import javax.jcr.Node; //導入方法依賴的package包/類
@Override
@SuppressWarnings("unchecked")
protected void doGet(final SlingHttpServletRequest request, final SlingHttpServletResponse response)
        throws IOException, ServletException {
    //TODO: put all of the logic in a context processor (need to fix templating support filter bug first)
    String transformName = BLANK;
    if (PathInfoUtil.getSuffixSegments(request).length == 2) {
        String firstSuffixSegment = PathInfoUtil.getFirstSuffixSegment(request);
        if (this.namedImageTransformers.keySet().contains(firstSuffixSegment)) {
            transformName = firstSuffixSegment;
        }
    }
    //Adds the asset binary to the inputStream
    try {
        Resource assetResource = getAssetResource(request);

        if (DamUtil.isAsset(assetResource)) {
            Binary binary;
            String mimeType = BLANK;
            Asset asset = DamUtil.resolveToAsset(assetResource);
            Resource original = asset.getOriginal();

            Node assetNode = original.adaptTo(Node.class);
            if (assetNode.hasNode(JCR_CONTENT)) {
                Node assetInfo = assetNode.getNode(JCR_CONTENT);
                if (assetInfo.hasProperty(JCR_MIMETYPE)) {
                    mimeType = assetInfo.getProperty(JCR_MIMETYPE).getString();
                }
                if (StringUtils.isNotBlank(mimeType)) {
                    response.setContentType(mimeType);
                }
                binary = assetInfo.getProperty(JCR_DATA).getBinary();
                InputStream inputStream = binary.getStream();
                OutputStream outputStream = response.getOutputStream();

                boolean shouldTransform = StringUtils.isNotBlank(transformName);
                if (shouldTransform && ImageUtils.isImage(assetResource)) {
                    double quality = 1;
                    double maxGifQuality = 255;

                    // Transform the image
                    final Layer layer = new Layer(inputStream, new Dimension(maxWidth, maxHeight));
                    Layer newLayer = null;
                    try {
                        final NamedImageTransformer namedImageTransformer = this.namedImageTransformers.get(transformName);
                        newLayer = namedImageTransformer.transform(layer);

                        if (StringUtils.isBlank(mimeType) || !ImageIO.getImageWritersByMIMEType(mimeType).hasNext()) {
                            mimeType = getImageMimeType(layer, asset.getName());
                            response.setContentType(mimeType);
                        }
                        // For GIF images the colors will be reduced according to the quality argument.
                        if (StringUtils.equals(mimeType, GIF_MIME_TYPE)) {
                            quality = quality * maxGifQuality;
                        }

                        newLayer.write(mimeType, quality, outputStream);
                    } finally {
                        if (layer != null) {
                            layer.dispose();
                        }
                        if (newLayer != null) {
                            newLayer.dispose();
                        }
                    }

                } else {
                    ByteStreams.copy(inputStream, outputStream);
                }

                response.flushBuffer();
                outputStream.close();

            }
        }
    } catch (RepositoryException repoException) {
        LOGGER.error("Repository Exception. ", repoException);
    }
}
 
開發者ID:DantaFramework,項目名稱:AEM,代碼行數:80,代碼來源:AssetProviderServlet.java

示例12: getGlobalPropertiesPath

import javax.jcr.Node; //導入方法依賴的package包/類
/**
 * Takes resource and resource resolver return the global property path from the resource
 *
 * @param resource The resource to get the global property path from
 * @return globalPropertiesPath
 */
public static String getGlobalPropertiesPath(Resource resource, ResourceResolver resourceResolver)
        throws RepositoryException, PersistenceException {
    String globalPropertiesPath = "";
    Designer designer = resourceResolver.adaptTo(Designer.class);
    Style style = designer.getStyle(resource);
    Design design;
    if (null != style) {
        design = style.getDesign();
        if (null != design) {
            if (null != design.getContentResource()) {
                if (null != design.getContentResource().getPath()) {
                    //add global node in design when it does not exist
                    Resource designResource = resourceResolver.getResource(design.getContentResource().getPath());
                    Node designNode = designResource.adaptTo(Node.class);
                    if (!designNode.hasNode(GLOBAL_PROPERTIES_KEY)) {
                        designNode.addNode(GLOBAL_PROPERTIES_KEY);
                        resourceResolver.commit();
                    }
                    // set global path
                    globalPropertiesPath = design.getContentResource().getPath() + GLOBAL_PATH;
                }
            }
        }
    }
    return globalPropertiesPath;
}
 
開發者ID:DantaFramework,項目名稱:AEM,代碼行數:33,代碼來源:ResourceUtils.java

示例13: getVersionFiles

import javax.jcr.Node; //導入方法依賴的package包/類
@Override
public List<VersionFile> getVersionFiles(String path) throws Exception{
	path = processPath(path);
	Node rootNode=getRootNode();
	if (!rootNode.hasNode(path)) {
		throw new RuleException("File [" + path + "] not exist.");
	}
	List<VersionFile> files = new ArrayList<VersionFile>();
	Node fileNode = rootNode.getNode(path);
	VersionHistory versionHistory = versionManager.getVersionHistory(fileNode.getPath());
	VersionIterator iterator = versionHistory.getAllVersions();
	while (iterator.hasNext()) {
		Version version = iterator.nextVersion();
		String versionName = version.getName();
		if (versionName.startsWith("jcr:")) {
			continue; // skip root version
		}
		Node fnode = version.getFrozenNode();
		VersionFile file = new VersionFile();
		file.setName(version.getName());
		file.setPath(fileNode.getPath());
		Property prop = fnode.getProperty(CRATE_USER);
		file.setCreateUser(prop.getString());
		prop = fnode.getProperty(CRATE_DATE);
		file.setCreateDate(prop.getDate().getTime());
		if(fnode.hasProperty(VERSION_COMMENT)){
			prop=fnode.getProperty(VERSION_COMMENT);
			file.setComment(prop.getString());
		}
		files.add(file);
	}
	return files;
}
 
開發者ID:youseries,項目名稱:urule,代碼行數:34,代碼來源:BaseRepositoryService.java

示例14: readVersionFile

import javax.jcr.Node; //導入方法依賴的package包/類
private InputStream readVersionFile(String path, String version) throws Exception{
	path = processPath(path);
	Node rootNode=getRootNode();
	if (!rootNode.hasNode(path)) {
		throw new RuleException("File [" + path + "] not exist.");
	}
	Node fileNode = rootNode.getNode(path);
	VersionHistory versionHistory = versionManager.getVersionHistory(fileNode.getPath());
	Version v = versionHistory.getVersion(version);
	Node fnode = v.getFrozenNode();
	Property property = fnode.getProperty(DATA);
	Binary fileBinary = property.getBinary();
	return fileBinary.getStream();
}
 
開發者ID:youseries,項目名稱:urule,代碼行數:15,代碼來源:BaseRepositoryService.java

示例15: 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


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