List of usage examples for org.springframework.http HttpStatus UNAUTHORIZED
HttpStatus UNAUTHORIZED
To view the source code for org.springframework.http HttpStatus UNAUTHORIZED.
Click Source Link
From source file:pl.edu.pw.eiti.groupbuying.partner.android.ClaimCouponsActivity.java
@Override public void onTaskFinished(AbstractGroupBuyingTask<?> task, TaskResult result) { FragmentManager manager = getSupportFragmentManager(); manager.popBackStackImmediate();// w ww. j a v a2 s. com if (result.equals(TaskResult.SUCCESSFUL)) { couponInfo = null; showFragment(OPTIONS, false); ClaimResponse claimResponse = ((ClaimCouponTask) task).getClaimResponse(); switch (claimResponse) { case CLAIMED: Toast.makeText(getApplicationContext(), "Coupon claimed successfully!", Toast.LENGTH_LONG).show(); break; case ALREADY_USED: Toast.makeText(getApplicationContext(), "Coupon already used!", Toast.LENGTH_LONG).show(); break; case EXPIRED: Toast.makeText(getApplicationContext(), "Coupon expired!", Toast.LENGTH_LONG).show(); break; } } else if (result.equals(TaskResult.FAILED)) { Exception e = task.getException(); if (e instanceof HttpClientErrorException) { HttpClientErrorException httpError = (HttpClientErrorException) e; if (httpError.getStatusCode() == HttpStatus.UNAUTHORIZED) { getApplicationContext().getConnectionRepository() .removeConnections(getApplicationContext().getConnectionFactory().getProviderId()); showFragment(SIGN_IN, true); } } else if (e instanceof ExpiredAuthorizationException) { getApplicationContext().getConnectionRepository() .removeConnections(getApplicationContext().getConnectionFactory().getProviderId()); showFragment(SIGN_IN, true); } else if (e instanceof ResourceAccessException) { Throwable t = ((ResourceAccessException) e).getRootCause(); if (t != null && t instanceof ApiErrorException) { ApiErrorException apiErrorException = (ApiErrorException) t; switch (apiErrorException.getApiError().getErrorCode()) { case INVALID_SECURITY_KEY: Toast.makeText(getApplicationContext(), "Invalid security key.", Toast.LENGTH_LONG).show(); break; case COUPON_NOT_FOUND: Toast.makeText(getApplicationContext(), "Invalid coupon ID.", Toast.LENGTH_LONG).show(); break; case INVALID_PARTNER: Toast.makeText(getApplicationContext(), "Another partner's coupon.", Toast.LENGTH_LONG) .show(); break; default: Toast.makeText(getApplicationContext(), apiErrorException.getApiError().getErrorMessage(), Toast.LENGTH_LONG).show(); break; } couponInfo = null; showFragment(OPTIONS, false); } else { showFragment(NO_INTERNET, true); } } else { Log.e(TAG, "Unknown error: " + e.getLocalizedMessage()); Toast.makeText(getApplicationContext(), "Unknown error occurred. Please try again later.", Toast.LENGTH_LONG).show(); couponInfo = null; showFragment(OPTIONS, false); } } }
From source file:software.coolstuff.springframework.owncloud.service.impl.rest.OwncloudRestResourceServiceTest.java
@Override protected void prepare_getOutputStream_NOK_Unauthorized(OwncloudTestFileResourceImpl owncloudFileResource) throws Exception { mockServer.expect(requestToWithPrefix(owncloudFileResource.getHref())).andExpect(method(HttpMethod.PUT)) .andExpect(header(HttpHeaders.AUTHORIZATION, getBasicAuthorizationHeader())) .andExpect(header(HttpHeaders.CONNECTION, "keep-alive")) .andExpect(content().contentType(owncloudFileResource.getMediaType())) .andExpect(content().bytes(new byte[] { 1 })).andRespond(withStatus(HttpStatus.UNAUTHORIZED)); }
From source file:software.coolstuff.springframework.owncloud.service.impl.rest.OwncloudRestResourceServiceTest.java
@Override protected void prepare_deleteFile_NOK_OtherError(OwncloudTestFileResourceImpl owncloudFileResource) throws Exception { mockServer.expect(requestToWithPrefix(owncloudFileResource.getHref())).andExpect(method(HttpMethod.DELETE)) .andExpect(header(HttpHeaders.AUTHORIZATION, getBasicAuthorizationHeader())) .andRespond(withStatus(HttpStatus.UNAUTHORIZED)); }