public override UnifiedPolicyStorageBase ConvertToStorage(ExPolicyConfigProvider provider, PolicyConfigBase policyConfig) { ArgumentValidator.ThrowIfNull("provider", provider); ArgumentValidator.ThrowIfNull("storageObject", policyConfig); UnifiedPolicyStorageBase unifiedPolicyStorageBase = policyConfig.RawObject as TPolicyStorage; if (unifiedPolicyStorageBase == null) { unifiedPolicyStorageBase = Activator.CreateInstance <TPolicyStorage>(); unifiedPolicyStorageBase.OrganizationId = provider.GetOrganizationId(); if (ExPolicyConfigProvider.IsFFOOnline) { unifiedPolicyStorageBase.SetId(new ADObjectId(PolicyStorage.PoliciesContainer.GetChildId(policyConfig.Name).DistinguishedName, policyConfig.Identity)); } else { PolicyRuleConfig policyRuleConfig = policyConfig as PolicyRuleConfig; ADObjectId policyConfigContainer = provider.GetPolicyConfigContainer((policyRuleConfig == null) ? null : new Guid?(policyRuleConfig.PolicyDefinitionConfigId)); unifiedPolicyStorageBase.SetId(policyConfigContainer.GetChildId(policyConfig.Name)); unifiedPolicyStorageBase.MasterIdentity = policyConfig.Identity; } } else if ((ExPolicyConfigProvider.IsFFOOnline && policyConfig.Identity != unifiedPolicyStorageBase.Guid) || (!ExPolicyConfigProvider.IsFFOOnline && policyConfig.Identity != unifiedPolicyStorageBase.MasterIdentity)) { throw new PolicyConfigProviderPermanentException(ServerStrings.ErrorCouldNotUpdateMasterIdentityProperty(policyConfig.Name)); } if (policyConfig.Version != null) { unifiedPolicyStorageBase.PolicyVersion = policyConfig.Version.InternalStorage; } unifiedPolicyStorageBase.Name = policyConfig.Name; if (unifiedPolicyStorageBase.Workload != policyConfig.Workload) { unifiedPolicyStorageBase.Workload = policyConfig.Workload; } this.copyPropertiesToStorageDelegate((TPolicyConfig)((object)policyConfig), (TPolicyStorage)((object)unifiedPolicyStorageBase)); return(unifiedPolicyStorageBase); }
public ExBindingStoreObjectProvider(ExPolicyConfigProvider policyConfigProvider) : base(policyConfigProvider.GetOrganizationId()) { ArgumentValidator.ThrowIfNull("policyConfigProvider", policyConfigProvider); this.policyConfigProvider = policyConfigProvider; }