use of org.apache.jackrabbit.core.fs.FileSystemException in project jackrabbit by apache.
the class ObjectPersistenceManager 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.error(msg, fse);
throw new ItemStateException(msg, fse);
}
}
use of org.apache.jackrabbit.core.fs.FileSystemException in project jackrabbit by apache.
the class ObjectPersistenceManager method load.
/**
* {@inheritDoc}
*/
public synchronized NodeState load(NodeId id) throws NoSuchItemStateException, ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
String nodeFilePath = buildNodeFilePath(id);
try {
if (!itemStateFS.isFile(nodeFilePath)) {
throw new NoSuchItemStateException(nodeFilePath);
}
} catch (FileSystemException fse) {
String msg = "failed to read node state: " + nodeFilePath;
log.debug(msg);
throw new ItemStateException(msg, fse);
}
try {
BufferedInputStream in = new BufferedInputStream(itemStateFS.getInputStream(nodeFilePath));
try {
NodeState state = createNew(id);
Serializer.deserialize(state, in);
return state;
} catch (Exception e) {
String msg = "failed to read node state: " + id;
log.debug(msg);
throw new ItemStateException(msg, e);
} finally {
in.close();
}
} catch (Exception e) {
String msg = "failed to read node state: " + nodeFilePath;
log.debug(msg);
throw new ItemStateException(msg, e);
}
}
use of org.apache.jackrabbit.core.fs.FileSystemException in project jackrabbit by apache.
the class ObjectPersistenceManager method destroy.
/**
* {@inheritDoc}
*/
protected void destroy(PropertyState state) throws ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
// delete binary values (stored as files)
InternalValue[] values = state.getValues();
if (values != null) {
for (int i = 0; i < values.length; i++) {
InternalValue val = values[i];
if (val != null) {
val.deleteBinaryResource();
}
}
}
// delete property file
String propFilePath = buildPropFilePath(state.getPropertyId());
FileSystemResource propFile = new FileSystemResource(itemStateFS, propFilePath);
try {
if (propFile.exists()) {
// delete resource and prune empty parent folders
propFile.delete(true);
}
} catch (FileSystemException fse) {
String msg = "failed to delete property state: " + state.getParentId() + "/" + state.getName();
log.debug(msg);
throw new ItemStateException(msg, fse);
}
}
use of org.apache.jackrabbit.core.fs.FileSystemException in project jackrabbit by apache.
the class ObjectPersistenceManager method loadReferencesTo.
/**
* {@inheritDoc}
*/
public synchronized NodeReferences loadReferencesTo(NodeId id) throws NoSuchItemStateException, ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
String refsFilePath = buildNodeReferencesFilePath(id);
try {
if (!itemStateFS.isFile(refsFilePath)) {
throw new NoSuchItemStateException(id.toString());
}
} catch (FileSystemException fse) {
String msg = "failed to load references: " + id;
log.debug(msg);
throw new ItemStateException(msg, fse);
}
try {
BufferedInputStream in = new BufferedInputStream(itemStateFS.getInputStream(refsFilePath));
try {
NodeReferences refs = new NodeReferences(id);
Serializer.deserialize(refs, in);
return refs;
} finally {
in.close();
}
} catch (Exception e) {
String msg = "failed to load references: " + id;
log.debug(msg);
throw new ItemStateException(msg, e);
}
}
use of org.apache.jackrabbit.core.fs.FileSystemException in project jackrabbit by apache.
the class ObjectPersistenceManager 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);
}
}
Aggregations