1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package davmail.exchange.ews;
20
21 import davmail.exchange.XMLStreamUtil;
22
23 import javax.xml.stream.XMLStreamException;
24 import javax.xml.stream.XMLStreamReader;
25 import java.io.IOException;
26 import java.io.Writer;
27
28
29
30
31 public class GetUserConfigurationMethod extends EWSMethod {
32
33
34
35
36 public GetUserConfigurationMethod() {
37 super("UserConfiguration", "GetUserConfiguration");
38 folderId = DistinguishedFolderId.getInstance(null, DistinguishedFolderId.Name.root);
39 }
40
41 @Override
42 protected void writeSoapBody(Writer writer) throws IOException {
43 writer.write("<m:UserConfigurationName Name=\"OWA.UserOptions\">");
44 folderId.write(writer);
45 writer.write("</m:UserConfigurationName>");
46 writer.write("<m:UserConfigurationProperties>All</m:UserConfigurationProperties>");
47 }
48
49 @Override
50 protected void handleCustom(XMLStreamReader reader) throws XMLStreamException {
51 if (XMLStreamUtil.isStartTag(reader, "UserConfiguration")) {
52 responseItems.add(handleUserConfiguration(reader));
53 }
54 }
55
56 private Item handleUserConfiguration(XMLStreamReader reader) throws XMLStreamException {
57 Item responseItem = new Item();
58 while (reader.hasNext() && !(XMLStreamUtil.isEndTag(reader, "UserConfiguration"))) {
59 reader.next();
60 if (XMLStreamUtil.isStartTag(reader)) {
61 String tagLocalName = reader.getLocalName();
62 if ("DictionaryEntry".equals(tagLocalName)) {
63 handleDictionaryEntry(reader, responseItem);
64 }
65 }
66 }
67 return responseItem;
68 }
69
70 private void handleDictionaryEntry(XMLStreamReader reader, Item responseItem) throws XMLStreamException {
71 String key = null;
72 while (reader.hasNext() && !(XMLStreamUtil.isEndTag(reader, "DictionaryEntry"))) {
73 reader.next();
74 if (XMLStreamUtil.isStartTag(reader)) {
75 String tagLocalName = reader.getLocalName();
76 if ("Value".equals(tagLocalName)) {
77 if (key == null) {
78 key = reader.getElementText();
79 } else {
80 responseItem.put(key, XMLStreamUtil.getElementText(reader));
81 }
82 }
83 }
84 }
85 }
86
87 }