davmail.exchange
Class ExchangeSession

java.lang.Object
  extended by davmail.exchange.ExchangeSession
Direct Known Subclasses:
DavExchangeSession, EwsExchangeSession

public abstract class ExchangeSession
extends Object

Exchange session through Outlook Web Access (DAV)


Nested Class Summary
static class ExchangeSession.AttributeCondition
          Attribute condition.
static interface ExchangeSession.Condition
          Exchange search filter.
 class ExchangeSession.Contact
          Contact object
static class ExchangeSession.ContactPhoto
          Contact picture
 class ExchangeSession.Event
          Calendar event object.
 class ExchangeSession.Folder
          Exchange folder with IMAP properties
static class ExchangeSession.FreeBusy
          Exchange to iCalendar Free/Busy parser.
static class ExchangeSession.Item
          Generic folder item.
static class ExchangeSession.ItemResult
          Event result object to hold HTTP status and event etag from an event creation/update.
 class ExchangeSession.Message
          Exchange message.
static class ExchangeSession.MessageList
          Message list, includes a single messsage cache
static class ExchangeSession.MonoCondition
          Single search filter condition.
static class ExchangeSession.MultiCondition
          Multiple condition.
static class ExchangeSession.NotCondition
          Not condition.
static class ExchangeSession.Operator
           
 
Field Summary
protected static String ADDRESSBOOK
           
protected  String alias
           
protected static String CALENDAR
           
static Set<String> CONTACT_ATTRIBUTES
          Full Contact attribute list
static String CONTACTS
          Contacts folder logical name
protected  String currentMailboxPath
          Lower case Caldav path to current user mailbox.
protected static String DRAFTS
           
protected  String email
           
protected static int FREE_BUSY_INTERVAL
           
static SimpleTimeZone GMT_TIMEZONE
          Reference GMT timezone to format dates
protected  org.apache.commons.httpclient.HttpClient httpClient
           
protected static Set<String> IMAP_MESSAGE_ATTRIBUTES
           
protected static String INBOX
           
protected static String JUNK
           
protected  String lastSentMessageId
           
protected static org.apache.log4j.Logger LOGGER
           
protected static String LOWER_CASE_INBOX
           
protected  String mailPath
          Base user mailboxes path (used to select folder)
protected static Set<String> PASSWORD_FIELDS
           
protected static Set<String> POP_MESSAGE_ATTRIBUTES
           
protected static String PUBLIC_ROOT
           
protected  String publicFolderUrl
           
protected  String rootPath
           
protected static String SENDMSG
           
protected static String SENT
           
protected  String serverVersion
           
protected static String TASKS
           
protected static Set<String> TOKEN_FIELDS
           
protected static String TRASH
           
protected static Set<String> UID_MESSAGE_ATTRIBUTES
           
protected static String UNSENT
           
protected static Set<String> USER_NAME_FIELDS
           
protected  String userName
           
protected  VObject vTimezone
           
protected static String YYYY_MM_DD_HH_MM_SS
           
protected static String YYYY_MM_DD_T_HHMMSS_Z
           
 
Constructor Summary
ExchangeSession(String url, String userName, String password)
          Create an exchange session for the given URL.
 
Method Summary
abstract  ExchangeSession.MultiCondition and(ExchangeSession.Condition... condition)
          And search filter.
protected  org.apache.commons.httpclient.HttpMethod buildLogonMethod(org.apache.commons.httpclient.HttpClient httpClient, org.apache.commons.httpclient.HttpMethod initmethod)
          Try to find logon method path from logon form body.
protected abstract  void buildSessionInfo(org.apache.commons.httpclient.HttpMethod method)
           
protected  void checkFormLoginQueryString(org.apache.commons.httpclient.HttpMethod logonMethod)
           
abstract  ExchangeSession.Condition contains(String attributeName, String value)
          Contains condition.
protected  String convertBDayToZulu(String value)
           
protected  void convertContactProperties(Map<String,String> properties, String[] contactProperties, List<String> values)
           
 String convertFlagToKeyword(String value)
          Convert IMAP flag to keyword value.
protected  String convertItemNameToEML(String itemName)
          convert vcf extension to EML.
 String convertKeywordToFlag(String value)
          Convert keyword value to IMAP flag.
protected  void convertResentHeader(javax.mail.internet.MimeMessage mimeMessage, String headerName)
           
protected  String convertZuluDateToBday(String value)
           
abstract  void copyMessage(ExchangeSession.Message message, String targetFolder)
          Copy message to target folder
 int createCalendarFolder(String folderName, Map<String,String> properties)
          Create Exchange calendar folder.
 int createContactFolder(String folderName, Map<String,String> properties)
          Create Exchange contact folder.
abstract  int createFolder(String folderName, String folderClass, Map<String,String> properties)
          Create Exchange folder with given folder class.
abstract  void createMessage(String folderPath, String messageName, HashMap<String,String> properties, javax.mail.internet.MimeMessage mimeMessage)
          Create message in specified folder.
 int createMessageFolder(String folderName)
          Create Exchange message folder.
protected  ExchangeSession.ItemResult createOrUpdateContact(String folderPath, String itemName, String itemBody, String etag, String noneMatch)
           
 ExchangeSession.ItemResult createOrUpdateItem(String folderPath, String itemName, String itemBody, String etag, String noneMatch)
          Create or update item (event or contact) on the Exchange server
abstract  void deleteFolder(String folderName)
          Delete Exchange folder.
abstract  void deleteItem(String folderPath, String itemName)
          Delete event named itemName in folder
abstract  void deleteMessage(ExchangeSession.Message message)
          Delete Exchange message.
abstract  String formatSearchDate(Date date)
          Format date to exchange search format.
protected  org.apache.commons.httpclient.HttpMethod formLogin(org.apache.commons.httpclient.HttpClient httpClient, org.apache.commons.httpclient.HttpMethod initmethod, String userName, String password)
           
abstract  Map<String,ExchangeSession.Contact> galFind(ExchangeSession.Condition condition, Set<String> returningAttributes, int sizeLimit)
          Search global address list
protected  String getAbsoluteUri(org.apache.commons.httpclient.HttpMethod method, String path)
           
 String getAlias()
          Get current user alias
 String getAliasFromLogin()
          Get current Exchange alias name from login name
 List<ExchangeSession.Contact> getAllContacts(String folderPath)
          Search contacts in provided folder.
 List<ExchangeSession.Event> getAllEvents(String folderPath)
          Search calendar events in provided folder.
 ExchangeSession.MessageList getAllMessageUidAndSize(String folderName)
          Return folder message list with id and size only (for POP3 listener).
protected  List<javax.mail.internet.InternetAddress> getAllRecipients(javax.mail.internet.MimeMessage mimeMessage)
           
protected abstract  ExchangeSession.Condition getCalendarItemCondition(ExchangeSession.Condition dateCondition)
           
abstract  ExchangeSession.ContactPhoto getContactPhoto(ExchangeSession.Contact contact)
          Retrieve contact photo attached to contact
protected abstract  byte[] getContent(ExchangeSession.Message message)
          Get raw MIME message content
 String getEmail()
          Get current user email
protected  void getEmailAndAliasFromOptions()
           
protected  String getEmailSuffixFromHostname()
           
abstract  List<ExchangeSession.Event> getEventMessages(String folderPath)
          Search calendar messages in provided folder.
protected static SimpleDateFormat getExchangeZuluDateFormat()
           
protected static SimpleDateFormat getExchangeZuluDateFormatMillisecond()
           
 ExchangeSession.Folder getFolder(String folderPath)
          Get folder object.
 ExchangeSession.FreeBusy getFreebusy(String attendee, String startDateValue, String endDateValue)
          Get freebusy info for attendee between start and end date.
protected abstract  String getFreeBusyData(String attendee, String start, String end, int interval)
          Get freebusy data string from Exchange.
 org.apache.commons.httpclient.HttpClient getHttpClient()
          Return internal HttpClient instance
abstract  ExchangeSession.Item getItem(String folderPath, String itemName)
          Get item named eventName in folder
protected abstract  Set<String> getItemProperties()
           
protected  ExchangeSession.Condition getPastDelayCondition(String attribute)
           
protected  ExchangeSession.Condition getRangeCondition(String timeRangeStart, String timeRangeEnd)
           
protected  String getScriptBasedFormURL(org.apache.commons.httpclient.HttpMethod initmethod, String pathQuery)
           
 String getServerVersion()
          Get server version (Exchange2003, Exchange2007 or Exchange2010)
 List<ExchangeSession.Folder> getSubCalendarFolders(String folderName, boolean recursive)
          Search calendar folders under given folder.
 List<ExchangeSession.Folder> getSubFolders(String folderName, boolean recursive)
          Search mail and generic folders under given folder.
abstract  List<ExchangeSession.Folder> getSubFolders(String folderName, ExchangeSession.Condition condition, boolean recursive)
          Search folders under given folder matching filter.
protected static SimpleDateFormat getVcardBdayFormat()
           
 VObject getVTimezone()
          Load and return current user OWA timezone.
static SimpleDateFormat getZuluDateFormat()
          Return standard zulu date formatter.
abstract  ExchangeSession.Condition gt(String attributeName, String value)
          Greater than condition.
abstract  ExchangeSession.Condition gte(String attributeName, String value)
          Greater than or equals condition.
abstract  ExchangeSession.Condition headerIsEqualTo(String headerName, String value)
          MIME header equals condition.
protected abstract  ExchangeSession.ItemResult internalCreateOrUpdateContact(String folderPath, String itemName, Map<String,String> properties, String etag, String noneMatch)
           
protected abstract  ExchangeSession.ItemResult internalCreateOrUpdateEvent(String folderPath, String itemName, String contentClass, String icsBody, String etag, String noneMatch)
           
protected abstract  ExchangeSession.Folder internalGetFolder(String folderName)
           
protected  boolean isAuthenticated()
          Look for session cookies.
protected  boolean isBasicAuthentication(org.apache.commons.httpclient.HttpClient httpClient, String url)
          Test authentication mode : form based or basic.
abstract  ExchangeSession.Condition isEqualTo(String attributeName, int value)
          Equals condition.
abstract  ExchangeSession.Condition isEqualTo(String attributeName, String value)
          Equals condition.
 boolean isExpired()
          Test if the session expired.
abstract  ExchangeSession.Condition isFalse(String attributeName)
          Is false condition.
abstract  boolean isMainCalendar(String folderPath)
          Test if folderPath is main calendar.
abstract  ExchangeSession.Condition isNull(String attributeName)
          Is null condition.
abstract  boolean isSharedFolder(String folderPath)
          Test if folderPath is inside user mailbox.
abstract  ExchangeSession.Condition isTrue(String attributeName)
          Is true condition.
protected abstract  void loadVtimezone()
           
abstract  ExchangeSession.Condition lt(String attributeName, String value)
          Lower than condition.
abstract  ExchangeSession.Condition lte(String attributeName, String value)
          Lower than or equals condition.
abstract  void moveFolder(String folderName, String targetName)
          Move folder to target name.
abstract  void moveItem(String sourcePath, String targetPath)
          Move item from source path to target path.
abstract  void moveMessage(ExchangeSession.Message message, String targetFolder)
          Move message to target folder
protected abstract  void moveToTrash(ExchangeSession.Message message)
           
abstract  ExchangeSession.Condition not(ExchangeSession.Condition condition)
          Not search filter.
abstract  ExchangeSession.MultiCondition or(ExchangeSession.Condition... condition)
          Or search filter.
protected static Date parseDate(String dateString)
           
protected  org.apache.commons.httpclient.HttpMethod postLogonMethod(org.apache.commons.httpclient.HttpClient httpClient, org.apache.commons.httpclient.HttpMethod logonMethod, String userName, String password)
           
abstract  void processItem(String folderPath, String itemName)
          Mark event processed named eventName in folder
protected  void purgeOldestFolderMessages(String folderPath, int keepDelay)
           
 void purgeOldestTrashAndSentMessages()
          Delete oldest messages in trash.
 boolean refreshFolder(ExchangeSession.Folder currentFolder)
          Check folder ctag and reload messages as needed.
protected  String replaceIcal4Principal(String value)
          Replace iCal4 (Snow Leopard) principal paths with mailto expression
abstract  List<ExchangeSession.Contact> searchContacts(String folderPath, Set<String> attributes, ExchangeSession.Condition condition, int maxCount)
          Search contacts in provided folder matching the search query.
 List<ExchangeSession.Event> searchEvents(String folderPath, ExchangeSession.Condition filter)
          Search calendar events in provided folder.
abstract  List<ExchangeSession.Event> searchEvents(String folderPath, Set<String> attributes, ExchangeSession.Condition condition)
          Search calendar events or messages in provided folder matching the search query.
 List<ExchangeSession.Event> searchEvents(String folderPath, String timeRangeStart, String timeRangeEnd)
          Search events between start and end.
 List<ExchangeSession.Event> searchEventsOnly(String folderPath, String timeRangeStart, String timeRangeEnd)
          Search events between start and end, exclude tasks.
 ExchangeSession.MessageList searchMessages(String folderPath)
          Get all folder messages.
 ExchangeSession.MessageList searchMessages(String folderName, ExchangeSession.Condition condition)
          Search folder for messages matching conditions, with attributes needed by IMAP listener.
abstract  ExchangeSession.MessageList searchMessages(String folderName, Set<String> attributes, ExchangeSession.Condition condition)
          Search folder for messages matching conditions, with given attributes.
 List<ExchangeSession.Event> searchTasksOnly(String folderPath)
          Search tasks only (VTODO).
abstract  int sendEvent(String icsBody)
          Build and send the MIME message for the provided ICS event.
 void sendMessage(List<String> rcptToRecipients, javax.mail.internet.MimeMessage mimeMessage)
          Send message in reader to recipients.
abstract  void sendMessage(javax.mail.internet.MimeMessage mimeMessage)
          Send Mime message.
protected  void setAuthFormFields(org.apache.commons.httpclient.HttpMethod logonMethod, org.apache.commons.httpclient.HttpClient httpClient, String password)
           
abstract  ExchangeSession.Condition startsWith(String attributeName, String value)
          Starts with condition.
protected  org.apache.commons.httpclient.HttpMethod submitLanguageSelectionForm(org.apache.commons.httpclient.HttpMethod logonMethod)
           
protected  void throwAuthenticationFailed()
           
abstract  int updateFolder(String folderName, Map<String,String> properties)
          Update Exchange folder properties.
abstract  void updateMessage(ExchangeSession.Message message, Map<String,String> properties)
          Update given properties on message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

protected static final org.apache.log4j.Logger LOGGER

GMT_TIMEZONE

public static final SimpleTimeZone GMT_TIMEZONE
Reference GMT timezone to format dates


USER_NAME_FIELDS

protected static final Set<String> USER_NAME_FIELDS

PASSWORD_FIELDS

protected static final Set<String> PASSWORD_FIELDS

TOKEN_FIELDS

protected static final Set<String> TOKEN_FIELDS

FREE_BUSY_INTERVAL

protected static final int FREE_BUSY_INTERVAL
See Also:
Constant Field Values

PUBLIC_ROOT

protected static final String PUBLIC_ROOT
See Also:
Constant Field Values

CALENDAR

protected static final String CALENDAR
See Also:
Constant Field Values

TASKS

protected static final String TASKS
See Also:
Constant Field Values

CONTACTS

public static final String CONTACTS
Contacts folder logical name

See Also:
Constant Field Values

ADDRESSBOOK

protected static final String ADDRESSBOOK
See Also:
Constant Field Values

INBOX

protected static final String INBOX
See Also:
Constant Field Values

LOWER_CASE_INBOX

protected static final String LOWER_CASE_INBOX
See Also:
Constant Field Values

SENT

protected static final String SENT
See Also:
Constant Field Values

SENDMSG

protected static final String SENDMSG
See Also:
Constant Field Values

DRAFTS

protected static final String DRAFTS
See Also:
Constant Field Values

TRASH

protected static final String TRASH
See Also:
Constant Field Values

JUNK

protected static final String JUNK
See Also:
Constant Field Values

UNSENT

protected static final String UNSENT
See Also:
Constant Field Values

publicFolderUrl

protected String publicFolderUrl

mailPath

protected String mailPath
Base user mailboxes path (used to select folder)


rootPath

protected String rootPath

email

protected String email

alias

protected String alias

currentMailboxPath

protected String currentMailboxPath
Lower case Caldav path to current user mailbox. /users/email


httpClient

protected final org.apache.commons.httpclient.HttpClient httpClient

userName

protected String userName

serverVersion

protected String serverVersion

YYYY_MM_DD_HH_MM_SS

protected static final String YYYY_MM_DD_HH_MM_SS
See Also:
Constant Field Values

YYYY_MM_DD_T_HHMMSS_Z

protected static final String YYYY_MM_DD_T_HHMMSS_Z
See Also:
Constant Field Values

POP_MESSAGE_ATTRIBUTES

protected static final Set<String> POP_MESSAGE_ATTRIBUTES

IMAP_MESSAGE_ATTRIBUTES

protected static final Set<String> IMAP_MESSAGE_ATTRIBUTES

UID_MESSAGE_ATTRIBUTES

protected static final Set<String> UID_MESSAGE_ATTRIBUTES

lastSentMessageId

protected String lastSentMessageId

CONTACT_ATTRIBUTES

public static final Set<String> CONTACT_ATTRIBUTES
Full Contact attribute list


vTimezone

protected VObject vTimezone
Constructor Detail

ExchangeSession

public ExchangeSession(String url,
                       String userName,
                       String password)
                throws IOException
Create an exchange session for the given URL. The session is established for given userName and password

Parameters:
url - Exchange url
userName - user login name
password - user password
Throws:
IOException - on error
Method Detail

formatSearchDate

public abstract String formatSearchDate(Date date)
Format date to exchange search format.

Parameters:
date - date object
Returns:
formatted search date

getZuluDateFormat

public static SimpleDateFormat getZuluDateFormat()
Return standard zulu date formatter.

Returns:
zulu date formatter

getVcardBdayFormat

protected static SimpleDateFormat getVcardBdayFormat()

getExchangeZuluDateFormat

protected static SimpleDateFormat getExchangeZuluDateFormat()

getExchangeZuluDateFormatMillisecond

protected static SimpleDateFormat getExchangeZuluDateFormatMillisecond()

parseDate

protected static Date parseDate(String dateString)
                         throws ParseException
Throws:
ParseException

isExpired

public boolean isExpired()
                  throws NoRouteToHostException,
                         UnknownHostException
Test if the session expired.

Returns:
true this session expired
Throws:
NoRouteToHostException - on error
UnknownHostException - on error

isBasicAuthentication

protected boolean isBasicAuthentication(org.apache.commons.httpclient.HttpClient httpClient,
                                        String url)
Test authentication mode : form based or basic.

Parameters:
url - exchange base URL
httpClient - httpClient instance
Returns:
true if basic authentication detected

getAbsoluteUri

protected String getAbsoluteUri(org.apache.commons.httpclient.HttpMethod method,
                                String path)
                         throws org.apache.commons.httpclient.URIException
Throws:
org.apache.commons.httpclient.URIException

getScriptBasedFormURL

protected String getScriptBasedFormURL(org.apache.commons.httpclient.HttpMethod initmethod,
                                       String pathQuery)
                                throws org.apache.commons.httpclient.URIException
Throws:
org.apache.commons.httpclient.URIException

buildLogonMethod

protected org.apache.commons.httpclient.HttpMethod buildLogonMethod(org.apache.commons.httpclient.HttpClient httpClient,
                                                                    org.apache.commons.httpclient.HttpMethod initmethod)
                                                             throws IOException
Try to find logon method path from logon form body.

Parameters:
httpClient - httpClient instance
initmethod - form body http method
Returns:
logon method
Throws:
IOException - on error

postLogonMethod

protected org.apache.commons.httpclient.HttpMethod postLogonMethod(org.apache.commons.httpclient.HttpClient httpClient,
                                                                   org.apache.commons.httpclient.HttpMethod logonMethod,
                                                                   String userName,
                                                                   String password)
                                                            throws IOException
Throws:
IOException

setAuthFormFields

protected void setAuthFormFields(org.apache.commons.httpclient.HttpMethod logonMethod,
                                 org.apache.commons.httpclient.HttpClient httpClient,
                                 String password)
                          throws IllegalArgumentException
Throws:
IllegalArgumentException

formLogin

protected org.apache.commons.httpclient.HttpMethod formLogin(org.apache.commons.httpclient.HttpClient httpClient,
                                                             org.apache.commons.httpclient.HttpMethod initmethod,
                                                             String userName,
                                                             String password)
                                                      throws IOException
Throws:
IOException

submitLanguageSelectionForm

protected org.apache.commons.httpclient.HttpMethod submitLanguageSelectionForm(org.apache.commons.httpclient.HttpMethod logonMethod)
                                                                        throws IOException
Throws:
IOException

isAuthenticated

protected boolean isAuthenticated()
Look for session cookies.

Returns:
true if session cookies are available

checkFormLoginQueryString

protected void checkFormLoginQueryString(org.apache.commons.httpclient.HttpMethod logonMethod)
                                  throws DavMailAuthenticationException
Throws:
DavMailAuthenticationException

throwAuthenticationFailed

protected void throwAuthenticationFailed()
                                  throws DavMailAuthenticationException
Throws:
DavMailAuthenticationException

buildSessionInfo

protected abstract void buildSessionInfo(org.apache.commons.httpclient.HttpMethod method)
                                  throws DavMailException
Throws:
DavMailException

createMessage

public abstract void createMessage(String folderPath,
                                   String messageName,
                                   HashMap<String,String> properties,
                                   javax.mail.internet.MimeMessage mimeMessage)
                            throws IOException
Create message in specified folder. Will overwrite an existing message with same subject in the same folder

Parameters:
folderPath - Exchange folder path
messageName - message name
properties - message properties (flags)
mimeMessage - MIME message
Throws:
IOException - when unable to create message

updateMessage

public abstract void updateMessage(ExchangeSession.Message message,
                                   Map<String,String> properties)
                            throws IOException
Update given properties on message.

Parameters:
message - Exchange message
properties - Webdav properties map
Throws:
IOException - on error

deleteMessage

public abstract void deleteMessage(ExchangeSession.Message message)
                            throws IOException
Delete Exchange message.

Parameters:
message - Exchange message
Throws:
IOException - on error

getContent

protected abstract byte[] getContent(ExchangeSession.Message message)
                              throws IOException
Get raw MIME message content

Parameters:
message - Exchange message
Returns:
message body
Throws:
IOException - on error

getAllMessageUidAndSize

public ExchangeSession.MessageList getAllMessageUidAndSize(String folderName)
                                                    throws IOException
Return folder message list with id and size only (for POP3 listener).

Parameters:
folderName - Exchange folder name
Returns:
folder message list
Throws:
IOException - on error

searchMessages

public ExchangeSession.MessageList searchMessages(String folderPath)
                                           throws IOException
Get all folder messages.

Parameters:
folderPath - Exchange folder name
Returns:
message list
Throws:
IOException - on error

searchMessages

public ExchangeSession.MessageList searchMessages(String folderName,
                                                  ExchangeSession.Condition condition)
                                           throws IOException
Search folder for messages matching conditions, with attributes needed by IMAP listener.

Parameters:
folderName - Exchange folder name
condition - search filter
Returns:
message list
Throws:
IOException - on error

searchMessages

public abstract ExchangeSession.MessageList searchMessages(String folderName,
                                                           Set<String> attributes,
                                                           ExchangeSession.Condition condition)
                                                    throws IOException
Search folder for messages matching conditions, with given attributes.

Parameters:
folderName - Exchange folder name
attributes - requested Webdav attributes
condition - search filter
Returns:
message list
Throws:
IOException - on error

getServerVersion

public String getServerVersion()
Get server version (Exchange2003, Exchange2007 or Exchange2010)

Returns:
server version

and

public abstract ExchangeSession.MultiCondition and(ExchangeSession.Condition... condition)
And search filter.

Parameters:
condition - search conditions
Returns:
condition

or

public abstract ExchangeSession.MultiCondition or(ExchangeSession.Condition... condition)
Or search filter.

Parameters:
condition - search conditions
Returns:
condition

not

public abstract ExchangeSession.Condition not(ExchangeSession.Condition condition)
Not search filter.

Parameters:
condition - search condition
Returns:
condition

isEqualTo

public abstract ExchangeSession.Condition isEqualTo(String attributeName,
                                                    String value)
Equals condition.

Parameters:
attributeName - logical Exchange attribute name
value - attribute value
Returns:
condition

isEqualTo

public abstract ExchangeSession.Condition isEqualTo(String attributeName,
                                                    int value)
Equals condition.

Parameters:
attributeName - logical Exchange attribute name
value - attribute value
Returns:
condition

headerIsEqualTo

public abstract ExchangeSession.Condition headerIsEqualTo(String headerName,
                                                          String value)
MIME header equals condition.

Parameters:
headerName - MIME header name
value - attribute value
Returns:
condition

gte

public abstract ExchangeSession.Condition gte(String attributeName,
                                              String value)
Greater than or equals condition.

Parameters:
attributeName - logical Exchange attribute name
value - attribute value
Returns:
condition

gt

public abstract ExchangeSession.Condition gt(String attributeName,
                                             String value)
Greater than condition.

Parameters:
attributeName - logical Exchange attribute name
value - attribute value
Returns:
condition

lt

public abstract ExchangeSession.Condition lt(String attributeName,
                                             String value)
Lower than condition.

Parameters:
attributeName - logical Exchange attribute name
value - attribute value
Returns:
condition

lte

public abstract ExchangeSession.Condition lte(String attributeName,
                                              String value)
Lower than or equals condition.

Parameters:
attributeName - logical Exchange attribute name
value - attribute value
Returns:
condition

contains

public abstract ExchangeSession.Condition contains(String attributeName,
                                                   String value)
Contains condition.

Parameters:
attributeName - logical Exchange attribute name
value - attribute value
Returns:
condition

startsWith

public abstract ExchangeSession.Condition startsWith(String attributeName,
                                                     String value)
Starts with condition.

Parameters:
attributeName - logical Exchange attribute name
value - attribute value
Returns:
condition

isNull

public abstract ExchangeSession.Condition isNull(String attributeName)
Is null condition.

Parameters:
attributeName - logical Exchange attribute name
Returns:
condition

isTrue

public abstract ExchangeSession.Condition isTrue(String attributeName)
Is true condition.

Parameters:
attributeName - logical Exchange attribute name
Returns:
condition

isFalse

public abstract ExchangeSession.Condition isFalse(String attributeName)
Is false condition.

Parameters:
attributeName - logical Exchange attribute name
Returns:
condition

getSubFolders

public List<ExchangeSession.Folder> getSubFolders(String folderName,
                                                  boolean recursive)
                                           throws IOException
Search mail and generic folders under given folder. Exclude calendar and contacts folders

Parameters:
folderName - Exchange folder name
recursive - deep search if true
Returns:
list of folders
Throws:
IOException - on error

getSubCalendarFolders

public List<ExchangeSession.Folder> getSubCalendarFolders(String folderName,
                                                          boolean recursive)
                                                   throws IOException
Search calendar folders under given folder.

Parameters:
folderName - Exchange folder name
recursive - deep search if true
Returns:
list of folders
Throws:
IOException - on error

getSubFolders

public abstract List<ExchangeSession.Folder> getSubFolders(String folderName,
                                                           ExchangeSession.Condition condition,
                                                           boolean recursive)
                                                    throws IOException
Search folders under given folder matching filter.

Parameters:
folderName - Exchange folder name
condition - search filter
recursive - deep search if true
Returns:
list of folders
Throws:
IOException - on error

purgeOldestTrashAndSentMessages

public void purgeOldestTrashAndSentMessages()
                                     throws IOException
Delete oldest messages in trash. keepDelay is the number of days to keep messages in trash before delete

Throws:
IOException - when unable to purge messages

purgeOldestFolderMessages

protected void purgeOldestFolderMessages(String folderPath,
                                         int keepDelay)
                                  throws IOException
Throws:
IOException

convertResentHeader

protected void convertResentHeader(javax.mail.internet.MimeMessage mimeMessage,
                                   String headerName)
                            throws javax.mail.MessagingException
Throws:
javax.mail.MessagingException

sendMessage

public void sendMessage(List<String> rcptToRecipients,
                        javax.mail.internet.MimeMessage mimeMessage)
                 throws IOException,
                        javax.mail.MessagingException
Send message in reader to recipients. Detect visible recipients in message body to determine bcc recipients

Parameters:
rcptToRecipients - recipients list
mimeMessage - mime message
Throws:
IOException - on error
javax.mail.MessagingException - on error

getAllRecipients

protected List<javax.mail.internet.InternetAddress> getAllRecipients(javax.mail.internet.MimeMessage mimeMessage)
                                                              throws javax.mail.MessagingException
Throws:
javax.mail.MessagingException

sendMessage

public abstract void sendMessage(javax.mail.internet.MimeMessage mimeMessage)
                          throws IOException,
                                 javax.mail.MessagingException
Send Mime message.

Parameters:
mimeMessage - MIME message
Throws:
IOException - on error
javax.mail.MessagingException - on error

getFolder

public ExchangeSession.Folder getFolder(String folderPath)
                                 throws IOException
Get folder object. Folder name can be logical names INBOX, Drafts, Trash or calendar, or a path relative to user base folder or absolute path.

Parameters:
folderPath - folder path
Returns:
Folder object
Throws:
IOException - on error

internalGetFolder

protected abstract ExchangeSession.Folder internalGetFolder(String folderName)
                                                     throws IOException
Throws:
IOException

refreshFolder

public boolean refreshFolder(ExchangeSession.Folder currentFolder)
                      throws IOException
Check folder ctag and reload messages as needed.

Parameters:
currentFolder - current folder
Returns:
true if folder changed
Throws:
IOException - on error

createMessageFolder

public int createMessageFolder(String folderName)
                        throws IOException
Create Exchange message folder.

Parameters:
folderName - logical folder name
Returns:
status
Throws:
IOException - on error

createCalendarFolder

public int createCalendarFolder(String folderName,
                                Map<String,String> properties)
                         throws IOException
Create Exchange calendar folder.

Parameters:
folderName - logical folder name
properties - folder properties
Returns:
status
Throws:
IOException - on error

createContactFolder

public int createContactFolder(String folderName,
                               Map<String,String> properties)
                        throws IOException
Create Exchange contact folder.

Parameters:
folderName - logical folder name
properties - folder properties
Returns:
status
Throws:
IOException - on error

createFolder

public abstract int createFolder(String folderName,
                                 String folderClass,
                                 Map<String,String> properties)
                          throws IOException
Create Exchange folder with given folder class.

Parameters:
folderName - logical folder name
folderClass - folder class
properties - folder properties
Returns:
status
Throws:
IOException - on error

updateFolder

public abstract int updateFolder(String folderName,
                                 Map<String,String> properties)
                          throws IOException
Update Exchange folder properties.

Parameters:
folderName - logical folder name
properties - folder properties
Returns:
status
Throws:
IOException - on error

deleteFolder

public abstract void deleteFolder(String folderName)
                           throws IOException
Delete Exchange folder.

Parameters:
folderName - logical folder name
Throws:
IOException - on error

copyMessage

public abstract void copyMessage(ExchangeSession.Message message,
                                 String targetFolder)
                          throws IOException
Copy message to target folder

Parameters:
message - Exchange message
targetFolder - target folder
Throws:
IOException - on error

moveMessage

public abstract void moveMessage(ExchangeSession.Message message,
                                 String targetFolder)
                          throws IOException
Move message to target folder

Parameters:
message - Exchange message
targetFolder - target folder
Throws:
IOException - on error

moveFolder

public abstract void moveFolder(String folderName,
                                String targetName)
                         throws IOException
Move folder to target name.

Parameters:
folderName - current folder name/path
targetName - target folder name/path
Throws:
IOException - on error

moveItem

public abstract void moveItem(String sourcePath,
                              String targetPath)
                       throws IOException
Move item from source path to target path.

Parameters:
sourcePath - item source path
targetPath - item target path
Throws:
IOException - on error

moveToTrash

protected abstract void moveToTrash(ExchangeSession.Message message)
                             throws IOException
Throws:
IOException

convertKeywordToFlag

public String convertKeywordToFlag(String value)
Convert keyword value to IMAP flag.

Parameters:
value - keyword value
Returns:
IMAP flag

convertFlagToKeyword

public String convertFlagToKeyword(String value)
Convert IMAP flag to keyword value.

Parameters:
value - IMAP flag
Returns:
keyword value

getItemProperties

protected abstract Set<String> getItemProperties()

getAllContacts

public List<ExchangeSession.Contact> getAllContacts(String folderPath)
                                             throws IOException
Search contacts in provided folder.

Parameters:
folderPath - Exchange folder path
Returns:
list of contacts
Throws:
IOException - on error

searchContacts

public abstract List<ExchangeSession.Contact> searchContacts(String folderPath,
                                                             Set<String> attributes,
                                                             ExchangeSession.Condition condition,
                                                             int maxCount)
                                                      throws IOException
Search contacts in provided folder matching the search query.

Parameters:
folderPath - Exchange folder path
attributes - requested attributes
condition - Exchange search query
maxCount - maximum item count
Returns:
list of contacts
Throws:
IOException - on error

getEventMessages

public abstract List<ExchangeSession.Event> getEventMessages(String folderPath)
                                                      throws IOException
Search calendar messages in provided folder.

Parameters:
folderPath - Exchange folder path
Returns:
list of calendar messages as Event objects
Throws:
IOException - on error

getAllEvents

public List<ExchangeSession.Event> getAllEvents(String folderPath)
                                         throws IOException
Search calendar events in provided folder.

Parameters:
folderPath - Exchange folder path
Returns:
list of calendar events
Throws:
IOException - on error

getCalendarItemCondition

protected abstract ExchangeSession.Condition getCalendarItemCondition(ExchangeSession.Condition dateCondition)

getPastDelayCondition

protected ExchangeSession.Condition getPastDelayCondition(String attribute)

getRangeCondition

protected ExchangeSession.Condition getRangeCondition(String timeRangeStart,
                                                      String timeRangeEnd)
                                               throws IOException
Throws:
IOException

searchEvents

public List<ExchangeSession.Event> searchEvents(String folderPath,
                                                String timeRangeStart,
                                                String timeRangeEnd)
                                         throws IOException
Search events between start and end.

Parameters:
folderPath - Exchange folder path
timeRangeStart - date range start in zulu format
timeRangeEnd - date range start in zulu format
Returns:
list of calendar events
Throws:
IOException - on error

searchEventsOnly

public List<ExchangeSession.Event> searchEventsOnly(String folderPath,
                                                    String timeRangeStart,
                                                    String timeRangeEnd)
                                             throws IOException
Search events between start and end, exclude tasks.

Parameters:
folderPath - Exchange folder path
timeRangeStart - date range start in zulu format
timeRangeEnd - date range start in zulu format
Returns:
list of calendar events
Throws:
IOException - on error

searchTasksOnly

public List<ExchangeSession.Event> searchTasksOnly(String folderPath)
                                            throws IOException
Search tasks only (VTODO).

Parameters:
folderPath - Exchange folder path
Returns:
list of tasks
Throws:
IOException - on error

searchEvents

public List<ExchangeSession.Event> searchEvents(String folderPath,
                                                ExchangeSession.Condition filter)
                                         throws IOException
Search calendar events in provided folder.

Parameters:
folderPath - Exchange folder path
filter - search filter
Returns:
list of calendar events
Throws:
IOException - on error

searchEvents

public abstract List<ExchangeSession.Event> searchEvents(String folderPath,
                                                         Set<String> attributes,
                                                         ExchangeSession.Condition condition)
                                                  throws IOException
Search calendar events or messages in provided folder matching the search query.

Parameters:
folderPath - Exchange folder path
attributes - requested attributes
condition - Exchange search query
Returns:
list of calendar messages as Event objects
Throws:
IOException - on error

convertItemNameToEML

protected String convertItemNameToEML(String itemName)
convert vcf extension to EML.

Parameters:
itemName - item name
Returns:
EML item name

getItem

public abstract ExchangeSession.Item getItem(String folderPath,
                                             String itemName)
                                      throws IOException
Get item named eventName in folder

Parameters:
folderPath - Exchange folder path
itemName - event name
Returns:
event object
Throws:
IOException - on error

getContactPhoto

public abstract ExchangeSession.ContactPhoto getContactPhoto(ExchangeSession.Contact contact)
                                                      throws IOException
Retrieve contact photo attached to contact

Parameters:
contact - address book contact
Returns:
contact photo
Throws:
IOException - on error

deleteItem

public abstract void deleteItem(String folderPath,
                                String itemName)
                         throws IOException
Delete event named itemName in folder

Parameters:
folderPath - Exchange folder path
itemName - item name
Throws:
IOException - on error

processItem

public abstract void processItem(String folderPath,
                                 String itemName)
                          throws IOException
Mark event processed named eventName in folder

Parameters:
folderPath - Exchange folder path
itemName - item name
Throws:
IOException - on error

replaceIcal4Principal

protected String replaceIcal4Principal(String value)
Replace iCal4 (Snow Leopard) principal paths with mailto expression

Parameters:
value - attendee value or ics line
Returns:
fixed value

sendEvent

public abstract int sendEvent(String icsBody)
                       throws IOException
Build and send the MIME message for the provided ICS event.

Parameters:
icsBody - event in iCalendar format
Returns:
HTTP status
Throws:
IOException - on error

createOrUpdateItem

public ExchangeSession.ItemResult createOrUpdateItem(String folderPath,
                                                     String itemName,
                                                     String itemBody,
                                                     String etag,
                                                     String noneMatch)
                                              throws IOException
Create or update item (event or contact) on the Exchange server

Parameters:
folderPath - Exchange folder path
itemName - event name
itemBody - event body in iCalendar format
etag - previous event etag to detect concurrent updates
noneMatch - if-none-match header value
Returns:
HTTP response event result (status and etag)
Throws:
IOException - on error

convertContactProperties

protected void convertContactProperties(Map<String,String> properties,
                                        String[] contactProperties,
                                        List<String> values)

createOrUpdateContact

protected ExchangeSession.ItemResult createOrUpdateContact(String folderPath,
                                                           String itemName,
                                                           String itemBody,
                                                           String etag,
                                                           String noneMatch)
                                                    throws IOException
Throws:
IOException

convertZuluDateToBday

protected String convertZuluDateToBday(String value)

convertBDayToZulu

protected String convertBDayToZulu(String value)

internalCreateOrUpdateContact

protected abstract ExchangeSession.ItemResult internalCreateOrUpdateContact(String folderPath,
                                                                            String itemName,
                                                                            Map<String,String> properties,
                                                                            String etag,
                                                                            String noneMatch)
                                                                     throws IOException
Throws:
IOException

internalCreateOrUpdateEvent

protected abstract ExchangeSession.ItemResult internalCreateOrUpdateEvent(String folderPath,
                                                                          String itemName,
                                                                          String contentClass,
                                                                          String icsBody,
                                                                          String etag,
                                                                          String noneMatch)
                                                                   throws IOException
Throws:
IOException

getAliasFromLogin

public String getAliasFromLogin()
Get current Exchange alias name from login name

Returns:
user name

getEmailSuffixFromHostname

protected String getEmailSuffixFromHostname()

isSharedFolder

public abstract boolean isSharedFolder(String folderPath)
Test if folderPath is inside user mailbox.

Parameters:
folderPath - absolute folder path
Returns:
true if folderPath is a public or shared folder

isMainCalendar

public abstract boolean isMainCalendar(String folderPath)
Test if folderPath is main calendar.

Parameters:
folderPath - absolute folder path
Returns:
true if folderPath is a public or shared folder

getEmailAndAliasFromOptions

protected void getEmailAndAliasFromOptions()

getEmail

public String getEmail()
Get current user email

Returns:
user email

getAlias

public String getAlias()
Get current user alias

Returns:
user email

galFind

public abstract Map<String,ExchangeSession.Contact> galFind(ExchangeSession.Condition condition,
                                                            Set<String> returningAttributes,
                                                            int sizeLimit)
                                                     throws IOException
Search global address list

Parameters:
condition - search filter
returningAttributes - returning attributes
sizeLimit - size limit
Returns:
matching contacts from gal
Throws:
IOException - on error

getFreeBusyData

protected abstract String getFreeBusyData(String attendee,
                                          String start,
                                          String end,
                                          int interval)
                                   throws IOException
Get freebusy data string from Exchange.

Parameters:
attendee - attendee email address
start - start date in Exchange zulu format
end - end date in Exchange zulu format
interval - freebusy interval in minutes
Returns:
freebusy data or null
Throws:
IOException - on error

getFreebusy

public ExchangeSession.FreeBusy getFreebusy(String attendee,
                                            String startDateValue,
                                            String endDateValue)
                                     throws IOException
Get freebusy info for attendee between start and end date.

Parameters:
attendee - attendee email
startDateValue - start date
endDateValue - end date
Returns:
FreeBusy info
Throws:
IOException - on error

getVTimezone

public VObject getVTimezone()
Load and return current user OWA timezone.

Returns:
current timezone

loadVtimezone

protected abstract void loadVtimezone()

getHttpClient

public org.apache.commons.httpclient.HttpClient getHttpClient()
Return internal HttpClient instance

Returns:
http client


Copyright © 2001-2013 MickaĆ«l Guessant. All Rights Reserved.