public int getIndex() { return getPath().getNormalizedIndex(); }
public int getIndex() { return getPath().getNormalizedIndex(); }
@Override public final boolean equals(Object that) { if (this == that) { return true; } else if (that instanceof Path) { Path path = (Path) that; return path.denotesName() && name.equals(path.getName()) && getNormalizedIndex() == path.getNormalizedIndex() && super.equals(that); } else { return false; } }
@Override public final boolean equals(Object that) { if (this == that) { return true; } else if (that instanceof Path) { Path path = (Path) that; return path.denotesName() && name.equals(path.getName()) && getNormalizedIndex() == path.getNormalizedIndex() && super.equals(that); } else { return false; } }
public static Operation create( NodeState parentState, Path srcPath, Path beforePath) throws ItemNotFoundException, RepositoryException { // make sure the parent hierarchy entry has its child entries loaded assertChildNodeEntries(parentState); NodeState insert = parentState.getChildNodeState( srcPath.getName(), srcPath.getNormalizedIndex()); NodeState before = null; if (beforePath != null) { before = parentState.getChildNodeState( beforePath.getName(), beforePath.getNormalizedIndex()); } return new ReorderNodes(parentState, insert, before); } }
public static Operation create( NodeState parentState, Path srcPath, Path beforePath) throws ItemNotFoundException, RepositoryException { // make sure the parent hierarchy entry has its child entries loaded assertChildNodeEntries(parentState); NodeState insert = parentState.getChildNodeState( srcPath.getName(), srcPath.getNormalizedIndex()); NodeState before = null; if (beforePath != null) { before = parentState.getChildNodeState( beforePath.getName(), beforePath.getNormalizedIndex()); } return new ReorderNodes(parentState, insert, before); } }
private Path calcRemovePath(Path removedNodePath) throws RepositoryException { removed.put(removedNodePath, removedNodePath); Name name = removedNodePath.getName(); int index = removedNodePath.getNormalizedIndex(); if (index > Path.INDEX_DEFAULT) { Path.Element[] elems = removedNodePath.getElements(); PathBuilder pb = new PathBuilder(); for (int i = 0; i <= elems.length - 2; i++) { pb.addLast(elems[i]); } Path parent = pb.getPath(); while (index > Path.INDEX_UNDEFINED) { Path siblingP = getPathFactory().create(parent, name, --index, true); if (removed.containsKey(siblingP)) { // as the previous sibling has been remove -> the same index // must be used to remove the node at removedNodePath. siblingP = removed.get(siblingP); removed.put(removedNodePath, siblingP); return siblingP; } } } // first of siblings or no sibling at all return removedNodePath; } }
private Path calcRemovePath(Path removedNodePath) throws RepositoryException { removed.put(removedNodePath, removedNodePath); Name name = removedNodePath.getName(); int index = removedNodePath.getNormalizedIndex(); if (index > Path.INDEX_DEFAULT) { Path.Element[] elems = removedNodePath.getElements(); PathBuilder pb = new PathBuilder(); for (int i = 0; i <= elems.length - 2; i++) { pb.addLast(elems[i]); } Path parent = pb.getPath(); while (index > Path.INDEX_UNDEFINED) { Path siblingP = getPathFactory().create(parent, name, --index, true); if (removed.containsKey(siblingP)) { // as the previous sibling has been remove -> the same index // must be used to remove the node at removedNodePath. siblingP = removed.get(siblingP); removed.put(removedNodePath, siblingP); return siblingP; } } } // first of siblings or no sibling at all return removedNodePath; } }
private NodeId calcRemoveNodeId(ItemId itemId) throws MalformedPathException { NodeId nodeId = (NodeId) itemId; Path p = itemId.getPath(); if (p != null) { removedNodeIds.add(nodeId); int index = p.getNormalizedIndex(); if (index > Path.INDEX_DEFAULT) { Path.Element[] elems = p.getElements(); PathBuilder pb = new PathBuilder(); for (int i = 0; i <= elems.length - 2; i++) { pb.addLast(elems[i]); } pb.addLast(p.getName(), index - 1); NodeId prevSibling = idFactory.createNodeId(itemId.getUniqueID(), pb.getPath()); if (removedNodeIds.contains(prevSibling)) { nodeId = prevSibling; } } } return nodeId; }
private NodeId calcRemoveNodeId(ItemId itemId) throws MalformedPathException { NodeId nodeId = (NodeId) itemId; Path p = itemId.getPath(); if (p != null) { removedNodeIds.add(nodeId); int index = p.getNormalizedIndex(); if (index > Path.INDEX_DEFAULT) { Path.Element[] elems = p.getElements(); PathBuilder pb = new PathBuilder(); for (int i = 0; i <= elems.length - 2; i++) { pb.addLast(elems[i]); } pb.addLast(p.getName(), index - 1); NodeId prevSibling = idFactory.createNodeId(itemId.getUniqueID(), pb.getPath()); if (removedNodeIds.contains(prevSibling)) { nodeId = prevSibling; } } } return nodeId; }
/** * Returns <code>true</code> if the item corresponding to the specified * <code>eventState</code> can be read the the current session. * * @param eventState * @return * @throws RepositoryException */ private boolean canRead(EventState eventState) throws RepositoryException { Path targetPath = pathFactory.create(eventState.getParentPath(), eventState.getChildRelPath().getName(), eventState.getChildRelPath().getNormalizedIndex(), true); return session.getAccessManager().isGranted(targetPath, Permission.READ); } }
/** * Returns <code>true</code> if the item corresponding to the specified * <code>eventState</code> can be read the the current session. * * @param eventState * @return * @throws RepositoryException */ private boolean canRead(EventState eventState) throws RepositoryException { Path targetPath = pathFactory.create(eventState.getParentPath(), eventState.getChildRelPath().getName(), eventState.getChildRelPath().getNormalizedIndex(), true); return session.getAccessManager().isGranted(targetPath, Permission.READ); } }
/** * Searches the child-entries of this NodeEntry for a matching child. * Since {@link #refresh(Event)} must always be called on the parent * NodeEntry, there is no need to check if a given event id would point * to this NodeEntry itself. * * @param eventId * @param eventPath * @return the entry or <code>null</code> if the matching entry has a status * <code>Status#NEW</code>. */ private HierarchyEntry lookupEntry(ItemId eventId, Path eventPath) { Name childName = eventPath.getName(); HierarchyEntry child; if (eventId.denotesNode()) { String uniqueChildID = (eventId.getPath() == null) ? eventId.getUniqueID() : null; int index = eventPath.getNormalizedIndex(); child = lookupNodeEntry(uniqueChildID, childName, index); } else { child = lookupPropertyEntry(childName); } return child; }
/** * Searches the child-entries of this NodeEntry for a matching child. * Since {@link #refresh(Event)} must always be called on the parent * NodeEntry, there is no need to check if a given event id would point * to this NodeEntry itself. * * @param eventId * @param eventPath * @return the entry or <code>null</code> if the matching entry has a status * <code>Status#NEW</code>. */ private HierarchyEntry lookupEntry(ItemId eventId, Path eventPath) { Name childName = eventPath.getName(); HierarchyEntry child; if (eventId.denotesNode()) { String uniqueChildID = (eventId.getPath() == null) ? eventId.getUniqueID() : null; int index = eventPath.getNormalizedIndex(); child = lookupNodeEntry(uniqueChildID, childName, index); } else { child = lookupPropertyEntry(childName); } return child; }
p.getName(), p.getNormalizedIndex()); if (cne != null) { return cne.getId();
p.getName(), p.getNormalizedIndex()); if (cne != null) { return cne.getId();
rp.getName(), rp.getNormalizedIndex(), true);
rp.getName(), rp.getNormalizedIndex(), true);
int index = eventPath.getNormalizedIndex(); internalAddNodeEntry(eventName, uniqueChildID, index); } else {
int index = eventPath.getNormalizedIndex(); internalAddNodeEntry(eventName, uniqueChildID, index); } else {