use of org.apache.jackrabbit.core.state.NoSuchItemStateException in project jackrabbit by apache.
the class XMLPersistenceManager method load.
/**
* {@inheritDoc}
*/
public synchronized NodeState load(NodeId id) throws NoSuchItemStateException, ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
Exception e = null;
String nodeFilePath = buildNodeFilePath(id);
try {
if (!itemStateFS.isFile(nodeFilePath)) {
throw new NoSuchItemStateException(id.toString());
}
InputStream in = itemStateFS.getInputStream(nodeFilePath);
try {
DOMWalker walker = new DOMWalker(in);
String ntName = walker.getAttribute(NODETYPE_ATTRIBUTE);
NodeState state = createNew(id);
state.setNodeTypeName(factory.create(ntName));
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 node state: " + id;
log.debug(msg);
throw new ItemStateException(msg, e);
}
use of org.apache.jackrabbit.core.state.NoSuchItemStateException in project jackrabbit by apache.
the class XMLPersistenceManager method loadReferencesTo.
/**
* {@inheritDoc}
*/
public synchronized NodeReferences loadReferencesTo(NodeId id) throws NoSuchItemStateException, ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
Exception e = null;
String refsFilePath = buildNodeReferencesFilePath(id);
try {
if (!itemStateFS.isFile(refsFilePath)) {
throw new NoSuchItemStateException(id.toString());
}
InputStream in = itemStateFS.getInputStream(refsFilePath);
try {
DOMWalker walker = new DOMWalker(in);
NodeReferences refs = new NodeReferences(id);
readState(walker, refs);
return refs;
} finally {
in.close();
}
} catch (IOException ioe) {
e = ioe;
// fall through
} catch (FileSystemException fse) {
e = fse;
// fall through
}
String msg = "failed to load references: " + id;
log.debug(msg);
throw new ItemStateException(msg, e);
}
use of org.apache.jackrabbit.core.state.NoSuchItemStateException in project jackrabbit by apache.
the class DatabasePersistenceManager method load.
/**
* {@inheritDoc}
*/
public PropertyState load(PropertyId id) throws NoSuchItemStateException, ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
synchronized (propertyStateSelectSQL) {
ResultSet rs = null;
InputStream in = null;
try {
Statement stmt = executeStmt(propertyStateSelectSQL, new Object[] { id.toString() });
rs = stmt.getResultSet();
if (!rs.next()) {
throw new NoSuchItemStateException(id.toString());
}
in = rs.getBinaryStream(1);
if (!externalBLOBs) {
// JCR-1532: pre-fetch/buffer stream data
ByteArrayInputStream bain = new ByteArrayInputStream(IOUtils.toByteArray(in));
IOUtils.closeQuietly(in);
in = bain;
}
PropertyState state = createNew(id);
Serializer.deserialize(state, in, blobStore);
return state;
} catch (Exception e) {
if (e instanceof NoSuchItemStateException) {
throw (NoSuchItemStateException) e;
}
String msg = "failed to read property state: " + id;
log.error(msg, e);
throw new ItemStateException(msg, e);
} finally {
IOUtils.closeQuietly(in);
closeResultSet(rs);
}
}
}
use of org.apache.jackrabbit.core.state.NoSuchItemStateException in project jackrabbit by apache.
the class ObjectPersistenceManager method load.
/**
* {@inheritDoc}
*/
public synchronized PropertyState load(PropertyId id) throws NoSuchItemStateException, ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
String propFilePath = buildPropFilePath(id);
try {
if (!itemStateFS.isFile(propFilePath)) {
throw new NoSuchItemStateException(propFilePath);
}
} catch (FileSystemException fse) {
String msg = "failed to read property state: " + propFilePath;
log.debug(msg);
throw new ItemStateException(msg, fse);
}
try {
BufferedInputStream in = new BufferedInputStream(itemStateFS.getInputStream(propFilePath));
try {
PropertyState state = createNew(id);
Serializer.deserialize(state, in, blobStore);
return state;
} finally {
in.close();
}
} catch (Exception e) {
String msg = "failed to read property state: " + propFilePath;
log.debug(msg);
throw new ItemStateException(msg, e);
}
}
use of org.apache.jackrabbit.core.state.NoSuchItemStateException in project jackrabbit by apache.
the class HierarchyManagerImpl method isShareAncestor.
/**
* {@inheritDoc}
*/
public boolean isShareAncestor(NodeId ancestor, NodeId descendant) throws ItemNotFoundException, RepositoryException {
if (ancestor.equals(descendant)) {
// can't be ancestor of self
return false;
}
try {
ItemState state = getItemState(descendant);
Set<NodeId> parentIds = getParentIds(state, false);
while (parentIds.size() > 0) {
if (parentIds.contains(ancestor)) {
return true;
}
Set<NodeId> grandparentIds = new LinkedHashSet<NodeId>();
for (NodeId parentId : parentIds) {
grandparentIds.addAll(getParentIds(getItemState(parentId), false));
}
parentIds = grandparentIds;
}
// not an ancestor
return false;
} catch (NoSuchItemStateException nsise) {
String msg = "failed to determine degree of relationship of " + ancestor + " and " + descendant;
log.debug(msg);
throw new ItemNotFoundException(msg, nsise);
} catch (ItemStateException ise) {
String msg = "failed to determine degree of relationship of " + ancestor + " and " + descendant;
log.debug(msg);
throw new RepositoryException(msg, ise);
}
}
Aggregations