1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-13 03:02:22 -05:00

make WELL_KNOWN_FOLDERS value static

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@221 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2008-12-09 08:54:08 +00:00
parent 87b37901ca
commit 4f4eb2fb9a

View File

@ -41,6 +41,17 @@ public class ExchangeSession {
MESSAGE_REQUEST_PROPERTIES.add("http://schemas.microsoft.com/mapi/proptag/x0e080003");
}
protected static final Vector<String> WELL_KNOWN_FOLDERS = new Vector<String>();
static {
WELL_KNOWN_FOLDERS.add("urn:schemas:httpmail:inbox");
WELL_KNOWN_FOLDERS.add("urn:schemas:httpmail:deleteditems");
WELL_KNOWN_FOLDERS.add("urn:schemas:httpmail:sentitems");
WELL_KNOWN_FOLDERS.add("urn:schemas:httpmail:sendmsg");
WELL_KNOWN_FOLDERS.add("urn:schemas:httpmail:drafts");
WELL_KNOWN_FOLDERS.add("urn:schemas:httpmail:calendar");
}
/**
* Date parser from Exchange format
*/
@ -300,17 +311,36 @@ public class ExchangeSession {
// got base http mailbox http url
wdr.setPath(mailPath);
getWellKnownFolders();
// set current folder to Inbox
currentFolderUrl = inboxUrl;
// Retrieve inbox and trash URLs
Vector<String> reqProps = new Vector<String>();
reqProps.add("urn:schemas:httpmail:inbox");
reqProps.add("urn:schemas:httpmail:deleteditems");
reqProps.add("urn:schemas:httpmail:sentitems");
reqProps.add("urn:schemas:httpmail:sendmsg");
reqProps.add("urn:schemas:httpmail:drafts");
reqProps.add("urn:schemas:httpmail:calendar");
wdr.setPath(URIUtil.getPath(inboxUrl));
Enumeration foldersEnum = wdr.propfindMethod(0, reqProps);
} catch (Exception exc) {
StringBuffer message = new StringBuffer();
message.append("DavMail login exception: ");
if (exc.getMessage() != null) {
message.append(exc.getMessage());
} else if (exc instanceof HttpException) {
message.append(((HttpException) exc).getReasonCode());
String httpReason = ((HttpException) exc).getReason();
if (httpReason != null) {
message.append(" ");
message.append(httpReason);
}
} else {
message.append(exc);
}
LOGGER.error(message.toString());
throw new IOException(message.toString());
}
}
protected void getWellKnownFolders() throws IOException {
// Retrieve well known URLs
Enumeration foldersEnum = wdr.propfindMethod(0, WELL_KNOWN_FOLDERS);
if (!foldersEnum.hasMoreElements()) {
throw new IOException("Unable to get mail folders");
}
@ -341,36 +371,13 @@ public class ExchangeSession {
calendarUrl = URIUtil.decode(inboxProp.getPropertyAsString());
}
}
// set current folder to Inbox
currentFolderUrl = inboxUrl;
LOGGER.debug("Inbox URL : " + inboxUrl);
LOGGER.debug("Trash URL : " + deleteditemsUrl);
LOGGER.debug("Sent URL : " + sentitemsUrl);
LOGGER.debug("Send URL : " + sendmsgUrl);
LOGGER.debug("Drafts URL : " + draftsUrl);
wdr.setPath(URIUtil.getPath(inboxUrl));
} catch (Exception exc) {
StringBuffer message = new StringBuffer();
message.append("DavMail login exception: ");
if (exc.getMessage() != null) {
message.append(exc.getMessage());
} else if (exc instanceof HttpException) {
message.append(((HttpException) exc).getReasonCode());
String httpReason = ((HttpException) exc).getReason();
if (httpReason != null) {
message.append(" ");
message.append(httpReason);
}
} else {
message.append(exc);
}
LOGGER.error(message.toString());
throw new IOException(message.toString());
}
LOGGER.debug("Inbox URL : " + inboxUrl +
" Trash URL : " + deleteditemsUrl +
" Sent URL : " + sentitemsUrl +
" Send URL : " + sendmsgUrl +
" Drafts URL : " + draftsUrl +
" Calendar URL : " + calendarUrl
);
}
/**
@ -802,7 +809,7 @@ public class ExchangeSession {
" ORDER BY \"urn:schemas:calendar:dtstart\" DESC\n" +
" </d:sql>\n" +
"</d:searchrequest>";
SearchMethod searchMethod = new SearchMethod(calendarUrl, searchRequest);
SearchMethod searchMethod = new SearchMethod(URIUtil.encodePath(calendarUrl), searchRequest);
//searchMethod.setDebug(4);
try {
int status = wdr.retrieveSessionInstance().executeMethod(searchMethod);