public Element handle(FreeColServer server, Player player,
                          Connection connection) {
        ServerPlayer serverPlayer = server.getPlayer(connection);

        Unit student;
        try {
            student = player.getFreeColGameObject(studentId, Unit.class);
        } catch (Exception e) {
            return DOMMessage.clientError(e.getMessage());
        }

        Unit teacher;
        try {
            teacher = player.getFreeColGameObject(teacherId, Unit.class);
        } catch (Exception e) {
            return DOMMessage.clientError(e.getMessage());
        }

        if (student.getColony() == null) {
            return DOMMessage.clientError("Student not in colony: "
                + studentId);
        } else if (!(student.getLocation() instanceof WorkLocation)) {
            return DOMMessage.clientError("Student not working colony: "
                + studentId);
        } else if (teacher.getColony() == null) {
            return DOMMessage.clientError("Teacher not in colony: "
                + teacherId);
        } else if (!teacher.getColony().canTrain(teacher)) {
            return DOMMessage.clientError("Teacher can not teach: "
                + teacherId);
        } else if (student.getColony() != teacher.getColony()) {
            return DOMMessage.clientError("Student and teacher not in same colony: "
                + studentId);
        } else if (!student.canBeStudent(teacher)) {
            return DOMMessage.clientError("Student can not be taught by teacher: "
                + studentId);
        }

        // Proceed to assign.
        return server.getInGameController()
            .assignTeacher(serverPlayer, student, teacher);
    }