use of org.apache.jackrabbit.spi.Name in project jackrabbit by apache.
the class BatchTest method testSetDateValue.
public void testSetDateValue() throws RepositoryException {
NodeId nid = getNodeId(testPath);
Name propName = resolver.getQName("dateProp");
QValue v = rs.getQValueFactory().create(Calendar.getInstance());
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(v.getString(), pi.getValues()[0].getString());
assertEquals(PropertyType.DATE, pi.getType());
pi = getPropertyInfo(nid, propName);
assertEquals(v, pi.getValues()[0]);
assertEquals(v.getString(), pi.getValues()[0].getString());
assertEquals(PropertyType.DATE, pi.getType());
}
use of org.apache.jackrabbit.spi.Name in project jackrabbit by apache.
the class BatchTest method testSetLongValue.
public void testSetLongValue() throws RepositoryException {
NodeId nid = getNodeId(testPath);
Name propName = resolver.getQName("doubleProp");
QValue v = rs.getQValueFactory().create(234567);
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(v.getString(), pi.getValues()[0].getString());
assertEquals(PropertyType.LONG, pi.getType());
pi = getPropertyInfo(nid, propName);
assertEquals(v, pi.getValues()[0]);
assertEquals(v.getString(), pi.getValues()[0].getString());
assertEquals(PropertyType.LONG, pi.getType());
}
use of org.apache.jackrabbit.spi.Name in project jackrabbit by apache.
the class BatchTest method testEmptyValueArray.
public void testEmptyValueArray() throws RepositoryException {
NodeId nid = getNodeId(testPath);
Name propName = resolver.getQName("mvProperty");
Batch b = rs.createBatch(si, nid);
b.addProperty(nid, propName, new QValue[0]);
rs.submit(b);
PropertyId pid = getPropertyId(nid, propName);
PropertyInfo pi = rs.getPropertyInfo(si, pid);
assertTrue(pi.isMultiValued());
assertEquals(Arrays.asList(new QValue[0]), Arrays.asList(pi.getValues()));
assertFalse(pi.getType() == PropertyType.UNDEFINED);
Iterator<? extends ItemInfo> it = rs.getItemInfos(si, nid);
while (it.hasNext()) {
ItemInfo info = it.next();
if (!info.denotesNode()) {
PropertyInfo pInfo = (PropertyInfo) info;
if (propName.equals((pInfo.getId().getName()))) {
assertTrue(pi.isMultiValued());
assertEquals(Arrays.asList(new QValue[0]), Arrays.asList(pi.getValues()));
assertFalse(pi.getType() == PropertyType.UNDEFINED);
break;
}
}
}
}
use of org.apache.jackrabbit.spi.Name 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());
}
use of org.apache.jackrabbit.spi.Name 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());
}
}
Aggregations