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.service.item.Item; 033import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; 034import microsoft.exchange.webservices.data.misc.ItemIdWrapperList; 035 036/** 037 * Represents an abstract Move/Copy Item request. 038 * 039 * @param <TResponse> The type of the response. 040 */ 041public abstract class MoveCopyItemRequest<TResponse extends ServiceResponse> 042 extends MoveCopyRequest<Item, TResponse> { 043 private ItemIdWrapperList itemIds = new ItemIdWrapperList(); 044 private Boolean newItemIds; 045 046 /** 047 * Validates request. 048 * 049 * @throws Exception the exception 050 */ 051 @Override 052 public void validate() throws Exception { 053 super.validate(); 054 EwsUtilities.validateParam(this.getItemIds(), "ItemIds"); 055 } 056 057 /** 058 * Initializes a new instance of the class. 059 * 060 * @param service the service 061 * @param errorHandlingMode the error handling mode 062 * @throws Exception on error 063 */ 064 protected MoveCopyItemRequest(ExchangeService service, 065 ServiceErrorHandling errorHandlingMode) 066 throws Exception { 067 super(service, errorHandlingMode); 068 } 069 070 /** 071 * Writes the ids as XML. 072 * 073 * @param writer the writer 074 * @throws Exception the exception 075 */ 076 @Override 077 protected void writeIdsToXml(EwsServiceXmlWriter writer) throws Exception { 078 this.getItemIds().writeToXml(writer, XmlNamespace.Messages, 079 XmlElementNames.ItemIds); 080 if (this.getReturnNewItemIds() != null) { 081 writer.writeElementValue( 082 XmlNamespace.Messages, 083 XmlElementNames.ReturnNewItemIds, 084 this.getReturnNewItemIds()); 085 } 086 } 087 088 /** 089 * Gets the expected response message count. 090 * 091 * @return Number of expected response messages. 092 */ 093 @Override 094 protected int getExpectedResponseMessageCount() { 095 return this.getItemIds().getCount(); 096 } 097 098 /** 099 * Gets the item ids. 100 * 101 * @return the item ids 102 */ 103 public ItemIdWrapperList getItemIds() { 104 return this.itemIds; 105 } 106 107 protected Boolean getReturnNewItemIds() { 108 return this.newItemIds; 109 } 110 111 public void setReturnNewItemIds(Boolean value) { 112 this.newItemIds = value; 113 } 114}