Java Code Examples for javax.net.ssl.HttpsURLConnection#HTTP_NOT_FOUND
The following examples show how to use
javax.net.ssl.HttpsURLConnection#HTTP_NOT_FOUND .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomHandler.java From tomee with Apache License 2.0 | 6 votes |
@Override public void handleMessage(final Message message) throws Fault { if (isResponseAlreadyHandled(message)) { return; } final MessageContentsList objs = MessageContentsList.getContentsList(message); if (objs == null || objs.isEmpty()) { return; } final Object responseObj = objs.get(0); if (Response.class.isInstance(responseObj)) { final Response response = Response.class.cast(responseObj); if (is404(message, response)) { switchResponse(message); } } else { final Object exchangeStatus = message.getExchange().get(Message.RESPONSE_CODE); final int status = exchangeStatus != null ? Integer.class.cast(exchangeStatus) : HttpsURLConnection.HTTP_OK; if (status == HttpsURLConnection.HTTP_NOT_FOUND) { switchResponse(message); } } }
Example 2
Source File: BasePresenter.java From android-mvp-interactor-architecture with Apache License 2.0 | 4 votes |
@Override public void handleApiError(ANError error) { if (error == null || error.getErrorBody() == null) { getMvpView().onError(R.string.api_default_error); return; } if (error.getErrorCode() == AppConstants.API_STATUS_CODE_LOCAL_ERROR && error.getErrorDetail().equals(ANConstants.CONNECTION_ERROR)) { getMvpView().onError(R.string.connection_error); return; } if (error.getErrorCode() == AppConstants.API_STATUS_CODE_LOCAL_ERROR && error.getErrorDetail().equals(ANConstants.REQUEST_CANCELLED_ERROR)) { getMvpView().onError(R.string.api_retry_error); return; } final GsonBuilder builder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation(); final Gson gson = builder.create(); try { ApiError apiError = gson.fromJson(error.getErrorBody(), ApiError.class); if (apiError == null || apiError.getMessage() == null) { getMvpView().onError(R.string.api_default_error); return; } switch (error.getErrorCode()) { case HttpsURLConnection.HTTP_UNAUTHORIZED: case HttpsURLConnection.HTTP_FORBIDDEN: setUserAsLoggedOut(); getMvpView().openActivityOnTokenExpire(); case HttpsURLConnection.HTTP_INTERNAL_ERROR: case HttpsURLConnection.HTTP_NOT_FOUND: default: getMvpView().onError(apiError.getMessage()); } } catch (JsonSyntaxException | NullPointerException e) { Log.e(TAG, "handleApiError", e); getMvpView().onError(R.string.api_default_error); } }
Example 3
Source File: BasePresenter.java From android-mvp-architecture with Apache License 2.0 | 4 votes |
@Override public void handleApiError(ANError error) { if (error == null || error.getErrorBody() == null) { getMvpView().onError(R.string.api_default_error); return; } if (error.getErrorCode() == AppConstants.API_STATUS_CODE_LOCAL_ERROR && error.getErrorDetail().equals(ANConstants.CONNECTION_ERROR)) { getMvpView().onError(R.string.connection_error); return; } if (error.getErrorCode() == AppConstants.API_STATUS_CODE_LOCAL_ERROR && error.getErrorDetail().equals(ANConstants.REQUEST_CANCELLED_ERROR)) { getMvpView().onError(R.string.api_retry_error); return; } final GsonBuilder builder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation(); final Gson gson = builder.create(); try { ApiError apiError = gson.fromJson(error.getErrorBody(), ApiError.class); if (apiError == null || apiError.getMessage() == null) { getMvpView().onError(R.string.api_default_error); return; } switch (error.getErrorCode()) { case HttpsURLConnection.HTTP_UNAUTHORIZED: case HttpsURLConnection.HTTP_FORBIDDEN: setUserAsLoggedOut(); getMvpView().openActivityOnTokenExpire(); case HttpsURLConnection.HTTP_INTERNAL_ERROR: case HttpsURLConnection.HTTP_NOT_FOUND: default: getMvpView().onError(apiError.getMessage()); } } catch (JsonSyntaxException | NullPointerException e) { Log.e(TAG, "handleApiError", e); getMvpView().onError(R.string.api_default_error); } }
Example 4
Source File: CustomHandler.java From tomee with Apache License 2.0 | 4 votes |
private boolean is404(final Message message, final Response response) { return response.getStatus() == HttpsURLConnection.HTTP_NOT_FOUND && message.getExchange().get(JAXRSUtils.EXCEPTION_FROM_MAPPER) == null; }