Esempio n. 1
0
        protected override void InternalSave(ConfigurableObject instance)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }
            MailboxFolder mailboxFolder = instance as MailboxFolder;

            if (mailboxFolder == null)
            {
                throw new NotSupportedException("Save: " + instance.GetType().FullName);
            }
            FolderSaveResult folderSaveResult = null;

            switch (mailboxFolder.ObjectState)
            {
            case ObjectState.New:
                try
                {
                    using (Folder folder = Folder.Create(base.MailboxSession, mailboxFolder.InternalParentFolderIdentity, ObjectClass.GetObjectType(mailboxFolder.FolderClass), mailboxFolder.Name, CreateMode.CreateNew))
                    {
                        mailboxFolder.SaveDataToXso(folder, new ReadOnlyCollection <XsoDriverPropertyDefinition>(new List <XsoDriverPropertyDefinition>
                        {
                            MailboxFolderSchema.Name,
                            MailboxFolderSchema.InternalParentFolderIdentity
                        }));
                        MailboxFolderDataProvider.ValidateXsoObjectAndThrowForError(mailboxFolder.Name, folder, mailboxFolder.Schema);
                        folderSaveResult = folder.Save();
                    }
                    goto IL_FD;
                }
                catch (ObjectExistedException innerException)
                {
                    throw new ObjectExistedException(ServerStrings.ErrorFolderAlreadyExists(mailboxFolder.Name), innerException);
                }
                break;

            case ObjectState.Unchanged:
                goto IL_FD;

            case ObjectState.Changed:
                break;

            case ObjectState.Deleted:
                throw new InvalidOperationException(ServerStrings.ExceptionObjectHasBeenDeleted);

            default:
                goto IL_FD;
            }
            throw new NotImplementedException("Save.Changed");
IL_FD:
            if (folderSaveResult != null && folderSaveResult.OperationResult != OperationResult.Succeeded)
            {
                throw folderSaveResult.ToException(ServerStrings.ErrorFolderSave(instance.Identity.ToString(), folderSaveResult.ToString()));
            }
        }
Esempio n. 2
0
        // Token: 0x060002D4 RID: 724 RVA: 0x00011398 File Offset: 0x0000F598
        private StoreObjectId CreateFolderHierarchy(string[] subfoldersToCreate, StoreObjectId startFolderId, string sourcePath, string targetRootPath, string elcPolicyName, string startFolderPath)
        {
            string text  = null;
            string text2 = string.Empty;

            foreach (string text2 in subfoldersToCreate)
            {
                text2 = text2.Replace('', '/');
                text2 = text2.Trim();
                FolderProcessor.Tracer.TraceDebug <FolderProcessor, string, string>((long)this.GetHashCode(), "{0}: ExpirationEnforcer is creating folder hierarchy under target folder. Source folder: {1}. Going to create subfolder {2} under target.", this, sourcePath, text2);
                try
                {
                    using (Folder folder = Folder.Create(this.mailboxSession, startFolderId, StoreObjectType.Folder, text2, CreateMode.OpenIfExists))
                    {
                        object obj = folder.TryGetProperty(FolderSchema.ExtendedFolderFlags);
                        if (!(obj is ExtendedFolderFlags))
                        {
                            folder[FolderSchema.ExtendedFolderFlags] = ExtendedFolderFlags.ShowTotal;
                        }
                        FolderSaveResult folderSaveResult = folder.Save();
                        if (folderSaveResult.OperationResult != OperationResult.Succeeded)
                        {
                            text = folderSaveResult.ToString();
                            break;
                        }
                        folder.Load();
                        startFolderId = folder.Id.ObjectId;
                        FolderProcessor.Tracer.TraceDebug <FolderProcessor, string, string>((long)this.GetHashCode(), "{0}: ExpirationEnforcer is creating folder hierarchy under target folder. Source folder name: {1}. Just created subfolder {2} under target.", this, sourcePath, folder.DisplayName);
                    }
                }
                catch (PropertyErrorException ex)
                {
                    text = ex.ToString();
                    break;
                }
                catch (CorruptDataException ex2)
                {
                    text = ex2.ToString();
                    break;
                }
                catch (ObjectNotFoundException ex3)
                {
                    text = ex3.ToString();
                    break;
                }
            }
            if (!string.IsNullOrEmpty(text))
            {
                FolderProcessor.Tracer.TraceError((long)this.GetHashCode(), "{0}: ExpirationEnforcer: Failed to create folder hierarchy. Policy '{1}'. Source folder path '{2}'.  Target folder path '{3}'. Creating the subfolder '{4}' under '{5}' failed. Error: ", new object[]
                {
                    this,
                    elcPolicyName,
                    sourcePath,
                    targetRootPath,
                    text2,
                    startFolderPath,
                    text
                });
                Globals.Logger.LogEvent(InfoWorkerEventLogConstants.Tuple_FailedToCreateFolderHierarchy, null, new object[]
                {
                    sourcePath,
                    this.mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(),
                    elcPolicyName,
                    targetRootPath,
                    text2,
                    startFolderPath,
                    text
                });
                throw new InvalidExpiryDestinationException(Strings.descFailedToCreateFolderHierarchy(sourcePath, this.mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString()));
            }
            return(startFolderId);
        }
        protected override void InternalSave(ConfigurableObject instance)
        {
            PublicFolder publicFolder = instance as PublicFolder;

            if (publicFolder == null)
            {
                throw new NotSupportedException("Save: " + instance.GetType().FullName);
            }
            FolderSaveResult folderSaveResult = null;

            switch (publicFolder.ObjectState)
            {
            case ObjectState.New:
                try
                {
                    using (Folder folder = Folder.Create(this.PublicFolderSession, publicFolder.InternalParentFolderIdentity, ObjectClass.GetObjectType(publicFolder.FolderClass), publicFolder.Name, CreateMode.CreateNew))
                    {
                        publicFolder.SaveDataToXso(folder, new ReadOnlyCollection <XsoDriverPropertyDefinition>(new List <XsoDriverPropertyDefinition>
                        {
                            PublicFolderSchema.Name,
                            MailboxFolderSchema.InternalParentFolderIdentity
                        }));
                        MailboxFolderDataProvider.ValidateXsoObjectAndThrowForError(publicFolder.Name, folder, publicFolder.Schema);
                        folderSaveResult            = folder.Save();
                        publicFolder.OrganizationId = this.PublicFolderSession.OrganizationId;
                    }
                    goto IL_157;
                }
                catch (ObjectExistedException innerException)
                {
                    throw new ObjectExistedException(ServerStrings.ErrorFolderAlreadyExists(publicFolder.Name), innerException);
                }
                break;

            case ObjectState.Unchanged:
                goto IL_157;

            case ObjectState.Changed:
                break;

            case ObjectState.Deleted:
                goto IL_147;

            default:
                goto IL_157;
            }
            using (Folder folder2 = Folder.Bind(this.PublicFolderSession, publicFolder.InternalFolderIdentity, null))
            {
                publicFolder.SaveDataToXso(folder2, new ReadOnlyCollection <XsoDriverPropertyDefinition>(new List <XsoDriverPropertyDefinition>
                {
                    MailboxFolderSchema.InternalParentFolderIdentity
                }));
                MailboxFolderDataProvider.ValidateXsoObjectAndThrowForError(publicFolder.Name, folder2, publicFolder.Schema);
                folderSaveResult = folder2.Save();
                goto IL_157;
            }
IL_147:
            throw new InvalidOperationException(ServerStrings.ExceptionObjectHasBeenDeleted);
IL_157:
            if (folderSaveResult != null && folderSaveResult.OperationResult != OperationResult.Succeeded && folderSaveResult.PropertyErrors.Length > 0)
            {
                foreach (PropertyError propertyError in folderSaveResult.PropertyErrors)
                {
                    if (propertyError.PropertyErrorCode == PropertyErrorCode.FolderNameConflict)
                    {
                        throw new ObjectExistedException(ServerStrings.ErrorFolderAlreadyExists(publicFolder.Name));
                    }
                }
                throw folderSaveResult.ToException(ServerStrings.ErrorFolderSave(instance.Identity.ToString(), folderSaveResult.ToString()));
            }
        }
Esempio n. 4
0
        // Token: 0x06000475 RID: 1141 RVA: 0x00020064 File Offset: 0x0001E264
        internal static void AssignTagPropsToFolder(FolderTuple source, Folder target, MailboxSession session)
        {
            StoreObjectId objectId = target.Id.ObjectId;

            for (FolderHelper.DataColumnIndex dataColumnIndex = FolderHelper.DataColumnIndex.startOfTagPropsIndex; dataColumnIndex <= FolderHelper.DataColumnIndex.containerClassIndex; dataColumnIndex++)
            {
                PropertyDefinition key = FolderHelper.DataColumns[(int)dataColumnIndex];
                object             obj = source.FolderProps[key];
                if (obj != null && !(obj is PropertyError))
                {
                    if (dataColumnIndex != FolderHelper.DataColumnIndex.containerClassIndex)
                    {
                        target[FolderHelper.DataColumns[(int)dataColumnIndex]] = obj;
                    }
                    else if (target.GetValueOrDefault <string>(FolderHelper.DataColumns[(int)dataColumnIndex], null) == null)
                    {
                        target[FolderHelper.DataColumns[(int)dataColumnIndex]] = obj;
                    }
                }
                else if (target.GetValueOrDefault <object>(FolderHelper.DataColumns[(int)dataColumnIndex]) != null && dataColumnIndex != FolderHelper.DataColumnIndex.containerClassIndex)
                {
                    target.DeleteProperties(new PropertyDefinition[]
                    {
                        FolderHelper.DataColumns[(int)dataColumnIndex]
                    });
                }
            }
            FolderSaveResult folderSaveResult = target.Save();

            if (folderSaveResult.OperationResult != OperationResult.Succeeded)
            {
                FolderTuple.Tracer.TraceError <StoreObjectId, FolderSaveResult>(0L, "AssignTagPropsToFolder for folder {0} save result {1}", objectId, folderSaveResult);
                throw new IWPermanentException(Strings.descUnableToSaveFolderTagProperties(objectId.ToString(), session.MailboxOwner.ToString(), folderSaveResult.ToString()));
            }
        }