diff --git a/src/java/davmail/caldav/CaldavConnection.java b/src/java/davmail/caldav/CaldavConnection.java index ad82c99b..dce4faf4 100644 --- a/src/java/davmail/caldav/CaldavConnection.java +++ b/src/java/davmail/caldav/CaldavConnection.java @@ -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(); diff --git a/src/java/davmail/exchange/ExchangeSession.java b/src/java/davmail/exchange/ExchangeSession.java index 9c2cbbde..bda799e9 100644 --- a/src/java/davmail/exchange/ExchangeSession.java +++ b/src/java/davmail/exchange/ExchangeSession.java @@ -1322,6 +1322,16 @@ public abstract class ExchangeSession { */ public abstract int createFolder(String folderName, String folderClass, Map 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 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. */ diff --git a/src/java/davmail/exchange/dav/DavExchangeSession.java b/src/java/davmail/exchange/dav/DavExchangeSession.java index 45256ad7..4b59eb18 100644 --- a/src/java/davmail/exchange/dav/DavExchangeSession.java +++ b/src/java/davmail/exchange/dav/DavExchangeSession.java @@ -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 properties) throws IOException { + Set propertyValues = new HashSet(); + if (properties != null) { + for (Map.Entry 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 */ diff --git a/src/java/davmail/exchange/ews/EwsExchangeSession.java b/src/java/davmail/exchange/ews/EwsExchangeSession.java index 125dbacd..ddf010da 100644 --- a/src/java/davmail/exchange/ews/EwsExchangeSession.java +++ b/src/java/davmail/exchange/ews/EwsExchangeSession.java @@ -924,6 +924,21 @@ public class EwsExchangeSession extends ExchangeSession { return HttpStatus.SC_CREATED; } + /** + * @inheritDoc + */ + @Override + public int updateFolder(String folderPath, Map properties) throws IOException { + ArrayList updates = new ArrayList(); + for (Map.Entry 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 */