use of org.apache.jackrabbit.spi.QValue in project jackrabbit by apache.
the class ItemInfoJsonHandler method endArray.
public void endArray() throws IOException {
try {
if (propertyType == PropertyType.UNDEFINED) {
if (propValues.isEmpty()) {
// make sure that type is set for mv-properties with empty value array.
propertyType = vFactory.retrieveType(getValueURI());
} else {
propertyType = propValues.get(0).getType();
}
}
// create multi-valued property info
NodeInfoImpl parent = getCurrentNodeInfo();
Path p = pFactory.create(parent.getPath(), name, true);
PropertyId id = idFactory.createPropertyId(parent.getId(), name);
PropertyInfoImpl propInfo = new PropertyInfoImpl(id, p, propertyType, propValues.toArray(new QValue[propValues.size()]));
propInfo.checkCompleted();
getCurrentPropInfos().add(propInfo);
} catch (RepositoryException e) {
throw new IOException(e.getMessage());
} finally {
// reset property-related handler state
propertyType = PropertyType.UNDEFINED;
multiValuedProperty = false;
propValues.clear();
name = null;
}
}
use of org.apache.jackrabbit.spi.QValue in project jackrabbit by apache.
the class NodeInfoImpl method setPropertyInfos.
//--------------------------------------------------------------------------
void setPropertyInfos(PropertyInfoImpl[] propInfos, IdFactory idFactory) throws RepositoryException {
boolean resolveUUID = false;
for (PropertyInfoImpl propInfo : propInfos) {
Name pn = propInfo.getId().getName();
if (NameConstants.JCR_UUID.equals(pn)) {
id = idFactory.createNodeId(propInfo.getValues()[0].getString());
resolveUUID = true;
} else if (NameConstants.JCR_PRIMARYTYPE.equals(pn)) {
primaryNodeTypeName = propInfo.getValues()[0].getName();
} else if (NameConstants.JCR_MIXINTYPES.equals(pn)) {
QValue[] vs = propInfo.getValues();
Name[] mixins = new Name[vs.length];
for (int i = 0; i < vs.length; i++) {
mixins[i] = vs[i].getName();
}
mixinNodeTypeNames = mixins;
}
}
propertyIds.clear();
for (PropertyInfoImpl propInfo : propInfos) {
if (resolveUUID) {
propInfo.setId(idFactory.createPropertyId(id, propInfo.getName()));
}
propertyIds.add(propInfo.getId());
}
}
use of org.apache.jackrabbit.spi.QValue 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.QValue in project jackrabbit by apache.
the class BatchTest method testSetPathValue.
public void testSetPathValue() throws RepositoryException {
NodeId nid = getNodeId(testPath);
Name propName = resolver.getQName("pathProp");
QValue v = rs.getQValueFactory().create(resolver.getQPath(testPath));
Batch b = rs.createBatch(si, nid);
b.addProperty(nid, propName, v);
rs.submit(b);
PropertyInfo pi = rs.getPropertyInfo(si, getPropertyId(nid, propName));
assertFalse(pi.isMultiValued());
assertEquals(v, pi.getValues()[0]);
assertEquals(PropertyType.PATH, pi.getType());
pi = getPropertyInfo(nid, propName);
assertEquals(v.getPath(), pi.getValues()[0].getPath());
assertEquals(v, pi.getValues()[0]);
assertEquals(PropertyType.PATH, pi.getType());
}
use of org.apache.jackrabbit.spi.QValue in project jackrabbit by apache.
the class BatchTest method testSetBooleanValue.
public void testSetBooleanValue() throws RepositoryException {
NodeId nid = getNodeId(testPath);
Name propName = resolver.getQName("booleanProp");
QValue v = rs.getQValueFactory().create(false);
Batch b = rs.createBatch(si, nid);
b.addProperty(nid, propName, v);
rs.submit(b);
PropertyInfo pi = rs.getPropertyInfo(si, getPropertyId(nid, propName));
assertFalse(pi.isMultiValued());
assertFalse(pi.getValues()[0].getBoolean());
assertEquals(PropertyType.BOOLEAN, pi.getType());
pi = getPropertyInfo(nid, propName);
assertFalse(pi.getValues()[0].getBoolean());
assertEquals(PropertyType.BOOLEAN, pi.getType());
}
Aggregations