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); }
//private bool ValidateOwnRelation(IRelation relation) //{ // RoleResult roles = relation.RetrieveAllRoles(); // IRelationType type = _relationTypes[relation.RelationTypeName]; // foreach (Role r in roles.Roles) // { // RoleInfo info = type[r.Name]; // if (!Role.ValidateRole(r.Value, type[r.Name], _server)) // { // return false; // } // } //} public void RemoveRelation(string relationId) { AssertRegistered(); RelationWrapper wrapper = GetRelationWrapper(relationId); string typeName = wrapper.Relation.RelationTypeName; _relations.Remove(relationId); foreach (Role r in wrapper.Relation.RetrieveAllRoles().Roles) { UpdateRoleMap(relationId, null, r.Value); } RelationNotification notif = RelationNotification.CreateForRemoval(this, -1, relationId, typeName, wrapper.Name); this.SendNotification(notif); }
public void CreateRelation(string relationId, string relationTypeName, IEnumerable <Role> roles) { AssertNotNull(relationId, "relationId"); AssertNotNull(relationTypeName, "relationTypeName"); AssertRegistered(); RelationSupport relation = new RelationSupport(relationId, _ownName, _server, relationTypeName, roles); ValidateRelation(relation); _relations[relationId] = new RelationWrapper(relation, null); foreach (Role r in roles) { UpdateRoleMap(relationId, r, null); } }
public void CreateRelation(string relationId, string relationTypeName, IEnumerable<Role> roles) { AssertNotNull(relationId, "relationId"); AssertNotNull(relationTypeName, "relationTypeName"); AssertRegistered(); RelationSupport relation = new RelationSupport(relationId, _ownName, _server, relationTypeName, roles); ValidateRelation(relation); _relations[relationId] = new RelationWrapper(relation, null); foreach (Role r in roles) { UpdateRoleMap(relationId, r, null); } }