use of org.apache.jackrabbit.spi.PropertyInfo 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.PropertyInfo 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());
}
use of org.apache.jackrabbit.spi.PropertyInfo in project jackrabbit by apache.
the class WorkspaceItemStateFactory method createDeepPropertyState.
/**
* Creates the PropertyState with information retrieved from the <code>RepositoryService</code>.
* Intermediate entries are created as needed.
*/
public PropertyState createDeepPropertyState(PropertyId propertyId, NodeEntry anyParent) throws RepositoryException {
try {
// Get item info from cache
Iterator<? extends ItemInfo> infos = null;
Entry<PropertyInfo> cached = cache.getPropertyInfo(propertyId);
ItemInfo info;
if (cached == null) {
// or from service if not in cache
infos = service.getItemInfos(sessionInfo, propertyId);
info = first(infos, null, 0);
if (info == null || info.denotesNode()) {
throw new ItemNotFoundException("PropertyId: " + propertyId);
}
} else {
info = cached.info;
}
// Build the hierarchy entry for the item info
HierarchyEntry entry = createHierarchyEntries(info, anyParent);
if (entry == null || entry.denotesNode()) {
throw new ItemNotFoundException("HierarchyEntry does not belong to any existing ItemInfo. No ItemState was created.");
} else {
long generation = entry.getGeneration();
if (isOutdated(cached, entry)) {
// if not, retrieve the item info from the service and put the whole batch into the cache
infos = service.getItemInfos(sessionInfo, propertyId);
info = first(infos, cache, generation);
} else if (infos != null) {
// Otherwise put the whole batch retrieved from the service earlier into the cache
cache.put(info, generation);
first(infos, cache, generation);
}
assertMatchingPath(info, entry);
return createPropertyState((PropertyInfo) info, (PropertyEntry) entry);
}
} catch (PathNotFoundException e) {
throw new ItemNotFoundException(e);
}
}
use of org.apache.jackrabbit.spi.PropertyInfo in project jackrabbit by apache.
the class BatchTest method testSetDoubleValue.
public void testSetDoubleValue() throws RepositoryException {
NodeId nid = getNodeId(testPath);
Name propName = resolver.getQName("doubleProp");
QValue v = rs.getQValueFactory().create((double) 12);
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.DOUBLE, pi.getType());
pi = getPropertyInfo(nid, propName);
assertEquals(v, pi.getValues()[0]);
assertEquals(v.getString(), pi.getValues()[0].getString());
assertEquals(PropertyType.DOUBLE, pi.getType());
}
use of org.apache.jackrabbit.spi.PropertyInfo in project jackrabbit by apache.
the class CreateFileTest method testPropertiesWithNonLatinCharacters.
public void testPropertiesWithNonLatinCharacters() throws RepositoryException, IOException {
Name fileName = resolver.getQName("سش.txt");
createFile(fileName);
NodeId nid = getNodeId(testPath + "/سش.txt/jcr:content");
PropertyInfo pi = rs.getPropertyInfo(si, rs.getIdFactory().createPropertyId(nid, NameConstants.JCR_LASTMODIFIED));
assertEquals(lastModified, pi.getValues()[0]);
pi = rs.getPropertyInfo(si, rs.getIdFactory().createPropertyId(nid, NameConstants.JCR_MIMETYPE));
assertEquals(mimeType, pi.getValues()[0]);
pi = rs.getPropertyInfo(si, rs.getIdFactory().createPropertyId(nid, NameConstants.JCR_ENCODING));
assertEquals(enc, pi.getValues()[0]);
pi = rs.getPropertyInfo(si, rs.getIdFactory().createPropertyId(nid, NameConstants.JCR_DATA));
assertEquals("سش", pi.getValues()[0].getString());
}
Aggregations