private QueryServiceResponse handlePostQueryResponse()

in asterixdb-jdbc/asterix-jdbc-driver/src/main/java/org/apache/asterix/jdbc/ADBProtocol.java [276:309]


    private QueryServiceResponse handlePostQueryResponse(CloseableHttpResponse httpResponse)
            throws SQLException, IOException {
        int httpStatus = httpResponse.getStatusLine().getStatusCode();
        switch (httpStatus) {
            case HttpStatus.SC_OK:
            case HttpStatus.SC_BAD_REQUEST:
            case HttpStatus.SC_INTERNAL_SERVER_ERROR:
            case HttpStatus.SC_SERVICE_UNAVAILABLE:
                break;
            case HttpStatus.SC_UNAUTHORIZED:
            case HttpStatus.SC_FORBIDDEN:
                throw getErrorReporter().errorAuth();
            default:
                throw getErrorReporter().errorInProtocol(httpResponse.getStatusLine().toString());
        }
        QueryServiceResponse response;
        try (InputStream contentStream = httpResponse.getEntity().getContent()) {
            response =
                    driverContext.getGenericObjectReader().forType(QueryServiceResponse.class).readValue(contentStream);
        }
        QueryServiceResponse.Status status = response.status;
        if (httpStatus == HttpStatus.SC_OK && status == QueryServiceResponse.Status.SUCCESS) {
            return response;
        }
        if (status == QueryServiceResponse.Status.TIMEOUT) {
            throw getErrorReporter().errorTimeout();
        }
        SQLException exc = getErrorIfExists(response);
        if (exc != null) {
            throw exc;
        } else {
            throw getErrorReporter().errorInProtocol(httpResponse.getStatusLine().toString());
        }
    }