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


Java NodeIterator.hasNext方法代码示例

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


在下文中一共展示了NodeIterator.hasNext方法的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: 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

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

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

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

示例14: addChildMap

import javax.jcr.NodeIterator; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void addChildMap(Field field, Object obj, Node node, String nodeName, Mapper mapper) throws RepositoryException, IllegalAccessException {

    Map<String, Object> map = (Map<String, Object>) field.get(obj);
    boolean nullOrEmpty = map == null || map.isEmpty();
    // remove the child node
    NodeIterator nodeIterator = node.getNodes(nodeName);
    while (nodeIterator.hasNext()) {
        nodeIterator.nextNode().remove();
    }
    // add the map as a child node
    Node childContainer = node.addNode(mapper.getCleanName(nodeName));
    if (!nullOrEmpty) {
        for (Map.Entry<String, Object> entry : map.entrySet()) {
            mapToProperty(entry.getKey(), ReflectionUtils.getParameterizedClass(field, 1), null, entry.getValue(), childContainer);
        }
    }
}
 
开发者ID:dooApp,项目名称:jcromfx,代码行数:19,代码来源:PropertyMapper.java

示例15: queryForVanityUrlNode

import javax.jcr.NodeIterator; //导入方法依赖的package包/类
/**
 * Query for a vanity url node.
 *
 * @param vanityUrl vanity url from request
 * @param siteName  site name from aggegation state
 * @return first vanity url node of result or null, if nothing found
 */
public Node queryForVanityUrlNode(final String vanityUrl, final String siteName) {
    Node node = null;

    try {
        Session jcrSession = MgnlContext.getJCRSession(VanityUrlModule.WORKSPACE);
        QueryManager queryManager = jcrSession.getWorkspace().getQueryManager();
        Query query = queryManager.createQuery(QUERY, JCR_SQL2);
        query.bindValue(PN_VANITY_URL, new StringValue(vanityUrl));
        query.bindValue(PN_SITE, new StringValue(siteName));
        QueryResult queryResult = query.execute();
        NodeIterator nodes = queryResult.getNodes();
        if (nodes.hasNext()) {
            node = nodes.nextNode();
        }
    } catch (RepositoryException e) {
        LOGGER.error("Error message.", e);
    }

    return node;
}
 
开发者ID:aperto,项目名称:magnolia-vanity-url,代码行数:28,代码来源:VanityUrlService.java


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