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:
parent
87b37901ca
commit
4f4eb2fb9a
@ -41,6 +41,17 @@ public class ExchangeSession {
|
|||||||
MESSAGE_REQUEST_PROPERTIES.add("http://schemas.microsoft.com/mapi/proptag/x0e080003");
|
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
|
* Date parser from Exchange format
|
||||||
*/
|
*/
|
||||||
@ -300,17 +311,36 @@ public class ExchangeSession {
|
|||||||
|
|
||||||
// got base http mailbox http url
|
// got base http mailbox http url
|
||||||
wdr.setPath(mailPath);
|
wdr.setPath(mailPath);
|
||||||
|
getWellKnownFolders();
|
||||||
|
// set current folder to Inbox
|
||||||
|
currentFolderUrl = inboxUrl;
|
||||||
|
|
||||||
// Retrieve inbox and trash URLs
|
wdr.setPath(URIUtil.getPath(inboxUrl));
|
||||||
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");
|
|
||||||
|
|
||||||
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()) {
|
if (!foldersEnum.hasMoreElements()) {
|
||||||
throw new IOException("Unable to get mail folders");
|
throw new IOException("Unable to get mail folders");
|
||||||
}
|
}
|
||||||
@ -341,36 +371,13 @@ public class ExchangeSession {
|
|||||||
calendarUrl = URIUtil.decode(inboxProp.getPropertyAsString());
|
calendarUrl = URIUtil.decode(inboxProp.getPropertyAsString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
LOGGER.debug("Inbox URL : " + inboxUrl +
|
||||||
// set current folder to Inbox
|
" Trash URL : " + deleteditemsUrl +
|
||||||
currentFolderUrl = inboxUrl;
|
" Sent URL : " + sentitemsUrl +
|
||||||
|
" Send URL : " + sendmsgUrl +
|
||||||
LOGGER.debug("Inbox URL : " + inboxUrl);
|
" Drafts URL : " + draftsUrl +
|
||||||
LOGGER.debug("Trash URL : " + deleteditemsUrl);
|
" Calendar URL : " + calendarUrl
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -802,7 +809,7 @@ public class ExchangeSession {
|
|||||||
" ORDER BY \"urn:schemas:calendar:dtstart\" DESC\n" +
|
" ORDER BY \"urn:schemas:calendar:dtstart\" DESC\n" +
|
||||||
" </d:sql>\n" +
|
" </d:sql>\n" +
|
||||||
"</d:searchrequest>";
|
"</d:searchrequest>";
|
||||||
SearchMethod searchMethod = new SearchMethod(calendarUrl, searchRequest);
|
SearchMethod searchMethod = new SearchMethod(URIUtil.encodePath(calendarUrl), searchRequest);
|
||||||
//searchMethod.setDebug(4);
|
//searchMethod.setDebug(4);
|
||||||
try {
|
try {
|
||||||
int status = wdr.retrieveSessionInstance().executeMethod(searchMethod);
|
int status = wdr.retrieveSessionInstance().executeMethod(searchMethod);
|
||||||
|
Loading…
Reference in New Issue
Block a user