mirror of
https://github.com/moparisthebest/davmail
synced 2024-08-13 16:53:51 -04:00
EWS: retrieve and decode MIME content
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1061 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
9d0cd0da4b
commit
b81fa5331a
@ -18,6 +18,7 @@
|
||||
*/
|
||||
package davmail.exchange.ews;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.httpclient.Header;
|
||||
import org.apache.commons.httpclient.HttpConnection;
|
||||
import org.apache.commons.httpclient.HttpState;
|
||||
@ -47,12 +48,15 @@ public abstract class EWSMethod extends PostMethod {
|
||||
protected FolderIdType folderId;
|
||||
protected FolderIdType parentFolderId;
|
||||
protected ItemIdType itemId;
|
||||
protected HashSet<FieldURI> additionalProperties = null;
|
||||
protected HashSet<FieldURI> additionalProperties;
|
||||
|
||||
protected final String itemType;
|
||||
protected final String methodName;
|
||||
protected final String responseCollectionName;
|
||||
|
||||
protected byte[] mimeContent;
|
||||
protected List<Item> responseItems;
|
||||
protected String errorDetail;
|
||||
|
||||
/**
|
||||
* Build EWS method
|
||||
@ -215,13 +219,22 @@ public abstract class EWSMethod extends PostMethod {
|
||||
}
|
||||
}
|
||||
|
||||
protected List<Item> responseItems;
|
||||
protected String errorDetail;
|
||||
|
||||
public List<Item> getResponseItems() {
|
||||
return responseItems;
|
||||
}
|
||||
|
||||
public Item getResponseItem() {
|
||||
if (responseItems != null && responseItems.size() == 1) {
|
||||
return responseItems.get(0);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] getMimeContent() {
|
||||
return mimeContent;
|
||||
}
|
||||
|
||||
protected String handleTag(XMLStreamReader reader, String localName) throws XMLStreamException {
|
||||
String result = null;
|
||||
int event = reader.getEventType();
|
||||
@ -270,6 +283,8 @@ public abstract class EWSMethod extends PostMethod {
|
||||
String value = null;
|
||||
if ("ExtendedProperty".equals(tagLocalName)) {
|
||||
addExtendedPropertyValue(reader, item);
|
||||
} else if (tagLocalName.endsWith("MimeContent")) {
|
||||
handleMimeContent(reader);
|
||||
} else {
|
||||
if (tagLocalName.endsWith("Id")) {
|
||||
value = getAttributeValue(reader, "Id");
|
||||
@ -286,6 +301,11 @@ public abstract class EWSMethod extends PostMethod {
|
||||
return item;
|
||||
}
|
||||
|
||||
protected void handleMimeContent(XMLStreamReader reader) throws XMLStreamException {
|
||||
byte[] base64MimeContent = reader.getElementText().getBytes();
|
||||
mimeContent = Base64.decodeBase64(base64MimeContent);
|
||||
}
|
||||
|
||||
protected void addExtendedPropertyValue(XMLStreamReader reader, Item item) throws XMLStreamException {
|
||||
String propertyTag = null;
|
||||
String propertyValue = null;
|
||||
|
@ -22,10 +22,10 @@ package davmail.exchange.ews;
|
||||
* Get Item method.
|
||||
*/
|
||||
public class GetItemMethod extends EWSMethod {
|
||||
public GetItemMethod(BaseShapeType baseShape, FolderIdType folderId, boolean includeMimeContent) {
|
||||
public GetItemMethod(BaseShapeType baseShape, ItemIdType itemId, boolean includeMimeContent) {
|
||||
super("Item", "GetItem");
|
||||
this.baseShape = baseShape;
|
||||
this.folderId = folderId;
|
||||
this.itemId = itemId;
|
||||
this.includeMimeContent = includeMimeContent;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user