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.service.item.EmailMessage;
028import microsoft.exchange.webservices.data.core.service.item.Item;
029import microsoft.exchange.webservices.data.core.service.schema.CalendarResponseObjectSchema;
030import microsoft.exchange.webservices.data.core.service.schema.EmailMessageSchema;
031import microsoft.exchange.webservices.data.core.service.schema.ItemSchema;
032import microsoft.exchange.webservices.data.core.service.schema.ServiceObjectSchema;
033import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState;
034import microsoft.exchange.webservices.data.core.enumeration.property.Sensitivity;
035import microsoft.exchange.webservices.data.property.complex.AttachmentCollection;
036import microsoft.exchange.webservices.data.property.complex.EmailAddress;
037import microsoft.exchange.webservices.data.property.complex.EmailAddressCollection;
038import microsoft.exchange.webservices.data.property.complex.InternetMessageHeaderCollection;
039import microsoft.exchange.webservices.data.property.complex.MessageBody;
040
041/**
042 * Represents the base class for accept, tentatively accept and decline response
043 * messages.
044 *
045 * @param <TMessage> The type of message that is created when this response message is
046 *                   saved.
047 */
048@EditorBrowsable(state = EditorBrowsableState.Never)
049public abstract class CalendarResponseMessage<TMessage extends EmailMessage>
050    extends CalendarResponseMessageBase<TMessage> {
051
052  /**
053   * Initializes a new instance of the CalendarResponseMessage class.
054   *
055   * @param referenceItem The reference item
056   * @throws Exception the exception
057   */
058  protected CalendarResponseMessage(Item referenceItem) throws Exception {
059    super(referenceItem);
060  }
061
062  /**
063   * Internal method to return the schema associated with this type of object.
064   *
065   * @return The schema associated with this type of object.
066   */
067  @Override public ServiceObjectSchema getSchema() {
068    return CalendarResponseObjectSchema.Instance;
069  }
070
071  /**
072   * Gets the body of the response.
073   *
074   * @return the body
075   * @throws Exception the exception
076   */
077  public MessageBody getBody() throws Exception {
078    return (MessageBody) this
079        .getObjectFromPropertyDefinition(ItemSchema.Body);
080  }
081
082  /**
083   * Sets the body.
084   *
085   * @param value the new body
086   * @throws Exception the exception
087   */
088  public void setBody(MessageBody value) throws Exception {
089    this.getPropertyBag().setObjectFromPropertyDefinition(ItemSchema.Body,
090        value);
091  }
092
093  /**
094   * Gets a list of recipients the response will be sent to.
095   *
096   * @return the to recipients
097   * @throws Exception the exception
098   */
099  public EmailAddressCollection getToRecipients() throws Exception {
100    return (EmailAddressCollection) this
101        .getObjectFromPropertyDefinition(
102            EmailMessageSchema.ToRecipients);
103  }
104
105  /**
106   * Gets a list of recipients the response will be sent to as Cc.
107   *
108   * @return the cc recipients
109   * @throws Exception the exception
110   */
111  public EmailAddressCollection getCcRecipients() throws Exception {
112    return (EmailAddressCollection) this
113        .getObjectFromPropertyDefinition(
114            EmailMessageSchema.CcRecipients);
115  }
116
117  /**
118   * Gets a list of recipients this response will be sent to as Bcc.
119   *
120   * @return the bcc recipients
121   * @throws Exception the exception
122   */
123  public EmailAddressCollection getBccRecipients() throws Exception {
124    return (EmailAddressCollection) this
125        .getObjectFromPropertyDefinition(
126            EmailMessageSchema.BccRecipients);
127  }
128
129  /**
130   * Gets the item class.
131   *
132   * @return the item class
133   * @throws Exception the exception
134   */
135  protected String getItemClass() throws Exception {
136    return (String) this
137        .getObjectFromPropertyDefinition(ItemSchema.ItemClass);
138  }
139
140  /**
141   * Sets the item class.
142   *
143   * @param value the new item class
144   * @throws Exception the exception
145   */
146  protected void setItemClass(String value) throws Exception {
147    this.getPropertyBag().setObjectFromPropertyDefinition(
148        ItemSchema.ItemClass, value);
149  }
150
151  /**
152   * Gets the sensitivity of this response.
153   *
154   * @return the sensitivity
155   * @throws Exception the exception
156   */
157  public Sensitivity getSensitivity() throws Exception {
158    return (Sensitivity) this
159        .getObjectFromPropertyDefinition(ItemSchema.Sensitivity);
160  }
161
162  /**
163   * Sets the sensitivity.
164   *
165   * @param value the new sensitivity
166   * @throws Exception the exception
167   */
168  public void setSensitivity(Sensitivity value) throws Exception {
169    this.getPropertyBag().setObjectFromPropertyDefinition(
170        ItemSchema.Sensitivity, value);
171  }
172
173  /**
174   * Gets a list of attachments to this response.
175   *
176   * @return the attachments
177   * @throws Exception the exception
178   */
179  public AttachmentCollection getAttachments() throws Exception {
180    return (AttachmentCollection) this
181        .getObjectFromPropertyDefinition(ItemSchema.Attachments);
182  }
183
184  /**
185   * Gets the internet message headers.
186   *
187   * @return the internet message headers
188   * @throws Exception the exception
189   */
190  protected InternetMessageHeaderCollection getInternetMessageHeaders()
191      throws Exception {
192    return (InternetMessageHeaderCollection) this
193        .getObjectFromPropertyDefinition(
194            ItemSchema.InternetMessageHeaders);
195  }
196
197  /**
198   * Gets the sender of this response.
199   *
200   * @return the sender
201   * @throws Exception the exception
202   */
203  public EmailAddress getSender() throws Exception {
204    return (EmailAddress) this
205        .getObjectFromPropertyDefinition(EmailMessageSchema.Sender);
206  }
207
208  /**
209   * Sets the sender.
210   *
211   * @param value the new sender
212   * @throws Exception the exception
213   */
214  public void setSender(EmailAddress value) throws Exception {
215    this.getPropertyBag().setObjectFromPropertyDefinition(
216        EmailMessageSchema.Sender, value);
217  }
218}