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.ExchangeService;
027 import microsoft.exchange.webservices.data.core.XmlElementNames;
028 import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling;
029 import microsoft.exchange.webservices.data.core.response.FindItemResponse;
030 import microsoft.exchange.webservices.data.core.service.item.Item;
031 import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion;
032 import microsoft.exchange.webservices.data.search.Grouping;
033
034 /**
035 * Represents a FindItem request.
036 *
037 * @param <TItem> The type of the item.
038 */
039 public final class FindItemRequest<TItem extends Item> extends
040 FindRequest<FindItemResponse<TItem>> {
041
042 /**
043 * The group by.
044 */
045 private Grouping groupBy;
046
047 /**
048 * Initializes a new instance of the FindItemRequest class.
049 *
050 * @param service The Service
051 * @param errorHandlingMode Indicates how errors should be handled.
052 * @throws Exception
053 */
054 public FindItemRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode)
055 throws Exception {
056 super(service, errorHandlingMode);
057 }
058
059 /**
060 * Creates the service response.
061 *
062 * @param service The service
063 * @param responseIndex Index of the response.
064 * @return Service response.
065 */
066 @Override
067 protected FindItemResponse<TItem> createServiceResponse(
068 ExchangeService service, int responseIndex) {
069 return new FindItemResponse<TItem>(this.getGroupBy() != null, this
070 .getView().getPropertySetOrDefault());
071 }
072
073 /**
074 * Gets the name of the XML element.
075 *
076 * @return XML element name.
077 */
078 @Override public String getXmlElementName() {
079 return XmlElementNames.FindItem;
080 }
081
082 /**
083 * Gets the name of the response XML element.
084 *
085 * @return XML element name.
086 */
087 @Override
088 protected String getResponseXmlElementName() {
089 return XmlElementNames.FindItemResponse;
090 }
091
092 /**
093 * Gets the name of the response message XML element.
094 *
095 * @return XML element name.
096 */
097 @Override
098 protected String getResponseMessageXmlElementName() {
099 return XmlElementNames.FindItemResponseMessage;
100 }
101
102 /**
103 * Gets the request version.
104 *
105 * @return Earliest Exchange version in which this request is supported.
106 */
107 @Override
108 protected ExchangeVersion getMinimumRequiredServerVersion() {
109 return ExchangeVersion.Exchange2007_SP1;
110 }
111
112 /**
113 * Gets the group by.
114 *
115 * @return the group by
116 */
117 public Grouping getGroupBy() {
118 return this.groupBy;
119 }
120
121 /**
122 * Sets the group by.
123 *
124 * @param value the new group by
125 */
126 public void setGroupBy(Grouping value) {
127 this.groupBy = value;
128
129 }
130
131 }