Search in sources :

Example 6 with ValueAndType

use of io.milton.http.values.ValueAndType in project lobcder by skoulouzis.

the class JsonPropFindHandler method filterResults.

/**
 * If the where argument is given, removes results where it does not
 * evaluate to true
 *
 * If the given where argument starts with ! the condition is negated
 *
 * @param results
 * @param where
 */
private void filterResults(List<PropFindResponse> results, String where) {
    if (where != null && where.length() > 0) {
        boolean negate = where.startsWith("!");
        if (negate) {
            where = where.substring(1);
        }
        ValueAndType prop;
        QName qnWhere = parseQName(where);
        Iterator<PropFindResponse> it = results.iterator();
        boolean removeValue = negate;
        while (it.hasNext()) {
            PropFindResponse result = it.next();
            boolean isTrue = eval(qnWhere, result);
            // eg iscollection for a folder -> false == true = false, so dont remove
            if (isTrue == removeValue) {
                it.remove();
            }
        }
    }
}
Also used : ValueAndType(io.milton.http.values.ValueAndType) QName(javax.xml.namespace.QName)

Aggregations

ValueAndType (io.milton.http.values.ValueAndType)6 QName (javax.xml.namespace.QName)5 NotAuthorizedException (io.milton.http.exceptions.NotAuthorizedException)4 Status (io.milton.http.Response.Status)2 NameAndError (io.milton.http.webdav.PropFindResponse.NameAndError)2 PropertySource (io.milton.property.PropertySource)2 PropertyMetaData (io.milton.property.PropertySource.PropertyMetaData)2 XmlWriter (io.milton.http.XmlWriter)1 LdapMappedProp (io.milton.ldap.LdapPropertyMapper.LdapMappedProp)1 PropertySetException (io.milton.property.PropertySource.PropertySetException)1 CollectionResource (io.milton.resource.CollectionResource)1 LdapContact (io.milton.resource.LdapContact)1 PropFindableResource (io.milton.resource.PropFindableResource)1 Resource (io.milton.resource.Resource)1 ArrayList (java.util.ArrayList)1 EnumMap (java.util.EnumMap)1 HashMap (java.util.HashMap)1 List (java.util.List)1