mirror of
https://github.com/moparisthebest/davmail
synced 2025-01-05 18:58:02 -05:00
EWS: rename equals to isEqualTo and format search date
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1300 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
875e7894ff
commit
fddab4b812
@ -116,9 +116,9 @@ public abstract class ExchangeSession {
|
|||||||
private final String userName;
|
private final String userName;
|
||||||
|
|
||||||
private boolean disableGalLookup;
|
private boolean disableGalLookup;
|
||||||
private static final String YYYY_MM_DD_HH_MM_SS = "yyyy/MM/dd HH:mm:ss";
|
protected static final String YYYY_MM_DD_HH_MM_SS = "yyyy/MM/dd HH:mm:ss";
|
||||||
private static final String YYYYMMDD_T_HHMMSS_Z = "yyyyMMdd'T'HHmmss'Z'";
|
private static final String YYYYMMDD_T_HHMMSS_Z = "yyyyMMdd'T'HHmmss'Z'";
|
||||||
private static final String YYYY_MM_DD_T_HHMMSS_Z = "yyyy-MM-dd'T'HH:mm:ss'Z'";
|
protected static final String YYYY_MM_DD_T_HHMMSS_Z = "yyyy-MM-dd'T'HH:mm:ss'Z'";
|
||||||
private static final String YYYY_MM_DD = "yyyy-MM-dd";
|
private static final String YYYY_MM_DD = "yyyy-MM-dd";
|
||||||
private static final String YYYY_MM_DD_T_HHMMSS_SSS_Z = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
|
private static final String YYYY_MM_DD_T_HHMMSS_SSS_Z = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
|
||||||
|
|
||||||
@ -193,11 +193,7 @@ public abstract class ExchangeSession {
|
|||||||
* @param date date object
|
* @param date date object
|
||||||
* @return formatted search date
|
* @return formatted search date
|
||||||
*/
|
*/
|
||||||
public static String formatSearchDate(Date date) {
|
public abstract String formatSearchDate(Date date);
|
||||||
SimpleDateFormat dateFormatter = new SimpleDateFormat(YYYY_MM_DD_HH_MM_SS, Locale.ENGLISH);
|
|
||||||
dateFormatter.setTimeZone(GMT_TIMEZONE);
|
|
||||||
return dateFormatter.format(date);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return standard zulu date formatter.
|
* Return standard zulu date formatter.
|
||||||
@ -762,7 +758,7 @@ public abstract class ExchangeSession {
|
|||||||
* @param value attribute value
|
* @param value attribute value
|
||||||
* @return condition
|
* @return condition
|
||||||
*/
|
*/
|
||||||
public abstract Condition equals(String attributeName, String value);
|
public abstract Condition isEqualTo(String attributeName, String value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Equals condition.
|
* Equals condition.
|
||||||
@ -771,7 +767,7 @@ public abstract class ExchangeSession {
|
|||||||
* @param value attribute value
|
* @param value attribute value
|
||||||
* @return condition
|
* @return condition
|
||||||
*/
|
*/
|
||||||
public abstract Condition equals(String attributeName, int value);
|
public abstract Condition isEqualTo(String attributeName, int value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MIME header equals condition.
|
* MIME header equals condition.
|
||||||
@ -780,7 +776,7 @@ public abstract class ExchangeSession {
|
|||||||
* @param value attribute value
|
* @param value attribute value
|
||||||
* @return condition
|
* @return condition
|
||||||
*/
|
*/
|
||||||
public abstract Condition headerEquals(String headerName, String value);
|
public abstract Condition headerIsEqualTo(String headerName, String value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Greater than or equals condition.
|
* Greater than or equals condition.
|
||||||
@ -870,7 +866,7 @@ public abstract class ExchangeSession {
|
|||||||
* @throws IOException on error
|
* @throws IOException on error
|
||||||
*/
|
*/
|
||||||
public List<Folder> getSubFolders(String folderName, boolean recursive) throws IOException {
|
public List<Folder> getSubFolders(String folderName, boolean recursive) throws IOException {
|
||||||
return getSubFolders(folderName, or(equals("folderclass", "IPF.Note"), isNull("folderclass")),
|
return getSubFolders(folderName, or(isEqualTo("folderclass", "IPF.Note"), isNull("folderclass")),
|
||||||
recursive);
|
recursive);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -883,7 +879,7 @@ public abstract class ExchangeSession {
|
|||||||
* @throws IOException on error
|
* @throws IOException on error
|
||||||
*/
|
*/
|
||||||
public List<Folder> getSubCalendarFolders(String folderName, boolean recursive) throws IOException {
|
public List<Folder> getSubCalendarFolders(String folderName, boolean recursive) throws IOException {
|
||||||
return getSubFolders(folderName, equals("folderclass", "IPF.Appointment"), recursive);
|
return getSubFolders(folderName, isEqualTo("folderclass", "IPF.Appointment"), recursive);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -939,7 +935,7 @@ public abstract class ExchangeSession {
|
|||||||
*/
|
*/
|
||||||
public void sendMessage(List<String> rcptToRecipients, MimeMessage mimeMessage) throws IOException, MessagingException {
|
public void sendMessage(List<String> rcptToRecipients, MimeMessage mimeMessage) throws IOException, MessagingException {
|
||||||
// check Sent folder for duplicates
|
// check Sent folder for duplicates
|
||||||
ExchangeSession.MessageList messages = searchMessages(SENT, headerEquals("message-id", mimeMessage.getMessageID()));
|
ExchangeSession.MessageList messages = searchMessages(SENT, headerIsEqualTo("message-id", mimeMessage.getMessageID()));
|
||||||
if (!messages.isEmpty()) {
|
if (!messages.isEmpty()) {
|
||||||
LOGGER.debug("Dropping message id " + mimeMessage.getMessageID() + ": already sent");
|
LOGGER.debug("Dropping message id " + mimeMessage.getMessageID() + ": already sent");
|
||||||
} else {
|
} else {
|
||||||
@ -2521,7 +2517,7 @@ public abstract class ExchangeSession {
|
|||||||
* @throws IOException on error
|
* @throws IOException on error
|
||||||
*/
|
*/
|
||||||
public List<ExchangeSession.Contact> getAllContacts(String folderPath) throws IOException {
|
public List<ExchangeSession.Contact> getAllContacts(String folderPath) throws IOException {
|
||||||
return searchContacts(folderPath, ITEM_PROPERTIES, equals("outlookmessageclass", "IPM.Contact"));
|
return searchContacts(folderPath, ITEM_PROPERTIES, isEqualTo("outlookmessageclass", "IPM.Contact"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2545,7 +2541,7 @@ public abstract class ExchangeSession {
|
|||||||
*/
|
*/
|
||||||
public List<Event> getEventMessages(String folderPath) throws IOException {
|
public List<Event> getEventMessages(String folderPath) throws IOException {
|
||||||
return searchEvents(folderPath, ITEM_PROPERTIES,
|
return searchEvents(folderPath, ITEM_PROPERTIES,
|
||||||
and(equals("outlookmessageclass", "IPM.Schedule.Meeting.Request"),
|
and(isEqualTo("outlookmessageclass", "IPM.Schedule.Meeting.Request"),
|
||||||
or(isNull("processed"), isFalse("processed"))));
|
or(isNull("processed"), isFalse("processed"))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2587,7 +2583,7 @@ public abstract class ExchangeSession {
|
|||||||
if (timeRangeEnd != null) {
|
if (timeRangeEnd != null) {
|
||||||
andCondition.add(lte("dtend", formatSearchDate(parser.parse(timeRangeEnd))));
|
andCondition.add(lte("dtend", formatSearchDate(parser.parse(timeRangeEnd))));
|
||||||
}
|
}
|
||||||
andCondition.add(equals("instancetype", 0));
|
andCondition.add(isEqualTo("instancetype", 0));
|
||||||
return searchEvents(folderPath, ITEM_PROPERTIES, andCondition);
|
return searchEvents(folderPath, ITEM_PROPERTIES, andCondition);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new IOException(e);
|
throw new IOException(e);
|
||||||
@ -2607,14 +2603,14 @@ public abstract class ExchangeSession {
|
|||||||
Condition privateCondition = null;
|
Condition privateCondition = null;
|
||||||
if (isSharedFolder(folderPath)) {
|
if (isSharedFolder(folderPath)) {
|
||||||
LOGGER.debug("Shared or public calendar: exclude private events");
|
LOGGER.debug("Shared or public calendar: exclude private events");
|
||||||
privateCondition = equals("sensitivity", 0);
|
privateCondition = isEqualTo("sensitivity", 0);
|
||||||
}
|
}
|
||||||
// instancetype 0 single appointment / 1 master recurring appointment
|
// instancetype 0 single appointment / 1 master recurring appointment
|
||||||
return searchEvents(folderPath, ITEM_PROPERTIES,
|
return searchEvents(folderPath, ITEM_PROPERTIES,
|
||||||
and(or(isNull("instancetype"),
|
and(or(isNull("instancetype"),
|
||||||
equals("instancetype", 1),
|
isEqualTo("instancetype", 1),
|
||||||
and(equals("instancetype", 0), dateCondition)),
|
and(isEqualTo("instancetype", 0), dateCondition)),
|
||||||
equals("outlookmessageclass", "IPM.Appointment"),
|
isEqualTo("outlookmessageclass", "IPM.Appointment"),
|
||||||
privateCondition));
|
privateCondition));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ import java.net.NoRouteToHostException;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
@ -501,17 +502,17 @@ public class DavExchangeSession extends ExchangeSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Condition equals(String attributeName, String value) {
|
public Condition isEqualTo(String attributeName, String value) {
|
||||||
return new AttributeCondition(attributeName, Operator.IsEqualTo, value);
|
return new AttributeCondition(attributeName, Operator.IsEqualTo, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Condition equals(String attributeName, int value) {
|
public Condition isEqualTo(String attributeName, int value) {
|
||||||
return new AttributeCondition(attributeName, Operator.IsEqualTo, value);
|
return new AttributeCondition(attributeName, Operator.IsEqualTo, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Condition headerEquals(String headerName, String value) {
|
public Condition headerIsEqualTo(String headerName, String value) {
|
||||||
return new HeaderCondition(headerName, Operator.IsEqualTo, value);
|
return new HeaderCondition(headerName, Operator.IsEqualTo, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -648,7 +649,7 @@ public class DavExchangeSession extends ExchangeSession {
|
|||||||
} else if (status == HttpStatus.SC_NOT_FOUND) {
|
} else if (status == HttpStatus.SC_NOT_FOUND) {
|
||||||
LOGGER.debug("Contact not found at " + encodedHref + ", searching permanenturl by urlcompname");
|
LOGGER.debug("Contact not found at " + encodedHref + ", searching permanenturl by urlcompname");
|
||||||
// failover, search item by urlcompname
|
// failover, search item by urlcompname
|
||||||
MultiStatusResponse[] responses = searchItems(folderPath, EVENT_REQUEST_PROPERTIES, DavExchangeSession.this.equals("urlcompname", convertItemNameToEML(itemName)), FolderQueryTraversal.Shallow);
|
MultiStatusResponse[] responses = searchItems(folderPath, EVENT_REQUEST_PROPERTIES, DavExchangeSession.this.isEqualTo("urlcompname", convertItemNameToEML(itemName)), FolderQueryTraversal.Shallow);
|
||||||
if (responses.length == 1) {
|
if (responses.length == 1) {
|
||||||
encodedHref = getPropertyIfExists(responses[0].getProperties(HttpStatus.SC_OK), "permanenturl");
|
encodedHref = getPropertyIfExists(responses[0].getProperties(HttpStatus.SC_OK), "permanenturl");
|
||||||
LOGGER.warn("Contact found, permanenturl is " + encodedHref);
|
LOGGER.warn("Contact found, permanenturl is " + encodedHref);
|
||||||
@ -861,7 +862,7 @@ public class DavExchangeSession extends ExchangeSession {
|
|||||||
} else if (status == HttpStatus.SC_NOT_FOUND) {
|
} else if (status == HttpStatus.SC_NOT_FOUND) {
|
||||||
LOGGER.debug("Event not found at " + encodedHref + ", searching permanenturl by urlcompname");
|
LOGGER.debug("Event not found at " + encodedHref + ", searching permanenturl by urlcompname");
|
||||||
// failover, search item by urlcompname
|
// failover, search item by urlcompname
|
||||||
MultiStatusResponse[] responses = searchItems(folderPath, EVENT_REQUEST_PROPERTIES, DavExchangeSession.this.equals("urlcompname", convertItemNameToEML(itemName)), FolderQueryTraversal.Shallow);
|
MultiStatusResponse[] responses = searchItems(folderPath, EVENT_REQUEST_PROPERTIES, DavExchangeSession.this.isEqualTo("urlcompname", convertItemNameToEML(itemName)), FolderQueryTraversal.Shallow);
|
||||||
if (responses.length == 1) {
|
if (responses.length == 1) {
|
||||||
encodedHref = getPropertyIfExists(responses[0].getProperties(HttpStatus.SC_OK), "permanenturl");
|
encodedHref = getPropertyIfExists(responses[0].getProperties(HttpStatus.SC_OK), "permanenturl");
|
||||||
LOGGER.warn("Event found, permanenturl is " + encodedHref);
|
LOGGER.warn("Event found, permanenturl is " + encodedHref);
|
||||||
@ -1182,7 +1183,7 @@ public class DavExchangeSession extends ExchangeSession {
|
|||||||
public List<ExchangeSession.Contact> searchContacts(String folderPath, Set<String> attributes, Condition condition) throws IOException {
|
public List<ExchangeSession.Contact> searchContacts(String folderPath, Set<String> attributes, Condition condition) throws IOException {
|
||||||
List<ExchangeSession.Contact> contacts = new ArrayList<ExchangeSession.Contact>();
|
List<ExchangeSession.Contact> contacts = new ArrayList<ExchangeSession.Contact>();
|
||||||
MultiStatusResponse[] responses = searchItems(folderPath, attributes,
|
MultiStatusResponse[] responses = searchItems(folderPath, attributes,
|
||||||
and(equals("outlookmessageclass", "IPM.Contact"), isFalse("isfolder"), isFalse("ishidden"), condition),
|
and(isEqualTo("outlookmessageclass", "IPM.Contact"), isFalse("isfolder"), isFalse("ishidden"), condition),
|
||||||
FolderQueryTraversal.Shallow);
|
FolderQueryTraversal.Shallow);
|
||||||
for (MultiStatusResponse response : responses) {
|
for (MultiStatusResponse response : responses) {
|
||||||
contacts.add(new Contact(response));
|
contacts.add(new Contact(response));
|
||||||
@ -1267,7 +1268,7 @@ public class DavExchangeSession extends ExchangeSession {
|
|||||||
} catch (HttpNotFoundException e) {
|
} catch (HttpNotFoundException e) {
|
||||||
LOGGER.debug(itemPath + " not found, searching by urlcompname");
|
LOGGER.debug(itemPath + " not found, searching by urlcompname");
|
||||||
// failover: try to get event by displayname
|
// failover: try to get event by displayname
|
||||||
responses = searchItems(folderPath, EVENT_REQUEST_PROPERTIES, equals("urlcompname", emlItemName), FolderQueryTraversal.Shallow);
|
responses = searchItems(folderPath, EVENT_REQUEST_PROPERTIES, isEqualTo("urlcompname", emlItemName), FolderQueryTraversal.Shallow);
|
||||||
if (responses.length == 0) {
|
if (responses.length == 0) {
|
||||||
throw new HttpNotFoundException(itemPath + " not found");
|
throw new HttpNotFoundException(itemPath + " not found");
|
||||||
}
|
}
|
||||||
@ -1277,7 +1278,7 @@ public class DavExchangeSession extends ExchangeSession {
|
|||||||
String urlcompname = getPropertyIfExists(responses[0].getProperties(HttpStatus.SC_OK), "urlcompname");
|
String urlcompname = getPropertyIfExists(responses[0].getProperties(HttpStatus.SC_OK), "urlcompname");
|
||||||
if ("urn:content-classes:person".equals(contentClass)) {
|
if ("urn:content-classes:person".equals(contentClass)) {
|
||||||
// retrieve Contact properties
|
// retrieve Contact properties
|
||||||
List<ExchangeSession.Contact> contacts = searchContacts(folderPath, CONTACT_ATTRIBUTES, equals("urlcompname", urlcompname));
|
List<ExchangeSession.Contact> contacts = searchContacts(folderPath, CONTACT_ATTRIBUTES, isEqualTo("urlcompname", urlcompname));
|
||||||
if (contacts.isEmpty()) {
|
if (contacts.isEmpty()) {
|
||||||
LOGGER.warn("Item found, but unable to build contact");
|
LOGGER.warn("Item found, but unable to build contact");
|
||||||
throw new HttpNotFoundException(itemPath + " not found");
|
throw new HttpNotFoundException(itemPath + " not found");
|
||||||
@ -1453,7 +1454,7 @@ public class DavExchangeSession extends ExchangeSession {
|
|||||||
Set<String> attributes = new HashSet<String>();
|
Set<String> attributes = new HashSet<String>();
|
||||||
attributes.add("roamingdictionary");
|
attributes.add("roamingdictionary");
|
||||||
|
|
||||||
MultiStatusResponse[] responses = searchItems("/users/" + getEmail() + "/NON_IPM_SUBTREE", attributes, equals("messageclass", "IPM.Configuration.OWA.UserOptions"), DavExchangeSession.FolderQueryTraversal.Deep);
|
MultiStatusResponse[] responses = searchItems("/users/" + getEmail() + "/NON_IPM_SUBTREE", attributes, isEqualTo("messageclass", "IPM.Configuration.OWA.UserOptions"), DavExchangeSession.FolderQueryTraversal.Deep);
|
||||||
if (responses.length == 1) {
|
if (responses.length == 1) {
|
||||||
byte[] roamingdictionary = getBinaryPropertyIfExists(responses[0].getProperties(HttpStatus.SC_OK), "roamingdictionary");
|
byte[] roamingdictionary = getBinaryPropertyIfExists(responses[0].getProperties(HttpStatus.SC_OK), "roamingdictionary");
|
||||||
if (roamingdictionary != null) {
|
if (roamingdictionary != null) {
|
||||||
@ -1742,4 +1743,18 @@ public class DavExchangeSession extends ExchangeSession {
|
|||||||
}
|
}
|
||||||
return zuluDateValue;
|
return zuluDateValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format date to exchange search format.
|
||||||
|
*
|
||||||
|
* @param date date object
|
||||||
|
* @return formatted search date
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String formatSearchDate(Date date) {
|
||||||
|
SimpleDateFormat dateFormatter = new SimpleDateFormat(YYYY_MM_DD_HH_MM_SS, Locale.ENGLISH);
|
||||||
|
dateFormatter.setTimeZone(GMT_TIMEZONE);
|
||||||
|
return dateFormatter.format(date);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@ import java.net.HttpURLConnection;
|
|||||||
import java.net.NoRouteToHostException;
|
import java.net.NoRouteToHostException;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -428,17 +429,17 @@ public class EwsExchangeSession extends ExchangeSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Condition equals(String attributeName, String value) {
|
public Condition isEqualTo(String attributeName, String value) {
|
||||||
return new AttributeCondition(attributeName, Operator.IsEqualTo, value);
|
return new AttributeCondition(attributeName, Operator.IsEqualTo, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Condition equals(String attributeName, int value) {
|
public Condition isEqualTo(String attributeName, int value) {
|
||||||
return new AttributeCondition(attributeName, Operator.IsEqualTo, String.valueOf(value));
|
return new AttributeCondition(attributeName, Operator.IsEqualTo, String.valueOf(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Condition headerEquals(String headerName, String value) {
|
public Condition headerIsEqualTo(String headerName, String value) {
|
||||||
return new HeaderCondition(headerName, Operator.IsEqualTo, value);
|
return new HeaderCondition(headerName, Operator.IsEqualTo, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -714,7 +715,7 @@ public class EwsExchangeSession extends ExchangeSession {
|
|||||||
String currentEtag = null;
|
String currentEtag = null;
|
||||||
ItemId currentItemId = null;
|
ItemId currentItemId = null;
|
||||||
FileAttachment currentFileAttachment = null;
|
FileAttachment currentFileAttachment = null;
|
||||||
List<EWSMethod.Item> responses = searchItems(folderPath, EVENT_REQUEST_PROPERTIES, EwsExchangeSession.this.equals("urlcompname", urlcompname), FolderQueryTraversal.SHALLOW);
|
List<EWSMethod.Item> responses = searchItems(folderPath, EVENT_REQUEST_PROPERTIES, EwsExchangeSession.this.isEqualTo("urlcompname", urlcompname), FolderQueryTraversal.SHALLOW);
|
||||||
if (!responses.isEmpty()) {
|
if (!responses.isEmpty()) {
|
||||||
EWSMethod.Item response = responses.get(0);
|
EWSMethod.Item response = responses.get(0);
|
||||||
currentItemId = new ItemId(response);
|
currentItemId = new ItemId(response);
|
||||||
@ -836,7 +837,7 @@ public class EwsExchangeSession extends ExchangeSession {
|
|||||||
String urlcompname = convertItemNameToEML(itemName);
|
String urlcompname = convertItemNameToEML(itemName);
|
||||||
String currentEtag = null;
|
String currentEtag = null;
|
||||||
ItemId currentItemId = null;
|
ItemId currentItemId = null;
|
||||||
List<EWSMethod.Item> responses = searchItems(folderPath, EVENT_REQUEST_PROPERTIES, EwsExchangeSession.this.equals("urlcompname", urlcompname), FolderQueryTraversal.SHALLOW);
|
List<EWSMethod.Item> responses = searchItems(folderPath, EVENT_REQUEST_PROPERTIES, EwsExchangeSession.this.isEqualTo("urlcompname", urlcompname), FolderQueryTraversal.SHALLOW);
|
||||||
if (!responses.isEmpty()) {
|
if (!responses.isEmpty()) {
|
||||||
EWSMethod.Item response = responses.get(0);
|
EWSMethod.Item response = responses.get(0);
|
||||||
currentItemId = new ItemId(response);
|
currentItemId = new ItemId(response);
|
||||||
@ -952,14 +953,14 @@ public class EwsExchangeSession extends ExchangeSession {
|
|||||||
@Override
|
@Override
|
||||||
public Item getItem(String folderPath, String itemName) throws IOException {
|
public Item getItem(String folderPath, String itemName) throws IOException {
|
||||||
String urlcompname = convertItemNameToEML(itemName);
|
String urlcompname = convertItemNameToEML(itemName);
|
||||||
List<EWSMethod.Item> responses = searchItems(folderPath, EVENT_REQUEST_PROPERTIES, equals("urlcompname", urlcompname), FolderQueryTraversal.SHALLOW);
|
List<EWSMethod.Item> responses = searchItems(folderPath, EVENT_REQUEST_PROPERTIES, isEqualTo("urlcompname", urlcompname), FolderQueryTraversal.SHALLOW);
|
||||||
if (responses.isEmpty()) {
|
if (responses.isEmpty()) {
|
||||||
throw new DavMailException("EXCEPTION_ITEM_NOT_FOUND");
|
throw new DavMailException("EXCEPTION_ITEM_NOT_FOUND");
|
||||||
}
|
}
|
||||||
String itemType = responses.get(0).type;
|
String itemType = responses.get(0).type;
|
||||||
if ("Contact".equals(itemType)) {
|
if ("Contact".equals(itemType)) {
|
||||||
// retrieve Contact properties
|
// retrieve Contact properties
|
||||||
List<ExchangeSession.Contact> contacts = searchContacts(folderPath, CONTACT_ATTRIBUTES, equals("urlcompname", urlcompname));
|
List<ExchangeSession.Contact> contacts = searchContacts(folderPath, CONTACT_ATTRIBUTES, isEqualTo("urlcompname", urlcompname));
|
||||||
if (contacts.isEmpty()) {
|
if (contacts.isEmpty()) {
|
||||||
throw new DavMailException("EXCEPTION_ITEM_NOT_FOUND");
|
throw new DavMailException("EXCEPTION_ITEM_NOT_FOUND");
|
||||||
}
|
}
|
||||||
@ -1005,7 +1006,7 @@ public class EwsExchangeSession extends ExchangeSession {
|
|||||||
@Override
|
@Override
|
||||||
public void deleteItem(String folderPath, String itemName) throws IOException {
|
public void deleteItem(String folderPath, String itemName) throws IOException {
|
||||||
String urlcompname = convertItemNameToEML(itemName);
|
String urlcompname = convertItemNameToEML(itemName);
|
||||||
List<EWSMethod.Item> responses = searchItems(folderPath, EVENT_REQUEST_PROPERTIES, equals("urlcompname", urlcompname), FolderQueryTraversal.SHALLOW);
|
List<EWSMethod.Item> responses = searchItems(folderPath, EVENT_REQUEST_PROPERTIES, isEqualTo("urlcompname", urlcompname), FolderQueryTraversal.SHALLOW);
|
||||||
if (!responses.isEmpty()) {
|
if (!responses.isEmpty()) {
|
||||||
DeleteItemMethod deleteItemMethod = new DeleteItemMethod(new ItemId(responses.get(0)), DeleteType.HardDelete);
|
DeleteItemMethod deleteItemMethod = new DeleteItemMethod(new ItemId(responses.get(0)), DeleteType.HardDelete);
|
||||||
executeMethod(deleteItemMethod);
|
executeMethod(deleteItemMethod);
|
||||||
@ -1015,7 +1016,7 @@ public class EwsExchangeSession extends ExchangeSession {
|
|||||||
@Override
|
@Override
|
||||||
public void processItem(String folderPath, String itemName) throws IOException {
|
public void processItem(String folderPath, String itemName) throws IOException {
|
||||||
String urlcompname = convertItemNameToEML(itemName);
|
String urlcompname = convertItemNameToEML(itemName);
|
||||||
List<EWSMethod.Item> responses = searchItems(folderPath, EVENT_REQUEST_PROPERTIES, equals("urlcompname", urlcompname), FolderQueryTraversal.SHALLOW);
|
List<EWSMethod.Item> responses = searchItems(folderPath, EVENT_REQUEST_PROPERTIES, isEqualTo("urlcompname", urlcompname), FolderQueryTraversal.SHALLOW);
|
||||||
if (!responses.isEmpty()) {
|
if (!responses.isEmpty()) {
|
||||||
HashMap<String, String> localProperties = new HashMap<String, String>();
|
HashMap<String, String> localProperties = new HashMap<String, String>();
|
||||||
localProperties.put("processed", "1");
|
localProperties.put("processed", "1");
|
||||||
@ -1157,5 +1158,19 @@ public class EwsExchangeSession extends ExchangeSession {
|
|||||||
return zuluDateValue;
|
return zuluDateValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format date to exchange search format.
|
||||||
|
*
|
||||||
|
* @param date date object
|
||||||
|
* @return formatted search date
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String formatSearchDate(Date date) {
|
||||||
|
SimpleDateFormat dateFormatter = new SimpleDateFormat(YYYY_MM_DD_T_HHMMSS_Z, Locale.ENGLISH);
|
||||||
|
dateFormatter.setTimeZone(GMT_TIMEZONE);
|
||||||
|
return dateFormatter.format(date);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1042,7 +1042,7 @@ public class ImapConnection extends AbstractConnection {
|
|||||||
return session.isFalse("read");
|
return session.isFalse("read");
|
||||||
} else if ("DELETED".equals(token)) {
|
} else if ("DELETED".equals(token)) {
|
||||||
// conditions.deleted = Boolean.TRUE;
|
// conditions.deleted = Boolean.TRUE;
|
||||||
return session.equals("deleted", "1");
|
return session.isEqualTo("deleted", "1");
|
||||||
} else if ("UNDELETED".equals(token) || "NOT DELETED".equals(token)) {
|
} else if ("UNDELETED".equals(token) || "NOT DELETED".equals(token)) {
|
||||||
// conditions.deleted = Boolean.FALSE;
|
// conditions.deleted = Boolean.FALSE;
|
||||||
return session.isNull("deleted");
|
return session.isNull("deleted");
|
||||||
@ -1060,7 +1060,7 @@ public class ImapConnection extends AbstractConnection {
|
|||||||
if ("message-id".equals(headerName) && !value.startsWith("<")) {
|
if ("message-id".equals(headerName) && !value.startsWith("<")) {
|
||||||
value = '<' + value + '>';
|
value = '<' + value + '>';
|
||||||
}
|
}
|
||||||
return session.headerEquals(headerName, value);
|
return session.headerIsEqualTo(headerName, value);
|
||||||
} else if ("UID".equals(token)) {
|
} else if ("UID".equals(token)) {
|
||||||
String range = tokens.nextToken();
|
String range = tokens.nextToken();
|
||||||
if ("1:*".equals(range)) {
|
if ("1:*".equals(range)) {
|
||||||
|
@ -1091,7 +1091,7 @@ public class LdapConnection extends AbstractConnection {
|
|||||||
ExchangeSession.Condition condition = null;
|
ExchangeSession.Condition condition = null;
|
||||||
|
|
||||||
if (operator == LDAP_FILTER_EQUALITY) {
|
if (operator == LDAP_FILTER_EQUALITY) {
|
||||||
condition = session.equals(contactAttributeName, value);
|
condition = session.isEqualTo(contactAttributeName, value);
|
||||||
} else if ("*".equals(value)) {
|
} else if ("*".equals(value)) {
|
||||||
condition = session.not(session.isNull(contactAttributeName));
|
condition = session.not(session.isNull(contactAttributeName));
|
||||||
// do not allow substring search on integer field imapUid
|
// do not allow substring search on integer field imapUid
|
||||||
@ -1263,7 +1263,7 @@ public class LdapConnection extends AbstractConnection {
|
|||||||
try {
|
try {
|
||||||
// check if this is a contact uid
|
// check if this is a contact uid
|
||||||
Integer.parseInt(uid);
|
Integer.parseInt(uid);
|
||||||
persons = contactFind(session.equals("imapUid", uid), returningAttributes);
|
persons = contactFind(session.isEqualTo("imapUid", uid), returningAttributes);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
// ignore, this is not a contact uid
|
// ignore, this is not a contact uid
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ public class TestCaldav extends AbstractDavMailTestCase {
|
|||||||
session.gt("dtstart", session.formatSearchDate(start)),
|
session.gt("dtstart", session.formatSearchDate(start)),
|
||||||
session.lt("dtend", session.formatSearchDate(end))
|
session.lt("dtend", session.formatSearchDate(end))
|
||||||
)
|
)
|
||||||
, session.or(session.equals("instancetype", 1), session.equals("instancetype", 0))
|
, session.or(session.isEqualTo("instancetype", 1), session.isEqualTo("instancetype", 0))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ public class TestExchangeSessionMessage extends AbstractExchangeSessionTestCase
|
|||||||
HashMap<String, String> properties = new HashMap<String, String>();
|
HashMap<String, String> properties = new HashMap<String, String>();
|
||||||
properties.put("draft", "0");
|
properties.put("draft", "0");
|
||||||
session.createMessage("testfolder", messageName, properties, getMimeBody(mimeMessage));
|
session.createMessage("testfolder", messageName, properties, getMimeBody(mimeMessage));
|
||||||
ExchangeSession.MessageList messageList = session.searchMessages("testfolder", session.equals("urlcompname", messageName));
|
ExchangeSession.MessageList messageList = session.searchMessages("testfolder", session.isEqualTo("urlcompname", messageName));
|
||||||
assertNotNull(messageList);
|
assertNotNull(messageList);
|
||||||
assertEquals(1, messageList.size());
|
assertEquals(1, messageList.size());
|
||||||
}
|
}
|
||||||
@ -117,7 +117,7 @@ public class TestExchangeSessionMessage extends AbstractExchangeSessionTestCase
|
|||||||
HashMap<String, String> properties = new HashMap<String, String>();
|
HashMap<String, String> properties = new HashMap<String, String>();
|
||||||
properties.put("draft", "0");
|
properties.put("draft", "0");
|
||||||
session.createMessage("testfolder", messageName, properties, getMimeBody(mimeMessage));
|
session.createMessage("testfolder", messageName, properties, getMimeBody(mimeMessage));
|
||||||
ExchangeSession.MessageList messageList = session.searchMessages("testfolder", session.equals("urlcompname", messageName));
|
ExchangeSession.MessageList messageList = session.searchMessages("testfolder", session.isEqualTo("urlcompname", messageName));
|
||||||
assertNotNull(messageList);
|
assertNotNull(messageList);
|
||||||
assertEquals(1, messageList.size());
|
assertEquals(1, messageList.size());
|
||||||
}
|
}
|
||||||
@ -131,7 +131,7 @@ public class TestExchangeSessionMessage extends AbstractExchangeSessionTestCase
|
|||||||
HashMap<String, String> properties = new HashMap<String, String>();
|
HashMap<String, String> properties = new HashMap<String, String>();
|
||||||
properties.put("draft", "0");
|
properties.put("draft", "0");
|
||||||
session.createMessage("testfolder", messageName, properties, getMimeBody(mimeMessage));
|
session.createMessage("testfolder", messageName, properties, getMimeBody(mimeMessage));
|
||||||
ExchangeSession.MessageList messageList = session.searchMessages("testfolder", session.equals("urlcompname", messageName));
|
ExchangeSession.MessageList messageList = session.searchMessages("testfolder", session.isEqualTo("urlcompname", messageName));
|
||||||
assertNotNull(messageList);
|
assertNotNull(messageList);
|
||||||
assertEquals(1, messageList.size());
|
assertEquals(1, messageList.size());
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ public class TestExchangeSessionSearchContact extends AbstractExchangeSessionTes
|
|||||||
attributes.add("uid");
|
attributes.add("uid");
|
||||||
List<ExchangeSession.Contact> contacts = session.searchContacts(ExchangeSession.CONTACTS, attributes, null);
|
List<ExchangeSession.Contact> contacts = session.searchContacts(ExchangeSession.CONTACTS, attributes, null);
|
||||||
for (ExchangeSession.Contact contact : contacts) {
|
for (ExchangeSession.Contact contact : contacts) {
|
||||||
System.out.println(session.searchContacts(ExchangeSession.CONTACTS, attributes, session.equals("uid", contact.get("uid"))));
|
System.out.println(session.searchContacts(ExchangeSession.CONTACTS, attributes, session.isEqualTo("uid", contact.get("uid"))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ public class TestDavExchangeSession extends AbstractExchangeSessionTestCase {
|
|||||||
Set<String> attributes = new HashSet<String>();
|
Set<String> attributes = new HashSet<String>();
|
||||||
attributes.add("permanenturl");
|
attributes.add("permanenturl");
|
||||||
attributes.add("roamingxmlstream");
|
attributes.add("roamingxmlstream");
|
||||||
MultiStatusResponse[] responses = davSession.searchItems("/users/" + davSession.getEmail() + "/calendar", attributes, davSession.and(davSession.isFalse("isfolder"), davSession.equals("messageclass", "IPM.Configuration.CategoryList")), DavExchangeSession.FolderQueryTraversal.Shallow);
|
MultiStatusResponse[] responses = davSession.searchItems("/users/" + davSession.getEmail() + "/calendar", attributes, davSession.and(davSession.isFalse("isfolder"), davSession.isEqualTo("messageclass", "IPM.Configuration.CategoryList")), DavExchangeSession.FolderQueryTraversal.Shallow);
|
||||||
String value = (String) responses[0].getProperties(HttpStatus.SC_OK).get(Field.getPropertyName("roamingxmlstream")).getValue();
|
String value = (String) responses[0].getProperties(HttpStatus.SC_OK).get(Field.getPropertyName("roamingxmlstream")).getValue();
|
||||||
String propertyList = new String(Base64.decodeBase64(value.getBytes()), "UTF-8");
|
String propertyList = new String(Base64.decodeBase64(value.getBytes()), "UTF-8");
|
||||||
System.out.println(propertyList);
|
System.out.println(propertyList);
|
||||||
@ -127,7 +127,7 @@ public class TestDavExchangeSession extends AbstractExchangeSessionTestCase {
|
|||||||
Set<String> attributes = new HashSet<String>();
|
Set<String> attributes = new HashSet<String>();
|
||||||
attributes.add("permanenturl");
|
attributes.add("permanenturl");
|
||||||
attributes.add("roamingxmlstream");
|
attributes.add("roamingxmlstream");
|
||||||
MultiStatusResponse[] responses = davSession.searchItems("/users/" + davSession.getEmail() + "/calendar", attributes, davSession.and(davSession.isFalse("isfolder"), davSession.equals("messageclass", "IPM.Configuration.Calendar")), DavExchangeSession.FolderQueryTraversal.Shallow);
|
MultiStatusResponse[] responses = davSession.searchItems("/users/" + davSession.getEmail() + "/calendar", attributes, davSession.and(davSession.isFalse("isfolder"), davSession.isEqualTo("messageclass", "IPM.Configuration.Calendar")), DavExchangeSession.FolderQueryTraversal.Shallow);
|
||||||
String value = (String) responses[0].getProperties(HttpStatus.SC_OK).get(Field.getPropertyName("roamingxmlstream")).getValue();
|
String value = (String) responses[0].getProperties(HttpStatus.SC_OK).get(Field.getPropertyName("roamingxmlstream")).getValue();
|
||||||
String propertyList = new String(Base64.decodeBase64(value.getBytes()), "UTF-8");
|
String propertyList = new String(Base64.decodeBase64(value.getBytes()), "UTF-8");
|
||||||
System.out.println(propertyList);
|
System.out.println(propertyList);
|
||||||
|
@ -114,7 +114,7 @@ public class TestSmtp extends AbstractDavMailTestCase {
|
|||||||
// wait for asynchronous message send
|
// wait for asynchronous message send
|
||||||
ExchangeSession.MessageList messages = null;
|
ExchangeSession.MessageList messages = null;
|
||||||
for (int i=0;i<5;i++) {
|
for (int i=0;i<5;i++) {
|
||||||
messages = session.searchMessages("Sent", session.headerEquals("message-id", mimeMessage.getMessageID()));
|
messages = session.searchMessages("Sent", session.headerIsEqualTo("message-id", mimeMessage.getMessageID()));
|
||||||
if (messages.size() > 0) {
|
if (messages.size() > 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user