当前位置: 首页>>代码示例>>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;未经允许,请勿转载。