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.ServiceObjectDefinition;
027import microsoft.exchange.webservices.data.core.PropertySet;
028import microsoft.exchange.webservices.data.core.XmlElementNames;
029import microsoft.exchange.webservices.data.core.service.ServiceObject;
030import microsoft.exchange.webservices.data.core.service.item.Item;
031import microsoft.exchange.webservices.data.core.service.schema.ResponseObjectSchema;
032import microsoft.exchange.webservices.data.core.service.schema.ServiceObjectSchema;
033import microsoft.exchange.webservices.data.core.enumeration.service.calendar.AffectedTaskOccurrence;
034import microsoft.exchange.webservices.data.core.enumeration.service.DeleteMode;
035import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion;
036import microsoft.exchange.webservices.data.core.enumeration.service.MessageDisposition;
037import microsoft.exchange.webservices.data.core.enumeration.service.SendCancellationsMode;
038import microsoft.exchange.webservices.data.property.complex.FolderId;
039import microsoft.exchange.webservices.data.property.complex.ItemId;
040
041/**
042 * Represents a response object created to supress read receipts for an item.
043 */
044@ServiceObjectDefinition(xmlElementName = XmlElementNames.SuppressReadReceipt, returnedByServer = false)
045public final class SuppressReadReceipt extends ServiceObject {
046
047  /**
048   * The reference item.
049   */
050  private Item referenceItem;
051
052  /**
053   * Initializes a new instance of the class.
054   *
055   * @param referenceItem the reference item
056   * @throws Exception the exception
057   */
058  public SuppressReadReceipt(Item referenceItem) throws Exception {
059    super(referenceItem.getService());
060
061    referenceItem.throwIfThisIsNew();
062    this.referenceItem = referenceItem;
063  }
064
065  /**
066   * Internal method to return the schema associated with this type of object.
067   *
068   * @return The schema associated with this type of object.
069   */
070  @Override public ServiceObjectSchema getSchema() {
071    return ResponseObjectSchema.Instance;
072  }
073
074  /**
075   * Gets the minimum required server version.
076   *
077   * @return Earliest Exchange version in which this service object type is
078   * supported.
079   */
080  @Override public ExchangeVersion getMinimumRequiredServerVersion() {
081    return ExchangeVersion.Exchange2007_SP1;
082  }
083
084  /**
085   * Loads the specified set of property on the object.
086   *
087   * @param propertySet the property set
088   */
089  @Override
090  protected void internalLoad(PropertySet propertySet) {
091    throw new UnsupportedOperationException();
092  }
093
094  /**
095   * Deletes the object.
096   *
097   * @param deleteMode              the delete mode
098   * @param sendCancellationsMode   the send cancellations mode
099   * @param affectedTaskOccurrences the affected task occurrences
100   */
101  @Override
102  protected void internalDelete(DeleteMode deleteMode,
103      SendCancellationsMode sendCancellationsMode,
104      AffectedTaskOccurrence affectedTaskOccurrences) {
105    throw new UnsupportedOperationException();
106  }
107
108  /**
109   * Create the response object.
110   *
111   * @param parentFolderId     the parent folder id
112   * @param messageDisposition the message disposition
113   * @throws Exception the exception
114   */
115  public void internalCreate(FolderId parentFolderId, MessageDisposition messageDisposition) throws Exception {
116    ((ItemId) this.getPropertyBag().getObjectFromPropertyDefinition(
117        ResponseObjectSchema.ReferenceItemId))
118        .assign(this.referenceItem.getId());
119    this.getService().internalCreateResponseObject(this, parentFolderId,
120        messageDisposition);
121  }
122}