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.core.request;
025
026 import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter;
027 import microsoft.exchange.webservices.data.core.EwsUtilities;
028 import microsoft.exchange.webservices.data.core.ExchangeService;
029 import microsoft.exchange.webservices.data.core.XmlElementNames;
030 import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling;
031 import microsoft.exchange.webservices.data.core.response.ServiceResponse;
032 import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion;
033 import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace;
034 import microsoft.exchange.webservices.data.misc.UserConfiguration;
035
036 /**
037 * Represents a CreateUserConfiguration request.
038 */
039 public class CreateUserConfigurationRequest extends
040 MultiResponseServiceRequest<ServiceResponse> {
041
042 /**
043 * The user configuration.
044 */
045 protected UserConfiguration userConfiguration;
046
047 /**
048 * Validate request.
049 *
050 * @throws Exception the exception
051 */
052 @Override
053 protected void validate() throws Exception {
054 super.validate();
055 EwsUtilities.validateParam(this.userConfiguration, "userConfiguration");
056 }
057
058 /**
059 * Creates the service response.
060 *
061 * @param service The service.
062 * @param responseIndex Index of the response.
063 * @return Service response.
064 */
065 @Override
066 protected ServiceResponse createServiceResponse(ExchangeService service,
067 int responseIndex) {
068 return new ServiceResponse();
069 }
070
071 /**
072 * Gets the request version.
073 *
074 * @return Earliest Exchange version in which this request is supported.
075 */
076 @Override
077 protected ExchangeVersion getMinimumRequiredServerVersion() {
078 return ExchangeVersion.Exchange2010;
079 }
080
081 /**
082 * Gets the expected response message count.
083 *
084 * @return Number of expected response messages.
085 */
086 @Override
087 protected int getExpectedResponseMessageCount() {
088 return 1;
089 }
090
091 /**
092 * Gets the name of the XML element.
093 *
094 * @return XML element name,
095 */
096 @Override public String getXmlElementName() {
097 return XmlElementNames.CreateUserConfiguration;
098 }
099
100 /**
101 * Gets the name of the response XML element.
102 *
103 * @return XML element name,
104 */
105 @Override
106 protected String getResponseXmlElementName() {
107 return XmlElementNames.CreateUserConfigurationResponse;
108 }
109
110 /**
111 * Gets the name of the response message XML element.
112 *
113 * @return XML element name,
114 */
115 @Override
116 protected String getResponseMessageXmlElementName() {
117 return XmlElementNames.CreateUserConfigurationResponseMessage;
118 }
119
120 /**
121 * Writes XML elements.
122 *
123 * @param writer the writer
124 * @throws Exception the exception
125 */
126 @Override
127 protected void writeElementsToXml(EwsServiceXmlWriter writer)
128 throws Exception {
129 // Write UserConfiguation element
130 this.userConfiguration.writeToXml(writer, XmlNamespace.Messages,
131 XmlElementNames.UserConfiguration);
132 }
133
134 /**
135 * Initializes a new instance of the <see
136 * cref="CreateUserConfigurationRequest"/> class.
137 *
138 * @param service The service.
139 * @throws Exception
140 */
141 public CreateUserConfigurationRequest(ExchangeService service)
142 throws Exception {
143 super(service, ServiceErrorHandling.ThrowOnError);
144 }
145
146 /**
147 * Gets the user configuration.
148 *
149 * @return The userConfiguration.
150 */
151 public UserConfiguration getUserConfiguration() {
152 return this.userConfiguration;
153
154 }
155
156 /**
157 * Sets the user configuration.
158 *
159 * @param value the new user configuration
160 */
161 public void setUserConfiguration(UserConfiguration value) {
162 this.userConfiguration = value;
163 }
164 }