use of org.apache.jackrabbit.core.state.ItemStateException in project jackrabbit-oak by apache.
the class BundleLoader method loadBundle.
NodePropBundle loadBundle(NodeId id) throws ItemStateException {
if (loadBundle != null) {
try {
return checkNotNull((NodePropBundle) loadBundle.invoke(pm, id), "Could not load NodePropBundle for id [%s]", id);
} catch (InvocationTargetException e) {
if (e.getCause() instanceof ItemStateException) {
throw (ItemStateException) e.getCause();
}
// fall through
} catch (IllegalArgumentException e) {
// fall through
} catch (IllegalAccessException e) {
// fall through
}
}
NodeState state = pm.load(id);
checkNotNull(state, "Could not load NodeState for id [%s]", id);
NodePropBundle bundle = new NodePropBundle(state);
for (Name name : state.getPropertyNames()) {
if (NameConstants.JCR_UUID.equals(name)) {
bundle.setReferenceable(true);
} else if (!NameConstants.JCR_PRIMARYTYPE.equals(name) && !NameConstants.JCR_MIXINTYPES.equals(name)) {
bundle.addProperty(new PropertyEntry(pm.load(new PropertyId(id, name))));
}
}
return bundle;
}
use of org.apache.jackrabbit.core.state.ItemStateException in project jackrabbit by apache.
the class DatabasePersistenceManager method store.
/**
* {@inheritDoc}
* <p>
* This method uses shared <code>PreparedStatement</code>s which must
* be executed strictly sequentially. Because this method synchronizes on
* the persistence manager instance there is no need to synchronize on the
* shared statement. If the method would not be synchronized the shared
* statements would have to be synchronized.
*/
@Override
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(state.getId());
String sql = (update) ? nodeStateUpdateSQL : nodeStateInsertSQL;
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
executeStmt(sql, new Object[] { out.toByteArray(), state.getNodeId().toString() });
// there's no need to close a ByteArrayOutputStream
// out.close();
} catch (Exception e) {
String msg = "failed to write node state: " + state.getNodeId();
log.error(msg, e);
throw new ItemStateException(msg, e);
}
}
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 InMemBundlePersistenceManager method storeBundle.
/**
* {@inheritDoc}
*/
@Override
protected void storeBundle(NodePropBundle bundle) throws ItemStateException {
ByteArrayOutputStream out = new ByteArrayOutputStream(INITIAL_BUFFER_SIZE);
try {
binding.writeBundle(out, bundle);
bundleStore.put(bundle.getId(), out.toByteArray());
} catch (IOException e) {
String msg = "failed to write bundle: " + bundle.getId();
log.error(msg, e);
throw new ItemStateException(msg, e);
}
}
use of org.apache.jackrabbit.core.state.ItemStateException 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);
}
}
Aggregations