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.schema; 025 026import microsoft.exchange.webservices.data.attribute.Schema; 027import microsoft.exchange.webservices.data.core.XmlElementNames; 028import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; 029import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; 030import microsoft.exchange.webservices.data.property.complex.FolderId; 031import microsoft.exchange.webservices.data.property.complex.ICreateComplexPropertyDelegate; 032import microsoft.exchange.webservices.data.property.complex.ManagedFolderInformation; 033import microsoft.exchange.webservices.data.property.definition.ComplexPropertyDefinition; 034import microsoft.exchange.webservices.data.property.definition.EffectiveRightsPropertyDefinition; 035import microsoft.exchange.webservices.data.property.definition.IntPropertyDefinition; 036import microsoft.exchange.webservices.data.property.definition.PermissionSetPropertyDefinition; 037import microsoft.exchange.webservices.data.property.definition.PropertyDefinition; 038import microsoft.exchange.webservices.data.property.definition.StringPropertyDefinition; 039 040import java.util.EnumSet; 041 042/** 043 * Represents the schema for folder. 044 */ 045@Schema 046public 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 * The Constant DistinguishedFolderId. 106 */ 107 public final static String DistinguishedFolderId = "folder:DistinguishedFolderId"; 108 } 109 110 111 /** 112 * Defines the Id property. 113 */ 114 public static final PropertyDefinition Id = 115 new ComplexPropertyDefinition<FolderId>( 116 FolderId.class, 117 XmlElementNames.FolderId, FieldUris.FolderId, EnumSet 118 .of(PropertyDefinitionFlags.CanFind), 119 ExchangeVersion.Exchange2007_SP1, 120 new ICreateComplexPropertyDelegate<FolderId>() { 121 public FolderId createComplexProperty() { 122 return new FolderId(); 123 } 124 } 125 126 ); 127 128 public static final PropertyDefinition WellKnownFolderName = new StringPropertyDefinition( 129 XmlElementNames.DistinguishedFolderId, FieldUris.DistinguishedFolderId, 130 EnumSet.of(PropertyDefinitionFlags.CanSet, PropertyDefinitionFlags.CanFind), ExchangeVersion.Exchange2013); 131 132 /** 133 * Defines the FolderClass property. 134 */ 135 public static final PropertyDefinition FolderClass = 136 new StringPropertyDefinition( 137 XmlElementNames.FolderClass, FieldUris.FolderClass, EnumSet.of( 138 PropertyDefinitionFlags.CanSet, 139 PropertyDefinitionFlags.CanUpdate, 140 PropertyDefinitionFlags.CanFind), 141 ExchangeVersion.Exchange2007_SP1); 142 143 /** 144 * Defines the ParentFolderId property. 145 */ 146 public static final PropertyDefinition ParentFolderId = 147 new ComplexPropertyDefinition<FolderId>( 148 FolderId.class, 149 XmlElementNames.ParentFolderId, FieldUris.ParentFolderId, EnumSet 150 .of(PropertyDefinitionFlags.CanFind), 151 ExchangeVersion.Exchange2007_SP1, 152 new ICreateComplexPropertyDelegate<FolderId>() { 153 public FolderId createComplexProperty() { 154 return new FolderId(); 155 } 156 }); 157 158 /** 159 * Defines the ChildFolderCount property. 160 */ 161 public static final PropertyDefinition ChildFolderCount = 162 new IntPropertyDefinition( 163 XmlElementNames.ChildFolderCount, FieldUris.ChildFolderCount, 164 EnumSet.of(PropertyDefinitionFlags.CanFind), 165 ExchangeVersion.Exchange2007_SP1); 166 167 /** 168 * Defines the DisplayName property. 169 */ 170 public static final PropertyDefinition DisplayName = 171 new StringPropertyDefinition( 172 XmlElementNames.DisplayName, FieldUris.DisplayName, EnumSet.of( 173 PropertyDefinitionFlags.CanSet, 174 PropertyDefinitionFlags.CanUpdate, 175 PropertyDefinitionFlags.CanDelete, 176 PropertyDefinitionFlags.CanFind), 177 ExchangeVersion.Exchange2007_SP1); 178 179 /** 180 * Defines the UnreadCount property. 181 */ 182 public static final PropertyDefinition UnreadCount = 183 new IntPropertyDefinition( 184 XmlElementNames.UnreadCount, FieldUris.UnreadCount, EnumSet 185 .of(PropertyDefinitionFlags.CanFind), 186 ExchangeVersion.Exchange2007_SP1); 187 188 /** 189 * Defines the TotalCount property. 190 */ 191 public static final PropertyDefinition TotalCount = 192 new IntPropertyDefinition( 193 XmlElementNames.TotalCount, FieldUris.TotalCount, EnumSet 194 .of(PropertyDefinitionFlags.CanFind), 195 ExchangeVersion.Exchange2007_SP1); 196 197 /** 198 * Defines the ManagedFolderInformation property. 199 */ 200 public static final PropertyDefinition ManagedFolderInformation = 201 new ComplexPropertyDefinition<microsoft.exchange.webservices.data.property.complex.ManagedFolderInformation>( 202 ManagedFolderInformation.class, 203 XmlElementNames.ManagedFolderInformation, 204 FieldUris.ManagedFolderInformation, 205 EnumSet.of(PropertyDefinitionFlags.CanFind), 206 ExchangeVersion.Exchange2007_SP1, 207 new ICreateComplexPropertyDelegate 208 <ManagedFolderInformation>() { 209 public ManagedFolderInformation createComplexProperty() { 210 return new ManagedFolderInformation(); 211 } 212 }); 213 214 /** 215 * Defines the EffectiveRights property. 216 */ 217 public static final PropertyDefinition EffectiveRights = 218 new EffectiveRightsPropertyDefinition( 219 XmlElementNames.EffectiveRights, FieldUris.EffectiveRights, EnumSet 220 .of(PropertyDefinitionFlags.CanFind), 221 ExchangeVersion.Exchange2007_SP1); 222 223 /** 224 * Defines the Permissions property. 225 */ 226 public static final PropertyDefinition Permissions = 227 new PermissionSetPropertyDefinition( 228 XmlElementNames.PermissionSet, FieldUris.PermissionSet, EnumSet.of( 229 PropertyDefinitionFlags.AutoInstantiateOnRead, 230 PropertyDefinitionFlags.CanSet, 231 PropertyDefinitionFlags.CanUpdate, 232 PropertyDefinitionFlags.CanDelete), 233 ExchangeVersion.Exchange2007_SP1); 234 235 /** 236 * This must be declared after the property definitions. 237 */ 238 public static final FolderSchema Instance = new FolderSchema(); 239 240 /** 241 * Registers property. IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN 242 * SCHEMA ORDER (i.e. the same order as they are defined in types.xsd) 243 */ 244 @Override 245 protected void registerProperties() { 246 super.registerProperties(); 247 248 this.registerProperty(Id); 249 this.registerProperty(ParentFolderId); 250 this.registerProperty(FolderClass); 251 this.registerProperty(DisplayName); 252 this.registerProperty(TotalCount); 253 this.registerProperty(ChildFolderCount); 254 this.registerProperty(ServiceObjectSchema.extendedProperties); 255 this.registerProperty(ManagedFolderInformation); 256 this.registerProperty(EffectiveRights); 257 this.registerProperty(Permissions); 258 this.registerProperty(UnreadCount); 259 this.registerProperty(WellKnownFolderName); 260 } 261}