List of usage examples for java.lang IllegalStateException printStackTrace
public void printStackTrace()
From source file:org.spirit.spring.handler.BotListAdminHandler.java
public Object onSubmit(HttpServletRequest request, HttpServletResponse response, Object form, BindException errors) {/*from ww w. j a v a 2 s. c om*/ BotListDocFileForm docFile = (BotListDocFileForm) form; // First process the given request and if // in generate mode, create the document if (request.getParameter("generate") != null) { this.processor.generate(); docFile.setViewName("botlistadmin/secure/extreme/docwrite/confirm"); return form; } // Upload document file BotListDocFileMetadata metadata = null; String content = null; if (errors.getErrorCount() > 0) { return form; } try { metadata = uploadDocFile(request, form); if (docFile.getUploadFilenameFirst() != null) { content = new String(docFile.getUploadFilenameFirst().getBytes()); } } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } BotListDocFile newDocFileBean = transformData(docFile, metadata, content); BotListDocFileDAO dao = this.controller.getDocFileDao(); dao.createDocFile(newDocFileBean); docFile.setViewName("botlistadmin/secure/extreme/docwrite/confirm"); return form; }
From source file:app.android.auto.net.sampleapp.oauth.blackwork.EasyHttpClient.java
/** * Make a get request to the specified url * @param url//from w ww . j a va 2 s . c o m * @return the response string, null if there was an error */ public String get(String url) { HttpGet getReq = new HttpGet(url); InputStream content = null; try { content = execute(getReq).getEntity().getContent(); ByteArrayOutputStream bout = new ByteArrayOutputStream(); byte[] buf = new byte[1024]; int len; while ((len = content.read(buf)) > 0) { bout.write(buf, 0, len); } content.close(); return bout.toString(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:com.jana.android.net.AbstractHttpConnection.java
protected void connect(HttpRequestBase httpMethod) { try {// w w w . ja v a 2s.c om httpResponse = sHttpClient.execute(httpMethod, httpContext); } catch (IllegalStateException e) { Logger.w("Invalid url, Error > " + e.getMessage()); e.printStackTrace(); } catch (ClientProtocolException e) { Logger.w("HTTP Protocol Error > " + e.getMessage()); e.printStackTrace(); } catch (IOException e) { Logger.w("IO Error > " + e.getMessage()); e.printStackTrace(); } }
From source file:com.oneteam.framework.android.net.AbstractHttpConnection.java
@Override public InputStream getContent() { if (!hasConnection()) { return null; }/* w ww . ja v a 2 s.c o m*/ HttpEntity httpEntity = mHttpResponse.getEntity(); try { InputStream in = httpEntity.getContent(); return in; } catch (IllegalStateException e) { Logger.w("No stream content as it has already been obtained, Error > " + e.getMessage()); e.printStackTrace(); return null; } catch (IOException e) { Logger.w("No stream content as stream could not be created, Error > " + e.getMessage()); e.printStackTrace(); return null; } }
From source file:biz.wolschon.fileformats.gnucash.jwsdpimpl.GnucashAccountImpl.java
/** * @see biz.wolschon.fileformats.gnucash.GnucashAccount#addTransactionSplit(biz.wolschon.fileformats.gnucash.GnucashTransactionSplit) *///from w ww . ja v a2 s . c om public void addTransactionSplit(final GnucashTransactionSplit split) { GnucashTransactionSplit old = getTransactionSplitByID(split.getId()); if (old != null) { if (old != split) { IllegalStateException ex = new IllegalStateException("DEBUG"); ex.printStackTrace(); replaceTransactionSplit(old, split); } } else { mySplits.add(split); mySplitsNeedSorting = true; } }
From source file:it.drwolf.ridire.session.async.callable.CorpusCreator.java
public IndexingResult call() { IndexingResult indexingResult = new IndexingResult(); Lifecycle.beginCall();/*from w w w . j a v a 2 s .c o m*/ try { this.contextsIndexManager = (ContextsIndexManager) Component.getInstance("contextsIndexManager"); this.contextsIndexManager.closeIndexWriter(); this.contextsIndexManager.getIndexSearcherW().getIndexReader().close(); this.entityManager = (EntityManager) Component.getInstance("entityManager"); this.userTx = (UserTransaction) org.jboss.seam.Component .getInstance("org.jboss.seam.transaction.transaction"); this.userTx.setTransactionTimeout(10 * 10 * 60); int jobsToAdd = 0; for (int i = 0; i < this.indexedJobs.size(); i++) { if (this.indexedJobs.get(i).isSelectedForCorpusCreation()) { this.setCurrentJob(this.indexedJobs.get(i)); if (!this.indexedJobs.get(i).isExternal()) { if (!this.userTx.isActive()) { this.userTx.begin(); } this.entityManager.joinTransaction(); this.totResources += (Long) this.entityManager.createQuery( "select count(cr.id) from CrawledResource cr where cr.deleted is false and cr.job.id=:jId and cr.wordsNumber>0") .setParameter("jId", this.indexedJobs.get(i).getId()).getSingleResult(); this.entityManager.flush(); this.entityManager.clear(); this.userTx.commit(); ++jobsToAdd; } else { this.totResources += this.contextsIndexManager .getResourcesNumberOfJob(this.indexedJobs.get(i).getName()); } } } System.out.println("Adding job to corpus; total resources " + this.totResources); int addedJobs = 0; for (int i = 0; i < this.indexedJobs.size(); i++) { SelectableJob selectableJob = this.indexedJobs.get(i); if (selectableJob.isSelectedForCorpusCreation()) { if (!this.userTx.isActive()) { this.userTx.begin(); } System.out.println("Adding job " + addedJobs + " of " + jobsToAdd); this.entityManager.joinTransaction(); Job j = this.entityManager.find(Job.class, selectableJob.getId()); this.setCurrentJob(selectableJob); this.entityManager.flush(); this.entityManager.clear(); this.userTx.commit(); for (int k = 0; k < this.totResources; k += CorpusCreator.MAXRESULTS) { if (!this.userTx.isActive()) { this.userTx.begin(); } this.entityManager.joinTransaction(); List<CrawledResource> crawledResources = this.entityManager.createQuery( "from CrawledResource cr where cr.deleted is false and cr.job=:j and cr.wordsNumber>0") .setParameter("j", j).setFirstResult(k).setMaxResults(CorpusCreator.MAXRESULTS) .getResultList(); for (CrawledResource cr : crawledResources) { this.contextsIndexManager.addResourceToCorpus(cr, this.corpusNames, false); ++this.indexedResource; } this.entityManager.flush(); this.entityManager.clear(); this.userTx.commit(); System.out.println("Adding job; resource " + k + " of " + this.totResources); } this.contextsIndexManager.closeIndexWriter(); ++addedJobs; } } } catch (Exception e) { 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(); } } Lifecycle.endCall(); this.setTerminated(true); return indexingResult; }
From source file:org.ptlug.ptwifiauth.UserSession.java
public String getHtmlContent() { InputStream is;/* ww w . j av a2s . co m*/ HttpEntity entity = this.last_response.getEntity(); try { is = entity.getContent(); BufferedReader rd = new BufferedReader(new InputStreamReader(is)); String line; StringBuffer responsestr = new StringBuffer(); while ((line = rd.readLine()) != null) { responsestr.append(line); responsestr.append('\r'); } rd.close(); return responsestr.toString(); } catch (IllegalStateException e) { e.printStackTrace(); return null; } catch (IOException e) { e.printStackTrace(); return null; } }
From source file:io.hawkcd.agent.services.FileManagementService.java
@Override public List<File> getFiles(String rootPath, String wildCardPattern) { List<File> allFiles = new ArrayList<>(); File file = new File(rootPath); if (file.isFile()) { allFiles.add(file);/* www. j ava2 s . co m*/ return allFiles; } if (!wildCardPattern.equals("")) { rootPath = rootPath.replace(wildCardPattern, ""); } DirectoryScanner scanner = new DirectoryScanner(); try { scanner.setBasedir(rootPath); scanner.setIncludes(new String[] { wildCardPattern }); scanner.scan(); } catch (IllegalStateException e) { e.printStackTrace(); } if (wildCardPattern.equals("**")) { File directory = scanner.getBasedir(); allFiles.add(directory); return allFiles; } String[] files = scanner.getIncludedFiles(); for (String f : files) { allFiles.add(new File(rootPath, f)); } return allFiles; }
From source file:it.drwolf.ridire.util.fixingpos.AsyncPosFixer.java
@SuppressWarnings("unchecked") @Asynchronous//from w ww .jav a 2 s .c om public void doAsyncFix(PosFixerData posFixerData) { StrTokenizer strTokenizer = new StrTokenizer("\t"); File destDir = new File(posFixerData.getDestDir()); File reverseDestDir = new File(posFixerData.getReverseDestDir()); if (!destDir.exists() || !destDir.isDirectory() || !reverseDestDir.exists() || !reverseDestDir.isDirectory()) { System.err.println("Not valid destination folder."); return; } this.ridireReTagger = new RIDIREReTagger(null); try { this.entityManager = (EntityManager) Component.getInstance("entityManager"); this.userTx = (UserTransaction) org.jboss.seam.Component .getInstance("org.jboss.seam.transaction.transaction"); this.userTx.setTransactionTimeout(1000 * 10 * 60); if (!this.userTx.isActive()) { this.userTx.begin(); } this.entityManager.joinTransaction(); String treeTaggerBin = this.entityManager .find(CommandParameter.class, CommandParameter.TREETAGGER_EXECUTABLE_KEY).getCommandValue(); this.ridireReTagger.setTreetaggerBin(treeTaggerBin); this.entityManager.flush(); this.entityManager.clear(); this.userTx.commit(); List<String> lines = FileUtils.readLines(new File(posFixerData.getFile())); int count = 0; for (String l : lines) { if (l == null || l.trim().length() < 1) { continue; } String digest = l.replaceAll("\\./", "").replaceAll("\\.vrt", ""); if (!this.userTx.isActive()) { this.userTx.begin(); } this.entityManager.joinTransaction(); List<CrawledResource> crs = this.entityManager .createQuery("from CrawledResource cr where cr.digest=:digest") .setParameter("digest", digest).getResultList(); if (crs.size() != 1) { System.err.println("PosFixer: " + l + " resource not found."); } else { CrawledResource cr = crs.get(0); String origFile = FilenameUtils.getFullPath(cr.getArcFile()) .concat(JobMapperMonitor.RESOURCESDIR).concat(digest.concat(".txt")); File toBeRetagged = new File(origFile); if (toBeRetagged.exists() && toBeRetagged.canRead()) { String retaggedFile = this.ridireReTagger.retagFile(toBeRetagged); int wordsNumber = this.wordCounter.countWordsFromPoSTagResource(new File(retaggedFile)); cr.setWordsNumber(wordsNumber); this.entityManager.persist(cr); this.vrtFilesBuilder.createVRTFile(retaggedFile, strTokenizer, cr, destDir); String vrtFileName = destDir + System.getProperty("file.separator") + digest + ".vrt"; File vrtFile = new File(vrtFileName); this.vrtFilesBuilder.reverseFile(reverseDestDir, vrtFile); } } this.userTx.commit(); System.out.println(" Processed " + (++count) + " of " + lines.size()); } } catch (SystemException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NotSupportedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (RollbackException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (HeuristicMixedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (HeuristicRollbackException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException 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(); } } }
From source file:com.nolanofra.test.lazyLoader.MainActivity.java
public String executeGet(String url) { int timeout = 5000; HttpGet get;// w w w .j a v a 2s.c o m InputStream instream; HttpParams httpParameters = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParameters, timeout); HttpClient client = new DefaultHttpClient(); String jsonText = ""; get = new HttpGet(url); HttpResponse response = null; instream = null; try { try { response = client.execute(get); } catch (ClientProtocolException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } int status = response.getStatusLine().getStatusCode(); if (status == HttpStatus.SC_OK) { HttpEntity entity = response.getEntity(); try { instream = entity.getContent(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } jsonText = convertStreamToString(instream); } } catch (Exception e) { } return jsonText; }