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.schema;
025    
026    import microsoft.exchange.webservices.data.attribute.Schema;
027    import microsoft.exchange.webservices.data.core.XmlElementNames;
028    import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion;
029    import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags;
030    import microsoft.exchange.webservices.data.property.complex.EmailAddress;
031    import microsoft.exchange.webservices.data.property.complex.EmailAddressCollection;
032    import microsoft.exchange.webservices.data.property.complex.ICreateComplexPropertyDelegate;
033    import microsoft.exchange.webservices.data.property.definition.BoolPropertyDefinition;
034    import microsoft.exchange.webservices.data.property.definition.ByteArrayPropertyDefinition;
035    import microsoft.exchange.webservices.data.property.definition.ComplexPropertyDefinition;
036    import microsoft.exchange.webservices.data.property.definition.ContainedPropertyDefinition;
037    import microsoft.exchange.webservices.data.property.definition.PropertyDefinition;
038    import microsoft.exchange.webservices.data.property.definition.StringPropertyDefinition;
039    
040    import java.util.EnumSet;
041    
042    /**
043     * Represents the schema for e-mail messages.
044     */
045    @Schema
046    public class EmailMessageSchema extends ItemSchema {
047    
048      /**
049       * The Interface FieldUris.
050       */
051      private static interface FieldUris {
052    
053        /**
054         * The Conversation index.
055         */
056        String ConversationIndex = "message:ConversationIndex";
057    
058        /**
059         * The Conversation topic.
060         */
061        String ConversationTopic = "message:ConversationTopic";
062    
063        /**
064         * The Internet message id.
065         */
066        String InternetMessageId = "message:InternetMessageId";
067    
068        /**
069         * The Is read.
070         */
071        String IsRead = "message:IsRead";
072    
073        /**
074         * The Is response requested.
075         */
076        String IsResponseRequested = "message:IsResponseRequested";
077    
078        /**
079         * The Is read receipt requested.
080         */
081        String IsReadReceiptRequested = "message:IsReadReceiptRequested";
082    
083        /**
084         * The Is delivery receipt requested.
085         */
086        String IsDeliveryReceiptRequested =
087            "message:IsDeliveryReceiptRequested";
088    
089        /**
090         * The References.
091         */
092        String References = "message:References";
093    
094        /**
095         * The Reply to.
096         */
097        String ReplyTo = "message:ReplyTo";
098    
099        /**
100         * The From.
101         */
102        String From = "message:From";
103    
104        /**
105         * The Sender.
106         */
107        String Sender = "message:Sender";
108    
109        /**
110         * The To recipients.
111         */
112        String ToRecipients = "message:ToRecipients";
113    
114        /**
115         * The Cc recipients.
116         */
117        String CcRecipients = "message:CcRecipients";
118    
119        /**
120         * The Bcc recipients.
121         */
122        String BccRecipients = "message:BccRecipients";
123    
124        /**
125         * The Received by.
126         */
127        String ReceivedBy = "message:ReceivedBy";
128    
129        /**
130         * The Received representing.
131         */
132        String ReceivedRepresenting = "message:ReceivedRepresenting";
133      }
134    
135    
136      /**
137       * Defines the ToRecipients property.
138       */
139      public static final PropertyDefinition ToRecipients =
140          new ComplexPropertyDefinition<EmailAddressCollection>(
141              EmailAddressCollection.class,
142              XmlElementNames.ToRecipients,
143              FieldUris.ToRecipients,
144              EnumSet.of(PropertyDefinitionFlags.AutoInstantiateOnRead,
145                  PropertyDefinitionFlags.CanSet,
146                  PropertyDefinitionFlags.CanUpdate,
147                  PropertyDefinitionFlags.CanDelete),
148              ExchangeVersion.Exchange2007_SP1,
149              new ICreateComplexPropertyDelegate<EmailAddressCollection>() {
150                @Override
151                public EmailAddressCollection createComplexProperty() {
152                  return new EmailAddressCollection();
153                }
154              });
155    
156      /**
157       * Defines the BccRecipients property.
158       */
159      public static final PropertyDefinition BccRecipients =
160          new ComplexPropertyDefinition<EmailAddressCollection>(
161              EmailAddressCollection.class,
162              XmlElementNames.BccRecipients,
163              FieldUris.BccRecipients,
164              EnumSet.of(PropertyDefinitionFlags.AutoInstantiateOnRead,
165                  PropertyDefinitionFlags.CanSet,
166                  PropertyDefinitionFlags.CanUpdate,
167                  PropertyDefinitionFlags.CanDelete),
168              ExchangeVersion.Exchange2007_SP1,
169              new ICreateComplexPropertyDelegate
170                  <EmailAddressCollection>() {
171                @Override
172                public EmailAddressCollection createComplexProperty() {
173                  return new EmailAddressCollection();
174                }
175              });
176    
177      /**
178       * Defines the CcRecipients property.
179       */
180      public static final PropertyDefinition CcRecipients =
181          new ComplexPropertyDefinition<EmailAddressCollection>(
182              EmailAddressCollection.class,
183              XmlElementNames.CcRecipients,
184              FieldUris.CcRecipients,
185              EnumSet.of(PropertyDefinitionFlags.AutoInstantiateOnRead,
186                  PropertyDefinitionFlags.CanSet,
187                  PropertyDefinitionFlags.CanUpdate,
188                  PropertyDefinitionFlags.CanDelete),
189              ExchangeVersion.Exchange2007_SP1,
190              new ICreateComplexPropertyDelegate
191                  <EmailAddressCollection>() {
192                @Override
193                public EmailAddressCollection createComplexProperty() {
194                  return new EmailAddressCollection();
195                }
196              });
197    
198      /**
199       * Defines the ConversationIndex property.
200       */
201      public static final PropertyDefinition ConversationIndex =
202          new ByteArrayPropertyDefinition(
203              XmlElementNames.ConversationIndex, FieldUris.ConversationIndex,
204              EnumSet.of(PropertyDefinitionFlags.CanFind),
205              ExchangeVersion.Exchange2007_SP1);
206    
207      /**
208       * Defines the ConversationTopic property.
209       */
210      public static final PropertyDefinition ConversationTopic =
211          new StringPropertyDefinition(
212              XmlElementNames.ConversationTopic, FieldUris.ConversationTopic,
213              EnumSet.of(PropertyDefinitionFlags.CanFind),
214              ExchangeVersion.Exchange2007_SP1);
215    
216      /**
217       * Defines the From property.
218       */
219      public static final PropertyDefinition From =
220          new ContainedPropertyDefinition<EmailAddress>(
221              EmailAddress.class,
222              XmlElementNames.From, FieldUris.From, XmlElementNames.Mailbox,
223              EnumSet.of(PropertyDefinitionFlags.CanSet,
224                  PropertyDefinitionFlags.CanUpdate,
225                  PropertyDefinitionFlags.CanDelete,
226                  PropertyDefinitionFlags.CanFind),
227              ExchangeVersion.Exchange2007_SP1,
228              new ICreateComplexPropertyDelegate<EmailAddress>() {
229                @Override
230                public EmailAddress createComplexProperty() {
231                  return new EmailAddress();
232                }
233              });
234    
235      /**
236       * Defines the IsDeliveryReceiptRequested property.
237       */
238      public static final PropertyDefinition IsDeliveryReceiptRequested =
239          new BoolPropertyDefinition(
240              XmlElementNames.IsDeliveryReceiptRequested,
241              FieldUris.IsDeliveryReceiptRequested, EnumSet.of(
242              PropertyDefinitionFlags.CanSet,
243              PropertyDefinitionFlags.CanUpdate,
244              PropertyDefinitionFlags.CanDelete,
245              PropertyDefinitionFlags.CanFind),
246              ExchangeVersion.Exchange2007_SP1);
247    
248      /**
249       * Defines the IsRead property.
250       */
251      public static final PropertyDefinition IsRead = new BoolPropertyDefinition(
252          XmlElementNames.IsRead, FieldUris.IsRead, EnumSet.of(
253          PropertyDefinitionFlags.CanSet,
254          PropertyDefinitionFlags.CanUpdate,
255          PropertyDefinitionFlags.CanFind),
256          ExchangeVersion.Exchange2007_SP1);
257    
258      /**
259       * Defines the IsReadReceiptRequested property.
260       */
261      public static final PropertyDefinition IsReadReceiptRequested =
262          new BoolPropertyDefinition(
263              XmlElementNames.IsReadReceiptRequested,
264              FieldUris.IsReadReceiptRequested, EnumSet.of(
265              PropertyDefinitionFlags.CanSet,
266              PropertyDefinitionFlags.CanUpdate,
267              PropertyDefinitionFlags.CanDelete,
268              PropertyDefinitionFlags.CanFind),
269              ExchangeVersion.Exchange2007_SP1);
270    
271      /**
272       * Defines the IsResponseRequested property.
273       */
274      public static final PropertyDefinition IsResponseRequested =
275          new BoolPropertyDefinition(
276              XmlElementNames.IsResponseRequested, FieldUris.IsResponseRequested,
277              EnumSet.of(PropertyDefinitionFlags.CanSet,
278                  PropertyDefinitionFlags.CanUpdate,
279                  PropertyDefinitionFlags.CanDelete,
280                  PropertyDefinitionFlags.CanFind),
281              ExchangeVersion.Exchange2007_SP1, true); // isNullable
282    
283      /**
284       * Defines the InternetMessageId property.
285       */
286      public static final PropertyDefinition InternetMessageId =
287          new StringPropertyDefinition(
288              XmlElementNames.InternetMessageId, FieldUris.InternetMessageId,
289              EnumSet.of(PropertyDefinitionFlags.CanFind),
290              ExchangeVersion.Exchange2007_SP1);
291    
292      /**
293       * Defines the References property.
294       */
295      public static final PropertyDefinition References =
296          new StringPropertyDefinition(
297              XmlElementNames.References, FieldUris.References, EnumSet.of(
298              PropertyDefinitionFlags.CanSet,
299              PropertyDefinitionFlags.CanUpdate,
300              PropertyDefinitionFlags.CanDelete,
301              PropertyDefinitionFlags.CanFind),
302              ExchangeVersion.Exchange2007_SP1);
303    
304      /**
305       * Defines the ReplyTo property.
306       */
307      public static final PropertyDefinition ReplyTo =
308          new ComplexPropertyDefinition<EmailAddressCollection>(
309              EmailAddressCollection.class,
310              XmlElementNames.ReplyTo,
311              FieldUris.ReplyTo,
312              EnumSet.of(PropertyDefinitionFlags.AutoInstantiateOnRead,
313                  PropertyDefinitionFlags.CanSet,
314                  PropertyDefinitionFlags.CanUpdate,
315                  PropertyDefinitionFlags.CanDelete),
316              ExchangeVersion.Exchange2007_SP1,
317              new ICreateComplexPropertyDelegate
318                  <EmailAddressCollection>() {
319                @Override
320                public EmailAddressCollection createComplexProperty() {
321                  return new EmailAddressCollection();
322                }
323              });
324    
325      /**
326       * Defines the Sender property.
327       */
328      public static final PropertyDefinition Sender =
329          new ContainedPropertyDefinition<EmailAddress>(
330              EmailAddress.class,
331              XmlElementNames.Sender, FieldUris.Sender, XmlElementNames.Mailbox,
332              EnumSet.of(PropertyDefinitionFlags.CanSet,
333                  PropertyDefinitionFlags.CanFind),
334              ExchangeVersion.Exchange2007_SP1,
335              new ICreateComplexPropertyDelegate<EmailAddress>() {
336                @Override
337                public EmailAddress createComplexProperty() {
338                  return new EmailAddress();
339                }
340              });
341    
342      /**
343       * Defines the ReceivedBy property.
344       */
345      public static final PropertyDefinition ReceivedBy =
346          new ContainedPropertyDefinition<EmailAddress>(
347              EmailAddress.class,
348              XmlElementNames.ReceivedBy, FieldUris.ReceivedBy,
349              XmlElementNames.Mailbox, EnumSet
350              .of(PropertyDefinitionFlags.CanFind),
351              ExchangeVersion.Exchange2007_SP1,
352              new ICreateComplexPropertyDelegate<EmailAddress>() {
353                @Override
354                public EmailAddress createComplexProperty() {
355                  return new EmailAddress();
356                }
357              });
358    
359      /**
360       * Defines the ReceivedRepresenting property.
361       */
362      public static final PropertyDefinition ReceivedRepresenting =
363          new ContainedPropertyDefinition<EmailAddress>(
364              EmailAddress.class,
365              XmlElementNames.ReceivedRepresenting,
366              FieldUris.ReceivedRepresenting, XmlElementNames.Mailbox, EnumSet
367              .of(PropertyDefinitionFlags.CanFind),
368              ExchangeVersion.Exchange2007_SP1,
369              new ICreateComplexPropertyDelegate<EmailAddress>() {
370                @Override
371                public EmailAddress createComplexProperty() {
372                  return new EmailAddress();
373                }
374              });
375    
376      /**
377       * The Constant Instance.
378       */
379      public static final EmailMessageSchema Instance =
380          new EmailMessageSchema();
381    
382      /**
383       * Gets the single instance of EmailMessageSchema.
384       *
385       * @return single instance of EmailMessageSchema
386       */
387      public static EmailMessageSchema getInstance() {
388        return Instance;
389      }
390    
391      /**
392       * Registers property. IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN
393       * SCHEMA ORDER (i.e. the same order as they are defined in types.xsd)
394       */
395      @Override
396      protected void registerProperties() {
397        super.registerProperties();
398        this.registerProperty(Sender);
399        this.registerProperty(ToRecipients);
400        this.registerProperty(CcRecipients);
401        this.registerProperty(BccRecipients);
402        this.registerProperty(IsReadReceiptRequested);
403        this.registerProperty(IsDeliveryReceiptRequested);
404        this.registerProperty(ConversationIndex);
405        this.registerProperty(ConversationTopic);
406        this.registerProperty(From);
407        this.registerProperty(InternetMessageId);
408        this.registerProperty(IsRead);
409        this.registerProperty(IsResponseRequested);
410        this.registerProperty(References);
411        this.registerProperty(ReplyTo);
412        this.registerProperty(ReceivedBy);
413        this.registerProperty(ReceivedRepresenting);
414      }
415    
416      /**
417       * Initializes a new instance.
418       */
419      protected EmailMessageSchema() {
420        super();
421      }
422    }