use of org.apache.jackrabbit.core.fs.FileSystemException in project jackrabbit by apache.
the class XMLPersistenceManager method exists.
/**
* {@inheritDoc}
*/
public synchronized boolean exists(NodeId id) throws ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
try {
String nodeFilePath = buildNodeFilePath(id);
FileSystemResource nodeFile = new FileSystemResource(itemStateFS, nodeFilePath);
return nodeFile.exists();
} catch (FileSystemException fse) {
String msg = "failed to check existence of item state: " + id;
log.debug(msg);
throw new ItemStateException(msg, fse);
}
}
use of org.apache.jackrabbit.core.fs.FileSystemException 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.fs.FileSystemException in project jackrabbit by apache.
the class XMLPersistenceManager method destroy.
/**
* {@inheritDoc}
*/
protected void destroy(NodeReferences refs) throws ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
String refsFilePath = buildNodeReferencesFilePath(refs.getTargetId());
FileSystemResource refsFile = new FileSystemResource(itemStateFS, refsFilePath);
try {
if (refsFile.exists()) {
// delete resource and prune empty parent folders
refsFile.delete(true);
}
} catch (FileSystemException fse) {
String msg = "failed to delete " + refs;
log.debug(msg);
throw new ItemStateException(msg, fse);
}
}
use of org.apache.jackrabbit.core.fs.FileSystemException in project jackrabbit by apache.
the class XMLPersistenceManager method exists.
/**
* {@inheritDoc}
*/
public synchronized boolean exists(PropertyId id) throws ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
try {
String propFilePath = buildPropFilePath(id);
FileSystemResource propFile = new FileSystemResource(itemStateFS, propFilePath);
return propFile.exists();
} catch (FileSystemException fse) {
String msg = "failed to check existence of item state: " + id;
log.error(msg, fse);
throw new ItemStateException(msg, fse);
}
}
use of org.apache.jackrabbit.core.fs.FileSystemException 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);
}
Aggregations