List of usage examples for java.lang IllegalStateException printStackTrace
public void printStackTrace()
From source file:net.ausgstecktis.DAL.OnlineProxy.java
private void prepareRestClientAndCallWebServiceWithGET(final String service) { if (currentRestClient == null) currentRestClient = new RestClient(service); if (!currentRestClient.getService().equals(service)) currentRestClient.setService(service); try {// w w w .j av a 2 s . c o m currentRestClient.callWebService(RestClient.GET); } catch (final IllegalStateException e1) { e1.printStackTrace(); } catch (final ClientProtocolException e1) { e1.printStackTrace(); } catch (final IOException e1) { e1.printStackTrace(); } }
From source file:net.ausgstecktis.DAL.OnlineProxy.java
@SuppressWarnings("unused") private void prepareRestClientAndCallWebServiceWithPOST(final String service) { if (currentRestClient == null) currentRestClient = new RestClient(service); if (!currentRestClient.getService().equals(service)) currentRestClient.setService(service); try {//from w ww . j a v a 2 s. c om currentRestClient.callWebService(RestClient.POST); } catch (final IllegalStateException e1) { e1.printStackTrace(); } catch (final ClientProtocolException e1) { e1.printStackTrace(); } catch (final IOException e1) { e1.printStackTrace(); } }
From source file:ca.cs.ualberta.localpost.view.MapsView.java
/** * Arraylist of comments are sent to be displayed as markers on map * @param commentThread/* w w w . j a va2 s.co m*/ */ @SuppressLint("SimpleDateFormat") private void markerThreadView(ArrayList<String> commentThread) { // Counter var and a date format one int i; SimpleDateFormat format = new SimpleDateFormat("HH:mm MM/dd/yy"); // Clear all markers on map googleMap.clear(); RootCommentModel fromJson = gson.fromJson(commentThread.get(0), RootCommentModel.class); // ArrayList of markers final List<Marker> mMarker = new ArrayList<Marker>(); latLng = new LatLng(fromJson.getAddress().getLatitude(), fromJson.getAddress().getLongitude()); // Store the location of the Top level comment for zooming purposes LatLng rootLocation = latLng; mMarker.add(googleMap.addMarker(new MarkerOptions().position(latLng) .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)) .title(fromJson.getContent() + " @ " + format.format(new Date(fromJson.getTimestamp()))))); LatLngBounds.Builder mapBounds = LatLngBounds.builder(); mapBounds = mapBounds.include(rootLocation); for (i = 1; i < commentThread.size(); i++) { RootCommentModel comment = gson.fromJson(commentThread.get(i), RootCommentModel.class); address = comment.getAddress(); // Creating an instance of GeoPoint, to display in Google Map latLng = new LatLng(address.getLatitude(), address.getLongitude()); mapBounds.include(latLng); mMarker.add(googleMap.addMarker(new MarkerOptions().position(latLng) .title(comment.getAuthor() + " @ " + format.format(new Date(comment.getTimestamp()))))); } LatLngBounds bounds = mapBounds.build(); // Calculates where all markers would be and positions camera appropriately. // Source: http://stackoverflow.com/a/17825157 try { googleMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 50)); //This line will cause the exception first times when map is still not "inflated" System.out.println("Set with padding"); } catch (IllegalStateException e) { e.printStackTrace(); googleMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 400, 400, 0)); System.out.println("Set with wh"); } }
From source file:edu.chl.dat255.sofiase.readyforapet.viewcontroller.PetActivity.java
/** * Pauses the music when exiting activity * /*from w w w .j a v a 2 s .c o m*/ */ @Override protected void onStop() { super.onStop(); player.stop(); try { player.prepare(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.cimmyt.csv.FileManagerCSVImpl.java
/** * Method that load file in different type of browser * @param media//from w w w. j a va 2s .c o m * @return */ private Reader getReader(Media media) { Reader reader = null; try { reader = new InputStreamReader(IOUtils.toInputStream(media.getStringData())); return reader; } catch (IllegalStateException ex) { logger.error(ex.getMessage()); } try { reader = media.getReaderData(); return reader; } catch (IllegalStateException ex) { logger.error(ex.getMessage()); ; } try { reader = new InputStreamReader(media.getStreamData()); return reader; } catch (IllegalStateException ex) { ex.printStackTrace(); } return reader; }
From source file:mydropbox.MyDropboxSwing.java
public void loadXMLDoc() { if (cursor.getTid() * cursor.getIndex() == 0) { DownloadService download = new DownloadService(); XmlFactory xmlFactory = new XmlFactory(); try {// w w w. jav a 2 s . c om Document doc = download.getServer(); xmlFactory.saveFileXml(doc, Constants.INDEXXML); dom = new DomRepresentation(); dom.setDocument(doc); } catch (IllegalStateException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException ex) { Logger.getLogger(MyDropboxSwing.class.getName()).log(Level.SEVERE, null, ex); } } else { File index = new File(Constants.INDEXXML); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); //Load file index try { DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.parse(index); dom = new DomRepresentation(); dom.setDocument(doc); } catch (ParserConfigurationException | SAXException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { DownloadService download = new DownloadService(); try { Document doc = download.getServer(); dom = new DomRepresentation(); dom.setDocument(doc); } catch (IllegalStateException | IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } //Kiem tra thu muc moi, them cac file moi, file bi xoa vao list commit } }
From source file:org.dasein.cloud.terremark.TerremarkMethod.java
public Document invoke(boolean debug) throws TerremarkException, CloudException, InternalException { if (logger.isTraceEnabled()) { logger.trace("ENTER - " + TerremarkMethod.class.getName() + ".invoke(" + debug + ")"); }/* w w w.j a v a2 s. co m*/ try { if (logger.isDebugEnabled()) { logger.debug("Talking to server at " + url); } if (parameters != null) { URIBuilder uri = null; try { uri = new URIBuilder(url); } catch (URISyntaxException e) { e.printStackTrace(); } for (NameValuePair parameter : parameters) { uri.addParameter(parameter.getName(), parameter.getValue()); } url = uri.toString(); } HttpUriRequest method = null; if (methodType.equals(HttpMethodName.GET)) { method = new HttpGet(url); } else if (methodType.equals(HttpMethodName.POST)) { method = new HttpPost(url); } else if (methodType.equals(HttpMethodName.DELETE)) { method = new HttpDelete(url); } else if (methodType.equals(HttpMethodName.PUT)) { method = new HttpPut(url); } else if (methodType.equals(HttpMethodName.HEAD)) { method = new HttpHead(url); } else { method = new HttpGet(url); } HttpResponse status = null; try { HttpClient client = new DefaultHttpClient(); HttpParams params = new BasicHttpParams(); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); HttpProtocolParams.setContentCharset(params, "UTF-8"); HttpProtocolParams.setUserAgent(params, "Dasein Cloud"); attempts++; String proxyHost = provider.getProxyHost(); if (proxyHost != null) { int proxyPort = provider.getProxyPort(); boolean ssl = url.startsWith("https"); params.setParameter(ConnRoutePNames.DEFAULT_PROXY, new HttpHost(proxyHost, proxyPort, ssl ? "https" : "http")); } for (Map.Entry<String, String> entry : headers.entrySet()) { method.addHeader(entry.getKey(), entry.getValue()); } if (body != null && body != "" && (methodType.equals(HttpMethodName.PUT) || methodType.equals(HttpMethodName.POST))) { try { HttpEntity entity = new StringEntity(body, "UTF-8"); ((HttpEntityEnclosingRequestBase) method).setEntity(entity); } catch (UnsupportedEncodingException e) { logger.warn(e); } } if (wire.isDebugEnabled()) { wire.debug(methodType.name() + " " + method.getURI()); for (Header header : method.getAllHeaders()) { wire.debug(header.getName() + ": " + header.getValue()); } if (body != null) { wire.debug(body); } } try { status = client.execute(method); if (wire.isDebugEnabled()) { wire.debug("HTTP STATUS: " + status); } } catch (IOException e) { logger.error("I/O error from server communications: " + e.getMessage()); e.printStackTrace(); throw new InternalException(e); } int statusCode = status.getStatusLine().getStatusCode(); if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_CREATED || statusCode == HttpStatus.SC_ACCEPTED) { try { InputStream input = status.getEntity().getContent(); try { return parseResponse(input); } finally { input.close(); } } catch (IOException e) { logger.error("Error parsing response from Teremark: " + e.getMessage()); e.printStackTrace(); throw new CloudException(CloudErrorType.COMMUNICATION, statusCode, null, e.getMessage()); } } else if (statusCode == HttpStatus.SC_NO_CONTENT) { logger.debug("Recieved no content in response. Creating an empty doc."); DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = null; try { docBuilder = dbfac.newDocumentBuilder(); } catch (ParserConfigurationException e) { e.printStackTrace(); } return docBuilder.newDocument(); } else if (statusCode == HttpStatus.SC_FORBIDDEN) { String msg = "OperationNotAllowed "; try { msg += parseResponseToString(status.getEntity().getContent()); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } wire.error(msg); throw new TerremarkException(statusCode, "OperationNotAllowed", msg); } else { String response = "Failed to parse response."; ParsedError parsedError = null; try { response = parseResponseToString(status.getEntity().getContent()); parsedError = parseErrorResponse(response); } catch (IllegalStateException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } if (logger.isDebugEnabled()) { logger.debug("Received " + status + " from " + url); } if (statusCode == HttpStatus.SC_SERVICE_UNAVAILABLE || statusCode == HttpStatus.SC_INTERNAL_SERVER_ERROR) { if (attempts >= 5) { String msg; wire.warn(response); if (statusCode == HttpStatus.SC_SERVICE_UNAVAILABLE) { msg = "Cloud service is currently unavailable."; } else { msg = "The cloud service encountered a server error while processing your request."; try { msg = msg + "Response from server was:\n" + response; } catch (RuntimeException runException) { logger.warn(runException); } catch (Error error) { logger.warn(error); } } wire.error(response); logger.error(msg); if (parsedError != null) { throw new TerremarkException(parsedError); } else { throw new CloudException("HTTP Status " + statusCode + msg); } } else { try { Thread.sleep(5000L); } catch (InterruptedException e) { /* ignore */ } return invoke(); } } wire.error(response); if (parsedError != null) { throw new TerremarkException(parsedError); } else { String msg = "\nResponse from server was:\n" + response; logger.error(msg); throw new CloudException("HTTP Status " + statusCode + msg); } } } finally { try { if (status != null) { EntityUtils.consume(status.getEntity()); } } catch (IOException e) { e.printStackTrace(); } } } finally { if (logger.isTraceEnabled()) { logger.trace("EXIT - " + TerremarkMethod.class.getName() + ".invoke()"); } } }
From source file:com.sxt.superqq.activity.LoginActivity.java
/** * ??//from www . ja v a 2 s . c o m * @param currentUsername? * @param currentPassword? * @return */ private boolean loginAppServer(String currentUsername, String currentPassword) { UserDao dao = new UserDao(this); UserBean user = dao.findUserByUserName(currentUsername); if (user != null) {//?? if (user.getPassword().equals(MD5.getData(currentPassword))) { saveUser(user); return true; } } //? try { user = NetUtils.login(currentUsername, currentPassword); saveUser(user); user.setPassword(MD5.getData(user.getPassword())); dao.addUser(user); return true; } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return false; }
From source file:com.clemot.julian.easylib.EasyActivity.java
public void replaceFragment(Fragment lastFrag, final Fragment frag, int id, boolean backStack, Pair<View, String>... sharedElements) { FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(id, frag, frag.getClass().getName()); // An optional name for this back stack state, or null. if (backStack) { fragmentTransaction.addToBackStack(null); }/*from ww w . j a v a 2s . c o m*/ fragmentTransaction = addTransitions(fragmentTransaction, lastFrag, frag, sharedElements); fragmentTransaction.commit(); try { fragmentManager.executePendingTransactions(); } catch (IllegalStateException iSe) { Log.e("MultiFrag", "Handle crash:" + iSe.getStackTrace()); iSe.printStackTrace(); } }
From source file:it.drwolf.ridire.index.sketch.SketchCreator.java
@Asynchronous public void createSketches(SketchCreatorData sketchCreatorData) { this.entityManager = (EntityManager) Component.getInstance("entityManager"); this.userTx = (UserTransaction) org.jboss.seam.Component .getInstance("org.jboss.seam.transaction.transaction"); try {/*from w w w . jav a 2s. co m*/ this.userTx.setTransactionTimeout(1000 * 10 * 60); if (!this.userTx.isActive()) { this.userTx.begin(); } this.entityManager.joinTransaction(); String cqpExecutable = this.entityManager.find(Parameter.class, Parameter.CQP_EXECUTABLE.getKey()) .getValue(); String cqpRegistry = this.entityManager.find(Parameter.class, Parameter.CQP_REGISTRY.getKey()) .getValue(); String cqpCorpusName = this.entityManager .find(Parameter.class, Parameter.CQP_CORPUSNAME_FOR_SKETCHES.getKey()).getValue(); LocalResourcesManager localResourcesManager = (LocalResourcesManager) Component .getInstance("localResourcesManager"); AsyncSketchCreator asyncSketchCreator = (AsyncSketchCreator) Component .getInstance("asyncSketchCreator"); Set<String> functionalMetadata = localResourcesManager.getAllFunctionalMetadataMap().keySet(); Set<String> semanticMetadata = localResourcesManager.getAllSemanticMetadataMap().keySet(); Map<String, List<String>> toBeProcessed = new HashMap<String, List<String>>(); for (String pos : SketchCreator.POSS) { toBeProcessed.put(pos, this.getToBeProcessed(pos, sketchCreatorData.getIndexWriter(), functionalMetadata, semanticMetadata, sketchCreatorData.getWorkingDir())); } for (String pos : SketchCreator.POSS) { this.processList(cqpExecutable, cqpRegistry, cqpCorpusName, toBeProcessed.get(pos), pos, sketchCreatorData, asyncSketchCreator); } } catch (SystemException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NotSupportedException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { try { if (this.userTx != null && this.userTx.isActive()) { this.userTx.rollback(); } } catch (IllegalStateException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (SecurityException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (SystemException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }