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


Java Node.getNode方法代碼示例

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


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

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

示例2: loadResourceSecurityConfigs

import javax.jcr.Node; //導入方法依賴的package包/類
@Override
public List<UserPermission> loadResourceSecurityConfigs(String companyId) throws Exception{
	List<UserPermission> configs=new ArrayList<UserPermission>();
	String filePath=RESOURCE_SECURITY_CONFIG_FILE+(companyId == null ? "" : companyId);
	Node rootNode=getRootNode();
	Node fileNode = rootNode.getNode(filePath);
	Property property = fileNode.getProperty(DATA);
	Binary fileBinary = property.getBinary();
	InputStream inputStream = fileBinary.getStream();
	String content = IOUtils.toString(inputStream, "utf-8");
	inputStream.close();
	Document document = DocumentHelper.parseText(content);
	Element rootElement = document.getRootElement();
	for (Object obj : rootElement.elements()) {
		if (!(obj instanceof Element)) {
			continue;
		}
		Element element = (Element) obj;
		if (!element.getName().equals("user-permission")) {
			continue;
		}
		UserPermission userResource=new UserPermission();
		userResource.setUsername(element.attributeValue("username"));
		userResource.setProjectConfigs(parseProjectConfigs(element));
		configs.add(userResource);
	}
	return configs;
}
 
開發者ID:youseries,項目名稱:urule,代碼行數:29,代碼來源:RepositoryServiceImpl.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: 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

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

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

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

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

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

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

示例11: loadClientConfigs

import javax.jcr.Node; //導入方法依賴的package包/類
@Override
public List<ClientConfig> loadClientConfigs(String project) throws Exception{
	if(!permissionService.isAdmin()){
		throw new NoPermissionException();
	}
	List<ClientConfig> clients=new ArrayList<ClientConfig>();
	Node rootNode=getRootNode();
	String filePath = processPath(project) + "/" + CLIENT_CONFIG_FILE;
	Node fileNode = rootNode.getNode(filePath);
	Property property = fileNode.getProperty(DATA);
	Binary fileBinary = property.getBinary();
	InputStream inputStream = fileBinary.getStream();
	String content = IOUtils.toString(inputStream, "utf-8");
	inputStream.close();
	Document document = DocumentHelper.parseText(content);
	Element rootElement = document.getRootElement();
	for (Object obj : rootElement.elements()) {
		if (!(obj instanceof Element)) {
			continue;
		}
		Element element = (Element) obj;
		if (!element.getName().equals("item")) {
			continue;
		}
		ClientConfig client = new ClientConfig();
		client.setName(element.attributeValue("name"));
		client.setClient(element.attributeValue("client"));
		client.setProject(project);
		clients.add(client);
	}
	return clients;
}
 
開發者ID:youseries,項目名稱:urule,代碼行數:33,代碼來源:RepositoryServiceImpl.java

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

示例13: deleteFile

import javax.jcr.Node; //導入方法依賴的package包/類
public void deleteFile(String path,User user) throws Exception{
	if(!permissionService.fileHasWritePermission(path)){
		throw new NoPermissionException();
	}
	repositoryInteceptor.deleteFile(path);
	path = processPath(path);
	Node rootNode=getRootNode();
	if (!rootNode.hasNode(path)) {
		throw new RuleException("File [" + path + "] not exist.");
	}
	String[] subpaths = path.split("/");
	Node fileNode = rootNode;
	for (String subpath : subpaths) {
		if (StringUtils.isEmpty(subpath)) {
			continue;
		}
		String subDirs[] = subpath.split("\\.");
		for (String dir : subDirs) {
			if (StringUtils.isEmpty(dir)) {
				continue;
			}
			if (!fileNode.hasNode(dir)) {
				continue;
			}
			fileNode = fileNode.getNode(dir);
			lockCheck(fileNode,user);
			if (!fileNode.isCheckedOut()) {
				versionManager.checkout(fileNode.getPath());
			}
		}
	}
	fileNode = rootNode.getNode(path);
	lockCheck(fileNode,user);
	if (!fileNode.isCheckedOut()) {
		versionManager.checkout(fileNode.getPath());
	}
	fileNode.remove();
	session.save();
}
 
開發者ID:youseries,項目名稱:urule,代碼行數:40,代碼來源:RepositoryServiceImpl.java

示例14: getFiles

import javax.jcr.Node; //導入方法依賴的package包/類
private List<String> getFiles(Node rootNode,String path) throws Exception{
	String project=getProject(path);
	List<String> list=new ArrayList<String>();
	Node projectNode=rootNode.getNode(project);		
	buildPath(list, projectNode);
	return list;
}
 
開發者ID:youseries,項目名稱:urule,代碼行數:8,代碼來源:RepositoryServiceImpl.java

示例15: getFiles

import javax.jcr.Node; //導入方法依賴的package包/類
public List<String> getFiles(Node rootNode,String path){
	String project=getProject(path);
	try{
		List<String> list=new ArrayList<String>();
		Node projectNode=rootNode.getNode(project);		
		buildPath(list, projectNode);
		return list;
	}catch(Exception ex){
		throw new RuleException(ex);
	}
}
 
開發者ID:youseries,項目名稱:urule,代碼行數:12,代碼來源:RepositoryRefactor.java


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