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.item;
025    
026    import microsoft.exchange.webservices.data.attribute.EditorBrowsable;
027    import microsoft.exchange.webservices.data.attribute.ServiceObjectDefinition;
028    import microsoft.exchange.webservices.data.core.ExchangeService;
029    import microsoft.exchange.webservices.data.core.PropertySet;
030    import microsoft.exchange.webservices.data.core.XmlElementNames;
031    import microsoft.exchange.webservices.data.core.service.schema.MeetingMessageSchema;
032    import microsoft.exchange.webservices.data.core.service.schema.ServiceObjectSchema;
033    import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState;
034    import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion;
035    import microsoft.exchange.webservices.data.core.enumeration.property.MeetingResponseType;
036    import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException;
037    import microsoft.exchange.webservices.data.property.complex.ItemAttachment;
038    import microsoft.exchange.webservices.data.property.complex.ItemId;
039    
040    import java.util.Date;
041    
042    /**
043     * Represents a meeting-related message. Properties available on meeting
044     * messages are defined in the MeetingMessageSchema class.
045     */
046    
047    @ServiceObjectDefinition(xmlElementName = XmlElementNames.MeetingMessage)
048    @EditorBrowsable(state = EditorBrowsableState.Never)
049    public class MeetingMessage extends EmailMessage {
050    
051      /**
052       * Initializes a new instance of the "MeetingMessage" class.
053       *
054       * @param parentAttachment the parent attachment
055       * @throws Exception the exception
056       */
057      public MeetingMessage(ItemAttachment parentAttachment) throws Exception {
058        super(parentAttachment);
059      }
060    
061      /**
062       * Initializes a new instance of the "MeetingMessage" class.
063       *
064       * @param service EWS service to which this object belongs.
065       * @throws Exception the exception
066       */
067      public MeetingMessage(ExchangeService service) throws Exception {
068        super(service);
069      }
070    
071      /**
072       * Binds to an existing meeting message and loads the specified set of
073       * property. Calling this method results in a call to EWS.
074       *
075       * @param service     The service to use to bind to the meeting message.
076       * @param id          The Id of the meeting message to bind to.
077       * @param propertySet The set of property to load.
078       * @return A MeetingMessage instance representing the meeting message
079       * corresponding to the specified Id.
080       * @throws Exception the exception
081       */
082      public static MeetingMessage bind(ExchangeService service, ItemId id,
083          PropertySet propertySet) throws Exception {
084        return (MeetingMessage) service.bindToItem(id, propertySet);
085      }
086    
087      /**
088       * Binds to an existing meeting message and loads its first class
089       * property. Calling this method results in a call to EWS.
090       *
091       * @param service The service to use to bind to the meeting message.
092       * @param id      The Id of the meeting message to bind to.
093       * @return A MeetingMessage instance representing the meeting message
094       * corresponding to the specified Id.
095       * @throws Exception the exception
096       */
097      public static MeetingMessage bind(ExchangeService service, ItemId id)
098          throws Exception {
099        return MeetingMessage.bind(service, id, PropertySet
100            .getFirstClassProperties());
101      }
102    
103      /**
104       * Internal method to return the schema associated with this type of object.
105       *
106       * @return The schema associated with this type of object.
107       */
108      @Override public ServiceObjectSchema getSchema() {
109        return MeetingMessageSchema.getInstance();
110      }
111    
112      /**
113       * Gets the minimum required server version.
114       *
115       * @return Earliest Exchange version in which this service object type is
116       * supported.
117       */
118      @Override public ExchangeVersion getMinimumRequiredServerVersion() {
119        return ExchangeVersion.Exchange2007_SP1;
120      }
121    
122      /**
123       * Gets the associated appointment ID.
124       *
125       * @return the associated appointment ID.
126       * @throws ServiceLocalException the service local exception
127       */
128      public ItemId getAssociatedAppointmentId()
129          throws ServiceLocalException {
130        return getPropertyBag().getObjectFromPropertyDefinition(
131            MeetingMessageSchema.AssociatedAppointmentId);
132      }
133    
134      /**
135       * Gets whether the meeting message has been processed.
136       *
137       * @return whether the meeting message has been processed.
138       * @throws ServiceLocalException the service local exception
139       */
140      public Boolean getHasBeenProcessed()
141          throws ServiceLocalException {
142        return getPropertyBag().getObjectFromPropertyDefinition(
143            MeetingMessageSchema.HasBeenProcessed);
144      }
145    
146      /**
147       * Gets the response type indicated by this meeting message.
148       *
149       * @return the response type indicated by this meeting message.
150       * @throws ServiceLocalException the service local exception
151       */
152      public MeetingResponseType getResponseType()
153          throws ServiceLocalException {
154        return getPropertyBag().getObjectFromPropertyDefinition(
155            MeetingMessageSchema.ResponseType);
156      }
157    
158      /**
159       * Gets the ICalendar Uid.
160       *
161       * @return the ical uid
162       * @throws ServiceLocalException the service local exception
163       */
164      public String getICalUid() throws ServiceLocalException {
165        return getPropertyBag().getObjectFromPropertyDefinition(
166            MeetingMessageSchema.ICalUid);
167      }
168    
169      /**
170       * Gets the ICalendar RecurrenceId.
171       *
172       * @return the ical recurrence id
173       * @throws ServiceLocalException the service local exception
174       */
175      public Date getICalRecurrenceId() throws ServiceLocalException {
176        return getPropertyBag().getObjectFromPropertyDefinition(
177            MeetingMessageSchema.ICalRecurrenceId);
178      }
179    
180      /**
181       * Gets the ICalendar DateTimeStamp.
182       *
183       * @return the ical date time stamp
184       * @throws ServiceLocalException the service local exception
185       */
186      public Date getICalDateTimeStamp() throws ServiceLocalException {
187        return getPropertyBag().getObjectFromPropertyDefinition(
188            MeetingMessageSchema.ICalDateTimeStamp);
189      }
190    
191      /**
192       * Gets the IsDelegated property.
193       *
194       * @return True if delegated; false otherwise.
195       * @throws ServiceLocalException the service local exception
196       */
197      public Boolean getIsDelegated() throws ServiceLocalException {
198        return getPropertyBag().getObjectFromPropertyDefinition(
199            MeetingMessageSchema.IsDelegated);
200      }
201    
202      /**
203       * Gets the IsOutOfDate property.
204       *
205       * @return True if out of date; false otherwise.
206       * @throws ServiceLocalException the service local exception
207       */
208      public Boolean getIsOutOfDate() throws ServiceLocalException {
209        return getPropertyBag().getObjectFromPropertyDefinition(
210            MeetingMessageSchema.IsOutOfDate);
211      }
212    
213    }