use of org.apache.jackrabbit.core.state.NoSuchItemStateException in project jackrabbit by apache.
the class EventStateCollection method createShareableNodeEvents.
//----------------------------< internal >----------------------------------
private void createShareableNodeEvents(NodeState n, ChangeLog changes, ChangeLogBasedHierarchyMgr hmgr, ItemStateManager stateMgr) throws ItemStateException {
if (n.isShareable()) {
// check if a share was added or removed
for (NodeId parentId : n.getAddedShares()) {
// ignore primary parent id
if (n.getParentId().equals(parentId)) {
continue;
}
NodeState parent = (NodeState) changes.get(parentId);
if (parent == null) {
// happens when mix:shareable is added to an existing node
// usually the parent node state is in the change log
// when a node is added to a shared set -> new child node
// entry on parent node state.
parent = (NodeState) stateMgr.getItemState(parentId);
}
Name ntName = getNodeType(parent, session).getQName();
EventState es = EventState.childNodeAdded(parentId, getPath(parentId, hmgr), n.getNodeId(), getNameElement(n.getNodeId(), parentId, hmgr), ntName, parent.getMixinTypeNames(), session);
es.setShareableNode(true);
events.add(es);
}
for (NodeId parentId : n.getRemovedShares()) {
// parent ids that are not primary
if (n.getParentId().equals(parentId)) {
continue;
}
NodeState parent = null;
try {
parent = (NodeState) changes.get(parentId);
} catch (NoSuchItemStateException e) {
// parent has been removed as well
// ignore and retrieve from stateMgr
}
if (parent == null) {
// happens when mix:shareable is removed from an existing
// node. Usually the parent node state is in the change log
// when a node is removed to a shared set -> removed child
// node entry on parent node state.
parent = (NodeState) stateMgr.getItemState(parentId);
}
Name ntName = getNodeType(parent, session).getQName();
EventState es = EventState.childNodeRemoved(parentId, getZombiePath(parentId, hmgr), n.getNodeId(), getZombieNameElement(n.getNodeId(), parentId, hmgr), ntName, parent.getMixinTypeNames(), session);
es.setShareableNode(true);
events.add(es);
}
}
}
use of org.apache.jackrabbit.core.state.NoSuchItemStateException in project jackrabbit by apache.
the class BundleFsPersistenceManager method destroyBundle.
/**
* {@inheritDoc}
*/
protected synchronized void destroyBundle(NodePropBundle bundle) throws ItemStateException {
try {
StringBuffer buf = buildNodeFilePath(null, bundle.getId());
itemFs.deleteFile(buf.toString());
} catch (Exception e) {
if (e instanceof NoSuchItemStateException) {
throw (NoSuchItemStateException) e;
}
String msg = "failed to delete bundle: " + bundle.getId();
BundleFsPersistenceManager.log.error(msg, e);
throw new ItemStateException(msg, e);
}
}
use of org.apache.jackrabbit.core.state.NoSuchItemStateException in project jackrabbit by apache.
the class MultiIndex method createIndex.
/**
* Recursively creates an index starting with the NodeState
* <code>node</code>.
*
* @param node the current NodeState.
* @param path the path of the current <code>node</code> state.
* @param stateMgr the shared item state manager.
* @param count the number of nodes already indexed.
* @return the number of nodes indexed so far.
* @throws IOException if an error occurs while writing to the
* index.
* @throws ItemStateException if an node state cannot be found.
* @throws RepositoryException if any other error occurs
*/
private long createIndex(NodeState node, Path path, ItemStateManager stateMgr, long count) throws IOException, ItemStateException, RepositoryException {
NodeId id = node.getNodeId();
if (excludedIDs.contains(id)) {
return count;
}
executeAndLog(new AddNode(getTransactionId(), id));
if (++count % 100 == 0) {
PathResolver resolver = new DefaultNamePathResolver(handler.getContext().getNamespaceRegistry());
log.info("indexing... {} ({})", resolver.getJCRPath(path), count);
}
if (count % 10 == 0) {
checkIndexingQueue(true);
}
checkVolatileCommit();
for (ChildNodeEntry child : node.getChildNodeEntries()) {
Path childPath = PATH_FACTORY.create(path, child.getName(), child.getIndex(), false);
NodeState childState = null;
try {
childState = (NodeState) stateMgr.getItemState(child.getId());
} catch (NoSuchItemStateException e) {
handler.getOnWorkspaceInconsistencyHandler().handleMissingChildNode(e, handler, path, node, child);
} catch (ItemStateException e) {
// JCR-3268 log bundle corruption and continue
handler.getOnWorkspaceInconsistencyHandler().logError(e, handler, childPath, node, child);
}
if (childState != null) {
count = createIndex(childState, childPath, stateMgr, count);
}
}
return count;
}
use of org.apache.jackrabbit.core.state.NoSuchItemStateException in project jackrabbit by apache.
the class NodeIndexer method createDoc.
/**
* Creates a lucene Document.
*
* @return the lucene Document with the index layout.
* @throws RepositoryException if an error occurs while reading property
* values from the <code>ItemStateProvider</code>.
*/
public Document createDoc() throws RepositoryException {
doNotUseInExcerpt.clear();
Document doc = new Document();
doc.setBoost(getNodeBoost());
// special fields
// UUID
doc.add(new IDField(node.getNodeId()));
try {
// parent UUID
if (node.getParentId() == null) {
// root node
Field parent = new Field(FieldNames.PARENT, false, "", Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS, Field.TermVector.NO);
parent.setIndexOptions(FieldInfo.IndexOptions.DOCS_ONLY);
doc.add(parent);
addNodeName(doc, "", "");
} else if (node.getSharedSet().isEmpty()) {
addParentChildRelation(doc, node.getParentId());
} else {
// shareable node
for (NodeId id : node.getSharedSet()) {
addParentChildRelation(doc, id);
}
// mark shareable nodes
doc.add(new Field(FieldNames.SHAREABLE_NODE, false, "", Field.Store.NO, Field.Index.NOT_ANALYZED_NO_NORMS, Field.TermVector.NO));
}
} catch (NoSuchItemStateException e) {
throwRepositoryException(e);
} catch (ItemStateException e) {
throwRepositoryException(e);
} catch (NamespaceException e) {
// will never happen, because this.mappings will dynamically add
// unknown uri<->prefix mappings
}
Set<Name> props = node.getPropertyNames();
for (Name propName : props) {
if (isIndexed(propName)) {
PropertyId id = new PropertyId(node.getNodeId(), propName);
try {
PropertyState propState = (PropertyState) stateProvider.getItemState(id);
// beginning with V2
if (indexFormatVersion.getVersion() >= IndexFormatVersion.V2.getVersion()) {
addPropertyName(doc, propState.getName());
}
InternalValue[] values = propState.getValues();
for (InternalValue value : values) {
addValue(doc, value, propState.getName());
}
if (values.length > 1) {
// real multi-valued
addMVPName(doc, propState.getName());
}
} catch (NoSuchItemStateException e) {
throwRepositoryException(e);
} catch (ItemStateException e) {
throwRepositoryException(e);
}
}
}
// now add fields that are not used in excerpt (must go at the end)
for (Fieldable field : doNotUseInExcerpt) {
doc.add(field);
}
return doc;
}
use of org.apache.jackrabbit.core.state.NoSuchItemStateException in project jackrabbit by apache.
the class XMLPersistenceManager method load.
/**
* {@inheritDoc}
*/
public synchronized PropertyState load(PropertyId id) throws NoSuchItemStateException, ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
Exception e = null;
String propFilePath = buildPropFilePath(id);
try {
if (!itemStateFS.isFile(propFilePath)) {
throw new NoSuchItemStateException(id.toString());
}
InputStream in = itemStateFS.getInputStream(propFilePath);
try {
DOMWalker walker = new DOMWalker(in);
PropertyState state = createNew(id);
readState(walker, state);
return state;
} finally {
in.close();
}
} catch (IOException ioe) {
e = ioe;
// fall through
} catch (FileSystemException fse) {
e = fse;
// fall through
}
String msg = "failed to read property state: " + id.toString();
log.debug(msg);
throw new ItemStateException(msg, e);
}
Aggregations