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:com.aurel.track.report.export.bl.XsltTransformer.java
public Document transform(Document dom, String xsltPath) { Document domResult = null;/*from ww w . j a v a 2s . c o m*/ try { TransformerFactory tFactory = TransformerFactory.newInstance(); File stylesheet = new File(xsltPath); StreamSource stylesource = new StreamSource(stylesheet); Transformer transformer = tFactory.newTransformer(stylesource); DOMSource source = new DOMSource(dom); ByteArrayOutputStream result = new ByteArrayOutputStream(); StreamResult sr = new StreamResult(result); transformer.transform(source, sr); LOGGER.debug("--------------------"); LOGGER.debug(result.toString()); LOGGER.debug("--------------------"); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); try { DocumentBuilder builder = factory.newDocumentBuilder(); domResult = builder.parse(new InputSource(new ByteArrayInputStream(result.toByteArray()))); } catch (Exception e) { LOGGER.error(ExceptionUtils.getStackTrace(e)); } } catch (TransformerConfigurationException tce) { LOGGER.error("Can't transform dom using xslt path :" + xsltPath, tce); } catch (TransformerException te) { LOGGER.error("Can't transform dom using xslt path :" + xsltPath, te); } return domResult; }
From source file:io.jare.tk.TkApp.java
/** * Regex takes.//from www.jav a 2s.c o m * @param base Base * @return Takes * @throws IOException If fails */ private static Take regex(final Base base) throws IOException { return new TkFork(new FkHost("relay.jare.io", new TkFallback(new TkRelay(base), req -> new Opt.Single<>(new RsWithType(new RsWithBody(new RsWithStatus(req.code()), String.format( // @checkstyle LineLength (1 line) "Please, submit this stacktrace to GitHub and we'll try to help: https://github.com/yegor256/jare/issues\n\n%s", ExceptionUtils.getStackTrace(req.throwable()))), "text/plain")))), new FkRegex("/robots.txt", ""), new FkRegex("/xsl/[a-z\\-]+\\.xsl", new TkWithType(TkApp.refresh("./src/main/xsl"), "text/xsl")), new FkRegex("/css/[a-z]+\\.css", new TkWithType(TkApp.refresh("./src/main/scss"), "text/css")), new FkRegex("/images/[a-z]+\\.svg", new TkWithType(TkApp.refresh("./src/main/resources"), "image/svg+xml")), new FkRegex("/images/[a-z]+\\.png", new TkWithType(TkApp.refresh("./src/main/resources"), "image/png")), new FkRegex("/", new TkIndex()), new FkAuthenticated(new TkSecure(new TkFork(new FkRegex("/domains", new TkDomains(base)), new FkRegex("/add", new TkAdd(base)), new FkRegex("/delete", new TkDelete(base)))))); }
From source file:com.aurel.track.persist.TReportCategoryPeer.java
/** * Loads a filterCategoryBean by primary key * @param objectID/*w w w .j ava2s . co m*/ * @return */ @Override public TReportCategoryBean loadByPrimaryKey(Integer objectID) { TReportCategory reportCategory = null; try { reportCategory = retrieveByPK(objectID); } catch (Exception e) { LOGGER.warn( "Loading of a reportCategory by primary key " + objectID + " failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } if (reportCategory != null) { return reportCategory.getBean(); } return null; }
From source file:com.aurel.track.fieldType.fieldChange.apply.MultipleTreeFieldChangeApply.java
/** * Sets the workItemBean's attribute/*from w w w. j a va 2 s .c o m*/ * @param workItemContext * @param workItemBean * @param fieldID * @param parameterCode * @param value * @return ErrorData if an error is found */ @Override public List<ErrorData> setWorkItemAttribute(WorkItemContext workItemContext, TWorkItemBean workItemBean, Integer parameterCode, Object value) { if (getSetter() == FieldChangeSetters.SET_NULL || getSetter() == FieldChangeSetters.SET_REQUIRED) { return super.setWorkItemAttribute(workItemContext, workItemBean, parameterCode, value); } Integer[] selectedValues = (Integer[]) value; if (getSetter() == FieldChangeSetters.SET_TO) { workItemBean.setAttribute(activityType, selectedValues); return null; } Object originalValue = workItemBean.getAttribute(activityType, parameterCode); Object[] originalSelections = null; if (originalValue != null) { try { //multiple values are loaded in the workItem as Object[], not as Integer[] !!! originalSelections = (Object[]) originalValue; } catch (Exception e) { LOGGER.debug( "Getting the original object array value for " + value + " failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } Set<Integer> originalSet = new HashSet<Integer>(); if (originalSelections != null && originalSelections.length > 0) { for (int i = 0; i < originalSelections.length; i++) { try { originalSet.add((Integer) originalSelections[i]); } catch (Exception e) { LOGGER.info("Transforming the original object value " + originalSelections[i] + " to Integer failed with " + e.getMessage()); LOGGER.info(ExceptionUtils.getStackTrace(e)); } } } Set<Integer> bulkSelectionsSet = GeneralUtils.createSetFromIntegerArr(selectedValues); switch (getSetter()) { case FieldChangeSetters.ADD_ITEMS: originalSet.addAll(bulkSelectionsSet); workItemBean.setAttribute(activityType, parameterCode, GeneralUtils.createIntegerArrFromCollection(originalSet)); break; case FieldChangeSetters.REMOVE_ITEMS: originalSet.removeAll(bulkSelectionsSet); workItemBean.setAttribute(activityType, parameterCode, GeneralUtils.createIntegerArrFromCollection(originalSet)); break; default: break; } return null; }
From source file:com.aurel.track.fieldType.runtime.base.CustomOnePieceBaseRT.java
/** * Loads the saved custom attribute value from the database * to the workItem customAttributeValues Map * @param fieldID /*from w w w.j a v a 2s .c o m*/ * @param parameterCode neglected for single custom fields * @param workItemBean * @param attributeValueMap: * - key: fieldID_parameterCode * - value: TAttributeValueBean or list of TAttributeValueBeans */ public void loadAttribute(Integer fieldID, Integer parameterCode, TWorkItemBean workItemBean, Map<String, Object> attributeValueMap) { if (isMultipleValues()) { List<TAttributeValueBean> attributeValueList = null; //get the attributes list from the custom attributes map try { attributeValueList = (List<TAttributeValueBean>) attributeValueMap .get(MergeUtil.mergeKey(fieldID, parameterCode)); } catch (Exception e) { LOGGER.error("Converting the attribute value for field " + fieldID + " and parameterCode " + parameterCode + " for workItem " + workItemBean.getObjectID() + " to List failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } //create an array with objects of specific type Object[] arrAttributeValues = null; if (attributeValueList != null) { List<Object> values = new LinkedList<Object>(); for (TAttributeValueBean attributeValueBean : attributeValueList) { if (attributeValueBean != null) { Object value = AttributeValueBL.getSpecificAttribute(attributeValueBean, getValueType()); if (value != null) { values.add(value); } } } if (!values.isEmpty()) { arrAttributeValues = values.toArray(); } } //set the attribute on workItem if (arrAttributeValues == null || arrAttributeValues.length == 0) { workItemBean.setAttribute(fieldID, parameterCode, null); } else { workItemBean.setAttribute(fieldID, parameterCode, arrAttributeValues); } } else { TAttributeValueBean tAttributeValueBean = null; try { tAttributeValueBean = (TAttributeValueBean) attributeValueMap .get(MergeUtil.mergeKey(fieldID, parameterCode)); } catch (Exception e) { LOGGER.error("Converting the attribute value for field " + fieldID + " and parameterCode " + parameterCode + " for workItem " + workItemBean.getObjectID() + " to TAttributeValueBean failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } //set the attribute on workItem if (tAttributeValueBean != null) { Object attributeValue = AttributeValueBL.getSpecificAttribute(tAttributeValueBean, getValueType()); workItemBean.setAttribute(fieldID, parameterCode, attributeValue); } } }
From source file:com.garethahealy.camel.dynamic.loadbalancer.statistics.mbeans.BaseMBeanAttributeCollector.java
private ObjectName createObjectName(String query) { ObjectName objectName = null; try {/* w ww .j a va2 s . c om*/ objectName = new ObjectName(agent.getMBeanObjectDomainName() + query); } catch (MalformedObjectNameException ex) { LOG.error(ExceptionUtils.getStackTrace(ex)); } return objectName; }
From source file:ke.co.tawi.babblesms.server.persistence.DBCredentials.java
/** * This method returns a pooled connection. * * @return Connection/*from w w w . j a v a2 s .co m*/ */ public Connection getConnection() { Connection conn = null; try { conn = datasource.getConnection(); } catch (SQLException e) { logger.error("SQLException when trying to get an SQL Connection."); logger.error(ExceptionUtils.getStackTrace(e)); initConnection(); } return conn; }
From source file:com.aurel.track.fieldType.runtime.matchers.converter.DateMatcherConverter.java
/** * Convert the object value to xml string for save * @param value//from ww w.j a v a 2 s .co m * @param matcherRelation * @return */ @Override public String toXMLString(Object value, Integer matcherRelation) { if (value == null || matcherRelation == null) { return null; } switch (matcherRelation.intValue()) { 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: 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: return value.toString(); 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 { Date dateValue = (Date) value; return DateTimeUtils.getInstance().formatISODateTime(dateValue); } catch (Exception e) { LOGGER.warn("Converting the " + value + " to Date for xml string failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } return null; }
From source file:com.aurel.track.persist.TCostPeer.java
/** * Loads an expense by primary key/* ww w.j av a 2 s . c o m*/ * @param objectID * @return */ @Override public TCostBean loadByPrimaryKey(Integer objectID) { TCost tCost = null; try { tCost = retrieveByPK(objectID); } catch (Exception e) { LOGGER.warn("Loading of an expense by primary key " + objectID + " failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } if (tCost != null) { return tCost.getBean(); } return null; }
From source file:com.aurel.track.persist.TScreenPeer.java
/** * Loads the screen by primary key/*from w w w. j ava 2s.c om*/ * @param objectID * @return */ @Override public TScreenBean loadByPrimaryKey(Integer objectID) { TScreen tobject = null; try { tobject = retrieveByPK(objectID); } catch (Exception e) { LOGGER.warn("Loading of a screen by primary key " + objectID + " failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } if (tobject != null) { return tobject.getBean(); } return null; }