예제 #1
0
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     if (this.DataObject != null && SharedConfiguration.IsSharedConfiguration(this.DataObject.OrganizationId) && !base.ShouldContinue(Strings.ConfirmSharedConfiguration(this.DataObject.OrganizationId.OrganizationalUnit.Name)))
     {
         TaskLogger.LogExit();
         return;
     }
     if (this.updateExistingDefaultPolicies)
     {
         if (!base.ShouldContinue(Strings.ConfirmationMessageSwitchMailboxPolicy("RetentionPolicy", this.DataObject.Name)))
         {
             return;
         }
         try
         {
             RetentionPolicyUtility.ClearDefaultPolicies(base.DataSession as IConfigurationSession, this.existingDefaultPolicies, this.IsDefaultArbitrationMailbox);
         }
         catch (DataSourceTransientException exception)
         {
             base.WriteError(exception, ErrorCategory.ReadError, null);
         }
     }
     base.InternalProcessRecord();
     TaskLogger.LogExit();
 }
 public static void ClearDefaultPolicies(IConfigurationSession session, IList <RetentionPolicy> defaultPolicies, bool isArbitrationMailbox)
 {
     if (isArbitrationMailbox)
     {
         RetentionPolicyUtility.ClearDefaultArbitrationMailboxPolicies(session, defaultPolicies);
         return;
     }
     DefaultMailboxPolicyUtility <RetentionPolicy> .ClearDefaultPolicies(session, defaultPolicies);
 }
예제 #3
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);
            }
        }
예제 #4
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);
         }
     }
 }