use of org.apache.jackrabbit.spi.PropertyId in project jackrabbit by apache.
the class BatchTest method testEmptyValueArray2.
public void testEmptyValueArray2() throws RepositoryException {
NodeId nid = getNodeId(testPath);
Name propName = resolver.getQName("mvProperty");
Batch b = rs.createBatch(si, nid);
b.addProperty(nid, propName, new QValue[] { rs.getQValueFactory().create(true) });
rs.submit(b);
PropertyId pid = getPropertyId(nid, propName);
b = rs.createBatch(si, pid);
b.setValue(pid, new QValue[0]);
rs.submit(b);
PropertyInfo pi = rs.getPropertyInfo(si, pid);
assertTrue(pi.isMultiValued());
assertEquals(Arrays.asList(new QValue[0]), Arrays.asList(pi.getValues()));
}
use of org.apache.jackrabbit.spi.PropertyId in project jackrabbit by apache.
the class BatchTest method testRemove.
public void testRemove() throws RepositoryException {
NodeId nid = getNodeId(testPath);
Batch b = rs.createBatch(si, nid);
NodeId id = getNodeId(testPath + "/aTestNode");
b.addNode(nid, resolver.getQName("aTestNode"), NameConstants.NT_UNSTRUCTURED, null);
b.addProperty(id, resolver.getQName("aString"), rs.getQValueFactory().create("ba", PropertyType.STRING));
rs.submit(b);
PropertyId pid = getPropertyId(id, resolver.getQName("aString"));
b = rs.createBatch(si, nid);
b.remove(pid);
rs.submit(b);
try {
rs.getPropertyInfo(si, pid);
fail();
} catch (RepositoryException e) {
// success
}
}
use of org.apache.jackrabbit.spi.PropertyId in project jackrabbit by apache.
the class BatchTest method testSetPropertyTwice.
public void testSetPropertyTwice() throws RepositoryException {
NodeId nid = getNodeId(testPath);
Name propName = resolver.getQName("nameProp");
PropertyId pid = getPropertyId(nid, propName);
QValue v = rs.getQValueFactory().create(NameConstants.JCR_AUTOCREATED);
QValue v2 = rs.getQValueFactory().create(NameConstants.JCR_BASEVERSION);
QValue v3 = rs.getQValueFactory().create(NameConstants.JCR_CONTENT);
Batch b = rs.createBatch(si, nid);
b.addProperty(nid, propName, v);
b.setValue(pid, v2);
b.setValue(pid, v3);
rs.submit(b);
PropertyInfo pi = rs.getPropertyInfo(si, getPropertyId(nid, propName));
assertFalse(pi.isMultiValued());
assertEquals(1, pi.getValues().length);
assertEquals(v3, pi.getValues()[0]);
assertEquals(PropertyType.NAME, pi.getType());
pi = getPropertyInfo(nid, propName);
assertFalse(pi.isMultiValued());
assertEquals(1, pi.getValues().length);
assertEquals(v3, pi.getValues()[0]);
assertEquals(PropertyType.NAME, pi.getType());
}
use of org.apache.jackrabbit.spi.PropertyId in project jackrabbit by apache.
the class ReadTest method testReadNonExistingProperty.
public void testReadNonExistingProperty() throws RepositoryException {
NodeId nid = getNodeId(testPath);
PropertyId pid = getPropertyId(nid, NameConstants.JCR_CHILDNODEDEFINITION);
try {
rs.getPropertyInfo(si, pid);
fail();
} catch (ItemNotFoundException e) {
// ok
}
}
use of org.apache.jackrabbit.spi.PropertyId in project jackrabbit by apache.
the class ItemInfoJsonHandler method value.
// --------------------------------------------------------------------------
/**
* @param value
* @throws RepositoryException
*/
private void value(QValue value) throws RepositoryException {
if (!multiValuedProperty) {
try {
if (propertyType == PropertyType.UNDEFINED) {
propertyType = value.getType();
}
// create single-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, value);
propInfo.checkCompleted();
// add property info to current list, will be processed on endObject() event
getCurrentPropInfos().add(propInfo);
} finally {
// reset property-related handler state
propertyType = PropertyType.UNDEFINED;
multiValuedProperty = false;
propValues.clear();
name = null;
expectingHintValue = false;
}
} else {
// multi-valued property
// add value to current list, will be processed on endArray() event
propValues.add(value);
}
}
Aggregations