本文整理匯總了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);
}
}
示例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);
}
}
示例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();
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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("]"));
}
示例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("]"));
}
示例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();
}
}
示例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();
}
}
示例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);
}
}
}
示例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;
}