public RoleResult SetRoles(string relationId, IEnumerable <Role> roles) { AssertRegistered(); RelationWrapper wrapper = GetRelationWrapper(relationId); string typeName = wrapper.Relation.RelationTypeName; Dictionary <string, IList <ObjectName> > oldValues = new Dictionary <string, IList <ObjectName> >(); foreach (Role r in roles) { try { oldValues[r.Name] = wrapper.Relation[r.Name]; } catch (RoleNotFoundException) { oldValues[r.Name] = null; } } RoleResult result = wrapper.Relation.SetRoles(roles); foreach (Role r in roles) { UpdateRoleMap(relationId, r, oldValues[r.Name]); } foreach (Role r in roles) { SendNotification(RelationNotification.CreateForUpdate(this, -1, relationId, typeName, r.Name, wrapper.Name, r.Value, oldValues[r.Name])); } return(result); }
//public void SendRelationCreationNotification(string relationId) //{ // throw new Exception("The method or operation is not implemented."); //} //public void SendRelationRemovalNotification(string relationId, IEnumerable<ObjectName> unregMBeans) //{ // throw new Exception("The method or operation is not implemented."); //} //public void SendRoleUpdateNotification(string relationId, Role newRole, IList<ObjectName> oldRoleValue) //{ // throw new Exception("The method or operation is not implemented."); //} public void SetRole(string relationId, Role role) { AssertRegistered(); RelationWrapper wrapper = GetRelationWrapper(relationId); string typeName = wrapper.Relation.RelationTypeName; IList <ObjectName> oldValue = wrapper.Relation[role.Name]; wrapper.Relation[role.Name] = role.Value; UpdateRoleMap(relationId, role, oldValue); RelationNotification notif = RelationNotification.CreateForUpdate(this, -1, relationId, typeName, role.Name, wrapper.Name, role.Value, oldValue); SendNotification(notif); }