use of org.apache.jackrabbit.spi.PropertyInfo in project jackrabbit by apache.
the class WorkspaceItemStateFactory method createPropertyState.
/**
* Creates the PropertyState with information retrieved from the <code>RepositoryService</code>.
*/
public PropertyState createPropertyState(PropertyId propertyId, PropertyEntry entry) throws ItemNotFoundException, RepositoryException {
try {
// Get item info from cache and use it if up to date
Entry<PropertyInfo> cached = cache.getPropertyInfo(propertyId);
ItemInfo info;
if (isUpToDate(cached, entry)) {
info = cached.info;
} else {
// otherwise retrieve item info from service and cache the whole batch
Iterator<? extends ItemInfo> infos = service.getItemInfos(sessionInfo, propertyId);
info = first(infos, cache, entry.getGeneration());
if (info == null || info.denotesNode()) {
throw new ItemNotFoundException("PropertyId: " + propertyId);
}
}
assertMatchingPath(info, entry);
return createPropertyState((PropertyInfo) info, entry);
} catch (PathNotFoundException e) {
throw new ItemNotFoundException(e);
}
}
use of org.apache.jackrabbit.spi.PropertyInfo in project jackrabbit by apache.
the class RepositoryServiceImpl method getItemInfos.
@Override
public Iterator<? extends ItemInfo> getItemInfos(SessionInfo sessionInfo, ItemId itemId) throws RepositoryException {
// currently: missing prop-names with child-NodeInfo
if (itemId.denotesNode()) {
List<ItemInfo> l = new ArrayList<ItemInfo>();
NodeInfo nInfo = getNodeInfo(sessionInfo, (NodeId) itemId);
l.add(nInfo);
// at least add propertyInfos for the meta-props already known from the
// nodeInfo.
l.addAll(buildPropertyInfos(nInfo));
return l.iterator();
} else {
PropertyInfo pInfo = getPropertyInfo(sessionInfo, (PropertyId) itemId);
return Iterators.singleton(pInfo);
}
}
use of org.apache.jackrabbit.spi.PropertyInfo in project jackrabbit by apache.
the class BatchTest method testSetEmptyBinaryValues.
public void testSetEmptyBinaryValues() throws RepositoryException, IOException {
NodeId nid = getNodeId(testPath);
Name propName = resolver.getQName("binPropMV");
Batch b = rs.createBatch(si, nid);
QValue[] vs = new QValue[] { rs.getQValueFactory().create(new byte[0]), rs.getQValueFactory().create(new byte[0]), rs.getQValueFactory().create(new byte[0]) };
b.addProperty(nid, propName, vs);
rs.submit(b);
PropertyInfo pi = rs.getPropertyInfo(si, getPropertyId(nid, propName));
assertTrue(pi.isMultiValued());
vs = pi.getValues();
assertEquals("", vs[0].getString());
assertEquals("", vs[1].getString());
assertEquals("", vs[2].getString());
assertEquals(PropertyType.BINARY, pi.getType());
pi = getPropertyInfo(nid, propName);
vs = pi.getValues();
assertEquals("", vs[0].getString());
assertEquals("", vs[1].getString());
assertEquals("", vs[2].getString());
assertEquals(PropertyType.BINARY, pi.getType());
}
use of org.apache.jackrabbit.spi.PropertyInfo in project jackrabbit by apache.
the class BatchTest method testSetMixedBinaryValues.
public void testSetMixedBinaryValues() throws RepositoryException, IOException {
NodeId nid = getNodeId(testPath);
Name propName = resolver.getQName("binPropMV");
Batch b = rs.createBatch(si, nid);
QValue[] vs = new QValue[] { rs.getQValueFactory().create(new byte[] { 'a', 'b', 'c' }), rs.getQValueFactory().create(new byte[0]), rs.getQValueFactory().create(new byte[] { 'g', 'h', 'i' }) };
b.addProperty(nid, propName, vs);
rs.submit(b);
PropertyInfo pi = rs.getPropertyInfo(si, getPropertyId(nid, propName));
assertTrue(pi.isMultiValued());
vs = pi.getValues();
assertEquals("abc", vs[0].getString());
assertEquals("", vs[1].getString());
assertEquals("ghi", vs[2].getString());
assertEquals(PropertyType.BINARY, pi.getType());
pi = getPropertyInfo(nid, propName);
vs = pi.getValues();
assertEquals("abc", vs[0].getString());
assertEquals("", vs[1].getString());
assertEquals("ghi", vs[2].getString());
assertEquals(PropertyType.BINARY, pi.getType());
}
use of org.apache.jackrabbit.spi.PropertyInfo in project jackrabbit by apache.
the class BatchTest method testSetBinaryValue.
public void testSetBinaryValue() throws RepositoryException, IOException {
NodeId nid = getNodeId(testPath);
Name propName = resolver.getQName("binProp");
Batch b = rs.createBatch(si, nid);
b.addProperty(nid, propName, rs.getQValueFactory().create(new byte[] { 'a', 'b', 'c' }));
rs.submit(b);
PropertyInfo pi = rs.getPropertyInfo(si, getPropertyId(nid, propName));
assertFalse(pi.isMultiValued());
assertEquals("abc", pi.getValues()[0].getString());
assertEquals(PropertyType.BINARY, pi.getType());
}
Aggregations