Improve contact picture error handling

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@2240 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2014-03-09 10:13:22 +00:00
parent a16ae1203b
commit c3dabcdfe4
2 changed files with 47 additions and 48 deletions

View File

@ -2279,7 +2279,6 @@ public class DavExchangeSession extends ExchangeSession {
@Override
public ExchangeSession.ContactPhoto getContactPhoto(ExchangeSession.Contact contact) throws IOException {
ContactPhoto contactPhoto = null;
if ("true".equals(contact.get("haspicture"))) {
final GetMethod method = new GetMethod(URIUtil.encodePath(contact.getHref()) + "/ContactPicture.jpg");
method.setRequestHeader("Translate", "f");
method.setRequestHeader("Accept-Encoding", "gzip");
@ -2314,7 +2313,6 @@ public class DavExchangeSession extends ExchangeSession {
}
method.releaseConnection();
}
}
return contactPhoto;
}

View File

@ -2011,7 +2011,9 @@ public class EwsExchangeSession extends ExchangeSession {
getItemMethod.addAdditionalProperty(Field.get("attachments"));
executeMethod(getItemMethod);
EWSMethod.Item item = getItemMethod.getResponseItem();
if (item != null) {
if (item == null) {
throw new IOException("Missing contact picture");
}
FileAttachment attachment = item.getAttachmentByName("ContactPicture.jpg");
if (attachment == null) {
throw new IOException("Missing contact picture");
@ -2027,7 +2029,6 @@ public class EwsExchangeSession extends ExchangeSession {
} else {
contactPhoto.contentType = attachment.contentType;
}
}
return contactPhoto;
}