Ejemplo n.º 1
0
 internal bool Rename(string displayName, out PropertyError error)
 {
     if (this.defaultFolderInfo.DefaultFolderType != DefaultFolderType.ElcRoot)
     {
         throw new NotSupportedException(string.Format("We do not support renaming the default folder. defaultFolder = {0}.", this.defaultFolderInfo.DefaultFolderType));
     }
     error = DefaultFolderCreator.UpdateElcRootFolderName(this.context, displayName);
     return(error != null);
 }
Ejemplo n.º 2
0
        protected Folder CreateInternal(DefaultFolderContext context, string displayName, StoreObjectId parentFolderId, out bool hasCreatedNew)
        {
            hasCreatedNew = false;
            bool   flag   = false;
            Folder folder = null;

            try
            {
                folder = this.CreateNewFolder(context, displayName, parentFolderId);
                FolderSaveResult folderSaveResult = folder.Save();
                if (folderSaveResult.OperationResult != OperationResult.Succeeded)
                {
                    return(null);
                }
                folder.Load(null);
                hasCreatedNew = true;
                flag          = true;
            }
            catch (ObjectExistedException)
            {
                ExTraceGlobals.DefaultFoldersTracer.TraceDebug <DefaultFolderCreator, string>((long)this.GetHashCode(), "DefaultFolderCreator::CreateInternal. We found the folder has existed. strategy = {0}, displayName = {1}.", this, displayName);
                if (folder != null)
                {
                    folder.Dispose();
                    folder = null;
                }
                if (this.bindByNameIfAlreadyExists)
                {
                    folder = DefaultFolderCreator.BindToSubfolderByName(context.Session, parentFolderId, displayName, new PropertyDefinition[0]);
                    flag   = true;
                }
            }
            finally
            {
                if (!flag && folder != null)
                {
                    folder.Dispose();
                    folder = null;
                }
            }
            return(folder);
        }
Ejemplo n.º 3
0
 internal bool CreateInternal(ref DefaultFolderData data)
 {
     if ((this.defaultFolderInfo.Behavior & DefaultFolderBehavior.CanCreate) != DefaultFolderBehavior.CanCreate)
     {
         ExTraceGlobals.DefaultFoldersTracer.TraceError <DefaultFolder>((long)this.GetHashCode(), "DefaultFolder::Create. Cannot create default folder because DefaultFolderBehavior.CanCreate is not set. defaultFolder = {0}.", this);
         throw new NotSupportedException(string.Format("The defaultFolder cannot be created. defaultFolder = {0}.", this));
     }
     if (data.FolderId != null)
     {
         throw new InvalidOperationException(string.Format("Cannot create default folder {0}, because it already exists.", this.defaultFolderInfo.DefaultFolderType));
     }
     for (int i = 0; i <= StorageLimits.Instance.DefaultFolderMaximumSuffix; i++)
     {
         ExTraceGlobals.DefaultFoldersTracer.TraceDebug <DefaultFolder, int>((long)this.GetHashCode(), "DefaultFolder::CreateInternal. About to create the default folder. defaultFolder = {0}. Iteration = {1}.", this, i);
         Folder folder = null;
         bool   flag   = false;
         this.context.Session.Mailbox.Load(DefaultFolder.localeIdPropertyDefinition);
         string        text          = this.defaultFolderInfo.LocalizableDisplayName.ToString(this.cultureInfo);
         StoreObjectId storeObjectId = null;
         if (this.HideUnderNonIpmSubtree)
         {
             storeObjectId = this.context[DefaultFolderType.Configuration];
         }
         else
         {
             storeObjectId = this.context[this.defaultFolderInfo.FolderCreator.DefaultContainer];
         }
         if (i > 0)
         {
             text += i;
         }
         bool flag2 = false;
         try
         {
             folder = this.defaultFolderInfo.FolderCreator.Create(this.context, text, storeObjectId, out flag2);
         }
         catch (ObjectNotFoundException arg)
         {
             ExTraceGlobals.DefaultFoldersTracer.TraceDebug <DefaultFolder, string, ObjectNotFoundException>((long)this.GetHashCode(), "DefaultFolder::CreateInternal. The user may have no permission to the container folder. defaultFolder = {0}, session = {1}, exception = {2}.", this, this.context.Session.DisplayName, arg);
             return(false);
         }
         catch (AccessDeniedException arg2)
         {
             ExTraceGlobals.DefaultFoldersTracer.TraceDebug <DefaultFolder, string, AccessDeniedException>((long)this.GetHashCode(), "DefaultFolder::CreateInternal. The user may have no permission to the container folder. defaultFolder = {0}, session = {1}, exception = {2}.", this, this.context.Session.DisplayName, arg2);
             return(false);
         }
         catch (ObjectExistedException arg3)
         {
             ExTraceGlobals.DefaultFoldersTracer.TraceDebug <DefaultFolder, string, ObjectExistedException>((long)this.GetHashCode(), "DefaultFolder::CreateInternal. The folder already exists. defaultFolder = {0}, session = {1}, exception = {2}.", this, this.context.Session.DisplayName, arg3);
             if (folder != null && folder.Id != null)
             {
                 folder.Dispose();
                 folder = null;
                 data   = new DefaultFolderData(data.HasInitialized);
             }
             folder = DefaultFolderCreator.BindToSubfolderByName(this.context.Session, storeObjectId, text, new PropertyDefinition[0]);
             flag2  = false;
         }
         if (folder != null)
         {
             if (!flag2)
             {
                 data = new DefaultFolderData(folder.StoreObjectId, data.IdInitialized, data.HasInitialized);
             }
             StoreObjectId objectId = folder.Id.ObjectId;
             try
             {
                 if (flag2 || this.defaultFolderInfo.FolderValidationStrategy.EnsureIsValid(this.context, folder))
                 {
                     ExTraceGlobals.DefaultFoldersTracer.TraceDebug <DefaultFolder, bool>((long)this.GetHashCode(), "DefaultFolder::CreateInternal. We created or hijacked a new folder for the missing default folder. defaultFolder = {0}, hasCreatedNew = {1}.", this, flag2);
                     if (flag2)
                     {
                         this.SetProperties(folder);
                         folder.Load(null);
                     }
                     flag = true;
                 }
             }
             catch (DefaultFolderPropertyValidationException)
             {
                 this.SetProperties(folder);
                 folder.Load(null);
                 flag = true;
             }
             finally
             {
                 folder.Dispose();
             }
             if (flag)
             {
                 this.defaultFolderInfo.EntryIdStrategy.SetEntryId(this.context, objectId.ProviderLevelItemId);
                 data = new DefaultFolderData(StoreObjectId.FromProviderSpecificId(objectId.ProviderLevelItemId, this.StoreObjectType), data.IdInitialized, data.HasInitialized);
                 return(true);
             }
             ExTraceGlobals.DefaultFoldersTracer.TraceWarning <DefaultFolder, string, int>((long)this.GetHashCode(), "DefaultFolder::CreateInternal. We failed to create a default folder. We will try with a new name. defaultFolder = {0}, displayName = {1}, iteration = {2}.", this, text, i);
         }
     }
     ExTraceGlobals.DefaultFoldersTracer.TraceError <string, DefaultFolderType>((long)this.GetHashCode(), "DefaultFolder::CreateInternal. Failed to open or create default folder. Folder = {0}, defaultFolderType = {1}.", this.defaultFolderInfo.LocalizableDisplayName.ToString(this.cultureInfo), this.defaultFolderInfo.DefaultFolderType);
     throw new DefaultFolderNameClashException(ServerStrings.ExUnableToOpenOrCreateDefaultFolder(this.defaultFolderInfo.LocalizableDisplayName.ToString(this.cultureInfo)));
 }