mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-14 03:32:22 -05:00
Implement folder create
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@305 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
f619571390
commit
43ddbaf8e2
@ -14,6 +14,7 @@ import org.apache.webdav.lib.ResponseEntity;
|
||||
import org.apache.webdav.lib.WebdavResource;
|
||||
import org.apache.webdav.lib.methods.PropPatchMethod;
|
||||
import org.apache.webdav.lib.methods.SearchMethod;
|
||||
import org.apache.webdav.lib.methods.MkcolMethod;
|
||||
import org.htmlcleaner.CommentToken;
|
||||
import org.htmlcleaner.HtmlCleaner;
|
||||
import org.htmlcleaner.TagNode;
|
||||
@ -805,6 +806,41 @@ public class ExchangeSession {
|
||||
return folder;
|
||||
}
|
||||
|
||||
public void createFolder(String folderName) throws IOException {
|
||||
String folderPath = getFolderPath(folderName);
|
||||
int index = folderPath.lastIndexOf("/");
|
||||
|
||||
PropPatchMethod method = new PropPatchMethod(folderPath) {
|
||||
public String getName() {
|
||||
return "MKCOL";
|
||||
}
|
||||
};
|
||||
method.setDebug(4);
|
||||
method.addPropertyToSet("outlookfolderclass","IPF.Note","ex","http://schemas.microsoft.com/exchange/");
|
||||
wdr.retrieveSessionInstance().executeMethod(method);
|
||||
// ok or alredy exists
|
||||
if (method.getStatusCode() != HttpStatus.SC_MULTI_STATUS && method.getStatusCode() != HttpStatus.SC_METHOD_NOT_ALLOWED) {
|
||||
HttpException ex = new HttpException();
|
||||
ex.setReasonCode(method.getStatusCode());
|
||||
ex.setReason(method.getStatusText());
|
||||
throw ex;
|
||||
}
|
||||
/*
|
||||
PostMethod postMethod = new PostMethod(folderPath.substring(0, index));
|
||||
postMethod.addParameter("Cmd", "createfolder");
|
||||
postMethod.addParameter("Action", "Create");
|
||||
postMethod.addParameter("FolderName", folderPath.substring(index + 1));
|
||||
postMethod.addParameter("FolderType", "IPF.Note");
|
||||
wdr.retrieveSessionInstance().executeMethod(postMethod);
|
||||
if (postMethod.getStatusCode() != HttpStatus.SC_MOVED_TEMPORARILY) {
|
||||
HttpException ex = new HttpException();
|
||||
ex.setReasonCode(postMethod.getStatusCode());
|
||||
ex.setReason(postMethod.getStatusText());
|
||||
throw ex;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public static class Folder {
|
||||
public String folderUrl;
|
||||
public int objectCount;
|
||||
|
@ -161,12 +161,8 @@ public class ImapConnection extends AbstractConnection {
|
||||
} else if ("create".equalsIgnoreCase(command)) {
|
||||
if (tokens.hasMoreTokens()) {
|
||||
String folderName = BASE64MailboxDecoder.decode(removeQuotes(tokens.nextToken()));
|
||||
if (session.getFolder(folderName) != null) {
|
||||
sendClient(commandId + " OK folder already exists");
|
||||
} else {
|
||||
// TODO
|
||||
sendClient(commandId + " NO unsupported");
|
||||
}
|
||||
session.createFolder(folderName);
|
||||
sendClient(commandId + " OK folder created");
|
||||
} else {
|
||||
sendClient(commandId + " BAD missing create argument");
|
||||
}
|
||||
@ -281,7 +277,14 @@ public class ImapConnection extends AbstractConnection {
|
||||
int size = Integer.parseInt(removeQuotes(tokens.nextToken()));
|
||||
sendClient("+ send literal data");
|
||||
char[] buffer = new char[size];
|
||||
in.read(buffer);
|
||||
int index = 0;
|
||||
int count = 0;
|
||||
while (count >= 0 && index < size) {
|
||||
count = in.read(buffer, index, size - index);
|
||||
if (count >= 0) {
|
||||
index += count;
|
||||
}
|
||||
}
|
||||
// empty line
|
||||
readClient();
|
||||
session.createMessage(session.getFolderPath(folderName), "test", null, new String(buffer), true);
|
||||
|
Loading…
Reference in New Issue
Block a user