001 /*
002 * The MIT License
003 * Copyright (c) 2012 Microsoft Corporation
004 *
005 * Permission is hereby granted, free of charge, to any person obtaining a copy
006 * of this software and associated documentation files (the "Software"), to deal
007 * in the Software without restriction, including without limitation the rights
008 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
009 * copies of the Software, and to permit persons to whom the Software is
010 * furnished to do so, subject to the following conditions:
011 *
012 * The above copyright notice and this permission notice shall be included in
013 * all copies or substantial portions of the Software.
014 *
015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
016 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
017 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
018 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
019 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
020 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
021 * THE SOFTWARE.
022 */
023
024 package microsoft.exchange.webservices.data.autodiscover.exception.error;
025
026 import microsoft.exchange.webservices.data.attribute.EditorBrowsable;
027 import microsoft.exchange.webservices.data.core.EwsXmlReader;
028 import microsoft.exchange.webservices.data.core.XmlAttributeNames;
029 import microsoft.exchange.webservices.data.core.XmlElementNames;
030 import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState;
031 import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace;
032 import microsoft.exchange.webservices.data.security.XmlNodeType;
033
034 /**
035 * Defines the AutodiscoverError class.
036 */
037 @EditorBrowsable(state = EditorBrowsableState.Never)
038 public final class AutodiscoverError {
039
040 /**
041 * The time.
042 */
043 private String time;
044
045 /**
046 * The id.
047 */
048 private String id;
049
050 /**
051 * The error code.
052 */
053 private int errorCode;
054
055 /**
056 * The message.
057 */
058 private String message;
059
060 /**
061 * The debug data.
062 */
063 private String debugData;
064
065 /**
066 * Initializes a new instance of the AutodiscoverError class.
067 */
068 private AutodiscoverError() {
069 }
070
071 /**
072 * Parses the XML through the specified reader and creates an Autodiscover
073 * error.
074 *
075 * @param reader the reader
076 * @return AutodiscoverError
077 * @throws Exception the exception
078 */
079 public static AutodiscoverError parse(EwsXmlReader reader)
080 throws Exception {
081 AutodiscoverError error = new AutodiscoverError();
082 error.time = reader.readAttributeValue(XmlAttributeNames.Time);
083 error.id = reader.readAttributeValue(XmlAttributeNames.Id);
084
085 do {
086 reader.read();
087
088 if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) {
089 if (reader.getLocalName().equalsIgnoreCase(
090 XmlElementNames.ErrorCode)) {
091 error.errorCode = reader.readElementValue(Integer.class);
092 } else if (reader.getLocalName().equalsIgnoreCase(
093 XmlElementNames.Message)) {
094 error.message = reader.readElementValue();
095 } else if (reader.getLocalName().equalsIgnoreCase(
096 XmlElementNames.DebugData)) {
097 error.debugData = reader.readElementValue();
098 } else {
099 reader.skipCurrentElement();
100 }
101 }
102 } while (!reader.isEndElement(XmlNamespace.NotSpecified,
103 XmlElementNames.Error));
104
105 return error;
106 }
107
108 /**
109 * Gets the time when the error was returned.
110 *
111 * @return the time
112 */
113 public String getTime() {
114 return time;
115 }
116
117 /**
118 * Gets a hash of the name of the computer that is running Microsoft
119 * Exchange Server that has the Client Access server role installed.
120 *
121 * @return the id
122 */
123 public String getId() {
124 return id;
125 }
126
127 /**
128 * Gets the error code.
129 *
130 * @return the error code
131 */
132 public int getErrorCode() {
133 return errorCode;
134 }
135
136 /**
137 * Gets the error message.
138 *
139 * @return the message
140 */
141 public String getMessage() {
142 return message;
143 }
144
145 /**
146 * Gets the debug data.
147 *
148 * @return the debug data
149 */
150 public String getDebugData() {
151 return debugData;
152 }
153
154 }