Caldav: implement update folder

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1784 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2011-09-06 21:28:36 +00:00
parent 485a43f789
commit 3486940ec5
4 changed files with 67 additions and 6 deletions

View File

@ -675,10 +675,15 @@ public class CaldavConnection extends AbstractConnection {
}
CaldavResponse response = new CaldavResponse(HttpStatus.SC_MULTI_STATUS);
response.startMultistatus();
// just ignore calendar folder proppatch (color not supported in Exchange)
if (request.hasProperty("calendar-color")) {
// ical calendar folder proppatch
if (hasIcalProperties) {
response.startPropstat();
response.appendProperty("x1:calendar-color", "x1=\"http://apple.com/ns/ical/\"", null);
if (request.hasProperty("calendar-color")) {
response.appendProperty("x1:calendar-color", "x1=\"http://apple.com/ns/ical/\"", null);
}
if (request.hasProperty("calendar-order")) {
response.appendProperty("x1:calendar-order", "x1=\"http://apple.com/ns/ical/\"", null);
}
response.endPropStatOK();
}
response.endMultistatus();

View File

@ -1322,6 +1322,16 @@ public abstract class ExchangeSession {
*/
public abstract int createFolder(String folderName, String folderClass, Map<String, String> properties) throws IOException;
/**
* Update Exchange folder properties.
*
* @param folderName logical folder name
* @param properties folder properties
* @return status
* @throws IOException on error
*/
public abstract int updateFolder(String folderName, Map<String, String> properties) throws IOException;
/**
* Delete Exchange folder.
*
@ -1404,6 +1414,16 @@ public abstract class ExchangeSession {
* recent count
*/
public int recent;
/**
* Calendar color
*/
public String calendarColor;
/**
* Calendar order
*/
public String calendarOrder;
/**
* Folder message list, empty before loadMessages call.
*/

View File

@ -556,7 +556,7 @@ public class DavExchangeSession extends ExchangeSession {
// Exchange 2003
serverVersion = "Exchange2003";
fixClientHost(method);
checkPublicFolder(method);
checkPublicFolder();
try {
buildEmail(method.getURI().getHost());
} catch (URIException uriException) {
@ -571,7 +571,7 @@ public class DavExchangeSession extends ExchangeSession {
fixClientHost(method);
getEmailAndAliasFromOptions();
checkPublicFolder(method);
checkPublicFolder();
// failover: try to get email through Webdav and Galfind
if (alias == null || email == null) {
@ -749,7 +749,7 @@ public class DavExchangeSession extends ExchangeSession {
}
}
protected void checkPublicFolder(HttpMethod method) {
protected void checkPublicFolder() {
Cookie[] currentCookies = httpClient.getState().getCookies();
// check public folder access
@ -1837,6 +1837,27 @@ public class DavExchangeSession extends ExchangeSession {
return status;
}
/**
* @inheritDoc
*/
@Override
public int updateFolder(String folderPath, Map<String, String> properties) throws IOException {
Set<PropertyValue> propertyValues = new HashSet<PropertyValue>();
if (properties != null) {
for (Map.Entry<String, String> entry : properties.entrySet()) {
propertyValues.add(Field.createPropertyValue(entry.getKey(), entry.getValue()));
}
}
// standard MkColMethod does not take properties, override PropPatchMethod instead
ExchangePropPatchMethod method = new ExchangePropPatchMethod(URIUtil.encodePath(getFolderPath(folderPath)), propertyValues);
int status = DavGatewayHttpClientFacade.executeHttpMethod(httpClient, method);
if (status == HttpStatus.SC_MULTI_STATUS) {
status = method.getResponseStatusCode();
}
return status;
}
/**
* @inheritDoc
*/

View File

@ -924,6 +924,21 @@ public class EwsExchangeSession extends ExchangeSession {
return HttpStatus.SC_CREATED;
}
/**
* @inheritDoc
*/
@Override
public int updateFolder(String folderPath, Map<String, String> properties) throws IOException {
ArrayList<FieldUpdate> updates = new ArrayList<FieldUpdate>();
for (Map.Entry<String,String> entry:properties.entrySet()) {
updates.add(new FieldUpdate(Field.get(entry.getKey()), entry.getValue()));
}
UpdateFolderMethod updateFolderMethod = new UpdateFolderMethod(internalGetFolder(folderPath).folderId, updates);
executeMethod(updateFolderMethod);
return HttpStatus.SC_CREATED;
}
/**
* @inheritDoc
*/