Commit 9783032f authored by Mickaël Guessant's avatar Mickaël Guessant

EWS/Webdav: implement exists filter condition

git-svn-id: https://svn.code.sf.net/p/davmail/code/trunk@2449 3d1905a2-6b24-0410-a738-b14d5a86fcbd
parent c65ddad7
......@@ -1060,6 +1060,11 @@ public class DavExchangeSession extends ExchangeSession {
return new MonoCondition(attributeName, Operator.IsNull);
}
@Override
public Condition exists(String attributeName) {
return not(new MonoCondition(attributeName, Operator.IsNull));
}
@Override
public Condition isTrue(String attributeName) {
if ("Exchange2003".equals(this.serverVersion) && "deleted".equals(attributeName)) {
......
......@@ -974,6 +974,30 @@ public class EwsExchangeSession extends ExchangeSession {
}
protected static class ExistsCondition implements ExchangeSession.Condition, SearchExpression {
protected final String attributeName;
protected ExistsCondition(String attributeName) {
this.attributeName = attributeName;
}
public void appendTo(StringBuilder buffer) {
buffer.append("<t:Exists>");
Field.get(attributeName).appendTo(buffer);
buffer.append("</t:Exists>");
}
public boolean isEmpty() {
return false;
}
public boolean isMatch(ExchangeSession.Contact contact) {
String actualValue = contact.get(attributeName);
return actualValue == null;
}
}
@Override
public ExchangeSession.MultiCondition and(Condition... condition) {
return new MultiCondition(Operator.And, condition);
......@@ -1061,6 +1085,11 @@ public class EwsExchangeSession extends ExchangeSession {
return new IsNullCondition(attributeName);
}
@Override
public Condition exists(String attributeName) {
return new ExistsCondition(attributeName);
}
@Override
public Condition isTrue(String attributeName) {
return new AttributeCondition(attributeName, Operator.IsEqualTo, "true");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment