use of org.apache.jackrabbit.core.state.NoSuchItemStateException in project jackrabbit by apache.
the class HierarchyManagerImpl method getDepth.
/**
* {@inheritDoc}
*/
public int getDepth(ItemId id) throws ItemNotFoundException, RepositoryException {
// shortcut
if (id.equals(rootNodeId)) {
return 0;
}
try {
ItemState state = getItemState(id);
NodeId parentId = getParentId(state);
int depth = 0;
while (parentId != null) {
depth++;
state = getItemState(parentId);
parentId = getParentId(state);
}
return depth;
} catch (NoSuchItemStateException nsise) {
String msg = "failed to determine depth of " + id;
log.debug(msg);
throw new ItemNotFoundException(msg, nsise);
} catch (ItemStateException ise) {
String msg = "failed to determine depth of " + id;
log.debug(msg);
throw new RepositoryException(msg, ise);
}
}
use of org.apache.jackrabbit.core.state.NoSuchItemStateException in project jackrabbit by apache.
the class HierarchyManagerImpl method getRelativeDepth.
/**
* {@inheritDoc}
*/
public int getRelativeDepth(NodeId ancestorId, ItemId descendantId) throws ItemNotFoundException, RepositoryException {
if (ancestorId.equals(descendantId)) {
return 0;
}
int depth = 1;
try {
ItemState state = getItemState(descendantId);
NodeId parentId = getParentId(state);
while (parentId != null) {
if (parentId.equals(ancestorId)) {
return depth;
}
depth++;
state = getItemState(parentId);
parentId = getParentId(state);
}
// not an ancestor
return -1;
} catch (NoSuchItemStateException nsise) {
String msg = "failed to determine depth of " + descendantId + " relative to " + ancestorId;
log.debug(msg);
throw new ItemNotFoundException(msg, nsise);
} catch (ItemStateException ise) {
String msg = "failed to determine depth of " + descendantId + " relative to " + ancestorId;
log.debug(msg);
throw new RepositoryException(msg, ise);
}
}
use of org.apache.jackrabbit.core.state.NoSuchItemStateException in project jackrabbit by apache.
the class HierarchyManagerImpl method isAncestor.
/**
* {@inheritDoc}
*/
public boolean isAncestor(NodeId nodeId, ItemId itemId) throws ItemNotFoundException, RepositoryException {
if (nodeId.equals(itemId)) {
// can't be ancestor of self
return false;
}
try {
ItemState state = getItemState(itemId);
NodeId parentId = getParentId(state);
while (parentId != null) {
if (parentId.equals(nodeId)) {
return true;
}
state = getItemState(parentId);
parentId = getParentId(state);
}
// not an ancestor
return false;
} catch (NoSuchItemStateException nsise) {
String msg = "failed to determine degree of relationship of " + nodeId + " and " + itemId;
log.debug(msg);
throw new ItemNotFoundException(msg, nsise);
} catch (ItemStateException ise) {
String msg = "failed to determine degree of relationship of " + nodeId + " and " + itemId;
log.debug(msg);
throw new RepositoryException(msg, ise);
}
}
use of org.apache.jackrabbit.core.state.NoSuchItemStateException in project jackrabbit by apache.
the class SearchIndex method retrieveAggregateRoot.
/**
* Retrieves the root of the indexing aggregate for <code>removedIds</code>
* and puts it into <code>map</code>.
*
* @param removedIds the ids of removed nodes.
* @param aggregates aggregate roots are collected in this map
*/
protected void retrieveAggregateRoot(Set<NodeId> removedIds, Map<NodeId, NodeState> aggregates) {
if (removedIds.isEmpty() || indexingConfig == null) {
return;
}
AggregateRule[] aggregateRules = indexingConfig.getAggregateRules();
if (aggregateRules == null) {
return;
}
int found = 0;
long time = System.currentTimeMillis();
try {
CachingMultiIndexReader reader = index.getIndexReader();
try {
Term aggregateIds = new Term(FieldNames.AGGREGATED_NODE_UUID, "");
TermDocs tDocs = reader.termDocs();
try {
ItemStateManager ism = getContext().getItemStateManager();
for (NodeId id : removedIds) {
aggregateIds = aggregateIds.createTerm(id.toString());
tDocs.seek(aggregateIds);
while (tDocs.next()) {
Document doc = reader.document(tDocs.doc(), FieldSelectors.UUID);
NodeId nId = new NodeId(doc.get(FieldNames.UUID));
NodeState nodeState = (NodeState) ism.getItemState(nId);
aggregates.put(nId, nodeState);
found++;
// JCR-2989 Support for embedded index aggregates
int sizeBefore = aggregates.size();
retrieveAggregateRoot(nodeState, aggregates);
found += aggregates.size() - sizeBefore;
}
}
} finally {
tDocs.close();
}
} finally {
reader.release();
}
} catch (NoSuchItemStateException e) {
log.info("Exception while retrieving aggregate roots. Node is not available {}.", e.getMessage());
} catch (Exception e) {
log.warn("Exception while retrieving aggregate roots", e);
}
time = System.currentTimeMillis() - time;
log.debug("Retrieved {} aggregate roots in {} ms.", found, time);
}
use of org.apache.jackrabbit.core.state.NoSuchItemStateException in project jackrabbit by apache.
the class PropertyValueOperand method getPropertyState.
/**
* Returns the property state for the given score node or <code>null</code>
* if none exists.
*
* @param sn the current score node.
* @param context the evaluation context.
* @return the property state or <code>null</code>.
* @throws RepositoryException if an error occurs while reading.
*/
public final PropertyState getPropertyState(ScoreNode sn, EvaluationContext context) throws RepositoryException {
ItemStateManager ism = context.getItemStateManager();
PropertyId propId = new PropertyId(sn.getNodeId(), operand.getPropertyQName());
try {
return (PropertyState) ism.getItemState(propId);
} catch (NoSuchItemStateException e) {
return null;
} catch (ItemStateException e) {
throw new RepositoryException(e);
}
}
Aggregations