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.service.response; 025 026import microsoft.exchange.webservices.data.attribute.EditorBrowsable; 027import microsoft.exchange.webservices.data.core.EwsUtilities; 028import microsoft.exchange.webservices.data.core.service.item.EmailMessage; 029import microsoft.exchange.webservices.data.core.service.item.Item; 030import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; 031import microsoft.exchange.webservices.data.core.enumeration.service.MessageDisposition; 032import microsoft.exchange.webservices.data.core.enumeration.property.WellKnownFolderName; 033import microsoft.exchange.webservices.data.misc.CalendarActionResults; 034import microsoft.exchange.webservices.data.property.complex.FolderId; 035 036/** 037 * Represents the base class for all calendar-related response messages. 038 * 039 * @param <TMessage> The type of message that is created when this response message is 040 * saved. 041 */ 042@EditorBrowsable(state = EditorBrowsableState.Never) 043public abstract class CalendarResponseMessageBase<TMessage extends EmailMessage> 044 extends ResponseObject<TMessage> { 045 046 /** 047 * Initializes a new instance of the CalendarResponseMessageBase class. 048 * 049 * @param referenceItem the reference item 050 * @throws Exception the exception 051 */ 052 CalendarResponseMessageBase(Item referenceItem) throws Exception { 053 super(referenceItem); 054 } 055 056 /** 057 * Saves the response in the specified folder. Calling this method results 058 * in a call to EWS. 059 * 060 * @param destinationFolderId The Id of the folder in which to save the response. 061 * @return A CalendarActionResults object containing the various item that 062 * were created or modified as a results of this operation. 063 * @throws Exception the exception 064 */ 065 066 public CalendarActionResults calendarSave(FolderId destinationFolderId) 067 throws Exception { 068 EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); 069 070 return new CalendarActionResults(this.internalCreate( 071 destinationFolderId, MessageDisposition.SaveOnly)); 072 } 073 074 /** 075 * Saves the response in the specified folder. Calling this method results 076 * in a call to EWS. 077 * 078 * @param destinationFolderName The name of the folder in which to save the response. 079 * @return A CalendarActionResults object containing the various item that 080 * were created or modified as a results of this operation. 081 * @throws Exception the exception 082 */ 083 public CalendarActionResults calendarSave( 084 WellKnownFolderName destinationFolderName) throws Exception { 085 return new CalendarActionResults(this.internalCreate(new FolderId( 086 destinationFolderName), MessageDisposition.SaveOnly)); 087 } 088 089 /** 090 * Saves the response in the Drafts folder. Calling this method results in a 091 * call to EWS. 092 * 093 * @return A CalendarActionResults object containing the various item that 094 * were created or modified as a results of this operation. 095 * @throws Exception the exception 096 */ 097 public CalendarActionResults calendarSave() throws Exception { 098 return new CalendarActionResults(this.internalCreate(null, 099 MessageDisposition.SaveOnly)); 100 } 101 102 /** 103 * Sends this response without saving a copy. Calling this method results in 104 * a call to EWS. 105 * 106 * @return A CalendarActionResults object containing the various item that 107 * were created or modified as a results of this operation. 108 * @throws Exception the exception 109 */ 110 public CalendarActionResults calendarSend() throws Exception { 111 return new CalendarActionResults(this.internalCreate(null, 112 MessageDisposition.SendOnly)); 113 } 114 115 /** 116 * Sends this response ans saves a copy in the specified folder. Calling 117 * this method results in a call to EWS. 118 * 119 * @param destinationFolderId The Id of the folder in which to save the copy of the message. 120 * @return A CalendarActionResults object containing the various item that 121 * were created or modified as a results of this operation. 122 * @throws Exception the exception 123 */ 124 125 public CalendarActionResults calendarSendAndSaveCopy( 126 FolderId destinationFolderId) throws Exception { 127 EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); 128 return new CalendarActionResults(this.internalCreate( 129 destinationFolderId, MessageDisposition.SendAndSaveCopy)); 130 } 131 132 /** 133 * Sends this response ans saves a copy in the specified folder. Calling 134 * this method results in a call to EWS. 135 * 136 * @param destinationFolderName the destination folder name 137 * @return A CalendarActionResults object containing the various item that 138 * were created or modified as a results of this operation. 139 * @throws Exception the exception 140 */ 141 public CalendarActionResults calendarSendAndSaveCopy( 142 WellKnownFolderName destinationFolderName) throws Exception { 143 return new CalendarActionResults(this.internalCreate(new FolderId( 144 destinationFolderName), MessageDisposition.SendAndSaveCopy)); 145 } 146 147 /** 148 * Sends this response ans saves a copy in the specified folder. Calling 149 * this method results in a call to EWS. 150 * 151 * @return A CalendarActionResults object containing the various item that 152 * were created or modified as a results of this operation. 153 * @throws Exception the exception 154 */ 155 public CalendarActionResults calendarSendAndSaveCopy() throws Exception { 156 return new CalendarActionResults(this.internalCreate(null, 157 MessageDisposition.SendAndSaveCopy)); 158 } 159 160}