Package com.uip.tatar

Examples of com.uip.tatar.APITatarException


                    instream = new GZIPInputStream(instream);

                loadData(instream);
            }
        } catch (IOException exception) {
            throw new APITatarException(exception, response);
        }
    }
View Full Code Here


            try {
                while ((line = br.readLine()) != null) {
                    sb.append(line);
                }
            }  catch (IOException exception) {
                throw new APITatarException(exception, response);
            } finally {
                try {
                    br.close();
                } catch (IOException ignore) {/*ignore*/}
            }
View Full Code Here

            HttpConnectionParams.setSoTimeout(httpParameters, TIMEOUT_SOCKET);
            HttpConnectionParams.setConnectionTimeout(httpParameters, TIMEOUT_CONNECTION);
            org.apache.http.client.HttpClient httpClient = new DefaultHttpClient(httpParameters);
            mHttpResponse = httpClient.execute(httpRequest);
        } catch (IOException exception) {
            throw new APITatarException(exception);
        }
    }
View Full Code Here

            this.authorization = authorization;
        }

        @Override
        public APITatarException createException(APITatarResponse response) {
            APITatarException exception = super.createException(response);
            if(exception instanceof UnauthorizationException) {
                try {
                    this.authorization.updateSession();
                    return new NeedRetryRequestException();
                } catch (APITatarException e) {
View Full Code Here

                break;
            case PUT:
                mHttpClient.put(mRequestUrl, request.getContent(), request.getHeaders());
                break;
            default:
                throw new APITatarException("Unsupported HTTP method");
        }


        final APITatarResponse response = new APITatarResponse(mHttpClient.getResponse());

        if(isDebug) {
            System.out.println(response);
        }

        if(checkHttpStatus(mHttpClient.getResponseStatus())) {
            try {
                return (handler != null) ? handler.handleResult(response) : null;
            } catch (Exception jex) {
                throw new APITatarException(ERROR_WRONG_SERVER_RESPONSE);
            }
        } else {
            try {
                throw  errorHandler.createException(response);
            } catch (JSONException jsonexception) {
                throw new APITatarException(ERROR_WRONG_SERVER_RESPONSE);
            }
        }
    }
View Full Code Here

                JSONObject jsonResponse = new JSONObject(response.getData());
                if(jsonResponse.has("message")) {
                    if(jsonResponse.getString("message").equals("Invalid username or password")) {
                        return new APITatarWrongCredentialsException();
                    }
                    return new APITatarException(jsonResponse.getString("message"));
                } else if(jsonResponse.has("error") && jsonResponse.getJSONObject("error").has("type") && jsonResponse.getJSONObject("error").getString("type").equals("api_user_authorization_failed")) {
                    return new APITatarUnauthorizationException();
                else if(jsonResponse.has("error") && jsonResponse.getJSONObject("error").has("message")) {
                    return new APITatarException(jsonResponse.getJSONObject("error").getString("message"));
                } else if(jsonResponse.has("status") && jsonResponse.getString("status").equals("Unauthorized"))  {
                    return new APITatarUnauthorizationException();
                } else {
                    return new APITatarException(response.getResponse());
                }
            } catch (JSONException exception) {
                return new APITatarException(response.getResponse());
            }
        }
View Full Code Here

TOP

Related Classes of com.uip.tatar.APITatarException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.