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

Refactor message delete methods

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@323 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2009-02-03 21:02:33 +00:00
parent 4b1f7b9cbb
commit 6fa000b55a
3 changed files with 13 additions and 13 deletions

View File

@ -452,16 +452,6 @@ public class ExchangeSession {
); );
} }
/**
* Replace invalid url chars
*
* @param subject
* @return
*/
protected String encodeSubject(String subject) {
return subject.replaceAll("/", "_xF8FF_").replaceAll("\\?", "");
}
/** /**
* Create message in specified folder. * Create message in specified folder.
* Will overwrite an existing message with same subject in the same folder * Will overwrite an existing message with same subject in the same folder
@ -474,7 +464,7 @@ public class ExchangeSession {
* @throws java.io.IOException when unable to create message * @throws java.io.IOException when unable to create message
*/ */
public void createMessage(String folderUrl, String messageName, String bcc, String messageBody, boolean allowOverwrite) throws IOException { public void createMessage(String folderUrl, String messageName, String bcc, String messageBody, boolean allowOverwrite) throws IOException {
String messageUrl = URIUtil.encodePathQuery(folderUrl + "/" + encodeSubject(messageName) + ".EML"); String messageUrl = URIUtil.encodePathQuery(folderUrl + "/" + messageName + ".EML");
// create the message first as draft // create the message first as draft
PropPatchMethod patchMethod = new PropPatchMethod(messageUrl); PropPatchMethod patchMethod = new PropPatchMethod(messageUrl);
@ -1031,6 +1021,16 @@ public class ExchangeSession {
} }
public void delete() throws IOException { public void delete() throws IOException {
wdr.deleteMethod(messageUrl);
if (wdr.getStatusCode() != HttpStatus.SC_OK) {
HttpException ex = new HttpException();
ex.setReasonCode(wdr.getStatusCode());
ex.setReason(wdr.getStatusMessage());
throw ex;
}
}
public void moveToTrash() throws IOException {
String destination = deleteditemsUrl + messageUrl.substring(messageUrl.lastIndexOf("/")); String destination = deleteditemsUrl + messageUrl.substring(messageUrl.lastIndexOf("/"));
LOGGER.debug("Deleting : " + messageUrl + " to " + destination); LOGGER.debug("Deleting : " + messageUrl + " to " + destination);

View File

@ -466,7 +466,7 @@ public class ImapConnection extends AbstractConnection {
for (ExchangeSession.Message message : messages) { for (ExchangeSession.Message message : messages) {
index++; index++;
if (message.deleted) { if (message.deleted) {
session.deleteMessage(message.messageUrl); message.delete();
sendClient("* " + index + " EXPUNGE"); sendClient("* " + index + " EXPUNGE");
} }
} }

View File

@ -184,7 +184,7 @@ public class PopConnection extends AbstractConnection {
try { try {
int messageNumber = Integer.valueOf(tokens. int messageNumber = Integer.valueOf(tokens.
nextToken()) - 1; nextToken()) - 1;
messages.get(messageNumber).delete(); messages.get(messageNumber).moveToTrash();
sendOK("DELETE"); sendOK("DELETE");
} catch (SocketException e) { } catch (SocketException e) {
// can not send error to client after a socket exception // can not send error to client after a socket exception