private static string ReadAcl(XmlNode node)
    {
        if (node.Name == "Acl")
        {
            string nombre = NodeGetString(node, "nombre");
            Group g = (Group) NodeGetObject(node, "group", groups);
            Role r = (Role) NodeGetObject(node, "role", roles);

            Acl a = new Acl(nombre, g, r);
            System.Console.WriteLine ("Acl: "+ nombre);
            a.Save();
            acls[nombre] = a;
        }
        return null;
    }
    // ACLS

    public void AclCreate (int GroupId, int RoleId)
    {
        Commons.CheckSuperUser(Session);
        Acl Form = new Acl(GroupId, RoleId);
        Form.Save ();
        Response.Redirect (Context.UrlReferrer);       // vuelve al sitio de partida
    }
 public void New()
 {
     PropertyBag["acl"] = new Acl();
     PropertyBag["groups"] = Group.FindAll();
     PropertyBag["roles"] = Role.FindAll();
 }
    public void GroupCreate (string groupName)
    {
        Commons.CheckSuperUser(Session);
        Group group = new Group(groupName);
        string rolesString = (string) Request.Form["Roles[]"];
        if (rolesString != null)
        {
            string[] roles = rolesString.Split(',');
            if (roles != null)
            {
                group.Roles = new HashedSet();
                foreach (string i in roles)
                {
                    Role role = Role.Find(int.Parse(i));
                    if (role != null)
                    {
                        group.Roles.Add(role);
                    }
                }
            }
        }
        group.Save();

        Role[] rols = Role.FindAll();
        foreach (Role r in rols)
        {
            bool isDefaultRole = false;
            if (group.Roles != null)
            {
              foreach(Role rol in group.Roles)
              {
                 if (rol.Id == r.Id)
                 {
                    isDefaultRole = true;
                 }
              }
            }
            if ((isDefaultRole) && (Request.Form["updateAcls"] != null))
            {
                Acl acl = new Acl();
                acl.Group = group;
                acl.Role = r;
                acl.Containers = new Iesi.Collections.HashedSet(); //ArrayList();
                acl.Save();
                Category[] categories = Category.FindAll();
                foreach(Category category in categories)
                {
                    category.AclSet.Add(acl);
                    category.Save();
#if CACHE
                    acl.Containers.Add(category);
#endif
                }
            }
            //acl.Save();
        }
        
        RedirectToAction ("groupsedit");
    }
    public void RoleNew(string name)
    {
        Role role = new Role();
        role.Name = name;
        role.Save();

        Group[] groups = Group.FindAll();
        foreach (Group g in groups)
        {
            Acl acl = new Acl();
            acl.Group = g;
            acl.Role = role;
            acl.Containers = new Iesi.Collections.HashedSet(); // ArrayList();
            acl.Save();
        }

        RedirectToAction("rolesedit");
    }