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

View File

@ -18,6 +18,7 @@
*/
package davmail.exchange.dav;
import davmail.exchange.XMLStreamUtil;
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.RequestEntity;
@ -165,18 +166,6 @@ public class ExchangePropPatchMethod extends PostMethod {
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) {
return (reader.getEventType() == XMLStreamConstants.START_ELEMENT) && (reader.getLocalName().equals(tagLocalName));
}
@ -194,7 +183,7 @@ public class ExchangePropPatchMethod extends PostMethod {
responses = new ArrayList<MultiStatusResponse>();
XMLStreamReader reader;
try {
XMLInputFactory xmlInputFactory = getXmlInputFactory();
XMLInputFactory xmlInputFactory = XMLStreamUtil.getXmlInputFactory();
reader = xmlInputFactory.createXMLStreamReader(new FilterInputStream(getResponseBodyAsStream()) {
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()));
}
}
// force urlcompname, only for DavMail created items
if (!isItemId(itemName)) {
list.add(Field.createFieldUpdate("urlcompname", convertItemNameToEML(itemName)));
}
return list;
}
@ -749,17 +745,20 @@ public class EwsExchangeSession extends ExchangeSession {
}
}
Set<FieldUpdate> properties = buildProperties();
if (currentItemId != null) {
// update
createOrUpdateItemMethod = new UpdateItemMethod(MessageDisposition.SaveOnly,
ConflictResolution.AlwaysOverwrite,
SendMeetingInvitationsOrCancellations.SendToNone,
currentItemId, buildProperties());
currentItemId, properties);
} else {
// create
EWSMethod.Item newItem = new EWSMethod.Item();
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);
}
executeMethod(createOrUpdateItemMethod);
@ -843,7 +842,6 @@ public class EwsExchangeSession extends ExchangeSession {
EWSMethod createOrUpdateItemMethod;
// first try to load existing event
String urlcompname = convertItemNameToEML(itemName);
String currentEtag = null;
ItemId currentItemId = null;
EWSMethod.Item currentItem = getEwsItem(folderPath, itemName);