use of org.apache.jackrabbit.core.fs.FileSystemResource in project jackrabbit by apache.
the class InMemBundlePersistenceManager method storeContents.
/**
* Writes the content of the hash maps stores to the file system.
*
* @throws Exception if an error occurs
*/
public synchronized void storeContents() throws Exception {
// write bundles
FileSystemResource fsRes = new FileSystemResource(wspFS, BUNDLE_FILE_PATH);
fsRes.makeParentDirs();
BufferedOutputStream bos = new BufferedOutputStream(fsRes.getOutputStream());
DataOutputStream out = new DataOutputStream(bos);
try {
// number of entries
out.writeInt(bundleStore.size());
// entries
for (NodeId id : bundleStore.keySet()) {
// id
out.writeUTF(id.toString());
byte[] data = bundleStore.get(id);
// data length
out.writeInt(data.length);
// data
out.write(data);
}
} finally {
out.close();
}
// write references
fsRes = new FileSystemResource(wspFS, REFS_FILE_PATH);
fsRes.makeParentDirs();
bos = new BufferedOutputStream(fsRes.getOutputStream());
out = new DataOutputStream(bos);
try {
// number of entries
out.writeInt(refsStore.size());
// entries
for (NodeId id : refsStore.keySet()) {
// target id
out.writeUTF(id.toString());
byte[] data = refsStore.get(id);
// data length
out.writeInt(data.length);
// data
out.write(data);
}
} finally {
out.close();
}
if (!useFileBlobStore) {
// write blobs
fsRes = new FileSystemResource(wspFS, BLOBS_FILE_PATH);
fsRes.makeParentDirs();
bos = new BufferedOutputStream(fsRes.getOutputStream());
out = new DataOutputStream(bos);
try {
// number of entries
out.writeInt(blobs.size());
// entries
for (String id : blobs.keySet()) {
// id
out.writeUTF(id);
byte[] data = blobs.get(id);
// data length
out.writeInt(data.length);
// data
out.write(data);
}
} finally {
out.close();
}
}
}
use of org.apache.jackrabbit.core.fs.FileSystemResource in project jackrabbit by apache.
the class ObjectPersistenceManager 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.debug(msg);
throw new ItemStateException(msg, fse);
}
}
use of org.apache.jackrabbit.core.fs.FileSystemResource in project jackrabbit by apache.
the class ObjectPersistenceManager method store.
/**
* {@inheritDoc}
*/
protected void store(NodeState state) throws ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
String nodeFilePath = buildNodeFilePath(state.getNodeId());
FileSystemResource nodeFile = new FileSystemResource(itemStateFS, nodeFilePath);
try {
nodeFile.makeParentDirs();
BufferedOutputStream out = new BufferedOutputStream(nodeFile.getOutputStream());
try {
// serialize node state
Serializer.serialize(state, out);
} finally {
out.close();
}
} catch (Exception e) {
String msg = "failed to write node state: " + state.getNodeId();
log.debug(msg);
throw new ItemStateException(msg, e);
}
}
use of org.apache.jackrabbit.core.fs.FileSystemResource 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.FileSystemResource in project jackrabbit by apache.
the class ObjectPersistenceManager method destroy.
/**
* {@inheritDoc}
*/
protected void destroy(NodeState state) throws ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
String nodeFilePath = buildNodeFilePath(state.getNodeId());
FileSystemResource nodeFile = new FileSystemResource(itemStateFS, nodeFilePath);
try {
if (nodeFile.exists()) {
// delete resource and prune empty parent folders
nodeFile.delete(true);
}
} catch (FileSystemException fse) {
String msg = "failed to delete node state: " + state.getNodeId();
log.debug(msg);
throw new ItemStateException(msg, fse);
}
}
Aggregations