Esempio n. 1
0
 private void UpdateRoleMap(string relationId, Role newRole, IList<ObjectName> oldRoleValue)
 {
     if (newRole != null)
     {
         foreach (ObjectName name in newRole.Value)
         {
             if (oldRoleValue == null || !oldRoleValue.Contains(name))
             {
                 Dictionary<string, IList<string>> referencingThisBean;
                 if (!_referencingRelations.TryGetValue(name, out referencingThisBean))
                 {
                     referencingThisBean = new Dictionary<string, IList<string>>();
                     _referencingRelations[name] = referencingThisBean;
                 }
                 IList<string> rolesInThisRelation;
                 if (!referencingThisBean.TryGetValue(relationId, out rolesInThisRelation))
                 {
                     rolesInThisRelation = new List<string>();
                     referencingThisBean[relationId] = rolesInThisRelation;
                 }
                 rolesInThisRelation.Add(newRole.Name);
             }
         }
         if (oldRoleValue != null)
         {
             foreach (ObjectName name in oldRoleValue)
             {
                 if (!newRole.Value.Contains(name))
                 {
                     IList<string> rolesInThisRelation = _referencingRelations[name][relationId];
                     if (rolesInThisRelation.Count > 1)
                     {
                         _referencingRelations[name][relationId].Remove(newRole.Name);
                     }
                     else
                     {
                         _referencingRelations[name].Remove(relationId);
                     }
                 }
             }
         }
     }
     else
     {
         foreach (ObjectName name in oldRoleValue)
         {
             _referencingRelations[name].Remove(relationId);
         }
     }
 }
 public ManagedResourceRole(Role role)
 {
     name = role.Name;
      Value = role.Value.Select(ObjectNameSelector.CreateEndpointAddress).ToArray();
 }
Esempio n. 3
0
 //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);
 }
Esempio n. 4
0
 public IList<ObjectName> this[string roleName]
 {
     get
      {
     if (roleName == null)
     {
        throw new ArgumentNullException("roleName");
     }
     Role r;
     if (_roles.TryGetValue(roleName, out r))
     {
        RoleInfo info = _relationService.GetRoleInfo(_relationTypeName, roleName);
        if (info.Readable)
        {
           return r.Value;
        }
     }
     throw new RoleNotFoundException(roleName);
      }
      set
      {
     if (roleName == null)
     {
        throw new ArgumentNullException("roleName");
     }
     Role r;
     if (_roles.TryGetValue(roleName, out r))
     {
        RoleInfo info = _relationService.GetRoleInfo(_relationTypeName, roleName);
        if (!info.Writable)
        {
           throw new RoleNotFoundException(roleName);
        }
        if (!Role.ValidateRole(value, info, _relationServiceMBeanServer))
        {
           throw new InvalidRoleValueException();
        }
        _roles[roleName] = new Role(roleName, value);
     }
     else
     {
        throw new RoleNotFoundException(roleName);
     }
      }
 }