List of usage examples for java.lang Exception getStackTrace
public StackTraceElement[] getStackTrace()
From source file:org.apache.jsp.sources_jsp.java
private void testSource(HttpServletRequest request, HttpServletResponse response) { int numDocs = 10; try {/* w w w. java2s .c om*/ numDocs = Integer.parseInt(numberOfDocuments); if (numDocs < 1 || numDocs > 10) numDocs = 10; } catch (Exception e) { numDocs = 10; } String apiAddress = "config/source/test?returnFullText=" + getFullText + "&numReturn=" + String.valueOf(numDocs) + "&testUpdates=" + getTestUpdateLogic; harvesterOutput = ""; messageToDisplay = ""; try { JSONObject jsonObject = new JSONObject(postToRestfulApi(apiAddress, sourceJson, request, response)); JSONObject JSONresponse = jsonObject.getJSONObject("response"); try { messageToDisplay = JSONresponse.getString("message"); if (jsonObject.has("data")) { JSONArray data = jsonObject.getJSONArray("data"); StringBuffer s = new StringBuffer(); for (int i = 0; i < data.length(); i++) { JSONObject jo = data.getJSONObject(i); s.append("\n"); s.append(jo.toString(4)); } harvesterOutput = s.toString(); } } catch (Exception ex) { messageToDisplay = "Test Result: " + JSONresponse.getString("message"); } if (harvesterOutput.length() < 1) harvesterOutput = " "; } catch (Exception e) { messageToDisplay = "Error: " + e.getMessage() + " " + e.getStackTrace().toString(); } }
From source file:com.atlauncher.data.Settings.java
/** * Logs a stack trace to the console window * * @param exception The exception to show in the console *//*from www. j a v a 2s . co m*/ public void logStackTrace(Exception exception) { exception.printStackTrace(); LogManager.error(exception.getMessage()); for (StackTraceElement element : exception.getStackTrace()) { if (element.toString() != null) { LogManager.error(element.toString()); } } }
From source file:com.ut.healthelink.service.impl.transactionInManagerImpl.java
/** * The 'clearMessageTables' function will loop through all each message table and remove any rows matching transactionInIds belonging to a batch. * * @param batchId of the batch to be cleared. * * It will return 0 as in no errors./*ww w .j a v a 2 s . com*/ */ @Override public Integer clearMessageTables(int batchId) { List<String> mts = transactionInDAO.getMessageTables(); Integer sysErrorCount = 0; try { for (String mt : mts) { sysErrorCount = sysErrorCount + transactionInDAO.clearMessageTableForBatch(batchId, mt); } return sysErrorCount; } catch (Exception e) { System.err.println("clearMessageTables " + e.getStackTrace()); return 1; } }
From source file:it.imtech.metadata.MetaUtility.java
/** * Aggiunge il pannello delle classificazioni all'interfaccia dei metadati * * @param innerPanel Pannello sul quale aggiungere i metadati * @param kv Valori dei metadati//from ww w . j av a 2 s .c o m */ private void addClassification(JPanel innerPanel, Integer kv, final String sequence, final String panelname) throws Exception { try { ResourceBundle bundle = ResourceBundle.getBundle(Globals.RESOURCES, Globals.CURRENT_LOCALE, Globals.loader); DefaultMutableTreeNode hierarchy = new DefaultMutableTreeNode("root"); selected = null; String selectedPath = ""; String link = selectedClassificationList.get(panelname + "---" + sequence); recursiveOefosTreeviewBuild(hierarchy, oefos.get(link), sequence, panelname); DefaultTreeModel model = new DefaultTreeModel(hierarchy); final JTree tree = new JTree(model); tree.setRootVisible(false); if (selected != null) { TreePath selpath = new TreePath(selected.getPath()); tree.setSelectionPath(selpath); Object[] nodes = selpath.getPath(); for (int i = 1; i < nodes.length; i++) { selectedPath += nodes[i].toString(); selectedPath += (i != nodes.length - 1) ? "/" : ""; } } tree.setName("MID_" + Integer.toString(kv) + "---" + sequence); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { try { setOEFOS(tree, sequence, panelname); } catch (Exception ex) { logger.error(ex.getMessage()); } } }); javax.swing.JScrollPane tree_scroller = new javax.swing.JScrollPane(); tree_scroller .setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); tree_scroller.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); tree_scroller.setViewportView(tree); tree_scroller.setBorder(null); innerPanel.add(tree_scroller, "wrap, width 100:800:800"); JPanel iPanel = new JPanel(new MigLayout()); iPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), Utility.getBundleString("choose2", bundle), TitledBorder.LEFT, TitledBorder.TOP)); JLabel label = new JLabel(); label.setName("classification_path" + "---" + sequence); label.setText(selectedPath); iPanel.add(label, "wrap, growx, height 30:30:30"); innerPanel.add(iPanel, "wrap, width 100:800:800"); findLastClassification(panelname); } catch (Exception ex) { logger.error(ex.getMessage()); throw new Exception("Exception in addClassification: " + ex.getStackTrace() + "\n"); } }
From source file:com.ut.healthelink.service.impl.transactionInManagerImpl.java
/** * The sftp move files will grab all unique active SFTP pull paths and check folders for file. It will check path to see how many configurations it is associated with. It will also get the delimiter, check if there is a headerRow, how the file is being release. * *//*www . ja v a 2 s .c o m*/ @Override public Integer moveSFTPFiles() { Integer sysErrors = 0; try { //1 . get distinct ftp paths List<configurationFTPFields> inputPaths = getFTPInfoForJob(1); //loop ftp paths and check for (configurationFTPFields ftpInfo : inputPaths) { //we insert job so if anything goes wrong or the scheduler overlaps, we won't be checking the same folder over and over MoveFilesLog sftpJob = new MoveFilesLog(); sftpJob.setStatusId(1); sftpJob.setFolderPath(ftpInfo.getdirectory()); sftpJob.setTransportMethodId(3); sftpJob.setMethod(1); Integer lastId = insertSFTPRun(sftpJob); sftpJob.setId(lastId); // check if directory exists, if not create fileSystem fileSystem = new fileSystem(); String inPath = fileSystem.setPathFromRoot(ftpInfo.getdirectory()); File f = new File(inPath); if (!f.exists()) { sftpJob.setNotes("Directory " + ftpInfo.getdirectory() + " does not exist"); updateSFTPRun(sftpJob); //need to get out of loop since set up was not done properly, but should not throw exception as rest of job should go on sendEmailToAdmin(ftpInfo.getdirectory() + " does not exist", "SFTP Job Error"); break; } //we look up org for this path Integer orgId = configurationtransportmanager.getOrgIdForFTPPath(ftpInfo); sysErrors = sysErrors + moveFilesByPath(ftpInfo.getdirectory(), 3, orgId, ftpInfo.gettransportId()); if (sysErrors == 0) { sftpJob.setStatusId(2); sftpJob.setEndDateTime(new Date()); updateSFTPRun(sftpJob); } } // if there are no errors, we release the folder path } catch (Exception ex) { ex.printStackTrace(); System.err.println("moveSFTPFilesJob " + ex.toString()); try { sendEmailToAdmin((ex.toString() + "<br/>" + Arrays.toString(ex.getStackTrace())), "SFTP Job Error - main method errored"); } catch (Exception ex1) { System.err.println("moveSFTPFilesJob " + Arrays.toString(ex1.getStackTrace())); } return 1; } return sysErrors; }
From source file:com.ut.healthelink.service.impl.transactionInManagerImpl.java
@Override public Integer moveRhapsodyFiles() { Integer sysErrors = 0;//from w w w.j a v a 2 s . c o m try { //1 . get distinct ftp paths List<configurationRhapsodyFields> inputPaths = getRhapsodyInfoForJob(1); //loop ftp paths and check for (configurationRhapsodyFields rhapsodyInfo : inputPaths) { //we insert job so if anything goes wrong or the scheduler overlaps, we won't be checking the same folder over and over MoveFilesLog moveJob = new MoveFilesLog(); moveJob.setStatusId(1); moveJob.setFolderPath(rhapsodyInfo.getDirectory()); moveJob.setTransportMethodId(5); moveJob.setMethod(1); Integer lastId = insertSFTPRun(moveJob); moveJob.setId(lastId); // check if directory exists, if not create fileSystem fileSystem = new fileSystem(); //paths are from root instead of /home String inPath = fileSystem.setPathFromRoot(rhapsodyInfo.getDirectory()); File f = new File(inPath); if (!f.exists()) { moveJob.setNotes(("Directory " + rhapsodyInfo.getDirectory() + " does not exist")); updateSFTPRun(moveJob); //need to get out of loop since set up was not done properly, will try to throw error sendEmailToAdmin((rhapsodyInfo.getDirectory() + " does not exist"), "Rhapsody Job Error"); break; } //we look up org for this path Integer orgId = configurationtransportmanager.getOrgIdForRhapsodyPath(rhapsodyInfo); sysErrors = sysErrors + moveFilesByPath(rhapsodyInfo.getDirectory(), 5, orgId, rhapsodyInfo.getTransportId()); if (sysErrors == 0) { moveJob.setStatusId(2); moveJob.setEndDateTime(new Date()); updateSFTPRun(moveJob); } } // if there are no errors, we release the folder path } catch (Exception ex) { ex.printStackTrace(); System.err.println("moveRhapsodyFiles " + ex.toString()); try { sendEmailToAdmin((ex.toString() + "<br/>" + Arrays.toString(ex.getStackTrace())), "Rhapsody Job Error - main method errored"); } catch (Exception ex1) { ex1.printStackTrace(); System.err.println("moveRhapsodyFiles " + ex1.toString()); } return 1; } return sysErrors; }
From source file:eu.brokeratcloud.fpr.model.DivaRoot.java
public List<String> getRecommQuery(String consumer, List<String> srvs) { /**--- By default, for Customer----*/ if (environment.isEmpty()) environment.add("ForCustomer"); List<String> result = new ArrayList<String>(); Set<String> requirements = new HashSet<String>(); ServiceDependencySparql dc = new ServiceDependencySparql(); Context ctx = root.getSimulation().getScenario().get(0).getContext().get(0); ctx.getVariable().clear();// w ww . jav a 2s. c o m List<Dimension> notToRemove = new ArrayList<Dimension>(); for (Dimension dim : root.getDimension()) { boolean remitted = false; for (Variant v : dim.getVariant()) { for (String srv : srvs) { if (srv.equals(v.getId())) { dim.setLower(1); remitted = true; break; } } } if (remitted) notToRemove.add(dim); } for (Dimension dim : root.getDimension()) { for (Dimension dim2 : root.getDimension()) { boolean remitted = false; for (Dimension dim3 : root.getDimension()) { if (notToRemove.contains(dim3)) { for (Variant v2 : dim3.getVariant()) { try { if (v2.getDependency().getText().toLowerCase().contains(dim2.getId().substring(2))) remitted = true; } catch (Exception e) { } if (remitted) break; } } } if (remitted) notToRemove.add(dim2); } } List<Dimension> toRemove = new ArrayList<Dimension>(); for (Dimension dim : root.getDimension()) { if (!notToRemove.contains(dim)) { toRemove.add(dim); } } root.getDimension().removeAll(toRemove); // List<Dimension> toRemove = new ArrayList<Dimension>(); // for (Dimension dim : root.getDimension()) { // for (Variant v : dim.getVariant()) { // for (String srv : srvs) { // if (srv.equals(v.getId())) { // dim.setLower(1); // break; // } // } // // } // if(dim.getId().endsWith("todos")){ // toRemove.add(dim); // } // } // root.getDimension().removeAll(toRemove); for (Variable var : root.getContext()) { if (var instanceof BooleanVariable) { BoolVariableValue varval = DivaFactory.eINSTANCE.createBoolVariableValue(); String id = var.getId(); ctx.getVariable().add(varval); varval.setVariable(var); if (environment.contains(id)) varval.setBool(true); else varval.setBool(false); } } //saveModel(consumer + "-before"); this.fileNamePrefix = consumer; _runSimulation(); System.out.println("Finished Simulation"); try { Configuration config = null; List<Configuration> configs = root.getSimulation().getScenario().get(0).getContext().get(0) .getConfiguration(); int max = -100000; for (Configuration c : configs) { if (c.getTotalScore() > max) { config = c; max = c.getTotalScore(); } } for (ConfigVariant v : config.getVariant()) { result.add(v.getVariant().getId()); } } catch (Exception e) { e.printStackTrace(); result.add(e.getStackTrace().toString()); } System.out.println("Finished result extraction. " + result.toString()); return result; }
From source file:com.sentaroh.android.SMBSync2.ActivityMain.java
private void saveTaskData() { util.addDebugMsg(2, "I", "saveTaskData entered"); if (!isTaskTermination) { if (!isTaskDataExisted() || mGp.msgListAdapter.resetDataChanged()) { ActivityDataHolder data = new ActivityDataHolder(); data.ml = mGp.msgListAdapter.getMessageList(); data.pl = mGp.syncTaskAdapter.getArrayList(); try { FileOutputStream fos = openFileOutput(SMBSYNC_SERIALIZABLE_FILE_NAME, MODE_PRIVATE); BufferedOutputStream bos = new BufferedOutputStream(fos, 4096 * 256); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(data);//from w w w.j a va2 s. c o m oos.flush(); oos.close(); util.addDebugMsg(1, "I", "Task data was saved."); } catch (Exception e) { e.printStackTrace(); util.addLogMsg("E", "saveTaskData error, " + e.toString()); util.addLogMsg("E", "StackTrace element, " + printStackTraceElement(e.getStackTrace())); } } } }
From source file:com.sentaroh.android.SMBSync2.ActivityMain.java
private void restoreTaskData() { util.addDebugMsg(2, "I", "restoreTaskData entered"); File lf = new File(mGp.applicationRootDirectory + "/" + SMBSYNC_SERIALIZABLE_FILE_NAME); if (lf.exists()) { try {//from ww w.j a v a2 s . c om // FileInputStream fis = openFileInput(SMBSYNC_SERIALIZABLE_FILE_NAME); FileInputStream fis = new FileInputStream(lf); BufferedInputStream bis = new BufferedInputStream(fis, 4096 * 256); ObjectInputStream ois = new ObjectInputStream(bis); ActivityDataHolder data = (ActivityDataHolder) ois.readObject(); ois.close(); lf.delete(); ArrayList<MsgListItem> o_ml = new ArrayList<MsgListItem>(); for (int i = 0; i < mGp.msgListAdapter.getCount(); i++) o_ml.add(mGp.msgListAdapter.getItem(i)); mGp.msgListAdapter.clear(); mGp.msgListAdapter.setMessageList(data.ml); for (int i = 0; i < o_ml.size(); i++) mGp.msgListAdapter.add(o_ml.get(i)); mGp.msgListAdapter.notifyDataSetChanged(); mGp.msgListAdapter.resetDataChanged(); mGp.syncTaskAdapter.clear(); mGp.syncTaskAdapter.setArrayList(data.pl); util.addDebugMsg(1, "I", "Task data was restored."); } catch (Exception e) { e.printStackTrace(); util.addLogMsg("E", "restoreTaskData error, " + e.toString()); util.addLogMsg("E", "StackTrace element, " + printStackTraceElement(e.getStackTrace())); } } }
From source file:edu.ucsd.library.dams.api.DAMSAPIServlet.java
public static Document toXML(Map m) { Document doc = DocumentHelper.createDocument(); Element root = doc.addElement("response"); doc.setRootElement(root);//from w w w . java 2s . c o m Iterator keys = m.keySet().iterator(); while (keys.hasNext()) { String key = (String) keys.next(); Object val = m.get(key); Element e = root.addElement(key); if (val instanceof String) { e.setText(val.toString()); } else if (val instanceof Collection) { Collection col = (Collection) val; for (Iterator it = col.iterator(); it.hasNext();) { Object o = it.next(); Element sub = e.addElement("value"); if (o instanceof Map) { Map valmap = (Map) o; Iterator fields = valmap.keySet().iterator(); while (fields.hasNext()) { String field = (String) fields.next(); Element sub2 = sub.addElement(field); sub2.setText(valmap.get(field).toString()); } } else { sub.setText(o.toString()); } } } else if (val instanceof Map) { Map m2 = (Map) val; for (Iterator it = m2.keySet().iterator(); it.hasNext();) { String k2 = (String) it.next(); String v2 = (String) m2.get(k2); Element sub = e.addElement("value"); sub.addAttribute("key", k2); sub.setText(v2); } } else if (val instanceof Exception) { Exception ex = (Exception) val; e.addElement("p").setText(ex.toString()); StackTraceElement[] elem = ex.getStackTrace(); for (int i = 0; i < elem.length; i++) { e.addElement("p").setText(elem[i].toString()); } } else { e.setText(String.valueOf(val)); } } return doc; }