use of org.apache.jackrabbit.core.state.ItemStateException in project jackrabbit by apache.
the class OraclePersistenceManager method store.
/**
* {@inheritDoc}
*/
public synchronized void store(NodeState state) throws ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
// check if insert or update
boolean update = state.getStatus() != ItemState.STATUS_NEW;
//boolean update = exists((NodeId) state.getId());
String sql = (update) ? nodeStateUpdateSQL : nodeStateInsertSQL;
Blob blob = null;
try {
ByteArrayOutputStream out = new ByteArrayOutputStream(INITIAL_BUFFER_SIZE);
// serialize node state
Serializer.serialize(state, out);
// we are synchronized on this instance, therefore we do not
// not have to additionally synchronize on the sql statement
blob = createTemporaryBlob(new ByteArrayInputStream(out.toByteArray()));
executeStmt(sql, new Object[] { blob, state.getNodeId().toString() });
// there's no need to close a ByteArrayOutputStream
//out.close();
} catch (Exception e) {
String msg = "failed to write node state: " + state.getId();
log.error(msg, e);
throw new ItemStateException(msg, e);
} finally {
if (blob != null) {
try {
freeTemporaryBlob(blob);
} catch (Exception ignore) {
}
}
}
}
use of org.apache.jackrabbit.core.state.ItemStateException 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.state.ItemStateException 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.ItemStateException 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.state.ItemStateException 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