use of org.apache.jackrabbit.core.state.NoSuchItemStateException in project jackrabbit by apache.
the class AbstractBundlePersistenceManager method load.
/**
* {@inheritDoc}
*
* Loads the state via the appropriate NodePropBundle.
*/
public PropertyState load(PropertyId id) throws NoSuchItemStateException, ItemStateException {
NodePropBundle bundle = getBundle(id.getParentId());
if (bundle != null) {
PropertyState state = createNew(id);
PropertyEntry p = bundle.getPropertyEntry(id.getName());
if (p != null) {
state.setMultiValued(p.isMultiValued());
state.setType(p.getType());
state.setValues(p.getValues());
state.setModCount(p.getModCount());
} else if (id.getName().equals(JCR_UUID)) {
state.setType(PropertyType.STRING);
state.setMultiValued(false);
state.setValues(new InternalValue[] { InternalValue.create(id.getParentId().toString()) });
} else if (id.getName().equals(JCR_PRIMARYTYPE)) {
state.setType(PropertyType.NAME);
state.setMultiValued(false);
state.setValues(new InternalValue[] { InternalValue.create(bundle.getNodeTypeName()) });
} else if (id.getName().equals(JCR_MIXINTYPES)) {
state.setType(PropertyType.NAME);
state.setMultiValued(true);
Set<Name> mixins = bundle.getMixinTypeNames();
state.setValues(InternalValue.create(mixins.toArray(new Name[mixins.size()])));
} else {
throw new NoSuchItemStateException(id.toString());
}
return state;
} else {
throw new NoSuchItemStateException(id.toString());
}
}
use of org.apache.jackrabbit.core.state.NoSuchItemStateException in project jackrabbit by apache.
the class InMemBundlePersistenceManager method loadReferencesTo.
/**
* {@inheritDoc}
*/
public NodeReferences loadReferencesTo(NodeId id) throws NoSuchItemStateException, ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
if (!refsStore.containsKey(id)) {
throw new NoSuchItemStateException(id.toString());
}
try {
NodeReferences refs = new NodeReferences(id);
Serializer.deserialize(refs, new ByteArrayInputStream(refsStore.get(id)));
return refs;
} catch (Exception e) {
String msg = "failed to read references: " + id;
log.error(msg, e);
throw new ItemStateException(msg, e);
}
}
use of org.apache.jackrabbit.core.state.NoSuchItemStateException in project jackrabbit by apache.
the class DatabasePersistenceManager method load.
/**
* {@inheritDoc}
*/
public NodeState load(NodeId id) throws NoSuchItemStateException, ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
synchronized (nodeStateSelectSQL) {
ResultSet rs = null;
InputStream in = null;
try {
Statement stmt = executeStmt(nodeStateSelectSQL, new Object[] { id.toString() });
rs = stmt.getResultSet();
if (!rs.next()) {
throw new NoSuchItemStateException(id.toString());
}
in = rs.getBinaryStream(1);
NodeState state = createNew(id);
Serializer.deserialize(state, in);
return state;
} catch (Exception e) {
if (e instanceof NoSuchItemStateException) {
throw (NoSuchItemStateException) e;
}
String msg = "failed to read node state: " + id;
log.error(msg, e);
throw new ItemStateException(msg, e);
} finally {
IOUtils.closeQuietly(in);
closeResultSet(rs);
}
}
}
use of org.apache.jackrabbit.core.state.NoSuchItemStateException in project jackrabbit by apache.
the class BundleFsPersistenceManager method loadReferencesTo.
/**
* {@inheritDoc}
*/
public synchronized NodeReferences loadReferencesTo(NodeId targetId) throws NoSuchItemStateException, ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
InputStream in = null;
try {
String path = buildNodeReferencesFilePath(null, targetId).toString();
if (!itemFs.exists(path)) {
// special case
throw new NoSuchItemStateException(targetId.toString());
}
in = itemFs.getInputStream(path);
NodeReferences refs = new NodeReferences(targetId);
Serializer.deserialize(refs, in);
return refs;
} catch (NoSuchItemStateException e) {
throw e;
} catch (Exception e) {
String msg = "failed to read references: " + targetId;
BundleFsPersistenceManager.log.error(msg, e);
throw new ItemStateException(msg, e);
} finally {
IOUtils.closeQuietly(in);
}
}
use of org.apache.jackrabbit.core.state.NoSuchItemStateException in project jackrabbit by apache.
the class NodeIndexer method getValue.
/**
* Utility method that extracts the first value of the named property
* of the current node. Returns <code>null</code> if the property does
* not exist or contains no values.
*
* @param name property name
* @return value of the named property, or <code>null</code>
* @throws ItemStateException if the property can not be accessed
*/
protected InternalValue getValue(Name name) throws ItemStateException {
try {
PropertyId id = new PropertyId(node.getNodeId(), name);
PropertyState property = (PropertyState) stateProvider.getItemState(id);
InternalValue[] values = property.getValues();
if (values.length > 0) {
return values[0];
} else {
return null;
}
} catch (NoSuchItemStateException e) {
return null;
}
}
Aggregations