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 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 store.
/**
* {@inheritDoc}
*/
protected void store(PropertyState state) throws ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
String propFilePath = buildPropFilePath(state.getPropertyId());
FileSystemResource propFile = new FileSystemResource(itemStateFS, propFilePath);
try {
propFile.makeParentDirs();
BufferedOutputStream out = new BufferedOutputStream(propFile.getOutputStream());
try {
// serialize property state
Serializer.serialize(state, out, blobStore);
} finally {
out.close();
}
} catch (Exception e) {
String msg = "failed to store property state: " + state.getParentId() + "/" + state.getName();
log.debug(msg);
throw new ItemStateException(msg, e);
}
}
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 ObjectPersistenceManager method existsReferencesTo.
/**
* {@inheritDoc}
*/
public synchronized boolean existsReferencesTo(NodeId id) throws ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
try {
String refsFilePath = buildNodeReferencesFilePath(id);
FileSystemResource refsFile = new FileSystemResource(itemStateFS, refsFilePath);
return refsFile.exists();
} catch (FileSystemException fse) {
String msg = "failed to check existence of references: " + id;
log.debug(msg);
throw new ItemStateException(msg, fse);
}
}
Aggregations