コード例 #1
0
        protected override void InternalValidate()
        {
            base.InternalValidate();
            if (base.HasErrors)
            {
                return;
            }
            if (this.IsDefault && this.IsDefaultArbitrationMailbox)
            {
                base.WriteError(new ArgumentException(Strings.ErrorMultipleDefaultRetentionPolicy), ErrorCategory.InvalidArgument, this.DataObject.Identity);
            }
            if (this.IsDefault)
            {
                this.DataObject.IsDefaultArbitrationMailbox = false;
                this.DataObject.IsDefault = true;
                this.otherDefaultPolicies = RetentionPolicyUtility.GetDefaultPolicies((IConfigurationSession)base.DataSession, false);
            }
            else if (this.IsDefaultArbitrationMailbox)
            {
                this.DataObject.IsDefault = false;
                this.DataObject.IsDefaultArbitrationMailbox = true;
                this.otherDefaultPolicies = RetentionPolicyUtility.GetDefaultPolicies((IConfigurationSession)base.DataSession, true);
            }
            else if ((!this.IsDefault && base.Fields.IsChanged("IsDefault") && this.DataObject.IsDefault) || (!this.IsDefaultArbitrationMailbox && base.Fields.IsChanged("IsDefaultArbitrationMailbox") && this.DataObject.IsDefaultArbitrationMailbox))
            {
                base.WriteError(new InvalidOperationException(Strings.ResettingIsDefaultIsNotSupported(this.DataObject.IsDefault ? "IsDefault" : "IsDefaultArbitrationMailbox", "RetentionPolicy")), ErrorCategory.WriteError, this.DataObject);
            }
            if (this.otherDefaultPolicies != null && this.otherDefaultPolicies.Count > 0)
            {
                this.updateOtherDefaultPolicies = true;
            }
            if (base.Fields.IsModified("RetentionPolicyLinks"))
            {
                this.DataObject.RetentionPolicyTagLinks.Clear();
                if (this.RetentionPolicyTagLinks != null)
                {
                    PresentationRetentionPolicyTag[] array = (from x in (from x in this.RetentionPolicyTagLinks
                                                                         select(RetentionPolicyTag) base.GetDataObject <RetentionPolicyTag>(x, base.DataSession, null, new LocalizedString?(Strings.ErrorRetentionTagNotFound(x.ToString())), new LocalizedString?(Strings.ErrorAmbiguousRetentionPolicyTagId(x.ToString())))).Distinct <RetentionPolicyTag>()
                                                              select new PresentationRetentionPolicyTag(x)).ToArray <PresentationRetentionPolicyTag>();
                    RetentionPolicyValidator.ValicateDefaultTags(this.DataObject, array, new Task.TaskErrorLoggingDelegate(base.WriteError));
                    RetentionPolicyValidator.ValidateSystemFolderTags(this.DataObject, array, new Task.TaskErrorLoggingDelegate(base.WriteError));
                    array.ForEach(delegate(PresentationRetentionPolicyTag x)
                    {
                        this.DataObject.RetentionPolicyTagLinks.Add(x.Id);
                    });
                }
            }
            string policyName;

            if (this.DataObject.IsChanged(RetentionPolicySchema.RetentionId) && !(base.DataSession as IConfigurationSession).CheckForRetentionPolicyWithConflictingRetentionId(this.DataObject.RetentionId, this.DataObject.Identity.ToString(), out policyName))
            {
                base.WriteError(new RetentionPolicyTagTaskException(Strings.ErrorRetentionIdConflictsWithRetentionPolicy(this.DataObject.RetentionId.ToString(), policyName)), ErrorCategory.InvalidOperation, this.DataObject);
            }
        }
コード例 #2
0
 internal static void ValicateDefaultTags(RetentionPolicy retentionPolicy, PresentationRetentionPolicyTag[] retentionTags, Task.TaskErrorLoggingDelegate writeError)
 {
     PresentationRetentionPolicyTag[] array = (from x in retentionTags
                                               where x.Type == ElcFolderType.All && x.RetentionAction != RetentionActionType.MoveToArchive
                                               select x).ToArray <PresentationRetentionPolicyTag>();
     if (array.Count((PresentationRetentionPolicyTag x) => !x.MessageClass.Equals(ElcMessageClass.AllMailboxContent, StringComparison.OrdinalIgnoreCase) && !x.MessageClass.Equals(ElcMessageClass.VoiceMail, StringComparison.OrdinalIgnoreCase)) != 0)
     {
         writeError(new RetentionPolicyTagTaskException(Strings.ErrorIncorrectDefaultTag), ErrorCategory.InvalidOperation, retentionPolicy);
     }
     if (array.Length > 1)
     {
         RetentionPolicyValidator.ValidateNoOverlappingMessageClass(retentionPolicy, array, writeError);
     }
     array = (from x in retentionTags
              where x.Type == ElcFolderType.All && x.RetentionAction == RetentionActionType.MoveToArchive
              select x).ToArray <PresentationRetentionPolicyTag>();
     if (array.Length > 0)
     {
         RetentionPolicyValidator.ValidateNoOverlappingMessageClass(retentionPolicy, array, writeError);
     }
 }
コード例 #3
0
 protected override void InternalValidate()
 {
     base.InternalValidate();
     if (base.HasErrors)
     {
         return;
     }
     if (Datacenter.IsMicrosoftHostedOnly(false))
     {
         List <RetentionPolicy> allRetentionPolicies = AdPolicyReader.GetAllRetentionPolicies(this.ConfigurationSession, base.OrganizationId);
         if (allRetentionPolicies.Count >= 100)
         {
             base.WriteError(new RetentionPolicyTagTaskException(Strings.ErrorTenantRetentionPolicyLimitReached(100)), ErrorCategory.InvalidOperation, this.DataObject);
         }
     }
     if (this.IsDefault && this.IsDefaultArbitrationMailbox)
     {
         base.WriteError(new ArgumentException(Strings.ErrorMultipleDefaultRetentionPolicy), ErrorCategory.InvalidArgument, this.DataObject.Identity);
     }
     if (!this.IgnoreDehydratedFlag && SharedConfiguration.IsDehydratedConfiguration(base.CurrentOrganizationId))
     {
         base.WriteError(new ArgumentException(Strings.ErrorWriteOpOnDehydratedTenant), ErrorCategory.InvalidArgument, this.DataObject.Identity);
     }
     if (this.IsDefault && this.IsDefaultArbitrationMailbox)
     {
         base.WriteError(new ArgumentException(Strings.ErrorMultipleDefaultRetentionPolicy), ErrorCategory.InvalidArgument, this.DataObject.Identity);
     }
     if (this.IsDefault)
     {
         this.DataObject.IsDefault    = true;
         this.existingDefaultPolicies = RetentionPolicyUtility.GetDefaultPolicies((IConfigurationSession)base.DataSession, false);
     }
     else if (this.IsDefaultArbitrationMailbox)
     {
         this.DataObject.IsDefaultArbitrationMailbox = true;
         this.existingDefaultPolicies = RetentionPolicyUtility.GetDefaultPolicies((IConfigurationSession)base.DataSession, true);
     }
     if (this.existingDefaultPolicies != null && this.existingDefaultPolicies.Count > 0)
     {
         this.updateExistingDefaultPolicies = true;
     }
     if (this.RetentionPolicyTagLinks != null)
     {
         this.DataObject.RetentionPolicyTagLinks.Clear();
         PresentationRetentionPolicyTag[] array = (from x in (from x in this.RetentionPolicyTagLinks
                                                              select(RetentionPolicyTag) base.GetDataObject <RetentionPolicyTag>(x, base.DataSession, null, new LocalizedString?(Strings.ErrorRetentionTagNotFound(x.ToString())), new LocalizedString?(Strings.ErrorAmbiguousRetentionPolicyTagId(x.ToString())))).Distinct(new ADObjectComparer <RetentionPolicyTag>())
                                                   select new PresentationRetentionPolicyTag(x)).ToArray <PresentationRetentionPolicyTag>();
         RetentionPolicyValidator.ValicateDefaultTags(this.DataObject, array, new Task.TaskErrorLoggingDelegate(base.WriteError));
         RetentionPolicyValidator.ValidateSystemFolderTags(this.DataObject, array, new Task.TaskErrorLoggingDelegate(base.WriteError));
         array.ForEach(delegate(PresentationRetentionPolicyTag x)
         {
             this.DataObject.RetentionPolicyTagLinks.Add(x.Id);
         });
     }
     if (base.Fields.Contains("RetentionId"))
     {
         this.DataObject.RetentionId = this.RetentionId;
         string policyName;
         if (!(base.DataSession as IConfigurationSession).CheckForRetentionPolicyWithConflictingRetentionId(this.DataObject.RetentionId, out policyName))
         {
             base.WriteError(new RetentionPolicyTagTaskException(Strings.ErrorRetentionIdConflictsWithRetentionPolicy(this.DataObject.RetentionId.ToString(), policyName)), ErrorCategory.InvalidOperation, this.DataObject);
         }
     }
 }