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