List of usage examples for java.lang IllegalStateException toString
public String toString()
From source file:com.alibaba.akita.io.HttpInvoker.java
/** * Vversion 2 remoteimageview download impl, use byte[] to decode. * Note: Recommanded to use this method instead of version 1. * NUM_RETRIES retry.//from w ww. j a v a 2 s . c o m * @param imgUrl * @param httpReferer http Referer * @return * @throws AkServerStatusException * @throws AkInvokeException */ public static Bitmap getBitmapFromUrl(String imgUrl, String httpReferer, ProgressBar progressBar) throws AkServerStatusException, AkInvokeException { imgUrl = imgUrl.trim(); Log.v(TAG, "getBitmapFromUrl:" + imgUrl); int timesTried = 1; while (timesTried <= NUM_RETRIES) { timesTried++; try { if (progressBar != null) { progressBar.setProgress(0); } HttpGet request = new HttpGet(imgUrl); if (httpReferer != null) request.addHeader("Referer", httpReferer); HttpResponse response = client.execute(request); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_CREATED || statusCode == HttpStatus.SC_ACCEPTED) { HttpEntity resEntity = response.getEntity(); InputStream inputStream = resEntity.getContent(); byte[] imgBytes = retrieveImageData(inputStream, (int) (resEntity.getContentLength()), progressBar); if (imgBytes == null) { SystemClock.sleep(DEFAULT_RETRY_SLEEP_TIME); continue; } Bitmap bm = null; try { bm = ImageUtil.decodeSampledBitmapFromByteArray(imgBytes, 0, imgBytes.length, 682, 682); } catch (OutOfMemoryError ooe) { Log.e(TAG, ooe.toString(), ooe); return null; // if oom, no need to retry. } if (bm == null) { SystemClock.sleep(DEFAULT_RETRY_SLEEP_TIME); continue; } return bm; } else { HttpEntity resEntity = response.getEntity(); throw new AkServerStatusException(response.getStatusLine().getStatusCode(), EntityUtils.toString(resEntity, CHARSET)); } } catch (ClientProtocolException cpe) { Log.e(TAG, cpe.toString(), cpe); throw new AkInvokeException(AkInvokeException.CODE_HTTP_PROTOCOL_ERROR, cpe.toString(), cpe); } catch (IOException ioe) { Log.e(TAG, ioe.toString(), ioe); throw new AkInvokeException(AkInvokeException.CODE_CONNECTION_ERROR, ioe.toString(), ioe); } catch (IllegalStateException ise) { Log.e(TAG, ise.toString(), ise); throw new AkInvokeException(AkInvokeException.CODE_TARGET_HOST_OR_URL_ERROR, ise.toString(), ise); } catch (IllegalArgumentException iae) { throw new AkInvokeException(AkInvokeException.CODE_TARGET_HOST_OR_URL_ERROR, iae.toString(), iae); } catch (Exception e) { throw new AkInvokeException(AkInvokeException.CODE_UNKOWN_ERROR, e.toString(), e); } } return null; }
From source file:com.freshplanet.ane.GoogleCloudStorageUpload.functions.UploadBinaryFileToServer.java
@Override public FREObject call(FREContext ctx, FREObject[] args) { Log.d(TAG, "[UploadImageToServer] Entering call()"); String localURL = null;//from www.jav a 2 s . com String uploadURL = null; JSONObject uploadParamsJSON = null; Log.d(TAG, "[UploadImageToServer] try catch()"); try { localURL = args[0].getAsString(); uploadURL = args[1].getAsString(); uploadParamsJSON = new JSONObject(args[2].getAsString()); Log.d(TAG, "[UploadImageToServer] localURL: " + localURL + " uploadURL: " + uploadURL + " uploadParamsJSON: " + uploadParamsJSON); } catch (IllegalStateException e) { Log.e(TAG, e.toString()); e.printStackTrace(); } catch (FRETypeMismatchException e) { Log.e(TAG, e.toString()); e.printStackTrace(); } catch (FREInvalidObjectException e) { Log.e(TAG, e.toString()); e.printStackTrace(); } catch (FREWrongThreadException e) { Log.e(TAG, e.toString()); e.printStackTrace(); } catch (JSONException e) { Log.e(TAG, e.toString()); e.printStackTrace(); } catch (Exception e) { Log.e(TAG, e.toString()); e.printStackTrace(); } if (localURL != null && uploadURL != null && uploadParamsJSON != null) { new UploadToGoogleCloudStorageAsyncTask(uploadParamsJSON, localURL).execute(uploadURL); } Log.d(TAG, "[UploadImageToServer] Exiting call()"); return null; }
From source file:com.freshplanet.ane.GoogleCloudStorageUpload.functions.UploadImageToServer.java
@Override public FREObject call(FREContext ctx, FREObject[] args) { Log.d(TAG, "[UploadImageToServer] Entering call()"); String localURL = null;/*from w ww . j av a 2 s . c om*/ String uploadURL = null; JSONObject uploadParamsJSON = null; int maxWidth = -1; int maxHeight = -1; Log.d(TAG, "[UploadImageToServer] try catch()"); try { localURL = args[0].getAsString(); uploadURL = args[1].getAsString(); uploadParamsJSON = new JSONObject(args[2].getAsString()); maxWidth = args[3].getAsInt(); maxHeight = args[4].getAsInt(); Log.d(TAG, "[UploadImageToServer] localURL: " + localURL + " uploadURL: " + uploadURL + " uploadParamsJSON: " + uploadParamsJSON); } catch (IllegalStateException e) { Log.e(TAG, e.toString()); e.printStackTrace(); } catch (FRETypeMismatchException e) { Log.e(TAG, e.toString()); e.printStackTrace(); } catch (FREInvalidObjectException e) { Log.e(TAG, e.toString()); e.printStackTrace(); } catch (FREWrongThreadException e) { Log.e(TAG, e.toString()); e.printStackTrace(); } catch (JSONException e) { Log.e(TAG, e.toString()); e.printStackTrace(); } catch (Exception e) { Log.e(TAG, e.toString()); e.printStackTrace(); } if (localURL != null && uploadURL != null && uploadParamsJSON != null) { new UploadToGoogleCloudStorageAsyncTask(uploadParamsJSON, localURL).setMaxImageSize(maxWidth, maxHeight) .execute(uploadURL); } Log.d(TAG, "[UploadImageToServer] Exiting call()"); return null; }
From source file:com.vmware.identity.BaseSsoController.java
/** * Core SSO request processing/*from w w w . j a v a2 s .c om*/ * * @param locale * User locale * @param tenant * Tenant name, not null (resolve default tenant name prior to * the call) * @param request * SSO request * @param response * Response object * @param authenticator * authenticator to use, will be different for different * controllers (Kerb, UNP etc.) * @param messageSource * message source to use * @param sessionManager * session manager to use * @return boolean if this is a new session, the function returns needLoginView = true. This allows * to send user a login view */ protected void processSsoRequest(Locale locale, String tenant, HttpServletRequest request, HttpServletResponse response, AuthenticationFilter<AuthnRequestState> authenticator, AuthnRequestState requestState, MessageSource messageSource, SessionManager sessionManager) { requestState.setLocal(locale); requestState.setMessageSource(messageSource); requestState.setNeedLoginView(false); //if this is a new session, the function returns needLoginView = true; try { try { requestState.parseRequestForTenant(tenant, authenticator); } catch (IllegalStateException e) { logger.error("Could not parse tenant request {}", e.toString()); } Document token = null; if (requestState.getValidationResult().isValid()) { token = requestState.authenticate(tenant, authenticator); // if proxying the request. We are in async state. // The response is handled in logonProcessor if (requestState.isProxying() && requestState.getValidationResult().isValid()) { return; } } ValidationResult vr = requestState.getValidationResult(); Validate.notNull(vr, "Null validation result."); requestState.addResponseHeaders(response); if (vr.needsLogonView()) { //Post login form requestState.setNeedLoginView(true); return; } SAMLResponseSenderFactory responseSenderFactory = new SAMLAuthnResponseSenderFactory(); SAMLResponseSender responseSender = responseSenderFactory.buildResponseSender(tenant, response, locale, null, //for IDP initiated, no relay state in post Response to SP requestState, requestState.getAuthnMethod(), requestState.getSessionId(), requestState.getPrincipalId(), messageSource, sessionManager); AuthnRequest authnReq = requestState.getAuthnRequest(); String rpID = authnReq == null ? null : authnReq.getIssuer().getValue(); //It is possible rpID is not available due to bad request message responseSender.sendResponseToRP(rpID, token); logger.info("End processing SP-Initiated SSO response. Session was created."); } catch (IOException e) { logger.error("Caught IO exception " + e.toString()); } }
From source file:com.grendelscan.proxy.ssl.TunneledSSLConnection.java
@Override public boolean isOpen() { try {//from w w w . j av a 2 s . co m assertOpen(); } catch (IllegalStateException e) { LOGGER.trace("Gently caught an unexpected close: " + e.toString(), e); } return open; }
From source file:mx.edu.ittepic.proyectofinal.ejbs.ejbContrasena.java
public String updateUserWithoutPassword(String userid, String username, String phone, String neigborhood, String zipcode, String city, String country, String state, String region, String street, String email, String streetnumber, String photo, String cellphone, String companyid, String roleid, String gender) { Message m = new Message(); Users r = new Users(); GsonBuilder builder = new GsonBuilder(); Gson gson = builder.create();/* ww w . java 2 s . c om*/ Company com = entity.find(Company.class, Integer.parseInt(companyid)); Role rol = entity.find(Role.class, Integer.parseInt(roleid)); try { Query q = entity.createNamedQuery("Users.updateUserWithoutPassword").setParameter("username", username) .setParameter("phone", phone).setParameter("neigborhood", neigborhood) .setParameter("zipcode", zipcode).setParameter("city", city).setParameter("country", country) .setParameter("state", state).setParameter("region", region).setParameter("street", street) .setParameter("email", email).setParameter("streetnumber", streetnumber) .setParameter("photo", photo).setParameter("cellphone", cellphone) .setParameter("companyid", com).setParameter("roleid", rol) .setParameter("gender", gender.charAt(0)).setParameter("userid", Integer.parseInt(userid)); if (q.executeUpdate() == 1) { m.setCode(200); m.setMsg("Se actualizo correctamente."); m.setDetail("OK"); } else { m.setCode(404); m.setMsg("No se realizo la actualizacion"); m.setDetail(""); } } catch (IllegalStateException e) { m.setCode(404); m.setMsg("No se realizo la actualizacion"); m.setDetail(e.toString()); } catch (TransactionRequiredException e) { m.setCode(404); m.setMsg("No se realizo la actualizacion"); m.setDetail(e.toString()); } catch (QueryTimeoutException e) { m.setCode(404); m.setMsg("No se realizo la actualizacion"); m.setDetail(e.toString()); } catch (PersistenceException e) { m.setCode(404); m.setMsg("No se realizo la actualizacion"); m.setDetail(e.toString()); } return gson.toJson(m); }
From source file:org.xwalk.extensions.iap.java
private void purchase(String skuId) { if (!inited() || skuId == null) return;//from w ww .j a va2 s .c o m try { mHelper.flagEndAsync(); mHelper.launchPurchaseFlow(mExtensionContext.getActivity(), skuId, RC_REQUEST, mPurchaseFinishedListener, ""); } catch (java.lang.IllegalStateException e) { Log.e(TAG, e.toString()); } }
From source file:mx.edu.ittepic.proyectofinal.ejbs.ejbContrasena.java
public String updateUserWithPassword(String userid, String username, String password, String phone, String neigborhood, String zipcode, String city, String country, String state, String region, String street, String email, String streetnumber, String photo, String cellphone, String companyid, String roleid, String gender) { Message m = new Message(); Users r = new Users(); GsonBuilder builder = new GsonBuilder(); Gson gson = builder.create();//w ww . j a va 2 s. c o m Company com = entity.find(Company.class, Integer.parseInt(companyid)); Role rol = entity.find(Role.class, Integer.parseInt(roleid)); try { Query q = entity.createNamedQuery("Users.updateUserWithPassword").setParameter("username", username) .setParameter("password", password).setParameter("phone", phone) .setParameter("neigborhood", neigborhood).setParameter("zipcode", zipcode) .setParameter("city", city).setParameter("country", country).setParameter("state", state) .setParameter("region", region).setParameter("street", street).setParameter("email", email) .setParameter("streetnumber", streetnumber).setParameter("photo", photo) .setParameter("cellphone", cellphone).setParameter("companyid", com).setParameter("roleid", rol) .setParameter("gender", gender.charAt(0)).setParameter("userid", Integer.parseInt(userid)); String pass = password; String passmd5 = DigestUtils.md5Hex(pass); Query a = entity.createNamedQuery("Users.updateUserWithPasswordE").setParameter("username", username) .setParameter("password", passmd5).setParameter("phone", phone) .setParameter("neigborhood", neigborhood).setParameter("zipcode", zipcode) .setParameter("city", city).setParameter("country", country).setParameter("state", state) .setParameter("region", region).setParameter("street", street).setParameter("email", email) .setParameter("streetnumber", streetnumber).setParameter("photo", photo) .setParameter("cellphone", cellphone).setParameter("companyid", com).setParameter("roleid", rol) .setParameter("gender", gender.charAt(0)).setParameter("userid", Integer.parseInt(userid)); if (q.executeUpdate() == 1 && a.executeUpdate() == 1) { m.setCode(200); m.setMsg("Se actualizo correctamente."); m.setDetail("OK"); } else { m.setCode(404); m.setMsg("No se realizo la actualizacion"); m.setDetail(""); } } catch (IllegalStateException e) { m.setCode(404); m.setMsg("No se realizo la actualizacion"); m.setDetail(e.toString()); } catch (TransactionRequiredException e) { m.setCode(404); m.setMsg("No se realizo la actualizacion"); m.setDetail(e.toString()); } catch (QueryTimeoutException e) { m.setCode(404); m.setMsg("No se realizo la actualizacion"); m.setDetail(e.toString()); } catch (PersistenceException e) { m.setCode(404); m.setMsg("No se realizo la actualizacion"); m.setDetail(e.toString()); } return gson.toJson(m); }
From source file:org.xwalk.extensions.iap.java
private void consume(Purchase purchase) { if (!inited() || purchase == null) return;//from ww w .j a v a2 s . c om // e.g. no need to call consume for IabHelper.ITEM_TYPE_SUBS if (purchase.getItemType() != IabHelper.ITEM_TYPE_INAPP) { return; } final Purchase p = purchase; mExtensionContext.getActivity().runOnUiThread(new Runnable() { public void run() { try { mHelper.flagEndAsync(); mHelper.consumeAsync(p, mConsumeFinishedListener); } catch (java.lang.IllegalStateException e) { Log.e(TAG, e.toString()); } } }); }
From source file:com.decody.android.core.json.JSONClient.java
private <T> T performCall(HttpRequestBase request, Class<T> classOfT) throws ResourceNotFoundException, UnauthorizedException { String url = request.getURI().toString(); T toReturn = null;/*from ww w. ja v a 2 s . com*/ Log.i(TAG, "Calling to get the resource in the url: " + url); try { HttpResponse response = client.execute(request); if (response.getStatusLine().getStatusCode() == HttpStatus.SC_NOT_FOUND) { Log.w(TAG, "Resource not found, throwing an exception"); throw new ResourceNotFoundException("Resource not found in " + url); } else if (response.getStatusLine().getStatusCode() == HttpStatus.SC_UNAUTHORIZED) { Log.w(TAG, "Not authorized to get the given resource"); throw new UnauthorizedException("Your user is not authorized to access to the resource: " + url); } else if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { Log.w(TAG, "Bad request from the server"); throw new UnauthorizedException("Bad request to the resource: " + url); } HttpEntity entity = response.getEntity(); Reader reader; reader = new InputStreamReader(entity.getContent()); toReturn = (T) factory.newInstance().fromJson(reader, classOfT); } catch (IllegalStateException e) { Log.e(TAG, "Unexpected illegal state reading the content from the given resource: " + e.toString()); throw new ResourceNotFoundException( "Unexpected illegal state reading the given resource: " + e.toString()); } catch (ClientProtocolException e) { Log.e(TAG, "Unexpected communication exception: " + e.toString()); throw new ResourceNotFoundException("Unexpected communication problem with the given resource"); } catch (IOException e) { Log.e(TAG, "Unexpected communication reading exception: " + e.toString()); throw new ResourceNotFoundException("Unexpected communication reading problem with the given resource"); } catch (JsonSyntaxException e) { Log.e(TAG, "Unexpected response received from the server: " + e.toString()); throw new ResourceNotFoundException("Unexpected response received"); } return toReturn; }