use of org.apache.jackrabbit.core.state.ItemStateException in project jackrabbit by apache.
the class DatabasePersistenceManager method exists.
/**
* {@inheritDoc}
*/
public boolean exists(PropertyId id) throws ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
synchronized (propertyStateSelectExistSQL) {
ResultSet rs = null;
try {
Statement stmt = executeStmt(propertyStateSelectExistSQL, new Object[] { id.toString() });
rs = stmt.getResultSet();
// a property state exists if the result has at least one entry
return rs.next();
} catch (Exception e) {
String msg = "failed to check existence of property state: " + id;
log.error(msg, e);
throw new ItemStateException(msg, e);
} finally {
closeResultSet(rs);
}
}
}
use of org.apache.jackrabbit.core.state.ItemStateException in project jackrabbit by apache.
the class DatabasePersistenceManager method existsReferencesTo.
/**
* {@inheritDoc}
*/
public boolean existsReferencesTo(NodeId targetId) throws ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
synchronized (nodeReferenceSelectExistSQL) {
ResultSet rs = null;
try {
Statement stmt = executeStmt(nodeReferenceSelectExistSQL, new Object[] { targetId.toString() });
rs = stmt.getResultSet();
// a reference exists if the result has at least one entry
return rs.next();
} catch (Exception e) {
String msg = "failed to check existence of node references: " + targetId;
log.error(msg, e);
throw new ItemStateException(msg, e);
} finally {
closeResultSet(rs);
}
}
}
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);
}
}
use of org.apache.jackrabbit.core.state.ItemStateException in project jackrabbit by apache.
the class BundleDbPersistenceManager method getAllNodeInfos.
/**
* {@inheritDoc}
*/
@Override
public synchronized Map<NodeId, NodeInfo> getAllNodeInfos(NodeId bigger, int maxCount) throws ItemStateException {
ResultSet rs = null;
try {
String sql = bundleSelectAllBundlesSQL;
NodeId lowId = null;
Object[] keys = new Object[0];
if (bigger != null) {
sql = bundleSelectAllBundlesFromSQL;
lowId = bigger;
keys = getKey(bigger);
}
if (getStorageModel() == SM_LONGLONG_KEYS && maxCount > 0) {
// get some more rows, in case the first row is smaller
// only required for SM_LONGLONG_KEYS
// probability is very low to get get the wrong first key, < 1 : 2^64
// see also bundleSelectAllIdsFrom SQL statement
maxCount += 10;
}
rs = conHelper.exec(sql, keys, false, maxCount);
Map<NodeId, NodeInfo> result = new LinkedHashMap<NodeId, NodeInfo>(maxCount);
while ((maxCount == 0 || result.size() < maxCount) && rs.next()) {
NodeId current;
if (getStorageModel() == SM_BINARY_KEYS) {
current = new NodeId(rs.getBytes(1));
} else {
long high = rs.getLong(1);
long low = rs.getLong(2);
current = new NodeId(high, low);
}
if (getStorageModel() == SM_LONGLONG_KEYS && lowId != null) {
// skip the keys that are smaller or equal (see above, maxCount += 10)
if (current.compareTo(lowId) <= 0) {
continue;
}
}
NodePropBundle bundle = readBundle(current, rs, getStorageModel() == SM_LONGLONG_KEYS ? 3 : 2);
NodeInfo nodeInfo = new NodeInfo(bundle);
result.put(nodeInfo.getId(), nodeInfo);
}
return result;
} catch (SQLException e) {
String msg = "getAllNodeIds failed.";
log.error(msg, e);
throw new ItemStateException(msg, e);
} finally {
DbUtility.close(rs);
}
}
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);
}
}
Aggregations