private void CompileNxBrePolicySet(IPolicySetVersionCache version, IPolicySet policySet, string target) { if ((null == version) || (null == policySet) || (string.IsNullOrEmpty(target))) return; NxPolicyStore nxBreStore = new NxPolicyStore(); nxBreStore.ResourceManager = ResourcesCache.GetResources(); policySet.Export(nxBreStore); CompiledPolicySetExtractor cpse = new CompiledPolicySetExtractor(nxBreStore.XMLRepresentation); List<string> channels = cpse.GetChannelNames(); foreach (string channel in channels) { string objects = cpse.GetObjects(channel); string rules = cpse.GetRules(channel); ICompiledPolicySetCache cps = version.GetCompiledPolicySet(channel, target); if (cps == null) { cps = version.NewCompiledPolicySet(channel, target, rules, objects); } else { cps.Content = rules; cps.ObjectReferences = objects; } SaveLanguages(cpse.GetLanguages(), cps); } }
internal static void TestVersionIsReadOnly(IPolicySetVersionCache version) { try { version.Content = "try and update"; Assert.Fail("Failed to throw exception when updating a read-only version"); } catch (Exception ex) { Assert.AreEqual(ex.Message, "Unable to update version information, this version is not the latest and therefore read-only"); } try { version.NewCompiledPolicySet("", "", "", ""); Assert.Fail("Failed to throw exception when updating a read-only version"); } catch (Exception ex) { Assert.AreEqual(ex.Message, "Unable to update version information, this version is not the latest and therefore read-only"); } try { version.NewMasterCatalogue(""); Assert.Fail("Failed to throw exception when updating a read-only version"); } catch (Exception ex) { Assert.AreEqual(ex.Message, "Unable to update version information, this version is not the latest and therefore read-only"); } try { version.NewReferenceCatalgue(""); Assert.Fail("Failed to throw exception when updating a read-only version"); } catch (Exception ex) { Assert.AreEqual(ex.Message, "Unable to update version information, this version is not the latest and therefore read-only"); } foreach (ICompiledPolicySetCache cps in version.CompiledPolicySets) { if (cps != null) { try { cps.Content = "try and update"; Assert.Fail("Failed to throw exception when updating a read-only version"); } catch (Exception ex) { Assert.AreEqual(ex.Message, "Unable to update version information, this version is not the latest and therefore read-only"); } try { cps.ObjectReferences = "try and update"; Assert.Fail("Failed to throw exception when updating a read-only version"); } catch (Exception ex) { Assert.AreEqual(ex.Message, "Unable to update version information, this version is not the latest and therefore read-only"); } try { cps.NewLanguage("", "", false); Assert.Fail("Failed to throw exception when updating a read-only version"); } catch (Exception ex) { Assert.AreEqual(ex.Message, "Unable to update version information, this version is not the latest and therefore read-only"); } foreach (IPolicyLanguageTableCache lplt in cps.Languages) { try { lplt.Content = "try and update"; Assert.Fail("Failed to throw exception when updating a read-only version"); } catch (Exception ex) { Assert.AreEqual(ex.Message, "Unable to update version information, this version is not the latest and therefore read-only"); } } } } if (version.MasterCatalogue != null) { try { version.MasterCatalogue.Content = "try and update"; Assert.Fail("Failed to throw exception when updating a read-only version"); } catch (Exception ex) { Assert.AreEqual(ex.Message, "Unable to update version information, this version is not the latest and therefore read-only"); } try { version.MasterCatalogue.NewLanguage("", "", false); Assert.Fail("Failed to throw exception when updating a read-only version"); } catch (Exception ex) { Assert.AreEqual(ex.Message, "Unable to update version information, this version is not the latest and therefore read-only"); } foreach (IPolicyLanguageTableCache lplt in version.MasterCatalogue.Languages) { try { lplt.Content = "try and update"; Assert.Fail("Failed to throw exception when updating a read-only version"); } catch (Exception ex) { Assert.AreEqual(ex.Message, "Unable to update version information, this version is not the latest and therefore read-only"); } } } }