Example #1
0
        public RoleResult SetRoles(IEnumerable <Role> roles)
        {
            List <Role>           resovedRoles    = new List <Role>();
            List <RoleUnresolved> unresolvedRoles = new List <RoleUnresolved>();
            IList <RoleInfo>      roleInfos       = _relationService.GetRoleInfos(_relationTypeName);

            foreach (Role role in roles)
            {
                RoleInfo roleInfo = FindRoleInfo(role.Name, roleInfos);
                if (roleInfo == null)
                {
                    unresolvedRoles.Add(new RoleUnresolved(role.Name, role.Value, RoleStatus.NoRoleWithName));
                }
                else if (!roleInfo.Writable)
                {
                    unresolvedRoles.Add(new RoleUnresolved(role.Name, role.Value, RoleStatus.RoleNotWritable));
                }
                else if (!roleInfo.CheckMaxDegree(role.Value.Count))
                {
                    unresolvedRoles.Add(new RoleUnresolved(role.Name, role.Value, RoleStatus.MoreThanMaxRoleDegree));
                }
                else if (!roleInfo.CheckMinDegree(role.Value.Count))
                {
                    unresolvedRoles.Add(new RoleUnresolved(role.Name, role.Value, RoleStatus.LessThanMinRoleDegree));
                }
                else
                {
                    _roles[role.Name] = role;
                    resovedRoles.Add(role);
                }
            }
            return(new RoleResult(resovedRoles, unresolvedRoles));
        }
Example #2
0
 internal static bool ValidateRole(IList<ObjectName> value, RoleInfo info, IMBeanServerConnection serverConnection)
 {
     return info.CheckMaxDegree(value.Count) && info.CheckMinDegree(value.Count) && CheckRoleClassNames(info, value, serverConnection);
 }
Example #3
0
        //private Role(SerializationInfo info, StreamingContext ctx)
        //{
        //   info.AddValue("name", _name);
        //   info.AddValue(_value.
        //}
        #endregion

        //#region ISerializable Members
        //public void GetObjectData(SerializationInfo info, StreamingContext context)
        //{
        //   _name = info.GetString("name");
        //   info.get
        //}
        //#endregion

        #region Internal static interface
        internal static bool ValidateRole(IList <ObjectName> value, RoleInfo info, IMBeanServerConnection serverConnection)
        {
            return(info.CheckMaxDegree(value.Count) && info.CheckMinDegree(value.Count) && CheckRoleClassNames(info, value, serverConnection));
        }