use of org.apache.jackrabbit.spi.commons.conversion.MalformedPathException in project jackrabbit by apache.
the class JCRSQLQueryBuilder method visit.
public Object visit(ASTContainsExpression node, Object data) {
NAryQueryNode parent = (NAryQueryNode) data;
try {
Path relPath = null;
if (node.getPropertyName() != null) {
PathBuilder builder = new PathBuilder();
builder.addLast(node.getPropertyName());
relPath = builder.getPath();
}
TextsearchQueryNode tsNode = factory.createTextsearchQueryNode(parent, node.getQuery());
tsNode.setRelativePath(relPath);
tsNode.setReferencesProperty(true);
parent.addOperand(tsNode);
} catch (MalformedPathException e) {
// path is always valid
}
return parent;
}
use of org.apache.jackrabbit.spi.commons.conversion.MalformedPathException in project jackrabbit by apache.
the class NodeImpl method clone.
/**
* Create a child node that is a clone of a shareable node.
*
* @param src shareable source node
* @param name name of new node
* @return child node
* @throws ItemExistsException if there already is a child node with the
* name given and the definition does not allow creating another one
* @throws VersionException if this node is not checked out
* @throws ConstraintViolationException if no definition is found in this
* node that would allow creating the child node
* @throws LockException if this node is locked
* @throws RepositoryException if some other error occurs
*/
public synchronized NodeImpl clone(NodeImpl src, Name name) throws ItemExistsException, VersionException, ConstraintViolationException, LockException, RepositoryException {
Path nodePath;
try {
nodePath = PathFactoryImpl.getInstance().create(getPrimaryPath(), name, true);
} catch (MalformedPathException e) {
// should never happen
String msg = "internal error: invalid path " + this;
log.debug(msg);
throw new RepositoryException(msg, e);
}
// (1) make sure that parent node is checked-out
// (2) check lock status
// (3) check protected flag of parent (i.e. this) node
int options = ItemValidator.CHECK_LOCK | ItemValidator.CHECK_CHECKED_OUT | ItemValidator.CHECK_CONSTRAINTS;
sessionContext.getItemValidator().checkModify(this, options, Permission.NONE);
// (4) check for name collisions
NodeDefinitionImpl def;
try {
def = getApplicableChildNodeDefinition(name, null);
} catch (RepositoryException re) {
String msg = "no definition found in parent node's node type for new node";
log.debug(msg);
throw new ConstraintViolationException(msg, re);
}
NodeState thisState = data.getNodeState();
ChildNodeEntry cne = thisState.getChildNodeEntry(name, 1);
if (cne != null) {
// check same-name sibling setting of new node
if (!def.allowsSameNameSiblings()) {
throw new ItemExistsException(itemMgr.safeGetJCRPath(nodePath));
}
// check same-name sibling setting of existing node
NodeId newId = cne.getId();
if (!((NodeImpl) itemMgr.getItem(newId)).getDefinition().allowsSameNameSiblings()) {
throw new ItemExistsException(itemMgr.safeGetJCRPath(nodePath));
}
}
// (5) do clone operation
NodeId parentId = getNodeId();
src.addShareParent(parentId);
// (6) modify the state of 'this', i.e. the parent node
NodeId srcId = src.getNodeId();
thisState = (NodeState) getOrCreateTransientItemState();
// add new child node entry
thisState.addChildNodeEntry(name, srcId);
return itemMgr.getNode(srcId, parentId);
}
use of org.apache.jackrabbit.spi.commons.conversion.MalformedPathException in project jackrabbit by apache.
the class CachingHierarchyManager method nodeAdded.
/**
* {@inheritDoc}
*/
public void nodeAdded(NodeState state, Name name, int index, NodeId id) {
synchronized (cacheMonitor) {
if (idCache.containsKey(state.getNodeId())) {
// Optimization: ignore notifications for nodes that are not in the cache
try {
Path path = PathFactoryImpl.getInstance().create(getPath(state.getNodeId()), name, index, true);
nodeAdded(state, path, id);
checkConsistency();
} catch (PathNotFoundException e) {
log.warn("Unable to get path of node " + state.getNodeId() + ", event ignored.");
} catch (MalformedPathException e) {
log.warn("Unable to create path of " + id, e);
} catch (ItemNotFoundException e) {
log.warn("Unable to find item " + state.getNodeId(), e);
} catch (ItemStateException e) {
log.warn("Unable to find item " + id, e);
} catch (RepositoryException e) {
log.warn("Unable to get path of " + state.getNodeId(), e);
}
} else if (state.getParentId() == null && idCache.containsKey(id)) {
// A top level node was added
evictAll(id, true);
}
}
}
use of org.apache.jackrabbit.spi.commons.conversion.MalformedPathException in project jackrabbit by apache.
the class CachingHierarchyManager method nodeRemoved.
/**
* {@inheritDoc}
*/
public void nodeRemoved(NodeState state, Name name, int index, NodeId id) {
synchronized (cacheMonitor) {
if (idCache.containsKey(state.getNodeId())) {
// Optimization: ignore notifications for nodes that are not in the cache
try {
Path path = PathFactoryImpl.getInstance().create(getPath(state.getNodeId()), name, index, true);
nodeRemoved(state, path, id);
checkConsistency();
} catch (PathNotFoundException e) {
log.warn("Unable to get path of node " + state.getNodeId() + ", event ignored.");
} catch (MalformedPathException e) {
log.warn("Unable to create path of " + id, e);
} catch (ItemStateException e) {
log.warn("Unable to find item " + id, e);
} catch (ItemNotFoundException e) {
log.warn("Unable to get path of " + state.getNodeId(), e);
} catch (RepositoryException e) {
log.warn("Unable to get path of " + state.getNodeId(), e);
}
} else if (state.getParentId() == null && idCache.containsKey(id)) {
// A top level node was removed
evictAll(id, true);
}
}
}
use of org.apache.jackrabbit.spi.commons.conversion.MalformedPathException in project jackrabbit by apache.
the class IndexingConfigurationImpl method getCondition.
/**
* Gets the condition expression from the configuration.
*
* @param config the config node.
* @return the condition expression or <code>null</code> if there is no
* condition set on the <code>config</code>.
* @throws MalformedPathException if the condition string is malformed.
* @throws IllegalNameException if a name contains illegal characters.
* @throws NamespaceException if a name contains an unknown prefix.
*/
private PathExpression getCondition(Node config) throws MalformedPathException, IllegalNameException, NamespaceException {
Node conditionAttr = config.getAttributes().getNamedItem("condition");
if (conditionAttr == null) {
return null;
}
String conditionString = conditionAttr.getNodeValue();
int idx;
int axis;
Name elementTest = null;
Name nameTest = null;
Name propertyName;
String propertyValue;
// parse axis
if (conditionString.startsWith("ancestor::")) {
axis = PathExpression.ANCESTOR;
idx = "ancestor::".length();
} else if (conditionString.startsWith("parent::")) {
axis = PathExpression.PARENT;
idx = "parent::".length();
} else if (conditionString.startsWith("@")) {
axis = PathExpression.SELF;
idx = "@".length();
} else {
axis = PathExpression.CHILD;
idx = 0;
}
try {
if (conditionString.startsWith("element(", idx)) {
int colon = conditionString.indexOf(',', idx + "element(".length());
String name = conditionString.substring(idx + "element(".length(), colon).trim();
if (!name.equals("*")) {
nameTest = resolver.getQName(ISO9075.decode(name));
}
idx = conditionString.indexOf(")/@", colon);
String type = conditionString.substring(colon + 1, idx).trim();
elementTest = resolver.getQName(ISO9075.decode(type));
idx += ")/@".length();
} else {
if (axis == PathExpression.ANCESTOR || axis == PathExpression.CHILD || axis == PathExpression.PARENT) {
// simple name test
String name = conditionString.substring(idx, conditionString.indexOf('/', idx));
if (!name.equals("*")) {
nameTest = resolver.getQName(ISO9075.decode(name));
}
idx += name.length() + "/@".length();
}
}
// parse property name
int eq = conditionString.indexOf('=', idx);
String name = conditionString.substring(idx, eq).trim();
propertyName = resolver.getQName(ISO9075.decode(name));
// parse string value
int quote = conditionString.indexOf('\'', eq) + 1;
propertyValue = conditionString.substring(quote, conditionString.indexOf('\'', quote));
} catch (IndexOutOfBoundsException e) {
throw new MalformedPathException(conditionString);
}
return new PathExpression(axis, elementTest, nameTest, propertyName, propertyValue);
}
Aggregations