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.FolderId;
031    import microsoft.exchange.webservices.data.property.complex.ICreateComplexPropertyDelegate;
032    import microsoft.exchange.webservices.data.property.complex.ManagedFolderInformation;
033    import microsoft.exchange.webservices.data.property.definition.ComplexPropertyDefinition;
034    import microsoft.exchange.webservices.data.property.definition.EffectiveRightsPropertyDefinition;
035    import microsoft.exchange.webservices.data.property.definition.IntPropertyDefinition;
036    import microsoft.exchange.webservices.data.property.definition.PermissionSetPropertyDefinition;
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 folder.
044     */
045    @Schema
046    public class FolderSchema extends ServiceObjectSchema {
047    
048      /**
049       * Field URIs for folder.
050       */
051      private static class FieldUris {
052    
053        /**
054         * The Constant FolderId.
055         */
056        public final static String FolderId = "folder:FolderId";
057    
058        /**
059         * The Constant ParentFolderId.
060         */
061        public final static String ParentFolderId = "folder:ParentFolderId";
062    
063        /**
064         * The Constant DisplayName.
065         */
066        public final static String DisplayName = "folder:DisplayName";
067    
068        /**
069         * The Constant UnreadCount.
070         */
071        public final static String UnreadCount = "folder:UnreadCount";
072    
073        /**
074         * The Constant TotalCount.
075         */
076        public final static String TotalCount = "folder:TotalCount";
077    
078        /**
079         * The Constant ChildFolderCount.
080         */
081        public final static String ChildFolderCount = "folder:ChildFolderCount";
082    
083        /**
084         * The Constant FolderClass.
085         */
086        public final static String FolderClass = "folder:FolderClass";
087    
088        /**
089         * The Constant ManagedFolderInformation.
090         */
091        public final static String ManagedFolderInformation =
092            "folder:ManagedFolderInformation";
093    
094        /**
095         * The Constant EffectiveRights.
096         */
097        public final static String EffectiveRights = "folder:EffectiveRights";
098    
099        /**
100         * The Constant PermissionSet.
101         */
102        public final static String PermissionSet = "folder:PermissionSet";
103      }
104    
105    
106      /**
107       * Defines the Id property.
108       */
109      public static final PropertyDefinition Id =
110          new ComplexPropertyDefinition<FolderId>(
111              FolderId.class,
112              XmlElementNames.FolderId, FieldUris.FolderId, EnumSet
113              .of(PropertyDefinitionFlags.CanFind),
114              ExchangeVersion.Exchange2007_SP1,
115              new ICreateComplexPropertyDelegate<FolderId>() {
116                public FolderId createComplexProperty() {
117                  return new FolderId();
118                }
119              }
120    
121          );
122    
123      /**
124       * Defines the FolderClass property.
125       */
126      public static final PropertyDefinition FolderClass =
127          new StringPropertyDefinition(
128              XmlElementNames.FolderClass, FieldUris.FolderClass, EnumSet.of(
129              PropertyDefinitionFlags.CanSet,
130              PropertyDefinitionFlags.CanUpdate,
131              PropertyDefinitionFlags.CanFind),
132              ExchangeVersion.Exchange2007_SP1);
133    
134      /**
135       * Defines the ParentFolderId property.
136       */
137      public static final PropertyDefinition ParentFolderId =
138          new ComplexPropertyDefinition<FolderId>(
139              FolderId.class,
140              XmlElementNames.ParentFolderId, FieldUris.ParentFolderId, EnumSet
141              .of(PropertyDefinitionFlags.CanFind),
142              ExchangeVersion.Exchange2007_SP1,
143              new ICreateComplexPropertyDelegate<FolderId>() {
144                public FolderId createComplexProperty() {
145                  return new FolderId();
146                }
147              });
148    
149      /**
150       * Defines the ChildFolderCount property.
151       */
152      public static final PropertyDefinition ChildFolderCount =
153          new IntPropertyDefinition(
154              XmlElementNames.ChildFolderCount, FieldUris.ChildFolderCount,
155              EnumSet.of(PropertyDefinitionFlags.CanFind),
156              ExchangeVersion.Exchange2007_SP1);
157    
158      /**
159       * Defines the DisplayName property.
160       */
161      public static final PropertyDefinition DisplayName =
162          new StringPropertyDefinition(
163              XmlElementNames.DisplayName, FieldUris.DisplayName, EnumSet.of(
164              PropertyDefinitionFlags.CanSet,
165              PropertyDefinitionFlags.CanUpdate,
166              PropertyDefinitionFlags.CanDelete,
167              PropertyDefinitionFlags.CanFind),
168              ExchangeVersion.Exchange2007_SP1);
169    
170      /**
171       * Defines the UnreadCount property.
172       */
173      public static final PropertyDefinition UnreadCount =
174          new IntPropertyDefinition(
175              XmlElementNames.UnreadCount, FieldUris.UnreadCount, EnumSet
176              .of(PropertyDefinitionFlags.CanFind),
177              ExchangeVersion.Exchange2007_SP1);
178    
179      /**
180       * Defines the TotalCount property.
181       */
182      public static final PropertyDefinition TotalCount =
183          new IntPropertyDefinition(
184              XmlElementNames.TotalCount, FieldUris.TotalCount, EnumSet
185              .of(PropertyDefinitionFlags.CanFind),
186              ExchangeVersion.Exchange2007_SP1);
187    
188      /**
189       * Defines the ManagedFolderInformation property.
190       */
191      public static final PropertyDefinition ManagedFolderInformation =
192          new ComplexPropertyDefinition<microsoft.exchange.webservices.data.property.complex.ManagedFolderInformation>(
193              ManagedFolderInformation.class,
194              XmlElementNames.ManagedFolderInformation,
195              FieldUris.ManagedFolderInformation,
196              EnumSet.of(PropertyDefinitionFlags.CanFind),
197              ExchangeVersion.Exchange2007_SP1,
198              new ICreateComplexPropertyDelegate
199                  <ManagedFolderInformation>() {
200                public ManagedFolderInformation createComplexProperty() {
201                  return new ManagedFolderInformation();
202                }
203              });
204    
205      /**
206       * Defines the EffectiveRights property.
207       */
208      public static final PropertyDefinition EffectiveRights =
209          new EffectiveRightsPropertyDefinition(
210              XmlElementNames.EffectiveRights, FieldUris.EffectiveRights, EnumSet
211              .of(PropertyDefinitionFlags.CanFind),
212              ExchangeVersion.Exchange2007_SP1);
213    
214      /**
215       * Defines the Permissions property.
216       */
217      public static final PropertyDefinition Permissions =
218          new PermissionSetPropertyDefinition(
219              XmlElementNames.PermissionSet, FieldUris.PermissionSet, EnumSet.of(
220              PropertyDefinitionFlags.AutoInstantiateOnRead,
221              PropertyDefinitionFlags.CanSet,
222              PropertyDefinitionFlags.CanUpdate,
223              PropertyDefinitionFlags.CanDelete),
224              ExchangeVersion.Exchange2007_SP1);
225    
226      /**
227       * This must be declared after the property definitions.
228       */
229      public static final FolderSchema Instance = new FolderSchema();
230    
231      /**
232       * Registers property. IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN
233       * SCHEMA ORDER (i.e. the same order as they are defined in types.xsd)
234       */
235      @Override
236      protected void registerProperties() {
237        super.registerProperties();
238    
239        this.registerProperty(Id);
240        this.registerProperty(ParentFolderId);
241        this.registerProperty(FolderClass);
242        this.registerProperty(DisplayName);
243        this.registerProperty(TotalCount);
244        this.registerProperty(ChildFolderCount);
245        this.registerProperty(ServiceObjectSchema.extendedProperties);
246        this.registerProperty(ManagedFolderInformation);
247        this.registerProperty(EffectiveRights);
248        this.registerProperty(Permissions);
249        this.registerProperty(UnreadCount);
250      }
251    }