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.util.LdapSynchronizer.java
@Override public Map handleEvent(Map inputBinding) { TSiteBean siteBean = (TSiteBean) inputBinding.get(BINDING_PARAMS.SITEBEAN); String ldapURL = siteBean.getLdapServerURL(); String baseURL = LdapUtil.getBaseURL(ldapURL); boolean deactivateUnknown = true; Map<String, String> ldapMap = LdapUtil.getLdapMap(); if (ldapMap != null) { try {/*from w ww . jav a 2 s. c om*/ deactivateUnknown = Boolean.valueOf(ldapMap.get(LdapUtil.LDAP_CONFIG.DEACTIVATE_UNKNOWN)); } catch (Exception e) { } } /** * Format of parameter file is "Group name : ldap URL" */ TScriptsBean scriptsBean = ScriptAdminBL.loadByClassName("LdapSynchronizerParams"); List<String> lines = new ArrayList<String>(); if (scriptsBean == null) { LOGGER.warn("Could not find the script LdapSynchronizerParams"); } else { String params = scriptsBean.getSourceCode(); if (params != null) { lines = ScriptUtil.getParameterDataLines(params); } } Map<String, TPersonBean> ldapPersonsFromGroups = null; Map<String, String> groups = ScriptUtil.getParameterMap("^(.*):\\s*(.*)", "#", lines); Map<String, List<String>> groupToMemberReferencesMap = new HashMap<String, List<String>>(); try { Map<String, TPersonBean> ldapGroups = LdapUtil.getLdapGroupsByList(baseURL, siteBean, null/*groupAttributeName*/, groupToMemberReferencesMap, groups); Map<String, List<TPersonBean>> ldapGroupsToPersons = LdapUtil.getGroupToPersonMaps(baseURL, siteBean, ldapGroups, groupToMemberReferencesMap); ldapPersonsFromGroups = GroupMemberBL.synchronizeUserListWithGroup(ldapGroupsToPersons); if (deactivateUnknown) { try { LdapUtil.deactivateUsers(ldapPersonsFromGroups); } catch (Exception e) { } } } catch (Exception e) { // TODO Auto-generated catch block LOGGER.error(ExceptionUtils.getStackTrace(e)); } return ldapPersonsFromGroups; }
From source file:com.threewks.thundr.jrebel.ThundrJRebelPlugin.java
@SuppressWarnings("unchecked") private void registerListener() { // Set up the reload listener final Set<String> watchedClasses = loadWatchedClassList(); ReloaderFactory.getInstance().addClassReloadListener(new ClassEventListener() { @Override/*from ww w. j a va2s .c o m*/ public void onClassEvent(int eventType, Class klass) { try { Class applicationModuleClass = Class.forName(BaseModuleClassName); if (applicationModuleClass.isAssignableFrom(klass) || watchedClasses.contains(klass.getCanonicalName())) { Logger.info("%s was modified. InjectionContext will be reloaded on next request...", klass.getCanonicalName()); ThundrServletReloader.markDirty(); } } catch (Exception e) { Logger.error("Error marking ApplicationModule for reloading: %s", ExceptionUtils.getStackTrace(e)); } } @Override public int priority() { return 0; } }); }
From source file:ke.co.tawi.babblesms.server.persistence.geolocation.CountryDAO.java
/** * *///from w w w . j av a 2 s .c o m @Override public Country getCountry(String uuid) { Country network = null; Connection conn = null; PreparedStatement pstmt = null; ResultSet rset = null; BeanProcessor b = new BeanProcessor(); try { conn = dbCredentials.getConnection(); pstmt = conn.prepareStatement("SELECT * FROM Country WHERE Uuid = ?;"); pstmt.setString(1, uuid); rset = pstmt.executeQuery(); if (rset.next()) { network = b.toBean(rset, Country.class); } } catch (SQLException e) { logger.error("SQL Exception when getting network with uuid: " + uuid); logger.error(ExceptionUtils.getStackTrace(e)); } return network; }
From source file:com.aurel.track.persist.TCardGroupingFieldPeer.java
@Override public Integer save(TCardGroupingFieldBean cardGroupingFieldBean) { try {/* www .j a v a 2 s . c om*/ TCardGroupingField cardGroupingField = BaseTCardGroupingField .createTCardGroupingField(cardGroupingFieldBean); cardGroupingField.save(); return cardGroupingField.getObjectID(); } catch (Exception e) { LOGGER.error("Saving of a cardGroupingField failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); return null; } }
From source file:com.daou.terracelicense.controller.MachineController.java
/** * Machine-Controller-05//w w w . j a va 2 s.c om * Update Machine */ @RequestMapping(value = "/update", method = RequestMethod.PUT) @ResponseBody public int updateMachine(@RequestBody Machine machine) { int result = 0; try { result = machineService.updateMachine(machine); } catch (Exception e) { logger.error(ExceptionUtils.getStackTrace(e)); } return result; }
From source file:com.aurel.track.fieldType.runtime.base.WBSComparable.java
@Override public int compareTo(Object o) { WBSComparable wbsComparable = (WBSComparable) o; List<Integer> paramWbsOnLevelsList = wbsComparable.getWbsOnLevelsList(); if ((wbsOnLevelsList == null || wbsOnLevelsList.isEmpty()) && (paramWbsOnLevelsList == null || paramWbsOnLevelsList.isEmpty())) { return 0; }//w w w.j av a2s . com if (wbsOnLevelsList == null || wbsOnLevelsList.isEmpty()) { return -1; } if (paramWbsOnLevelsList == null || paramWbsOnLevelsList.isEmpty()) { return 1; } int length = wbsOnLevelsList.size(); int paramLength = paramWbsOnLevelsList.size(); int minLength = length; if (minLength > paramLength) { minLength = paramLength; } for (int i = 0; i < minLength; i++) { Integer wbsOnLevel = wbsOnLevelsList.get(i); Integer paramWbsOnLevel = paramWbsOnLevelsList.get(i); if (wbsOnLevel == null && paramWbsOnLevel == null) { return 0; } if (wbsOnLevel == null) { return -1; } if (paramWbsOnLevel == null) { return 1; } try { int compareResult = wbsOnLevel.compareTo(paramWbsOnLevel); if (compareResult != 0) { //return only if the part if different return compareResult; } } catch (Exception e) { LOGGER.warn("Sorting the values " + wbsOnLevel + " of class " + wbsOnLevel.getClass().getName() + " and " + paramWbsOnLevel + " of class " + paramWbsOnLevel.getClass().getName() + " failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } //ancestor-descendant relation: the longer the path the later in wbs return Integer.valueOf(length).compareTo(Integer.valueOf(paramLength)); }
From source file:com.aurel.track.persist.TUserLevelSettingPeer.java
/** * Saves a userLevelSetting to the TUuserLevelSetting table. * @param userLevelSettingBean/*w w w . java 2s. c o m*/ * @return */ @Override public Integer save(TUserLevelSettingBean userLevelSettingBean) { try { TUserLevelSetting tUserLevelSetting = TUserLevelSetting.createTUserLevelSetting(userLevelSettingBean); tUserLevelSetting.save(); return tUserLevelSetting.getObjectID(); } catch (Exception e) { LOGGER.error("Saving of a user level setting failed with " + e.getMessage()); if (LOGGER.isDebugEnabled()) { LOGGER.debug(ExceptionUtils.getStackTrace(e)); } return null; } }
From source file:com.chiorichan.console.CommandDispatch.java
public static void handleCommands() { for (Entry<InteractiveConsole, List<Interviewer>> entry : interviewers.entrySet()) { if (activeInterviewer.get(entry.getKey()) == null) { if (entry.getValue().isEmpty()) { interviewers.remove(entry.getKey()); entry.getKey().resetPrompt(); } else { Interviewer i = entry.getValue().remove(0); activeInterviewer.put(entry.getKey(), i); entry.getKey().setPrompt(i.getPrompt()); }/*from ww w . ja v a2 s.c o m*/ } } while (!pendingCommands.isEmpty()) { CommandRef command = pendingCommands.remove(0); try { Interviewer i = activeInterviewer.get(command.handler); InteractivePermissible permissible = command.handler.getPersistence(); if (i != null) { if (i.handleInput(command.command)) activeInterviewer.remove(command.handler); else command.handler.prompt(); } else { CommandIssuedEvent event = new CommandIssuedEvent(command.command, permissible); Loader.getEventBus().callEvent(event); if (event.isCancelled()) { permissible.sendMessage(ConsoleColor.RED + "Your entry was cancelled by the event system."); return; } String[] args = PATTERN_ON_SPACE.split(command.command); if (args.length > 0) { String sentCommandLabel = args[0].toLowerCase(); Command target = getCommand(sentCommandLabel); if (target != null) { try { if (target.testPermission(permissible)) target.execute(command.handler, sentCommandLabel, Arrays.copyOfRange(args, 1, args.length)); return; } catch (CommandException ex) { throw ex; } catch (Throwable ex) { command.handler.sendMessage( ConsoleColor.RED + "Unhandled exception executing '" + command.command + "' in " + target + "\n" + ExceptionUtils.getStackTrace(ex)); throw new CommandException( "Unhandled exception executing '" + command.command + "' in " + target, ex); } } } permissible.sendMessage( ConsoleColor.YELLOW + "Your entry was unrecognized, type \"help\" for help."); } } catch (Exception ex) { Loader.getLogger().warning( "Unexpected exception while parsing console command \"" + command.command + '"', ex); } } }
From source file:com.aurel.track.admin.customize.category.filter.execute.ReportQueryBL.java
private static String dcl(String encryptedText, char[] password) { byte[] clearText = { ' ' }; int count = 20; PBEKeySpec pbeKeySpec;/*ww w.j a va 2 s . com*/ PBEParameterSpec pbeParamSpec; SecretKeyFactory keyFac; // Create PBE parameter set pbeParamSpec = new PBEParameterSpec(salt, count); pbeKeySpec = new PBEKeySpec(password); try { keyFac = SecretKeyFactory.getInstance("PBEWithMD5AndDES"); SecretKey pbeKey = keyFac.generateSecret(pbeKeySpec); // Create PBE Cipher Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES"); // Initialize PBE Cipher with key and parameters pbeCipher.init(Cipher.DECRYPT_MODE, pbeKey, pbeParamSpec); byte[] ciphertext = Base64.decodeBase64(encryptedText); //Decrypt the cleartext clearText = pbeCipher.doFinal(ciphertext); } catch (Exception e) { LOGGER.debug(ExceptionUtils.getStackTrace(e), e); } return new String(clearText); }
From source file:com.aurel.track.admin.customize.category.report.execute.ReportBeansToXML.java
/** * @param items// w w w . java 2s . com * @return */ public static void convertToXml(OutputStream outputStream, Document dom) { Transformer transformer = null; try { TransformerFactory factory = TransformerFactory.newInstance(); transformer = factory.newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); } catch (TransformerConfigurationException e) { LOGGER.error( "Creating the transformer failed with TransformerConfigurationException: " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); return; } try { transformer.transform(new DOMSource(dom), new StreamResult(outputStream)); } catch (TransformerException e) { LOGGER.error("Transform failed with TransformerException: " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } }