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.EwsServiceXmlWriter;
027import microsoft.exchange.webservices.data.core.EwsUtilities;
028import microsoft.exchange.webservices.data.core.ExchangeService;
029import microsoft.exchange.webservices.data.core.XmlElementNames;
030import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling;
031import microsoft.exchange.webservices.data.core.response.ServiceResponse;
032import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion;
033import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace;
034import microsoft.exchange.webservices.data.misc.UserConfiguration;
035import microsoft.exchange.webservices.data.property.complex.FolderId;
036
037/**
038 * Represents a DeleteUserConfiguration request.
039 */
040public class DeleteUserConfigurationRequest extends
041    MultiResponseServiceRequest<ServiceResponse> {
042
043  /**
044   * The name.
045   */
046  private String name;
047
048  /**
049   * The parent folder id.
050   */
051  private FolderId parentFolderId;
052
053  /**
054   * Validate request.
055   *
056   * @throws Exception the exception
057   */
058  @Override
059  protected void validate() throws Exception {
060    super.validate();
061    EwsUtilities.validateParam(this.name, "name");
062    EwsUtilities.validateParam(this.parentFolderId, "parentFolderId");
063    this.getParentFolderId().validate(
064        this.getService().getRequestedServerVersion());
065  }
066
067  /**
068   * Creates the service response.
069   *
070   * @param service       the service
071   * @param responseIndex the response index
072   * @return Service response.
073   */
074  @Override
075  protected ServiceResponse createServiceResponse(ExchangeService service,
076      int responseIndex) {
077    return new ServiceResponse();
078  }
079
080  /**
081   * Gets the request version.
082   *
083   * @return Earliest Exchange version in which this request is supported.
084   */
085  @Override
086  protected ExchangeVersion getMinimumRequiredServerVersion() {
087    return ExchangeVersion.Exchange2010;
088  }
089
090  /**
091   * Gets the expected response message count.
092   *
093   * @return Number of expected response messages.
094   */
095  @Override
096  protected int getExpectedResponseMessageCount() {
097    return 1;
098  }
099
100  /**
101   * Gets the name of the XML element.
102   *
103   * @return XML element name
104   */
105  @Override public String getXmlElementName() {
106    return XmlElementNames.DeleteUserConfiguration;
107  }
108
109  /**
110   * Gets the name of the response XML element.
111   *
112   * @return XML element name
113   */
114  @Override
115  protected String getResponseXmlElementName() {
116    return XmlElementNames.DeleteUserConfigurationResponse;
117  }
118
119  /**
120   * Gets the name of the response message XML element.
121   *
122   * @return XML element name
123   */
124  @Override
125  protected String getResponseMessageXmlElementName() {
126    return XmlElementNames.DeleteUserConfigurationResponseMessage;
127  }
128
129  /**
130   * Writes XML elements.
131   *
132   * @param writer the writer
133   * @throws Exception the exception
134   */
135  @Override
136  protected void writeElementsToXml(EwsServiceXmlWriter writer)
137      throws Exception {
138    // Write UserConfiguationName element
139    UserConfiguration
140        .writeUserConfigurationNameToXml(writer, XmlNamespace.Messages, this.name, this.parentFolderId);
141  }
142
143  /**
144   * Initializes a new instance of the class.
145   *
146   * @param service the service
147   * @throws Exception on error
148   */
149  public DeleteUserConfigurationRequest(ExchangeService service)
150      throws Exception {
151    super(service, ServiceErrorHandling.ThrowOnError);
152  }
153
154  /**
155   * Gets  the name.
156   *
157   * @return the name
158   */
159  protected String getName() {
160    return this.name;
161  }
162
163  /**
164   * Sets the name.
165   *
166   * @param name the new name
167   */
168  public void setName(String name) {
169    this.name = name;
170  }
171
172  /**
173   * Gets the parent folThe parent folder Id.
174   *
175   * @return the parent folder id
176   */
177  protected FolderId getParentFolderId() {
178    return this.parentFolderId;
179  }
180
181  /**
182   * Sets the parent folder id.
183   *
184   * @param parentFolderId the new parent folder id
185   */
186  public void setParentFolderId(FolderId parentFolderId) {
187    this.parentFolderId = parentFolderId;
188  }
189}