List of usage examples for org.apache.commons.lang3.exception ExceptionUtils getStackTrace
public static String getStackTrace(final Throwable throwable)
Gets the stack trace from a Throwable as a String.
The result of this method vary by JDK version as this method uses Throwable#printStackTrace(java.io.PrintWriter) .
From source file:lu.list.itis.dkd.aig.template.TemplateService.java
protected Response getTemplate(final ServletContext context, final String name, final String folder) { try {// ww w . j ava 2s.c o m return Response.status(200).type(MediaType.TEXT_XML) .entity(TemplateManager.fetch(context, name, folder)).build(); } catch (final NoSuchFileException e) { return Response.status(404).type(MediaType.TEXT_PLAIN).entity("No template with given name was found!") //$NON-NLS-1$ .build(); } catch (final IOException e) { Logger.getLogger(TemplateService.class.getSimpleName()).log(Level.SEVERE, e.getMessage(), e); return Response.serverError() .entity("Error while attempting to retrieve the template!\n" + ExceptionUtils.getStackTrace(e)) //$NON-NLS-1$ .build(); } }
From source file:ke.co.tawi.babblesms.server.persistence.smsgw.tawi.GatewayDAO.java
/** * @see ke.co.tawi.babblesms.server.persistence.smsgw.tawi.BabbleGatewayDAO#put(ke.co.tawi.babblesms.server.beans.account.Account, ke.co.tawi.babblesms.server.beans.smsgateway.TawiGateway) *///from w ww. j a v a 2 s.c om public boolean put(TawiGateway gateway) { boolean success = true; try (Connection conn = dbCredentials.getConnection(); PreparedStatement pstmt = conn.prepareStatement( "INSERT INTO SMSGateway" + "(accountUuid, url, username, passwd) VALUES (?,?,?,?);");) { pstmt.setString(1, gateway.getAccountUuid()); pstmt.setString(2, gateway.getUrl()); pstmt.setString(3, gateway.getUsername()); pstmt.setString(4, SecurityUtil.getMD5Hash(gateway.getPasswd())); pstmt.execute(); } catch (SQLException e) { logger.error("SQLException when trying to put TawiGateway " + gateway); logger.error(ExceptionUtils.getStackTrace(e)); success = false; } return success; }
From source file:ke.co.tawi.babblesms.server.persistence.logs.ContactGroupSentDAO.java
/** * @see ke.co.tawi.babblesms.server.persistence.logs.BabbleContactGroupSentDAO#getUsingSentContact(java.lang.String) *//*from w w w. j a v a 2 s .c o m*/ @Override public List<contactGroupsent> getUsingSentContact(String SentContactUuid) { List<contactGroupsent> ContactsentList = new ArrayList<>(); try (Connection conn = dbCredentials.getConnection(); PreparedStatement pstmt = conn .prepareStatement("SELECT * FROM contactgroupsent WHERE sentcontactuuid=?;");) { pstmt.setString(1, SentContactUuid); try (ResultSet rset = pstmt.executeQuery();) { ContactsentList = beanProcessor.toBeanList(rset, contactGroupsent.class); } } catch (SQLException e) { logger.error("SQL Exception when trying to List associated with " + SentContactUuid); logger.error(ExceptionUtils.getStackTrace(e)); } return ContactsentList; }
From source file:com.aurel.track.teamgeist.TeamgeistServicesTest.java
/** * This method returns Teamgeist source path till Services.cpp. * The source base directory is provided by: buildwin or buildux properties (Windows or mac) * @return/*w ww . j a va2 s. co m*/ */ private String getSrcPath() { String propertiesFileName = null; if (System.getProperty("os.name").toLowerCase().contains("windows")) { propertiesFileName = "buildwin.properties"; } else if (System.getProperty("os.name").toLowerCase().contains("mac") || System.getProperty("os.name").toLowerCase().contains("linux")) { propertiesFileName = "buildux.properties"; } else { return null; } final String COM_TRACKPLUS_RELATIVE_PATH = "/com.trackplus/" + propertiesFileName; File file = new java.io.File(""); String propertiesPath = file.getAbsoluteFile().getParentFile().getAbsolutePath(); String srcPath = null; if (propertiesPath.contains("\\")) { propertiesPath = propertiesPath.replace("\\", "/"); if (propertiesPath.lastIndexOf("/") == propertiesPath.length() - 1) { propertiesPath = propertiesPath.substring(0, propertiesPath.length() - 1); } } propertiesPath += COM_TRACKPLUS_RELATIVE_PATH; try { final String RELATIVE_PART_OF_PATH = "/services/Services.cpp"; System.err.println(propertiesPath); InputStream input = new FileInputStream(propertiesPath); Properties prop = new Properties(); prop.load(input); srcPath = prop.get("teamgeist.srcAbsolutePath").toString(); srcPath = srcPath.replace("\\", "/"); if (srcPath.lastIndexOf("/") == srcPath.length() - 1) { srcPath = srcPath.substring(0, srcPath.length() - 1); } srcPath += RELATIVE_PART_OF_PATH; } catch (Exception ex) { LOGGER.error(ExceptionUtils.getStackTrace(ex)); } System.out.println("Using Teamgeist source from " + srcPath); return srcPath; }
From source file:com.aurel.track.admin.customize.category.filter.tree.io.TreeFilterParser.java
@Override public void startElement(String uri, String localName, String qName, Attributes attributes) { if (qName.equalsIgnoreCase(TreeFilterReader.ROOT_NODE)) { return;/*w w w .j a va 2 s.com*/ } boolean negate = false; String negateString = attributes.getValue("negate"); if (negateString != null) { negate = negateString.equalsIgnoreCase("true"); } if (qName.equalsIgnoreCase(TreeFilterReader.AND_NODE)) { currentNode = new QNode(); currentNode.setType(QNode.AND); currentNode.setNegate(negate); } if (qName.equalsIgnoreCase(TreeFilterReader.OR_NODE)) { currentNode = new QNode(); currentNode.setType(QNode.OR); currentNode.setNegate(negate); } if (qName.equalsIgnoreCase(TreeFilterReader.EXP_NODE)) { currentNode = new QNodeExpression(); currentNode.setType(QNode.EXP); String strFieldMoment = attributes.getValue("fieldMoment"); if (strFieldMoment != null) { Integer fieldMoment = null; try { fieldMoment = Integer.valueOf(strFieldMoment); ((QNodeExpression) currentNode).setFieldMoment(fieldMoment); } catch (Exception e) { LOGGER.info( "Parsing the fieldMoment from " + strFieldMoment + " failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } String strFieldID = attributes.getValue("fieldId"); Integer fieldID = null; if (strFieldID != null) { try { fieldID = Integer.valueOf(strFieldID); } catch (Exception e) { LOGGER.info("Parsing the fieldID from " + strFieldID + " failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } String strMatcher = attributes.getValue("matcherId"); Integer matcherID = null; if (strMatcher != null && !"".equals(strMatcher)) { try { matcherID = Integer.valueOf(strMatcher); } catch (Exception e) { LOGGER.info("Parsing the matcher from " + strMatcher + " failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } ((QNodeExpression) currentNode).setField(fieldID); ((QNodeExpression) currentNode).setMatcherID(matcherID); String value = attributes.getValue("value"); if (!TreeFilterString.isPseudoField(fieldID)) { MatcherConverter mc = null; if (fieldID.intValue() > 0) { IFieldTypeRT fieldTypeRT = FieldTypeManager.getFieldTypeRT(fieldID); //It can be that this field is already deleted. //The query containing this field was not deleted because the foreign key //relationship is not direct (just inside the clob). if (fieldTypeRT != null) { //real (system or custom) and existing field mc = fieldTypeRT.getMatcherConverter(); } } else { mc = FieldExpressionBL.getPseudoFieldMatcherConverter(fieldID); } if (mc != null) { ((QNodeExpression) currentNode).setValue(mc.fromXMLString(value, matcherID)); } else { //the field does not exists any more //and mark this with setting the fieldID as null //to avoid adding it to the tree (see endElement()) ((QNodeExpression) currentNode).setField(null); return; } } else { //pseudo field ((QNodeExpression) currentNode) .setValue(TreeFilterString.getPseudoFieldFromXMLString(fieldID, value, matcherID)); } if (negate) { removeNegate((QNodeExpression) currentNode); } } stack.push(currentNode); if (root == null) { root = currentNode; } }
From source file:ke.co.tawi.babblesms.server.persistence.utils.DateResetUtil.java
/** * Reset dates for Outgoing SMS./*from w ww.j av a2s. c o m*/ * * @param startDate A start date in the format yyyy-MM-dd HH:mm:ss * @param endDate An end date in the format yyyy-MM-dd HH:mm:ss */ public void resetOutgoingDates(String startDate, String endDate) { SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // Example 2011-06-01 00:16:45" List<String> uuids = new ArrayList<>(); RandomDataGenerator generator = new RandomDataGenerator(); // Get UUIDs of Incoming SMS are in the database try (Connection conn = dbCredentials.getConnection(); PreparedStatement pstmt = conn.prepareStatement("SELECT uuid FROM outgoinglog;");) { ResultSet rset = pstmt.executeQuery(); while (rset.next()) { uuids.add(rset.getString("uuid")); } } catch (SQLException e) { logger.error("SQLException when getting uuids of outgoinglog."); logger.error(ExceptionUtils.getStackTrace(e)); } try (Connection conn = dbCredentials.getConnection(); PreparedStatement pstmt = conn .prepareStatement("UPDATE outgoinglog SET logTime=? " + "WHERE Uuid=?;");) { long start = dateFormatter.parse(startDate).getTime(); long end = dateFormatter.parse(endDate).getTime(); for (String uuid : uuids) { pstmt.setTimestamp(1, new Timestamp(generator.nextLong(start, end))); pstmt.setString(2, uuid); pstmt.executeUpdate(); } } catch (SQLException e) { logger.error("SQLException when trying to reset dates of outgoinglog."); logger.error(ExceptionUtils.getStackTrace(e)); } catch (ParseException e) { logger.error("ParseException when trying to reset dates of outgoinglog."); logger.error(ExceptionUtils.getStackTrace(e)); } }
From source file:com.aurel.track.Constants.java
public static void setGroovyScriptEngine() { // Create a plugin directory for Groovy scripts if it does not exist // already anyways. File groovyPluginDir = new File(HandleHome.getGroovyPluginPath()); if (!groovyPluginDir.exists() || !groovyPluginDir.isDirectory()) { LOGGER.info("Creating " + HandleHome.getGroovyPluginPath()); if (HandleHome.getGroovyPluginPath().length() > 1) { if (!groovyPluginDir.mkdirs()) { System.err.println("Create failed."); }/*w w w. j a v a 2 s . co m*/ } } try { URL extern = groovyPluginDir.toURL(); ClassLoader parent = ApplicationBean.getInstance().getClass().getClassLoader(); GroovyClassLoader loader = new GroovyClassLoader(parent); // external plugins have precedence; they can cover internal // plugins with the same name! URL[] roots = new URL[] { extern/*, groovyURL*/ }; groovyScriptEngine = null; groovyScriptEngine = new GroovyScriptEngine(roots, loader); } catch (Exception ioe) { System.err.println("Cannot initialize Groovy script engine"); LOGGER.error(ExceptionUtils.getStackTrace(ioe)); } }
From source file:com.aurel.track.persist.TNavigatorLayoutPeer.java
/** * * @param navigatorLayoutBean/*from www .j ava 2 s. co m*/ * @return */ @Override public Integer save(TNavigatorLayoutBean navigatorLayoutBean) { try { TNavigatorLayout navigatorLayout = BaseTNavigatorLayout.createTNavigatorLayout(navigatorLayoutBean); navigatorLayout.save(); return navigatorLayout.getObjectID(); } catch (Exception e) { LOGGER.error("Saving of a navigator layout failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); return null; } }
From source file:com.aurel.track.fieldType.runtime.matchers.run.DateMatcherRT.java
/** * Reinitialize dayBegin and dayEnd/*from w w w . ja va2 s . com*/ */ @Override public void setMatchValue(Object matcherValue) { super.setMatchValue(matcherValue); if (relation == MatchRelations.LATER_AS_LASTLOGIN && matcherContext != null) { matcherValue = matcherContext.getLastLoggedDate(); } Calendar calendaMatcherValue = new GregorianCalendar(matcherContext.getLocale()); calendaMatcherValue.setTime(new Date()); calendaMatcherValue = CalendarUtil.clearTime(calendaMatcherValue); int firstDayOfWeek = calendaMatcherValue.getFirstDayOfWeek(); switch (relation) { case MatchRelations.THIS_WEEK: calendaMatcherValue.set(Calendar.DAY_OF_WEEK, firstDayOfWeek); dayBegin = calendaMatcherValue.getTime(); calendaMatcherValue.add(Calendar.WEEK_OF_YEAR, 1); calendaMatcherValue.set(Calendar.DAY_OF_WEEK, firstDayOfWeek); dayEnd = calendaMatcherValue.getTime(); return; case MatchRelations.LAST_WEEK: calendaMatcherValue.set(Calendar.DAY_OF_WEEK, firstDayOfWeek); dayEnd = calendaMatcherValue.getTime(); calendaMatcherValue.add(Calendar.WEEK_OF_YEAR, -1); calendaMatcherValue.set(Calendar.DAY_OF_WEEK, firstDayOfWeek); dayBegin = calendaMatcherValue.getTime(); return; case MatchRelations.THIS_MONTH: calendaMatcherValue.set(Calendar.DAY_OF_MONTH, 1); dayBegin = calendaMatcherValue.getTime(); calendaMatcherValue.add(Calendar.MONTH, 1); calendaMatcherValue.set(Calendar.DAY_OF_MONTH, 1); dayEnd = calendaMatcherValue.getTime(); return; case MatchRelations.LAST_MONTH: calendaMatcherValue.set(Calendar.DAY_OF_MONTH, 1); dayEnd = calendaMatcherValue.getTime(); calendaMatcherValue.add(Calendar.MONTH, -1); calendaMatcherValue.set(Calendar.DAY_OF_MONTH, 1); dayBegin = calendaMatcherValue.getTime(); return; } if (matcherValue == null) { return; } //reinitialize dayBegin and dayEnd Date matcherValueDate = null; Integer matcherValueInteger = null; switch (relation) { case MatchRelations.MORE_THAN_DAYS_AGO: case MatchRelations.MORE_THAN_EQUAL_DAYS_AGO: case MatchRelations.LESS_THAN_DAYS_AGO: case MatchRelations.LESS_THAN_EQUAL_DAYS_AGO: try { matcherValueInteger = (Integer) matchValue; } catch (Exception e) { LOGGER.warn("Converting the matcher value " + matchValue + " of type " + matchValue.getClass().getName() + " to Integer failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } calendaMatcherValue.setTime(new Date()); if (matcherValueInteger != null) { int matcherValueInt = matcherValueInteger.intValue(); if (relation == MatchRelations.MORE_THAN_EQUAL_DAYS_AGO) { matcherValueInt--; } if (relation == MatchRelations.LESS_THAN_EQUAL_DAYS_AGO) { matcherValueInt++; } calendaMatcherValue.add(Calendar.DATE, -matcherValueInt); } break; case MatchRelations.IN_MORE_THAN_DAYS: case MatchRelations.IN_MORE_THAN_EQUAL_DAYS: case MatchRelations.IN_LESS_THAN_DAYS: case MatchRelations.IN_LESS_THAN_EQUAL_DAYS: try { matcherValueInteger = (Integer) matchValue; } catch (Exception e) { LOGGER.warn("Converting the matcher value " + matchValue + " of type " + matchValue.getClass().getName() + " to Integer failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } calendaMatcherValue.setTime(new Date()); if (matcherValueInteger != null) { int matcherValueInt = matcherValueInteger.intValue(); if (relation == MatchRelations.IN_MORE_THAN_EQUAL_DAYS) { matcherValueInt--; } if (relation == MatchRelations.IN_LESS_THAN_EQUAL_DAYS) { matcherValueInt++; } calendaMatcherValue.add(Calendar.DATE, matcherValueInt); } break; case MatchRelations.EQUAL_DATE: case MatchRelations.NOT_EQUAL_DATE: case MatchRelations.GREATHER_THAN_DATE: case MatchRelations.GREATHER_THAN_EQUAL_DATE: case MatchRelations.LESS_THAN_DATE: case MatchRelations.LESS_THAN_EQUAL_DATE: try { matcherValueDate = (Date) matchValue; } catch (Exception e) { LOGGER.warn("Converting the matcher value " + matchValue + " of type " + matchValue.getClass().getName() + " to Date failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } if (matcherValueDate != null) { calendaMatcherValue.setTime(matcherValueDate); if (relation == MatchRelations.GREATHER_THAN_EQUAL_DATE) { calendaMatcherValue.add(Calendar.DATE, -1); } else { if (relation == MatchRelations.LESS_THAN_EQUAL_DATE) { calendaMatcherValue.add(Calendar.DATE, 1); } } } break; case MatchRelations.LATER_AS_LASTLOGIN: if (matcherContext != null) { dayBegin = matcherContext.getLastLoggedDate(); dayEnd = matcherContext.getLastLoggedDate(); } //return because later the dayBegin and dayEnd will be assigned again return; } calendaMatcherValue = CalendarUtil.clearTime(calendaMatcherValue); dayBegin = calendaMatcherValue.getTime(); calendaMatcherValue.add(Calendar.DATE, 1); dayEnd = calendaMatcherValue.getTime(); }