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
024package microsoft.exchange.webservices.data.autodiscover.response;
025
026import microsoft.exchange.webservices.data.autodiscover.enumeration.AutodiscoverErrorCode;
027import microsoft.exchange.webservices.data.core.EwsXmlReader;
028import microsoft.exchange.webservices.data.core.XmlElementNames;
029
030import java.net.URI;
031
032/**
033 * Represents the base class for all response returned by the Autodiscover
034 * service.
035 */
036public abstract class AutodiscoverResponse {
037
038  /**
039   * The error code.
040   */
041  private AutodiscoverErrorCode errorCode;
042
043  /**
044   * The error message.
045   */
046  private String errorMessage;
047
048  /**
049   * The redirection url.
050   */
051  private URI redirectionUrl;
052
053  /**
054   * Initializes a new instance of the AutodiscoverResponse class.
055   */
056  public AutodiscoverResponse() {
057    this.errorCode = AutodiscoverErrorCode.NoError;
058  }
059
060  /**
061   * Initializes a new instance of the AutodiscoverResponse class.
062   *
063   * @param reader         the reader
064   * @param endElementName the end element name
065   * @throws Exception the exception
066   */
067  public void loadFromXml(EwsXmlReader reader, String endElementName)
068      throws Exception {
069    if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.ErrorCode)) {
070      this.errorCode = reader
071          .readElementValue(AutodiscoverErrorCode.class);
072    } else if (reader.getLocalName().equalsIgnoreCase(
073        XmlElementNames.ErrorMessage)) {
074      this.errorMessage = reader.readElementValue();
075    }
076  }
077
078  /**
079   * Gets  the error code that was returned by the service.
080   *
081   * @return the error code
082   */
083  public AutodiscoverErrorCode getErrorCode() {
084    return errorCode;
085  }
086
087  /**
088   * Sets the error code.
089   *
090   * @param errorCode the new error code
091   */
092  public void setErrorCode(AutodiscoverErrorCode errorCode) {
093    this.errorCode = errorCode;
094  }
095
096  /**
097   * Gets the error message that was returned by the service.
098   *
099   * @return the error message
100   */
101  public String getErrorMessage() {
102    return errorMessage;
103  }
104
105  /**
106   * Sets the error message.
107   *
108   * @param errorMessage the new error message
109   */
110  public void setErrorMessage(String errorMessage) {
111    this.errorMessage = errorMessage;
112  }
113
114  /**
115   * Gets  the redirection URL.
116   *
117   * @return the redirection url
118   */
119  public URI getRedirectionUrl() {
120    return redirectionUrl;
121  }
122
123  /**
124   * Sets the redirection url.
125   *
126   * @param redirectionUrl the new redirection url
127   */
128  public void setRedirectionUrl(URI redirectionUrl) {
129    this.redirectionUrl = redirectionUrl;
130  }
131}