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