示例#1
0
        private string ValidateAgainstBusinessRulesAndReadMetadata(XDocument rulePackXDoc)
        {
            ExAssert.RetailAssert(this.rulePackageIdentifier != null && this.DataObject != null, "Business rules validation in Set-ClassificationRuleCollection must take place after the DataObject resolution");
            string result = string.Empty;

            try
            {
                this.validationContext = new ValidationContext(ClassificationRuleCollectionOperationType.Update, base.CurrentOrganizationId, VariantConfiguration.InvariantNoFlightingSnapshot.Global.MultiTenancy.Enabled && this.OutOfBoxCollection, false, (IConfigurationSession)base.DataSession, this.DataObject, null, null);
                result = ClassificationRuleCollectionValidationUtils.ValidateRulePackageContents(this.validationContext, rulePackXDoc);
                ClassificationRuleCollectionLocalizableDetails classificationRuleCollectionLocalizableDetails = XmlProcessingUtils.ReadDefaultRulePackageMetadata(rulePackXDoc);
                this.defaultName = classificationRuleCollectionLocalizableDetails.Name;
                ClassificationRuleCollectionLocalizableDetails classificationRuleCollectionLocalizableDetails2 = XmlProcessingUtils.ReadRulePackageMetadata(rulePackXDoc, CultureInfo.CurrentCulture);
                this.localizedName = ((classificationRuleCollectionLocalizableDetails2 != null && classificationRuleCollectionLocalizableDetails2.Name != null) ? classificationRuleCollectionLocalizableDetails2.Name : this.defaultName);
                if (VariantConfiguration.InvariantNoFlightingSnapshot.Global.MultiTenancy.Enabled && OrganizationId.ForestWideOrgId.Equals(((IDirectorySession)base.DataSession).SessionSettings.CurrentOrganizationId))
                {
                    this.WriteWarning(Strings.ClassificationRuleCollectionIneffectiveSharingViolationCheck);
                }
                SortedSet <string> sortedSet         = new SortedSet <string>();
                IList <string>     deletedRulesInUse = ClassificationRuleCollectionValidationUtils.GetDeletedRulesInUse(base.DataSession, this.DataObject, sortedSet, rulePackXDoc);
                if (deletedRulesInUse.Count > 0)
                {
                    LocalizedString message = Strings.ClassificationRuleCollectionSharingViolationSetOperationVerbose(this.localizedName ?? this.rulePackageIdentifier, string.Join(Strings.ClassificationRuleCollectionOffendingListSeparator, deletedRulesInUse), string.Join(Strings.ClassificationRuleCollectionOffendingListSeparator, sortedSet));
                    throw ClassificationDefinitionUtils.PopulateExceptionSource <ClassificationRuleCollectionSharingViolationException, IList <string> >(new ClassificationRuleCollectionSharingViolationException(message), deletedRulesInUse);
                }
            }
            catch (ClassificationRuleCollectionSharingViolationException exception)
            {
                base.WriteError(exception, ErrorCategory.InvalidOperation, null);
            }
            catch (ClassificationRuleCollectionInternalValidationException ex)
            {
                base.WriteError(ex, (-2147287038 == ex.Error) ? ErrorCategory.ObjectNotFound : ErrorCategory.InvalidResult, null);
            }
            catch (ClassificationRuleCollectionTimeoutException exception2)
            {
                base.WriteError(exception2, ErrorCategory.OperationTimeout, null);
            }
            catch (LocalizedException exception3)
            {
                base.WriteError(exception3, ErrorCategory.InvalidData, null);
            }
            return(result);
        }
示例#2
0
 private IList <string> GetAllRulesInUse(TransportRule transportRule, ISet <string> referencingRules = null)
 {
     ExAssert.RetailAssert(((IDirectorySession)base.DataSession).SessionSettings.CurrentOrganizationId.Equals(transportRule.OrganizationId), "Remove-ClassificationRuleCollection session must be underscoped to tenant organization to check whether the collection is in-use.");
     return(ClassificationRuleCollectionValidationUtils.GetDeletedRulesInUse(base.DataSession, transportRule, referencingRules, null));
 }