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.core.request;
025
026import microsoft.exchange.webservices.data.core.EwsServiceXmlReader;
027import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter;
028import microsoft.exchange.webservices.data.core.ExchangeService;
029import microsoft.exchange.webservices.data.core.XmlElementNames;
030import microsoft.exchange.webservices.data.core.response.GetRoomsResponse;
031import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion;
032import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace;
033import microsoft.exchange.webservices.data.property.complex.EmailAddress;
034
035/**
036 * Represents a GetRooms request.
037 */
038public final class GetRoomsRequest extends SimpleServiceRequestBase<GetRoomsResponse> {
039
040  /**
041   * Represents a GetRooms request.
042   *
043   * @param service the service
044   * @throws Exception
045   */
046  public GetRoomsRequest(ExchangeService service)
047      throws Exception {
048    super(service);
049  }
050
051  /**
052   * Gets the name of the XML element.
053   *
054   * @return XML element name
055   */
056  @Override public String getXmlElementName() {
057    return XmlElementNames.GetRoomsRequest;
058  }
059
060  /**
061   * Writes XML elements.
062   *
063   * @param writer the writer
064   * @throws Exception the exception
065   */
066  @Override
067  protected void writeElementsToXml(EwsServiceXmlWriter writer)
068      throws Exception {
069    this.getRoomList().writeToXml(writer, XmlNamespace.Messages,
070        XmlElementNames.RoomList);
071  }
072
073  /**
074   * Gets the name of the response XML element.
075   *
076   * @return XML element name.
077   */
078  @Override
079  protected String getResponseXmlElementName() {
080    return XmlElementNames.GetRoomsResponse;
081  }
082
083  /**
084   * {@inheritDoc}
085   */
086  @Override
087  protected GetRoomsResponse parseResponse(EwsServiceXmlReader reader)
088      throws Exception {
089    GetRoomsResponse response = new GetRoomsResponse();
090    response.loadFromXml(reader, XmlElementNames.GetRoomsResponse);
091    return response;
092  }
093
094  /**
095   * Gets the request version.
096   *
097   * @return Earliest Exchange version in which this request is supported.
098   */
099  @Override
100  protected ExchangeVersion getMinimumRequiredServerVersion() {
101    return ExchangeVersion.Exchange2010;
102  }
103
104  /**
105   * Executes this request.
106   *
107   * @return Service response.
108   * @throws Exception the exception
109   */
110  public GetRoomsResponse execute() throws Exception {
111    GetRoomsResponse serviceResponse = internalExecute();
112    serviceResponse.throwIfNecessary();
113    return serviceResponse;
114  }
115
116  /**
117   * Gets  the room list to retrieve rooms from.
118   *
119   * @return the room list
120   */
121  protected EmailAddress getRoomList() {
122    return this.roomList;
123  }
124
125  /**
126   * Sets the room list.
127   *
128   * @param value the new room list
129   */
130  public void setRoomList(EmailAddress value) {
131    this.roomList = value;
132  }
133
134  /**
135   * The room list.
136   */
137  private EmailAddress roomList;
138
139}