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.response.DelegateManagementResponse;
031 import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion;
032 import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace;
033 import microsoft.exchange.webservices.data.property.complex.UserId;
034
035 import java.util.ArrayList;
036 import java.util.List;
037
038 /**
039 * Represents a RemoveDelete request.
040 */
041 public class RemoveDelegateRequest extends
042 DelegateManagementRequestBase<DelegateManagementResponse> {
043
044 /**
045 * The user ids.
046 */
047 private List<UserId> userIds = new ArrayList<UserId>();
048
049 /**
050 * Initializes a new instance of the class.
051 *
052 * @param service the service
053 * @throws Exception
054 */
055 public RemoveDelegateRequest(ExchangeService service)
056 throws Exception {
057 super(service);
058 }
059
060 /**
061 * Asserts the valid.
062 *
063 * @throws Exception the exception
064 */
065 @Override
066 protected void validate() throws Exception {
067 super.validate();
068 EwsUtilities.validateParamCollection(this.getUserIds().iterator(), "UserIds");
069 }
070
071 /**
072 * Asserts the valid.
073 *
074 * @param writer the writer
075 * @throws Exception the exception
076 */
077 @Override
078 protected void writeElementsToXml(EwsServiceXmlWriter writer)
079 throws Exception {
080 super.writeElementsToXml(writer);
081 writer
082 .writeStartElement(XmlNamespace.Messages,
083 XmlElementNames.UserIds);
084
085 for (UserId userId : this.getUserIds()) {
086 userId.writeToXml(writer, XmlElementNames.UserId);
087 }
088
089 writer.writeEndElement(); // UserIds
090 }
091
092 /**
093 * Gets the name of the response XML element.
094 *
095 * @return XML element name
096 */
097 @Override
098 protected String getResponseXmlElementName() {
099 return XmlElementNames.RemoveDelegateResponse;
100 }
101
102 /**
103 * Gets the name of the XML element.
104 *
105 * @return XML element name
106 */
107 @Override public String getXmlElementName() {
108 return XmlElementNames.RemoveDelegate;
109 }
110
111 /**
112 * Creates the response.
113 *
114 * @return Service response
115 */
116 @Override
117 protected DelegateManagementResponse createResponse() {
118 return new DelegateManagementResponse(false, null);
119 }
120
121 /**
122 * Gets the request version.
123 *
124 * @return Earliest Exchange version in which this request is supported.
125 */
126 @Override
127 protected ExchangeVersion getMinimumRequiredServerVersion() {
128 return ExchangeVersion.Exchange2007_SP1;
129 }
130
131 /**
132 * Gets the user ids.
133 *
134 * @return the user ids
135 */
136 public List<UserId> getUserIds() {
137 return this.userIds;
138 }
139 }