1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package davmail.exchange.ews;
21
22 import davmail.exchange.XMLStreamUtil;
23
24 import javax.xml.stream.XMLStreamException;
25 import javax.xml.stream.XMLStreamReader;
26 import java.io.IOException;
27 import java.io.Writer;
28
29 public class GetUserPhotoMethod extends EWSMethod {
30 public enum SizeRequested {
31 HR48x48, HR64x64, HR96x96, HR120x120, HR240x240, HR360x360,
32 HR432x432, HR504x504, HR648x648
33 }
34
35 protected String email;
36 protected SizeRequested sizeRequested;
37
38 protected String contentType = null;
39 protected String pictureData = null;
40
41
42
43
44 public GetUserPhotoMethod(String email, SizeRequested sizeRequested) {
45 super("GetUserPhoto", "GetUserPhoto");
46 this.email = email;
47 this.sizeRequested = sizeRequested;
48 }
49
50 @Override
51 protected void writeSoapBody(Writer writer) throws IOException {
52 writer.write("<m:Email>");
53 writer.write(email);
54 writer.write("</m:Email>");
55
56 writer.write("<m:SizeRequested>");
57 writer.write(sizeRequested.toString());
58 writer.write("</m:SizeRequested>");
59
60 }
61
62 @Override
63 protected void handleCustom(XMLStreamReader reader) throws XMLStreamException {
64 if (XMLStreamUtil.isStartTag(reader, "PictureData")) {
65 pictureData = reader.getElementText();
66 if (pictureData.isEmpty()) {
67 pictureData = null;
68 }
69 }
70 if (XMLStreamUtil.isStartTag(reader, "ContentType")) {
71 contentType = reader.getElementText();
72 }
73
74 }
75
76 public String getContentType() {
77 return contentType;
78 }
79
80 public String getPictureData() {
81 return pictureData;
82 }
83 }