/**
   * Add a role info. This method of course should not be used after the creation of the relation
   * type, because updating it would invalidate that the relations created associated to that type
   * still conform to it. Can throw a RuntimeException if trying to update a relation type declared
   * in the Relation Service.
   *
   * @param roleInfo role info to be added.
   * @exception IllegalArgumentException if null parameter.
   * @exception InvalidRelationTypeException if there is already a role info in current relation
   *     type with the same name.
   */
  protected void addRoleInfo(RoleInfo roleInfo)
      throws IllegalArgumentException, InvalidRelationTypeException {

    if (roleInfo == null) {
      String excMsg = "Invalid parameter.";
      throw new IllegalArgumentException(excMsg);
    }

    if (isDebugOn()) debug("addRoleInfo: entering", roleInfo.toString());

    if (isInRelationService) {
      // Trying to update a declared relation type
      String excMsg = "Relation type cannot be updated as it is declared in the Relation Service.";
      throw new RuntimeException(excMsg);
    }

    String roleName = roleInfo.getName();

    // Checks if the role info has already been described
    if (roleName2InfoMap.containsKey(roleName)) {
      StringBuilder excMsgStrB = new StringBuilder();
      String excMsg = "Two role infos provided for role ";
      excMsgStrB.append(excMsg);
      excMsgStrB.append(roleName);
      throw new InvalidRelationTypeException(excMsgStrB.toString());
    }

    roleName2InfoMap.put(roleName, new RoleInfo(roleInfo));

    if (isDebugOn()) debug("addRoleInfo: exiting", null);
    return;
  }