Search in sources :

Example 11 with PropertyInfo

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());
}
Also used : QValue(org.apache.jackrabbit.spi.QValue) Batch(org.apache.jackrabbit.spi.Batch) NodeId(org.apache.jackrabbit.spi.NodeId) PropertyInfo(org.apache.jackrabbit.spi.PropertyInfo) Name(org.apache.jackrabbit.spi.Name)

Example 12 with PropertyInfo

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());
}
Also used : QValue(org.apache.jackrabbit.spi.QValue) Batch(org.apache.jackrabbit.spi.Batch) NodeId(org.apache.jackrabbit.spi.NodeId) PropertyInfo(org.apache.jackrabbit.spi.PropertyInfo) Name(org.apache.jackrabbit.spi.Name)

Example 13 with PropertyInfo

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);
    }
}
Also used : ItemInfo(org.apache.jackrabbit.spi.ItemInfo) PathNotFoundException(javax.jcr.PathNotFoundException) PropertyInfo(org.apache.jackrabbit.spi.PropertyInfo) HierarchyEntry(org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry) ItemNotFoundException(javax.jcr.ItemNotFoundException)

Example 14 with PropertyInfo

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());
}
Also used : QValue(org.apache.jackrabbit.spi.QValue) Batch(org.apache.jackrabbit.spi.Batch) NodeId(org.apache.jackrabbit.spi.NodeId) PropertyInfo(org.apache.jackrabbit.spi.PropertyInfo) Name(org.apache.jackrabbit.spi.Name)

Example 15 with PropertyInfo

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());
}
Also used : NodeId(org.apache.jackrabbit.spi.NodeId) PropertyInfo(org.apache.jackrabbit.spi.PropertyInfo) Name(org.apache.jackrabbit.spi.Name)

Aggregations

PropertyInfo (org.apache.jackrabbit.spi.PropertyInfo)27 NodeId (org.apache.jackrabbit.spi.NodeId)23 Name (org.apache.jackrabbit.spi.Name)22 Batch (org.apache.jackrabbit.spi.Batch)19 QValue (org.apache.jackrabbit.spi.QValue)18 ItemInfo (org.apache.jackrabbit.spi.ItemInfo)5 NodeInfo (org.apache.jackrabbit.spi.NodeInfo)5 PropertyId (org.apache.jackrabbit.spi.PropertyId)5 ArrayList (java.util.ArrayList)4 ItemNotFoundException (javax.jcr.ItemNotFoundException)3 InputStream (java.io.InputStream)2 PathNotFoundException (javax.jcr.PathNotFoundException)2 RepositoryException (javax.jcr.RepositoryException)2 Path (org.apache.jackrabbit.spi.Path)2 IOException (java.io.IOException)1 ItemVisitor (javax.jcr.ItemVisitor)1 Node (javax.jcr.Node)1 Property (javax.jcr.Property)1 TraversingItemVisitor (javax.jcr.util.TraversingItemVisitor)1 HttpEntity (org.apache.http.HttpEntity)1