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


Java NodeIterator类代码示例

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


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

示例1: copyNode

import javax.jcr.NodeIterator; //导入依赖的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.NodeIterator; //导入依赖的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: queryJcrContent

import javax.jcr.NodeIterator; //导入依赖的package包/类
String queryJcrContent(Session session) throws RepositoryException {

    // get query manager
    QueryManager queryManager = session.getWorkspace().getQueryManager();

    // query for all nodes with tag "JCR"
    Query query = queryManager.createQuery("/jcr:root/content/adaptto//*[tags='JCR']", Query.XPATH);

    // iterate over results
    QueryResult result = query.execute();
    NodeIterator nodes = result.getNodes();
    StringBuilder output = new StringBuilder();
    while (nodes.hasNext()) {
      Node node = nodes.nextNode();
      output.append("path=" + node.getPath() + "\n");
    }

    return output.toString();
  }
 
开发者ID:adaptto,项目名称:2015-sling-rookie-session,代码行数:20,代码来源:JcrQuerySample.java

示例4: buildDirectories

import javax.jcr.NodeIterator; //导入依赖的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

示例5: unlockAllChildNodes

import javax.jcr.NodeIterator; //导入依赖的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

示例6: purge

import javax.jcr.NodeIterator; //导入依赖的package包/类
private void purge(final Context context, final ActionResult actionResult)
		throws RepositoryException, ActionExecutionException {
	NodeIterator iterator = getPermissions(context);
	String normalizedPath = normalizePath(path);
	while (iterator != null && iterator.hasNext()) {
		Node node = iterator.nextNode();
		if (node.hasProperty(PermissionConstants.REP_ACCESS_CONTROLLED_PATH)) {
			String parentPath = node.getProperty(PermissionConstants.REP_ACCESS_CONTROLLED_PATH)
					.getString();
			String normalizedParentPath = normalizePath(parentPath);
			boolean isUsersPermission = parentPath.startsWith(context.getCurrentAuthorizable().getPath());
			if (StringUtils.startsWith(normalizedParentPath, normalizedPath) && !isUsersPermission) {
				RemoveAll removeAll = new RemoveAll(parentPath);
				ActionResult removeAllResult = removeAll.execute(context);
				if (Status.ERROR.equals(removeAllResult.getStatus())) {
					actionResult.logError(removeAllResult);
				}
			}
		}
	}
}
 
开发者ID:Cognifide,项目名称:APM,代码行数:22,代码来源:Purge.java

示例7: getWrappedNodesFromQuery

import javax.jcr.NodeIterator; //导入依赖的package包/类
/**
 * Query news items using JCR SQL2 syntax.
 *
 * @param query         Query string
 * @param maxResultSize Max results returned
 * @param pageNumber    paging number
 * @param nodeTypeName  Node type
 * @return List List of news item nodes
 * @throws javax.jcr.RepositoryException Repository Exceotopn
 */
public static List<Node> getWrappedNodesFromQuery(String query, int maxResultSize, int pageNumber, String nodeTypeName) throws RepositoryException {
    final List<Node> itemsListPaged = new ArrayList<>(0);
    final NodeIterator items = QueryUtil.search(NewsRepositoryConstants.COLLABORATION, query, Query.JCR_SQL2, nodeTypeName);

    // Paging result set
    final int startRow = (maxResultSize * (pageNumber - 1));
    if (startRow > 0) {
        try {
            items.skip(startRow);
        } catch (NoSuchElementException e) {
            LOGGER.error("No more news items found beyond this item number: {}", startRow);
        }
    }

    int count = 1;
    while (items.hasNext() && count <= maxResultSize) {
        itemsListPaged.add(new I18nNodeWrapper(items.nextNode()));
        count++;
    }
    return itemsListPaged;
}
 
开发者ID:tricode,项目名称:magnolia-news,代码行数:32,代码来源:NewsJcrUtils.java

示例8: executeQuery

import javax.jcr.NodeIterator; //导入依赖的package包/类
/**
 * Execute JCR query returning Nodes matching given statement and return node type
 *
 * @param statement      JCR query string
 * @param workspace      Search in JCR workspace like website
 * @param returnItemType Return nodes based on primary node type
 * @return List<Node>
 * @throws javax.jcr.RepositoryException
 */
private static List<Node> executeQuery(final String statement,
                                       final String workspace,
                                       final String returnItemType) throws RepositoryException {
    List<Node> nodeList = new ArrayList<>(0);

    NodeIterator items = QueryUtil.search(workspace, statement, Query.JCR_SQL2, returnItemType);

    LOGGER.debug("Query Executed: {}", statement);

    while (items.hasNext()) {
        Node node = items.nextNode();
        nodeList.add(new I18nNodeWrapper(node));
    }
    return nodeList;
}
 
开发者ID:tricode,项目名称:magnolia-blog,代码行数:25,代码来源:BlogServiceImpl.java

示例9: getWrappedNodesFromQuery

import javax.jcr.NodeIterator; //导入依赖的package包/类
private static List<Node> getWrappedNodesFromQuery(String query, int maxResultSize, int pageNumber, String nodeTypeName, String workspace) throws RepositoryException {
    final List<Node> itemsListPaged = new ArrayList<>(0);
    final NodeIterator items = QueryUtil.search(workspace, query, Query.JCR_SQL2, nodeTypeName);

    // Paging result set
    final int startRow = (maxResultSize * (pageNumber - 1));
    if (startRow > 0) {
        try {
            items.skip(startRow);
        } catch (NoSuchElementException e) {
            LOGGER.info("No more blog items found beyond this item number: {}", startRow);
        }
    }

    int count = 1;
    while (items.hasNext() && count <= maxResultSize) {
        itemsListPaged.add(new I18nNodeWrapper(items.nextNode()));
        count++;
    }
    return itemsListPaged;
}
 
开发者ID:tricode,项目名称:magnolia-blog,代码行数:22,代码来源:BlogJcrUtils.java

示例10: getAllowedChildNodesContentMapsOf

import javax.jcr.NodeIterator; //导入依赖的package包/类
private Collection<EntryableContentMap> getAllowedChildNodesContentMapsOf(Node n, int levels) {
    try {
        Collection<EntryableContentMap> childNodes = new LinkedList<EntryableContentMap>();
        NodeIterator nodes = n.getNodes();
        asNodeStream(nodes)
        .filter(this::isSearchInNodeType)
        .forEach(new PredicateSplitterConsumer<Node>(this::isOfAllowedDepthAndType,
                allowedNode -> childNodes.add(new EntryableContentMap(this.cloneWith(allowedNode))),
                allowedParent -> childNodes.addAll(this.getAllowedChildNodesContentMapsOf(allowedParent, levels + 1))));
        return childNodes;
    } catch (RepositoryException e) {
        // failed to get child nodes
        log.error(e.getMessage(), e);
        return Collections.EMPTY_LIST;
    }
}
 
开发者ID:rah003,项目名称:neat-jsonfn,代码行数:17,代码来源:JsonBuilder.java

示例11: testExpandAndFilterWithChildren

import javax.jcr.NodeIterator; //导入依赖的package包/类
/**
 * jsonfn.from(content).expand("baz", "category").exclude(".*:.*").print()
 *
 * ==> { "foo" : "hahaha", "baz" : {"identifier" : "1234-123456-1234", "name" : "cat1"}, b: 1234, "bar" : "meh", ... }
 */
@Test
public void testExpandAndFilterWithChildren() throws Exception {
    Node node = session.getNode("/home/section/article/mgnl:apex");
    NodeIterator iter = node.getNodes();
    while (iter.hasNext()) {
        iter.nextNode().setProperty("baz", catNode.getIdentifier());
    }
    session.save();
    // WHEN
    String json = JsonTemplatingFunctions.fromChildNodesOf(node).expand("baz", "category").add("@name").add("name").print();
    // THEN
    assertThat(json, startsWith("["));
    assertThat(json, allOf(containsString("\"alias\""), containsString("\"alias2\""), containsString("\"alias3\""), containsString("\"alias4\""), containsString("\"alias5\""), containsString("\"alias6\"")));
    assertThat(json, not(containsString("\"" + node.getIdentifier() + "\"")));
    assertThat(json, not(containsString("\"jcr:created\" : ")));
    assertThat(json, containsString("\"baz\" : {"));
    assertThat(json, containsString("\"name\" : \"myCategory\""));
    assertThat(json, endsWith("]"));
}
 
开发者ID:rah003,项目名称:neat-jsonfn,代码行数:25,代码来源:JsonBuilderTest.java

示例12: testExpandAndFilterAndRepeatWithChildren

import javax.jcr.NodeIterator; //导入依赖的package包/类
/**
 * jsonfn.from(content).expand("baz", "category").down(4).print()
 *
 * ==> { "foo" : "hahaha", "baz" : {"identifier" : "1234-123456-1234", "name" : "cat1"}, b: 1234, "bar" : "meh", ... }
 */
@Test
public void testExpandAndFilterAndRepeatWithChildren() throws Exception {
    // GIVEN
    Node node = session.getNode("/home/section/article/mgnl:apex");
    NodeIterator iter = node.getNodes();
    while (iter.hasNext()) {
        iter.nextNode().setProperty("baz", catNode.getIdentifier());
    }
    node.getNode("alias2").addNode("level3", "mgnl:contentNode").addNode("level4", "mgnl:contentNode").addNode("level5", "mgnl:contentNode");
    session.save();
    // WHEN
    String json = JsonTemplatingFunctions.fromChildNodesOf(node).expand("baz", "category").down(3).add("@name").print();

    // THEN
    assertThat(json, startsWith("["));
    assertThat(json, allOf(containsString("\"alias\""), containsString("\"alias2\""), containsString("\"alias3\""), containsString("\"alias4\""), containsString("\"alias5\""), containsString("\"alias6\"")));
    assertThat(json, not(containsString("\"" + node.getIdentifier() + "\"")));
    assertThat(json, not(containsString("\"jcr:created\" : ")));
    assertThat(json, containsString("\"baz\" : {"));
    assertThat(json, containsString("\"@name\" : \"foo\""));
    assertThat(json, containsString("\"@name\" : \"level4\""));
    assertThat(json, not(containsString("\"@name\" : \"level5\"")));
    assertThat(json, endsWith("]"));
}
 
开发者ID:rah003,项目名称:neat-jsonfn,代码行数:30,代码来源:JsonBuilderTest.java

示例13: singleRun

import javax.jcr.NodeIterator; //导入依赖的package包/类
private void singleRun() throws Exception {
    Session session = MgnlContext.getInstance().getJCRSession("website");
    NodeIterator iter = session.getNode("/home").getNodes();
    String json = "[]";
    int count = 0;
    while (iter.hasNext()) {
        count++;
        Node n = iter.nextNode();
        json = JsonTemplatingFunctions.appendFrom(json, n)
                .add("name",
                        "link",
                        "linkText",
                        "displayName",
                        "partnerInContentApp",
                        "@path",
                        "mgnl:created",
                        "mgnl:activationStatus")
                .expand("categoriesFilter", "category")
                .expand("image", "dam")
                .binaryLinkRendition("zoom")
                .maskChar(':', '_')
                .wrapForI18n()
                .inline().print();
    }

}
 
开发者ID:rah003,项目名称:neat-jsonfn,代码行数:27,代码来源:JsonBuilderTest.java

示例14: getPosts

import javax.jcr.NodeIterator; //导入依赖的package包/类
/**
 * Get blog posts with pagination
 *
 * @param offset The starting point of blog posts to return.
 * @param limit The number of blog posts to return.
 * @return The blog posts.
 */
public NodeIterator getPosts(Long offset, Long limit) {
    NodeIterator nodes = null;

    if (session != null) {
        try {
            QueryManager queryManager = session.getWorkspace().getQueryManager();
            Query query = queryManager.createQuery(BLOG_QUERY, Query.JCR_SQL2);

            if (offset != null) {
                query.setOffset(offset);
            }

            if (limit != null) {
                query.setLimit(limit);
            }

            QueryResult result = query.execute();
            nodes = result.getNodes();
        } catch (RepositoryException e) {
            LOGGER.error("Could not search repository", e);
        }
    }

    return nodes;
}
 
开发者ID:nateyolles,项目名称:publick-sling-blog,代码行数:33,代码来源:BlogServiceImpl.java

示例15: getTasksComplete

import javax.jcr.NodeIterator; //导入依赖的package包/类
public void getTasksComplete(Card card) throws Exception {
    ObjectContentManager ocm = ocmFactory.getOcm();
    try{	        
    	
     Node node = ocm.getSession().getNode(String.format(URI.TASKS_URI, card.getBoard(), card.getPhase(), card.getId().toString(),""));  
     int complete = 0;
     NodeIterator nodes = node.getNodes();
     while(nodes.hasNext()){
         Node nextNode = nodes.nextNode();
         Property property = nextNode.getProperty("complete");
         if( property!=null && property.getBoolean() ){
         	complete++;
         }
     }
     card.setCompleteTasks(Long.valueOf(complete));
     
    } finally {
    	ocm.logout();
    }              
}
 
开发者ID:cheetah100,项目名称:gravity,代码行数:21,代码来源:PhaseController.java


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