/**
   * readRoles
   *
   * @return List
   */
  public List<Role> readRoles() {
    List<Role> list = new ArrayList<Role>();
    Element element;
    Role role;
    NodeList roles = OrganizationElementFactory.getListRoles(this.getRolesElement());

    for (int i = 0; i < roles.getLength(); i++) {
      element = (Element) roles.item(i);
      role = factory.elementToRole(element);
      list.add(role);
    }
    return list;
  }
  /**
   * readUsers
   *
   * @return List
   */
  public List<User> readUsers() {
    List<User> list = new ArrayList<User>();
    Element element;
    User user;
    NodeList users = OrganizationElementFactory.getListUsers(this.getUsersElement());

    for (int i = 0; i < users.getLength(); i++) {
      element = (Element) users.item(i);
      user = factory.elementToUser(element);
      list.add(user);
    }
    return list;
  }
  /**
   * readAssignedRoles
   *
   * @param anUser User
   * @return List
   */
  public List<Role> readAssignedRoles(User anUser) {
    List<Role> list = new ArrayList<Role>();
    Element userElement = this.getUserElement(anUser);
    Element element;
    Role role;
    NodeList roles = OrganizationElementFactory.getListRoles(userElement);

    for (int i = 0; i < roles.getLength(); i++) {
      element = (Element) roles.item(i);
      role = new Role(factory.elementToBase(element).getId());
      list.add(role);
    }
    return list;
  }
 /**
  * editUser
  *
  * @param anUser User
  * @return boolean
  */
 public boolean editUser(User anUser) {
   Element element = this.getUserElement(anUser);
   if (element != null) {
     factory.updateUserElement(anUser, element);
     writeDocument();
     return true;
   }
   return false;
 }
 /**
  * editRole
  *
  * @param aRole Role
  * @return boolean
  */
 public boolean editRole(Role aRole) {
   Element element = this.getRoleElement(aRole);
   if (element != null) {
     factory.updateRoleElement(aRole, element);
     writeDocument();
     return true;
   }
   return false;
 }
 /**
  * addRole
  *
  * @param aRole Role
  */
 public void addRole(Role aRole) {
   Element newRole = factory.roleToElement(aRole);
   Element roles = this.getRolesElement();
   roles.appendChild(newRole);
   writeDocument();
 }
 /**
  * addUser
  *
  * @param anUser User
  */
 public void addUser(User anUser) {
   Element newUser = factory.userToElement(anUser);
   Element users = this.getUsersElement();
   users.appendChild(newUser);
   writeDocument();
 }
 /**
  * disassignRole
  *
  * @param anUser User
  * @param aRole Role
  */
 public void disassignRole(User anUser, Role aRole) {
   Element user = this.getUserElement(anUser);
   factory.removeUserRole(user, aRole);
   writeDocument();
 }
 /**
  * getUsersElement
  *
  * @return Element
  */
 private Element getUsersElement() {
   // return this.getFirstElement(this.getDocumentRoot(), TAG_USERS);
   return factory.getUsersElement(this.getDocumentRoot());
 }
 /**
  * getRolesElement
  *
  * @return Element
  */
 private Element getRolesElement() {
   // return factory.getFirstElement(this.getDocumentRoot(), TAG_ROLES);
   return factory.getRolesElement(this.getDocumentRoot());
 }
 /**
  * getUserElement
  *
  * @param user User
  * @return Element
  */
 private Element getUserElement(User user) {
   return factory.getUserElement(user, this.getUsersElement());
 }
 /**
  * getRoleElement
  *
  * @param role Role
  * @return Element
  */
 private Element getRoleElement(Role role) {
   return factory.getRoleElement(role, this.getRolesElement());
 }