use of org.apache.jackrabbit.spi.commons.name.PathBuilder in project jackrabbit by apache.
the class AggregateRuleImpl method getPropertyIncludes.
/**
* Creates property includes defined in the <code>config</code>.
*
* @param config the indexing aggregate configuration.
* @return the property includes defined in the <code>config</code>.
* @throws MalformedPathException if a path in the configuration is
* malformed.
* @throws IllegalNameException if the node type name contains illegal
* characters.
* @throws NamespaceException if the node type contains an unknown
* prefix.
* @throws RepositoryException If the PropertyInclude cannot be builded
* due to unknown ancestor relationship.
*/
private PropertyInclude[] getPropertyIncludes(Node config) throws MalformedPathException, IllegalNameException, NamespaceException, RepositoryException {
List<PropertyInclude> includes = new ArrayList<PropertyInclude>();
NodeList childNodes = config.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
Node n = childNodes.item(i);
if (n.getNodeName().equals("include-property")) {
PathBuilder builder = new PathBuilder();
for (String element : Text.explode(getTextContent(n), '/')) {
if (element.equals("*")) {
throw new IllegalNameException("* not supported in include-property");
}
builder.addLast(resolver.getQName(element));
}
includes.add(new PropertyInclude(builder.getPath()));
}
}
return includes.toArray(new PropertyInclude[includes.size()]);
}
use of org.apache.jackrabbit.spi.commons.name.PathBuilder in project jackrabbit by apache.
the class NodeEntryImpl method buildPath.
/**
* @see HierarchyEntryImpl#buildPath(boolean)
*/
@Override
Path buildPath(boolean wspPath) throws RepositoryException {
PathFactory pf = getPathFactory();
// shortcut for root state
if (parent == null) {
return pf.getRootPath();
}
// build path otherwise
PathBuilder builder = new PathBuilder(pf);
buildPath(builder, this, wspPath);
return builder.getPath();
}
use of org.apache.jackrabbit.spi.commons.name.PathBuilder in project jackrabbit by apache.
the class NodeEntryImpl method getDeepPropertyEntry.
/**
* @see NodeEntry#getDeepPropertyEntry(Path)
*/
public PropertyEntry getDeepPropertyEntry(Path path) throws PathNotFoundException, RepositoryException {
NodeEntryImpl entry = this;
Path.Element[] elems = path.getElements();
int i = 0;
for (; i < elems.length - 1; i++) {
Path.Element elem = elems[i];
if (elems[i].denotesRoot()) {
if (entry.getParent() != null) {
throw new RepositoryException("NodeEntry out of 'hierarchy' " + path.toString());
}
continue;
}
int index = elem.getNormalizedIndex();
Name name = elem.getName();
// first try to resolve to known node or property entry
NodeEntry cne = entry.getNodeEntry(name, index, false);
if (cne != null) {
entry = (NodeEntryImpl) cne;
} else {
// on the persistent layer.
if (entry.childNodeEntries.isComplete()) {
throw new PathNotFoundException(factory.saveGetJCRPath(path));
}
// -> check for moved child entry in node-attic
// -> check if child points to a removed/moved sns
List<NodeEntry> siblings = entry.childNodeEntries.get(name);
if (entry.containsAtticChild(siblings, name, index)) {
throw new PathNotFoundException(factory.saveGetJCRPath(path));
}
// break out of the loop and start deep loading the property
break;
}
}
int st = entry.getStatus();
PropertyEntry pe;
if (i == elems.length - 1 && Status.INVALIDATED != st && Status._UNDEFINED_ != st) {
// all node entries present in the hierarchy and the direct ancestor
// has already been resolved and isn't invalidated -> no need to
// retrieve property entry from SPI
pe = entry.properties.get(path.getName());
} else {
/*
* Unknown parent entry (not-existing or not yet loaded) or a parent
* entry that has been invalidated:
* Skip all intermediate entries and directly try to load the
* PropertyState (including building the intermediate entries. If that
* fails ItemNotFoundException is thrown.
*/
PathBuilder pb = new PathBuilder(getPathFactory());
for (int j = i; j < elems.length; j++) {
pb.addLast(elems[j]);
}
Path remainingPath = pb.getPath();
IdFactory idFactory = getIdFactory();
NodeId parentId = entry.getWorkspaceId();
if (remainingPath.getLength() != 1) {
parentId = idFactory.createNodeId(parentId, remainingPath.getAncestor(1));
}
PropertyId propId = idFactory.createPropertyId(parentId, remainingPath.getName());
pe = entry.loadPropertyEntry(propId);
}
if (pe == null) {
throw new PathNotFoundException(factory.saveGetJCRPath(path));
}
return pe;
}
use of org.apache.jackrabbit.spi.commons.name.PathBuilder in project jackrabbit by apache.
the class NodeEntryImpl method buildNodeId.
private static NodeId buildNodeId(NodeEntryImpl entry, PathFactory pathFactory, IdFactory idFactory, boolean wspId) throws RepositoryException {
PathBuilder pathBuilder = new PathBuilder(pathFactory);
while (entry.getParent() != null && entry.getUniqueID() == null) {
pathBuilder.addFirst(entry.getName(wspId), entry.getIndex(wspId));
entry = (wspId && entry.revertInfo != null) ? entry.revertInfo.oldParent : entry.parent;
}
// a NodeId from an uuid and a relative path.
if (entry.getParent() == null) {
pathBuilder.addRoot();
return idFactory.createNodeId((String) null, pathBuilder.getPath());
} else {
return idFactory.createNodeId(entry.getUniqueID(), pathBuilder.getPath());
}
}
use of org.apache.jackrabbit.spi.commons.name.PathBuilder in project jackrabbit by apache.
the class EventStateCollection method prefixPath.
/**
* Prefixes the Path <code>p</code> with {@link #pathPrefix}.
*
* @param p the Path to prefix.
* @return the prefixed path or <code>p</code> itself if {@link #pathPrefix}
* is <code>null</code>.
* @throws RepositoryException if the path cannot be prefixed.
*/
private Path prefixPath(Path p) throws RepositoryException {
if (pathPrefix == null) {
return p;
}
PathBuilder builder = new PathBuilder(pathPrefix.getElements());
Path.Element[] elements = p.getElements();
for (int i = 0; i < elements.length; i++) {
if (elements[i].denotesRoot()) {
continue;
}
builder.addLast(elements[i]);
}
return builder.getPath();
}
Aggregations