use of org.apache.jackrabbit.jcr2spi.state.ItemStateFactory in project jackrabbit by apache.
the class HierarchyEntryImpl method reload.
/**
* {@inheritDoc}
* @see HierarchyEntry#reload(boolean)
*/
public void reload(boolean recursive) {
int status = getStatus();
if (status == Status._UNDEFINED_) {
// unresolved: entry will be loaded and validated upon resolution.
return;
}
if (Status.isTransient(status) || Status.isStale(status) || Status.isTerminal(status)) {
// transient || stale: avoid reloading
// new || terminal: cannot be reloaded from persistent layer anyway.
log.debug("Skip reload for item with status " + Status.getName(status) + ".");
return;
}
/**
* Retrieved a fresh ItemState from the persistent layer. Which will
* then be merged into the current state.
*/
try {
ItemStateFactory isf = getItemStateFactory();
if (denotesNode()) {
NodeEntry ne = (NodeEntry) this;
isf.createNodeState(ne.getWorkspaceId(), ne);
} else {
PropertyEntry pe = (PropertyEntry) this;
isf.createPropertyState(pe.getWorkspaceId(), pe);
}
} catch (ItemNotFoundException e) {
// remove hierarchyEntry including all children
log.debug("Item '" + getName() + "' cannot be found on the persistent layer -> remove.");
remove();
} catch (RepositoryException e) {
// TODO: rather throw?
log.error("Exception while reloading item: " + e);
}
}
Aggregations