public override void ModifyAccessProfile(AccessProfile AccessProfile) { ConfStorageLoad(); EventServerLoad(); ServiceCapabilities capabilities = Simulator.SystemCapabilities.Instance.AccessRulesCapabilities; //Check that access profile exists if (!ConfStorage.AccessProfileList.ContainsKey(AccessProfile.token)) { string message = string.Format("Access Profile with specified token {0} does not exists.", AccessProfile.token); LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error); FaultLib.ReturnFault(message, new string[] { "Sender", "InvalidArgVal", "NotFound" }); } //Check MaxAccessPoliciesPerAccessProfile capability if (AccessProfile.AccessPolicy != null) { if (AccessProfile.AccessPolicy.Count() > capabilities.MaxAccessPoliciesPerAccessProfile) { string message = string.Format("Max Access Polisies per AccessProfile exeeded."); LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error); FaultLib.ReturnFault(message, new string[] { "Sender", "CapabilityViolated", "MaxAccessPoliciesPerAccessProfile" }); } //Check MultipleSchedulesPerAccessPointSupported capability if (!capabilities.MultipleSchedulesPerAccessPointSupported) { foreach (var group in AccessProfile.AccessPolicy.GroupBy(C => C.Entity)) { if (group.Count() > 1) { string message = string.Format("Multiple AccessPoints are not supported for the same schedule, see MultipleSchedulesPerAccessPointSupported capability."); LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error); FaultLib.ReturnFault(message, new string[] { "Sender", "CapabilityViolated", "MultipleSchedulesPerAccessPointSupported" }); } } } //Check that only access points are used if (AccessProfile.AccessPolicy.Any(C => (C.EntityType != null) && ((C.EntityType.Namespace != "http://www.onvif.org/ver10/accesscontrol/wsdl") || (C.EntityType.Name != "AccessPoint")))) { string message = string.Format("Specified Entity is not supported."); LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error); FaultLib.ReturnFault(message, new string[] { "Sender", "InvalidArgVal" }); } //Check that all Access Pioints exists if (AccessProfile.AccessPolicy.Any(C => !(ConfStorage.AccessPointInfoList.Keys.Contains(C.Entity)))) { string message = string.Format("Access Profile does not exist."); LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error); FaultLib.ReturnFault(message, new string[] { "Sender", "InvalidArgVal" }); } } //TODO: Check that all Schedules exists ConfStorage.AccessProfileList.Remove(AccessProfile.token); ConfStorage.AccessProfileList.Add(AccessProfile.token, AccessProfile); EventServer.ConfigurationAccessProfileChangedEvent(this, AccessProfile.token); EventServerSave(); ConfStorageSave(); }