当前位置: 首页>>代码示例>>Java>>正文


Java Node类代码示例

本文整理汇总了Java中javax.jcr.Node的典型用法代码示例。如果您正苦于以下问题:Java Node类的具体用法?Java Node怎么用?Java Node使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Node类属于javax.jcr包,在下文中一共展示了Node类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: copyNode

import javax.jcr.Node; //导入依赖的package包/类
/**
 * Copies nodes.
 *
 * @param node              Node to copy
 * @param destinationParent Destination parent node
 * @throws RepositoryException if problem with jcr repository occurred
 */
public void copyNode(Node node, Node destinationParent) throws RepositoryException {
  LOG.debug("Copying node '{}' into '{}'", node.getPath(), destinationParent.getPath());
  Node newNode = destinationParent.addNode(node.getName(), node.getPrimaryNodeType().getName());
  PropertyIterator it = node.getProperties();
  while (it.hasNext()) {
    Property property = it.nextProperty();
    if (!property.getDefinition().isProtected()) {
      newNode
          .setProperty(property.getName(), property.getValue().getString(), property.getType());
    }
  }
  NodeIterator nodeIterator = node.getNodes();
  while (nodeIterator.hasNext()) {
    copyNode(nodeIterator.nextNode(), newNode);
  }
}
 
开发者ID:Cognifide,项目名称:bobcat,代码行数:24,代码来源:JcrHelper.java

示例2: buildPath

import javax.jcr.Node; //导入依赖的package包/类
private void buildPath(List<String> list, Node parentNode) throws RepositoryException {
	NodeIterator nodeIterator=parentNode.getNodes();
	while(nodeIterator.hasNext()){
		Node node=nodeIterator.nextNode();
		String nodePath=node.getPath();
		if(nodePath.endsWith(FileType.Ruleset.toString())){
			list.add(nodePath);
		}else if(nodePath.endsWith(FileType.UL.toString())){
			list.add(nodePath);
		}else if(nodePath.endsWith(FileType.DecisionTable.toString())){
			list.add(nodePath);
		}else if(nodePath.endsWith(FileType.ScriptDecisionTable.toString())){
			list.add(nodePath);
		}else if(nodePath.endsWith(FileType.DecisionTree.toString())){
			list.add(nodePath);					
		}else if(nodePath.endsWith(FileType.RuleFlow.toString())){
			list.add(nodePath);					
		}
		buildPath(list,node);
	}
}
 
开发者ID:youseries,项目名称:urule,代码行数:22,代码来源:RepositoryServiceImpl.java

示例3: process

import javax.jcr.Node; //导入依赖的package包/类
@Override
public void process(final ExecutionContext executionContext, final TemplateContentModelImpl contentModel)
        throws ProcessException {
    SlingHttpServletRequest request = (SlingHttpServletRequest) executionContext.get(SLING_HTTP_REQUEST);
    Resource resource = request.getResource();
    Map<String, Object> content = (contentModel.has(RESOURCE_CONTENT_KEY)) ? ((Map<String, Object>) contentModel.get(RESOURCE_CONTENT_KEY)) : new HashMap<String, Object>();

    if (resource != null) {
        Node node = resource.adaptTo(Node.class);
        if (node != null) {
            String componentContentId = DigestUtils.md5Hex(resource.getPath());
            content.put(XK_CONTENT_ID_CP, componentContentId);
        } else {
            content.put(XK_CONTENT_ID_CP, "_NONE");
        }
        content.put(PATH, resource.getPath());
        content.put(NAME, resource.getName());
    }
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:20,代码来源:AddBasicResourcePropertiesContextProcessor.java

示例4: getSinglePropertyAs

import javax.jcr.Node; //导入依赖的package包/类
/**
 * Takes type, resource, and propertyName and returns its value of the object based on the given type
 *
 * @param type This is type parameter
 * @param resource The resource to fetch the value from
 * @param propertyName The property name to be used to fetch the value from the resource
 * @return value The value of the object based on the given type
 */
private static <T> T getSinglePropertyAs(Class<T> type, Resource resource, String propertyName) {
    T val = null;
    try {
        if (null != resource) {
            Node node = resource.adaptTo(Node.class);
            if (null != node) {
                if (node.hasProperty(propertyName)) {
                    Property property = node.getProperty(propertyName);
                    if (!property.isMultiple()) {
                        Value value = property.getValue();
                        val = PropertyUtils.as(type, value);
                    }
                }
            }
        }
    } catch (Exception e) {
        LOG.error(ERROR, e);
    }
    return val;
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:29,代码来源:ResourceUtils.java

示例5: getMultiplePropertyAs

import javax.jcr.Node; //导入依赖的package包/类
/**
 * Takes type, resource, and property name and returns the list of value of the object based on the given type
 *
 * @param type This is type parameter
 * @param resource The resource to fetch the value from
 * @param propertyName The property name to be used to fetch the value from the resource
 * @return valueList The list of values of the object based on the given type
 */
private static <T> List<T> getMultiplePropertyAs(Class<T> type, Resource resource, String propertyName) {
    List<T> val = Collections.EMPTY_LIST;
    try {
        if (null != resource) {
            Node node = resource.adaptTo(Node.class);
            if (null != node) {
                if (node.hasProperty(propertyName)) {
                    Property property = node.getProperty(propertyName);
                    if (property.isMultiple()) {
                        Value[] value = property.getValues();
                        val = PropertyUtils.as(type, value);
                    }
                }
            }
        }
    } catch (Exception e) {
        LOG.error(ERROR, e);
    }
    return val;
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:29,代码来源:ResourceUtils.java

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

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

示例8: setFieldExternalDocuments

import javax.jcr.Node; //导入依赖的package包/类
/**
 * This method sets what data form the external source should be stored on the document.
 * In this case it stores the entire json object as string
 *
 * @param context
 * @param exdocs
 */
@Override
public void setFieldExternalDocuments(ExternalDocumentServiceContext context, ExternalDocumentCollection<JSONObject> exdocs) {
    final String fieldName = context.getPluginConfig().getString(PARAM_EXTERNAL_DOCS_FIELD_NAME);

    if (StringUtils.isBlank(fieldName)) {
        throw new IllegalArgumentException("Invalid plugin configuration parameter for '" + PARAM_EXTERNAL_DOCS_FIELD_NAME + "': " + fieldName);
    }

    try {
        final Node contextNode = context.getContextModel().getNode();
        final List<String> docIds = new ArrayList<String>();

        for (Iterator<? extends JSONObject> it = exdocs.iterator(); it.hasNext(); ) {
            JSONObject doc = it.next();
            docIds.add(doc.toString());
        }

        contextNode.setProperty(fieldName, docIds.toArray(new String[docIds.size()]));
    } catch (RepositoryException e) {
        log.error("Failed to set related exdoc array field.", e);
    }
}
 
开发者ID:jenskooij,项目名称:hippo-external-document-picker-example-implementation,代码行数:30,代码来源:DocumentServiceFacade.java

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

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

示例11: buildDirectories

import javax.jcr.Node; //导入依赖的package包/类
private void buildDirectories(Node node, List<RepositoryFile> fileList, String projectPath) throws Exception {
	NodeIterator nodeIterator = node.getNodes();
	while (nodeIterator.hasNext()) {
		Node dirNode = nodeIterator.nextNode();
		if (!dirNode.hasProperty(FILE)) {
			continue;
		}
		if (!dirNode.hasProperty(DIR_TAG)) {
			continue;
		}
		RepositoryFile file = new RepositoryFile();
		file.setName(dirNode.getPath().substring(projectPath.length()));
		file.setFullPath(dirNode.getPath());
		buildDirectories(dirNode, fileList, projectPath);
		fileList.add(file);
	}
}
 
开发者ID:youseries,项目名称:urule,代码行数:18,代码来源:RepositoryServiceImpl.java

示例12: buildProjectFile

import javax.jcr.Node; //导入依赖的package包/类
private RepositoryFile buildProjectFile(Node projectNode,FileType[] types,boolean classify,String searchFileName) throws Exception{
	RepositoryFile projectFile = new RepositoryFile();
	projectFile.setType(Type.project);
	projectFile.setName(projectNode.getName());
	projectFile.setFullPath("/" + projectNode.getName());
	RepositoryFile resDir = new RepositoryFile();
	resDir.setFullPath(projectFile.getFullPath());
	resDir.setName("资源");
	if((types==null || types.length==0) && permissionService.projectPackageHasReadPermission(projectNode.getPath())){
		RepositoryFile packageFile = new RepositoryFile();
		packageFile.setName("知识包");
		packageFile.setType(Type.resourcePackage);
		packageFile.setFullPath(projectFile.getFullPath());
		projectFile.addChild(packageFile, false);
	}
	if(classify){
		resDir.setType(Type.resource);
		createResourceCategory(projectNode, resDir,types,searchFileName);			
	}else{
		resDir.setType(Type.all);
		buildResources(projectNode, resDir, types,searchFileName);
	}
	projectFile.addChild(resDir, false);
	return projectFile;
}
 
开发者ID:youseries,项目名称:urule,代码行数:26,代码来源:RepositoryServiceImpl.java

示例13: unlockAllChildNodes

import javax.jcr.Node; //导入依赖的package包/类
private void unlockAllChildNodes(Node node,User user,List<Node> nodeList,String rootPath) throws Exception{
	NodeIterator iter=node.getNodes();
	while(iter.hasNext()){
		Node nextNode=iter.nextNode();
		String absPath=nextNode.getPath();
		if(!lockManager.isLocked(absPath)){
			continue;
		}
		Lock lock=lockManager.getLock(absPath);
		String owner=lock.getLockOwner();
		if(!user.getUsername().equals(owner)){
			throw new NodeLockException("当前目录下有子目录被其它人锁定,您不能执行锁定"+rootPath+"目录");
		}
		nodeList.add(nextNode);
		unlockAllChildNodes(nextNode, user, nodeList, rootPath);
	}
}
 
开发者ID:youseries,项目名称:urule,代码行数:18,代码来源:RepositoryServiceImpl.java

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

示例15: getReferenceFiles

import javax.jcr.Node; //导入依赖的package包/类
@Override
public List<String> getReferenceFiles(String path,String searchText) throws Exception{
	Node rootNode=getRootNode();
	List<String> referenceFiles=new ArrayList<String>();
	List<String> files=getFiles(rootNode, path);
	for(String nodePath:files){
		InputStream inputStream=readFile(nodePath,null);
		try {
			String content = IOUtils.toString(inputStream);
			inputStream.close();
			boolean containPath=content.contains(path);
			boolean containText=content.contains(searchText);
			if(containPath && containText){
				referenceFiles.add(nodePath);
			}
		} catch (IOException e) {
			throw new RuleException(e);
		}
	}
	return referenceFiles;
}
 
开发者ID:youseries,项目名称:urule,代码行数:22,代码来源:RepositoryServiceImpl.java


注:本文中的javax.jcr.Node类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。