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

EWS: force urlcompname only on create

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1304 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2010-07-27 19:28:27 +00:00
parent d074d6094f
commit 6e9ed2e942
3 changed files with 9 additions and 21 deletions

View File

@ -28,6 +28,7 @@ import davmail.exception.HttpNotFoundException;
import davmail.exchange.ExchangeSession; import davmail.exchange.ExchangeSession;
import davmail.exchange.ExchangeSessionFactory; import davmail.exchange.ExchangeSessionFactory;
import davmail.exchange.ICSBufferedReader; import davmail.exchange.ICSBufferedReader;
import davmail.exchange.XMLStreamUtil;
import davmail.ui.tray.DavGatewayTray; import davmail.ui.tray.DavGatewayTray;
import davmail.util.StringUtil; import davmail.util.StringUtil;
import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.HttpException;
@ -1359,7 +1360,7 @@ public class CaldavConnection extends AbstractConnection {
protected void parseXmlBody() throws IOException { protected void parseXmlBody() throws IOException {
XMLStreamReader streamReader = null; XMLStreamReader streamReader = null;
try { try {
XMLInputFactory inputFactory = XMLInputFactory.newInstance(); XMLInputFactory inputFactory = XMLStreamUtil.getXmlInputFactory();
inputFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE); inputFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE);
inputFactory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.TRUE); inputFactory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.TRUE);

View File

@ -18,6 +18,7 @@
*/ */
package davmail.exchange.dav; package davmail.exchange.dav;
import davmail.exchange.XMLStreamUtil;
import org.apache.commons.httpclient.*; import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.PostMethod; import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.RequestEntity; import org.apache.commons.httpclient.methods.RequestEntity;
@ -165,18 +166,6 @@ public class ExchangePropPatchMethod extends PostMethod {
return "PROPPATCH"; return "PROPPATCH";
} }
/**
* Build a new XMLInputFactory.
*
* @return XML input factory
*/
public static XMLInputFactory getXmlInputFactory() {
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
inputFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE);
inputFactory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.TRUE);
return inputFactory;
}
protected boolean isStartTag(XMLStreamReader reader, String tagLocalName) { protected boolean isStartTag(XMLStreamReader reader, String tagLocalName) {
return (reader.getEventType() == XMLStreamConstants.START_ELEMENT) && (reader.getLocalName().equals(tagLocalName)); return (reader.getEventType() == XMLStreamConstants.START_ELEMENT) && (reader.getLocalName().equals(tagLocalName));
} }
@ -194,7 +183,7 @@ public class ExchangePropPatchMethod extends PostMethod {
responses = new ArrayList<MultiStatusResponse>(); responses = new ArrayList<MultiStatusResponse>();
XMLStreamReader reader; XMLStreamReader reader;
try { try {
XMLInputFactory xmlInputFactory = getXmlInputFactory(); XMLInputFactory xmlInputFactory = XMLStreamUtil.getXmlInputFactory();
reader = xmlInputFactory.createXMLStreamReader(new FilterInputStream(getResponseBodyAsStream()) { reader = xmlInputFactory.createXMLStreamReader(new FilterInputStream(getResponseBodyAsStream()) {
final byte[] lastbytes = new byte[3]; final byte[] lastbytes = new byte[3];

View File

@ -696,10 +696,6 @@ public class EwsExchangeSession extends ExchangeSession {
list.add(Field.createFieldUpdate(entry.getKey(), entry.getValue())); list.add(Field.createFieldUpdate(entry.getKey(), entry.getValue()));
} }
} }
// force urlcompname, only for DavMail created items
if (!isItemId(itemName)) {
list.add(Field.createFieldUpdate("urlcompname", convertItemNameToEML(itemName)));
}
return list; return list;
} }
@ -749,17 +745,20 @@ public class EwsExchangeSession extends ExchangeSession {
} }
} }
Set<FieldUpdate> properties = buildProperties();
if (currentItemId != null) { if (currentItemId != null) {
// update // update
createOrUpdateItemMethod = new UpdateItemMethod(MessageDisposition.SaveOnly, createOrUpdateItemMethod = new UpdateItemMethod(MessageDisposition.SaveOnly,
ConflictResolution.AlwaysOverwrite, ConflictResolution.AlwaysOverwrite,
SendMeetingInvitationsOrCancellations.SendToNone, SendMeetingInvitationsOrCancellations.SendToNone,
currentItemId, buildProperties()); currentItemId, properties);
} else { } else {
// create // create
EWSMethod.Item newItem = new EWSMethod.Item(); EWSMethod.Item newItem = new EWSMethod.Item();
newItem.type = "Contact"; newItem.type = "Contact";
newItem.setFieldUpdates(buildProperties()); // force urlcompname on create
properties.add(Field.createFieldUpdate("urlcompname", convertItemNameToEML(itemName)));
newItem.setFieldUpdates(properties);
createOrUpdateItemMethod = new CreateItemMethod(MessageDisposition.SaveOnly, getFolderId(folderPath), newItem); createOrUpdateItemMethod = new CreateItemMethod(MessageDisposition.SaveOnly, getFolderId(folderPath), newItem);
} }
executeMethod(createOrUpdateItemMethod); executeMethod(createOrUpdateItemMethod);
@ -843,7 +842,6 @@ public class EwsExchangeSession extends ExchangeSession {
EWSMethod createOrUpdateItemMethod; EWSMethod createOrUpdateItemMethod;
// first try to load existing event // first try to load existing event
String urlcompname = convertItemNameToEML(itemName);
String currentEtag = null; String currentEtag = null;
ItemId currentItemId = null; ItemId currentItemId = null;
EWSMethod.Item currentItem = getEwsItem(folderPath, itemName); EWSMethod.Item currentItem = getEwsItem(folderPath, itemName);