當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。