/** * @see * com.yahoo.petermwenda83.persistence.guardian.SchoolParentsDAO#updateParent(com.yahoo.petermwenda83.bean.student.guardian.StudentParent) */ @Override public boolean updateParent(StudentParent parent) { boolean success = true; try (Connection conn = dbutils.getConnection(); PreparedStatement pstmt = conn.prepareStatement( "UPDATE StudentParent SET Fathername = ?,Fatherphone = ?,FatherEmail = ?," + "FatherID =?,Fatheroccupation =?,Mothername =?,Motherphone =?,MotherEmail=?,MotherID =?,Motheroccupation=?," + "RelativeName =?,RelativePhone =? WHERE StudentUuid = ?;"); ) { pstmt.setString(1, parent.getFathername()); pstmt.setString(2, parent.getFatherphone()); pstmt.setString(3, parent.getFatherEmail()); pstmt.setString(4, parent.getFatherID()); pstmt.setString(5, parent.getFatheroccupation()); pstmt.setString(6, parent.getMothername()); pstmt.setString(7, parent.getMotherphone()); pstmt.setString(8, parent.getMotherEmail()); pstmt.setString(9, parent.getMotherID()); pstmt.setString(10, parent.getMotheroccupation()); pstmt.setString(11, parent.getRelativeName()); pstmt.setString(12, parent.getRelativePhone()); pstmt.setString(13, parent.getStudentUuid()); pstmt.executeUpdate(); } catch (SQLException e) { logger.error("SQL Exception when updating update StudentParent " + parent); logger.error(ExceptionUtils.getStackTrace(e)); System.out.println(ExceptionUtils.getStackTrace(e)); success = false; } return success; }
void writeFreqToInverter(float freq) { log.entry(freq); log.debug("writeFreqToInverter " + id + ": " + freq); long now = Calendar.getInstance().getTime().getTime(); try { FileWriter fw = new FileWriter(cfg.e_dati + id + cfg.log_suffix, true); log.debug("writeFreqToInverter: " + now + "|" + freq); fw.write(now + "|" + freq + "\n"); fw.close(); ((TimeSeriesPanel) freq_tsp).addMaxObservation(now, freq_plate); ((TimeSeriesPanel) freq_tsp).addCurrentObservation(now, freq); ((TimeSeriesPanel) kw_tsp).addMaxObservation(now, kw_max); ((TimeSeriesPanel) kw_tsp) .addCurrentObservation( now, (Math.pow(freq * 100. / freq_plate, 3) / 10000) * kw_max / 100); ((TimeSeriesPanel) h_tsp).addMaxObservation(now, volume_max * 7 * 1.25 / 1000); ((TimeSeriesPanel) h_tsp).addCurrentObservation(now, (volume_reale) * 7 * 1.25 / 1000); } catch (IOException e) { log.error(ExceptionUtils.getStackTrace(e)); } try { setFreq(freq); } catch (protocolException | transportException e) { log.error(ExceptionUtils.getStackTrace(e)); } log.exit(); }
public void execute(ActivityExecution execution) throws Exception { ScriptingEngines scriptingEngines = Context.getProcessEngineConfiguration().getScriptingEngines(); boolean noErrors = true; try { Object result = scriptingEngines.evaluate(script, language, execution, storeScriptVariables); if (resultVariable != null) { execution.setVariable(resultVariable, result); } } catch (ActivitiException e) { LOGGER.warn( "Exception while executing " + execution.getActivity().getId() + " : " + e.getMessage()); noErrors = false; Throwable rootCause = ExceptionUtils.getRootCause(e); if (rootCause instanceof BpmnError) { ErrorPropagation.propagateError((BpmnError) rootCause, execution); } else { throw e; } } if (noErrors) { leave(execution); } }
private void logExec(String pCmdString, Map<String, String> unsortedEnv) { if (_log.isInfoEnabled()) { TreeMap<String, String> env = new TreeMap<String, String>(); env.putAll(unsortedEnv); _log.info("Executing '" + pCmdString + "'"); _log.debug("Enviroment:"); FileWriter writer = null; try { if (_log.isDebugEnabled()) { File envvarFile = File.createTempFile("envvars", ".txt"); writer = new FileWriter(envvarFile); _log.debug("ENVVARS will be written to " + envvarFile.getAbsolutePath()); } for (String key : env.keySet()) { _log.debug(String.format(" %s", new Object[] {key + "=" + env.get(key)})); if (_log.isDebugEnabled()) writer.write(String.format(" %s%n", new Object[] {key + "=" + env.get(key)})); } if (_log.isDebugEnabled()) writer.close(); } catch (Exception e) { _log.error("Unable to log exec call: " + ExceptionUtils.getStackTrace(e)); } } }
public static String sendPOSTReq(List<BasicNameValuePair> params, String licenseProviderAddress) { String responseStr = ""; try { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(licenseProviderAddress); // Request parameters and other properties. httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8")); // Execute and get the response. HttpResponse response = httpclient.execute(httppost); HttpEntity entity = response.getEntity(); if (entity != null) { InputStream instream = entity.getContent(); responseStr = StringArrayParameterUtils.getStringFromInputStream(instream); try { // do something useful } finally { instream.close(); } } } catch (Exception ex) { LOGGER.error(ExceptionUtils.getStackTrace(ex)); } int idx = responseStr.indexOf("}<!DOCTYPE HTML", 0); if (idx > 0) { responseStr = responseStr.substring(0, idx + 1); } return responseStr; }
private String stackTrace() { if (description != null) { return description; } else { return exception.getMessage() != null ? "" : ExceptionUtils.getStackTrace(exception); } }
/** * Get the value to be shown from the database and then try to localize * * @param value * @param locale * @return */ @Override public String getShowValue(Object value, Locale locale) { String keySuffix = BooleanFields.FALSE_VALUE; if (value == null) { value = TWorkItemBean.ACCESS_LEVEL_PUBLIC; } Integer intValue = null; try { intValue = (Integer) value; } catch (Exception e) { LOGGER.warn( "Casting the value type " + value.getClass().getName() + " to Integer failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } if (intValue != null && TWorkItemBean.ACCESS_LEVEL_PRIVATE.equals(intValue)) { keySuffix = BooleanFields.TRUE_VALUE; } String localizedLabel = LocalizeUtil.getLocalizedTextFromApplicationResources( "common.boolean." + keySuffix, locale); if (localizedLabel != null && localizedLabel.length() > 0) { return localizedLabel; } return keySuffix; }
@Action("SignModeCheck") public String signModeCheck() throws Exception { try { HttpClient client = new HttpClient(); String url = "http://127.0.0.1:" + getServerPort() + "/service/"; logger.debug("url: " + url); CommunicationVo requestVo = new CommunicationVo(); requestVo.setTradeCode("000001"); requestVo.putParam("signMode", this.signVo.getSignMode()); requestVo.putParam("certDn", this.signVo.getCertDn()); PostMethod postMethod = new PostMethod(url); postMethod.addParameter("json", requestVo.toJson()); client.executeMethod(postMethod); String resp = postMethod.getResponseBodyAsString().trim(); postMethod.releaseConnection(); logger.info("resp: " + resp); CommunicationVo respVo = CommunicationVo.getInstancefromJson(resp); if (!"0000".equals(respVo.getStatus())) { throw new ServiceException(respVo.getMessage()); } this.dwzResp.ajaxSuccessForward(respVo.getMessage()); this.dwzResp.setAlertClose(Boolean.valueOf(false)); } catch (Exception e) { logger.error(ExceptionUtils.getStackTrace(e)); this.dwzResp.errorForward(e.getMessage()); return "dwz"; } return "dwz"; }
private String createRequestBody(Job job) { XmlBuilder xml = new XmlBuilder("Error"); String timestamp = df.format(job.received); xml.append("Timestamp", timestamp); xml.append("Version", EMCShopkeeper.VERSION); String dbVersionStr = (dbVersion == null) ? "null" : dbVersion.toString(); xml.append("DatabaseVersion", dbVersionStr); xml.append("JavaVendor", System.getProperty("java.vendor")); xml.append("JavaVersion", System.getProperty("java.version")); xml.append("OS", System.getProperty("os.name")); xml.append("Locale", Locale.getDefault().toString()); xml.append("WebStart", JarSignersHardLinker.isRunningOnWebstart() + ""); String message = job.message; if (message != null) { xml.append("Message", message); } if (job.throwable != null) { String stackTrace = ExceptionUtils.getStackTrace(job.throwable); xml.append("StackTrace", stackTrace); } return xml.toString(); }
/** @see com.yahoo.petermwenda83.persistence.guardian.SchoolParentsDAO#getParentList() */ @Override public List<StudentParent> getParentList() { List<StudentParent> list = null; try (Connection conn = dbutils.getConnection(); PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM StudentParent;"); ResultSet rset = pstmt.executeQuery(); ) { list = beanProcessor.toBeanList(rset, StudentParent.class); } catch (SQLException e) { logger.error("SQL Exception when getting Parent List"); logger.error(ExceptionUtils.getStackTrace(e)); System.out.println(ExceptionUtils.getStackTrace(e)); } return list; }
@CrossOrigin(origins = "*") @RequestMapping(value = "/sendEmailFromTo") @ResponseStatus(HttpStatus.OK) public String sendEmail(String fromAddress, String toAddress, String uuid) throws IOException { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); Message message = new Message( fromAddress, toAddress, "Your mazda routes exported at " + sdf.format(new Date()), "These are your exported cached routes from Mazda"); byte[] data = createZip(uuid); Attachment attachment = new Attachment("routes.zip", data); message.setAttachments(attachment); try { mailService.send(message); log.info("Routes sent to \"{}\"", toAddress); } catch (CallNotFoundException ex) { log.error("Cannot send email: {}", ExceptionUtils.getRootCauseMessage(ex)); File file = new File("routes_" + toAddress + "_" + System.currentTimeMillis() + ".zip"); FileUtils.writeByteArrayToFile(file, data); log.info("Routes save to file: {}", file.getAbsolutePath()); } finally { routeRepository.clearRoutes(uuid); } return "{}"; }
/** * Get the ISO show value for locale independent exporting to xml typically same as show value, * date and number values are formatted by iso format * * @param fieldID * @param parameterCode * @param value * @param workItemID * @param localLookupContainer * @param locale * @return */ @Override public String getShowISOValue( Integer fieldID, Integer parameterCode, Object value, Integer workItemID, LocalLookupContainer localLookupContainer, Locale locale) { if (value == null) { value = TWorkItemBean.ACCESS_LEVEL_PUBLIC; } Integer intValue = null; try { intValue = (Integer) value; } catch (Exception e) { LOGGER.error( "Casting the value type " + value.getClass().getName() + " to Integer failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } if (intValue != null && TWorkItemBean.ACCESS_LEVEL_PRIVATE.equals(intValue)) { return new Boolean(true).toString(); } else { return new Boolean(false).toString(); } }
/** * Creates new exception with fault code and fault message. * * @param faultCode the fault code * @param faultMessage the message */ public CodedException(String faultCode, String faultMessage) { super(faultMessage); this.faultCode = faultCode; faultDetail = ExceptionUtils.getStackTrace(this); faultString = faultMessage; }
/** Checking item usage for right click on entity */ public boolean checkEntityRightClick(ItemStack item, Resident res, Entity entity) { for (Iterator<SegmentEntity> it = segmentsEntities.iterator(); it.hasNext(); ) { SegmentEntity segment = it.next(); if (segment.getType() == EntityType.PROTECT && segment.getCheckClass().isAssignableFrom(entity.getClass())) { int dim = entity.dimension; int x = (int) Math.floor(entity.posX); int y = (int) Math.floor(entity.posY); int z = (int) Math.floor(entity.posZ); if (!hasPermission(res, segment, dim, x, y, z)) { return true; } } } if (item == null) return false; for (Iterator<SegmentItem> it = segmentsItems.iterator(); it.hasNext(); ) { SegmentItem segment = it.next(); if (segment.getType() == ItemType.RIGHT_CLICK_ENTITY && segment.getCheckClass().isAssignableFrom(item.getItem().getClass())) { try { if (segment.checkCondition(item)) { int range = segment.getRange(item); int dim = entity.dimension; int x = (int) Math.floor(entity.posX); int y = (int) Math.floor(entity.posY); int z = (int) Math.floor(entity.posZ); if (range == 0) { if (!hasPermission(res, segment, dim, x, y, z)) { return true; } } else { Volume rangeBox = new Volume(x - range, y - range, z - range, x + range, y + range, z + range); if (!hasPermission(res, segment, dim, rangeBox)) { return true; } } } } catch (Exception ex) { MyTown.instance.LOG.error( "Failed to check item use on {} at the player {} ({}, {}, {} | Dim: {})", item.getDisplayName(), res.getPlayerName(), entity.posX, entity.posY, entity.posZ, entity.dimension); MyTown.instance.LOG.error(ExceptionUtils.getStackTrace(ex)); if (ex instanceof GetterException || ex instanceof ConditionException) { this.disableSegment(it, segment, ex.getMessage()); } } } } return false; }
/** * Creates exception from fault code and cause. * * @param faultCode the fault code * @param cause the cause */ public CodedException(String faultCode, Throwable cause) { super(cause); this.faultCode = faultCode; this.faultDetail = ExceptionUtils.getStackTrace(cause); this.faultString = cause.getMessage(); }
/** @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (request.getCharacterEncoding() == null) request.setCharacterEncoding("UTF-8"); response.setContentType("application/json;charset=UTF-8"); response.setCharacterEncoding("UTF-8"); JSONObject ret = new JSONObject(); PrintWriter out = response.getWriter(); Enumeration<String> enumTest = request.getParameterNames(); HashMap<String, Object> requestMap = new HashMap<String, Object>(); while (enumTest.hasMoreElements()) { String tmp = enumTest.nextElement().toString(); requestMap.put(tmp, request.getParameter(tmp)); } try { Kayttaja kayttaja = new Kayttaja(SecurityContextHolder.getContext().getAuthentication().getName()); int orgId = Integer.parseInt(requestMap.get("org_id").toString()); String lang = requestMap.get("lang").toString(); if (lang == null || lang == "") lang = "fi"; org = new Organisation(lang); MapData md = new MapData(lang); ret = md.getExtentByType(MapData.TYPE_ORGANISATIONS, orgId); ret.put("success", true); out.println(ret.toString()); } catch (Exception e) { log.error(ExceptionUtils.getStackTrace(e)); out.println("{'success':'false', 'msg': 'Tapahtui odottamaton virhe sovelluksessa.'}"); } }
/** @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (request.getCharacterEncoding() == null) request.setCharacterEncoding("UTF-8"); response.setContentType("text/html;charset=UTF-8"); response.setCharacterEncoding("UTF-8"); String strLang = ""; Translate translate = new Translate(); Kayttaja kayttaja; /*System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog"); System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true"); System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "debug"); System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug");*/ PrintWriter out = response.getWriter(); Enumeration<String> enumTest = request.getParameterNames(); HashMap<String, Object> requestMap = new HashMap<String, Object>(); while (enumTest.hasMoreElements()) { String tmp = enumTest.nextElement().toString(); requestMap.put(tmp, request.getParameter(tmp)); } JSONObject ret = new JSONObject(); try { kayttaja = new Kayttaja(SecurityContextHolder.getContext().getAuthentication().getName()); // System.out.println(kayttaja.getKayttajaNimi()); strLang = requestMap.get("lang").toString(); String textValue = requestMap.get("textValue").toString(); int textId = -1; if (requestMap.containsKey("textId")) { textId = Integer.parseInt(requestMap.get("textId").toString()); } if (strLang == null || strLang == "") strLang = "fi"; JSONObject t = translate.getUITranslations(strLang); Translate transObj = new Translate(); System.out.println(requestMap); if (kayttaja.isSupervisor()) { if (textId == -1) { String textLabel = requestMap.get("textLabel").toString(); textId = transObj.createTranslation(textValue, textLabel, strLang); } if (textId == -1) { ret.put("success", false); ret.put("msg", t.getString("save_not_success")); } else { transObj.setTranslationText(textId, textValue, strLang); ret.put("success", true); ret.put("msg", t.getString("save_success")); } } else { ret.put("success", false); ret.put("msg", t.getString("insufficient_rights")); } out.println(ret.toString()); } catch (Exception e) { log.error(org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace(e)); out.println("{'success':'false', 'msg': 'Tapahtui odottamaton virhe sovelluksessa.'}"); } }
/** * @see * com.yahoo.petermwenda83.persistence.guardian.SchoolParentsDAO#deleteParent(com.yahoo.petermwenda83.bean.student.guardian.StudentParent) */ @Override public boolean deleteParent(StudentParent parent) { boolean success = true; try (Connection conn = dbutils.getConnection(); PreparedStatement pstmt = conn.prepareStatement("DELETE FROM StudentParent" + " WHERE StudentUuid =?;"); ) { pstmt.setString(1, parent.getStudentUuid()); pstmt.executeUpdate(); } catch (SQLException e) { logger.error("SQL Exception when deletting StudentParent : " + parent); logger.error(ExceptionUtils.getStackTrace(e)); System.out.println(ExceptionUtils.getStackTrace(e)); success = false; } return success; }
/** * gives an {@link OverpassPopup} of an {@link OverpassFeature}<br> * If it is not stored, it will be created automatically * * @since 0.0.1 * @param id the OpenStreetMap identifier to get the popup of * @param entityType the {@link EntityType} of the requested object * @return the {@link OverpassPopup} of the {@link Entity} with the identifier <code>id</code> */ public static OverpassPopup getPopup(long id, EntityType entityType) { PopupStore.clean(); if (!(PopupStore.expires.containsKey(id))) { String content; String entityTypeName = entityType.name().toLowerCase(); long delay; try { String query = "[out:popup];" + entityTypeName + "(" + id + ");out;"; content = IOUtils.toString( (new URL( "http://overpass-api.de/api/interpreter?data=" + URLEncoder.encode(query, "UTF-8"))) .openStream()); delay = PopupStore.try_again_delay; } catch (IOException e) { content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"; content += "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\r\n"; content += "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\r\n"; content += "<head>\r\n"; content += "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" lang=\"en\"/>\r\n"; content += "<title>Error on loading popup content!</title>\r\n"; content += "</head>\r\n"; content += "<body>\r\n"; content += "<p align=\"center\"><strong>Couldn't load popup content from Overpass API!</strong></p>\r\n"; content += "<p>The following exception occurred:<br />\r\n"; content += "<code><pre>" + StringEscapeUtils.escapeHtml4(ExceptionUtils.getStackTrace(e)) + "</pre></code>\r\n"; content += "</p>\r\n"; content += "<p style=\"font-size:smaller\">OpenStreetMap object: <a href=\"https://www.openstreetmap.org/" + entityTypeName + "/" + id + "\" target=\"_blank\">" + id + "</a></p>\r\n"; content += "</body>\r\n"; content += "</html>\r\n"; delay = PopupStore.expire_delay; } PopupStore.popups.put(id, new OverpassPopup(entityType, id, content)); PopupStore.expires.put(id, (new DateTime()).plus(delay)); } return PopupStore.popups.get(id); }
protected boolean shouldCheck(Object object) { try { if (condition != null && !condition.execute(object, getters)) { return false; } } catch (GetterException ex) { MyTown.instance.LOG.error( "Encountered error when checking condition for {}", checkClass.getSimpleName()); MyTown.instance.LOG.error(ExceptionUtils.getStackTrace(ex)); disable(); } catch (ConditionException ex) { MyTown.instance.LOG.error( "Encountered error when checking condition for {}", checkClass.getSimpleName()); MyTown.instance.LOG.error(ExceptionUtils.getStackTrace(ex)); disable(); } return true; }
/** * 获取缓存 * * @param key * @param callable * @return */ public static Object get(String key, Callable callable) { Object object = null; try { object = cache.get(key, callable); } catch (ExecutionException e) { logger.error("cache get error:{}", ExceptionUtils.getMessage(e)); } return object; }
@Override public void onFailure(Throwable t) { knownTasks.remove(taskWrapper.getRequestId()); taskWrapper.setIsInPreemptableQueue(false); taskWrapper.maybeUnregisterForFinishedStateNotifications(); taskWrapper.getTaskRunnerCallable().getCallback().onFailure(t); updatePreemptionListAndNotify(null); LOG.error("Failed notification received: Stacktrace: " + ExceptionUtils.getStackTrace(t)); }
@Override public void postToFeed(final User user, final Throwable ex) { LogHelper.logException(this.getClass(), ex); try { postToFeed(user, ExceptionUtils.getStackTrace(ex), FeedType.error); } catch (NimbitsException e) { LogHelper.logException(this.getClass(), e); } }
/** * @param act * @param locale * @param exception */ private void sendKrashAuditEmail(Act act, Locale locale, Exception exception) { ResourceBundle bundle = ResourceBundle.getBundle(BUNDLE_NAME, locale); String emailFrom = bundle.getString(RECIPIENT_KEY); String projectName = getProjectNameFromAct(act); if (isAllowedToSendKrashReport && CollectionUtils.isNotEmpty(krashReportMailList)) { Set<String> emailToSet = new HashSet<>(); emailToSet.addAll(krashReportMailList); String host = ""; try { host = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException uhe) { } String msgSubject = bundle.getString(KRASH_ADMIN_SUBJECT_KEY); msgSubject = StringUtils.replace(msgSubject, PROJECT_NAME_TO_REPLACE, projectName); msgSubject = StringUtils.replace(msgSubject, HOST_TO_REPLACE, host); String msgContent = bundle.getString(KRASH_ADMIN_MSG_CONTENT_KEY); msgContent = StringUtils.replace(msgContent, PROJECT_NAME_TO_REPLACE, projectName); msgContent = StringUtils.replace( msgContent, USER_EMAIL_TO_REPLACE, act.getContract().getUser().getEmail1()); msgContent = StringUtils.replace(msgContent, HOST_TO_REPLACE, host); msgContent = StringUtils.replace( msgContent, EXCEPTION_TO_REPLACE, ExceptionUtils.getStackTrace(exception)); if (act.getAudit().getSubject() != null) { msgContent = StringUtils.replace( msgContent, AUDIT_URL_TO_REPLACE, act.getAudit().getSubject().getURL()); } LOGGER.info( "krash email sent to " + krashReportMailList + " on audit n° " + act.getAudit().getId()); sendEmail(emailFrom, emailToSet, msgSubject, msgContent); } String emailTo = act.getContract().getUser().getEmail1(); if (this.emailSentToUserExclusionList.contains(emailTo)) { LOGGER.info("Email not set cause user " + emailTo + " belongs to " + "exlusion list"); return; } Set<String> emailToSet = new HashSet<>(); emailToSet.add(emailTo); String msgSubject = bundle.getString(KRASH_SUBJECT_KEY); msgSubject = StringUtils.replace(msgSubject, PROJECT_NAME_TO_REPLACE, projectName); String msgContent = bundle.getString(KRASH_MSG_CONTENT_KEY); msgContent = StringUtils.replace(msgContent, PROJECT_NAME_TO_REPLACE, projectName); msgContent = StringUtils.replace( msgContent, PROJECT_URL_TO_REPLACE, buildContractUrl(act.getContract())); LOGGER.info("krash email sent to [" + emailTo + "]" + " on audit n° " + act.getAudit().getId()); sendEmail(emailFrom, emailToSet, msgSubject, msgContent); }
public static String getResponseBody(HttpResponse response) { try { InputStream responseStream = getResponseStream(response); return IOUtils.toString(responseStream); } catch (IOException e) { logError( format( "Cannot read anm location from response due to exception: {0}. Stack trace: {1}", e.getMessage(), ExceptionUtils.getStackTrace(e))); } return ""; }
/** * @see com.yahoo.petermwenda83.persistence.guardian.SchoolParentsDAO#getParent(java.lang.String) */ @Override public StudentParent getParent(String studentUuid) { StudentParent studentParent = null; ResultSet rset = null; try (Connection conn = dbutils.getConnection(); PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM studentParent" + " WHERE studentUuid =?;"); ) { pstmt.setString(1, studentUuid); rset = pstmt.executeQuery(); while (rset.next()) { studentParent = beanProcessor.toBean(rset, StudentParent.class); } } catch (SQLException e) { logger.error("SQL Exception trying to get studentParent with studentuuid: " + studentUuid); logger.error(ExceptionUtils.getStackTrace(e)); System.out.println(ExceptionUtils.getStackTrace(e)); } return studentParent; }
public static void handleException(RestRequest request, RestResponse response, Throwable ex) { Throwable rootCause = ExceptionUtils.getRootCause(ex); rootCause = rootCause == null ? ex : rootCause; logger.error("捕获到Rest异常:request={}", request, rootCause); RestError restError = new RestError(); restError.setErrorCode(2); if (ex instanceof RestServiceException) { RestServiceException rse = (RestServiceException) ex; if (rse.getErrorCode() != 0) { restError.setErrorCode(rse.getErrorCode()); } restError.setErrorInfo(rse.getMessage()); } else { restError.setErrorInfo(RestApiConstants.DEFAULT_ERROR_INFO); if (request.isDebug()) { String stackTrace = ExceptionUtils.getStackTrace(rootCause); // 截取有用的部分 stackTrace = StringUtils.substringBefore(stackTrace, RestApiConstants.STACK_TRACE_BEFORE); response.setDebugInfo(stackTrace); } // 统计响应结果 recordToErrorCounter(request.getCmd()); } response.setStatusCode(500); response.setError(restError); response.setResponseTime(new Date()); }
/** * Determines if the submission metadata file conforms to the requirements for parsing. * * @param F Spreadsheet file */ public boolean hasConformingSubmissionMetadataFile() { try { List<Submission> items = getSubmissions(); return true; } catch (Exception ex) { String stack = ExceptionUtils.getStackTrace(ex); logger.log( Level.SEVERE, "Could not load submission metadata from \"{0}\".\n\n{1}", new Object[] {spreadsheet.getAbsolutePath(), stack}); } return false; }
@Action("B2Bi_SignConfig_save") public String save() throws Exception { try { this.signVo.setSignTradeCode(Arrays.asList(this.signTradeCodes.trim().split("\\s+"))); this.configManager.save(this.signVo); this.dwzResp.successForward("保存配置成功"); this.dwzResp.setCallbackType(null); } catch (Exception e) { logger.error(ExceptionUtils.getStackTrace(e)); this.dwzResp.errorForward(e.getMessage()); } return "dwz"; }
/** * @see * com.yahoo.petermwenda83.persistence.guardian.SchoolParentsDAO#putParent(com.yahoo.petermwenda83.bean.student.guardian.StudentParent) */ @Override public boolean putParent(StudentParent parent) { boolean success = true; try (Connection conn = dbutils.getConnection(); PreparedStatement pstmt = conn.prepareStatement( "INSERT INTO StudentParent" + "(Uuid, StudentUuid,Fathername,Fatherphone,FatherEmail,FatherID,Fatheroccupation,Mothername," + "Motherphone,MotherEmail,MotherID,Motheroccupation,RelativeName,RelativePhone) VALUES " + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?);"); ) { pstmt.setString(1, parent.getUuid()); pstmt.setString(2, parent.getStudentUuid()); pstmt.setString(3, parent.getFathername()); pstmt.setString(4, parent.getFatherphone()); pstmt.setString(5, parent.getFatherEmail()); pstmt.setString(6, parent.getFatherID()); pstmt.setString(7, parent.getFatheroccupation()); pstmt.setString(8, parent.getMothername()); pstmt.setString(9, parent.getMotherphone()); pstmt.setString(10, parent.getMotherEmail()); pstmt.setString(11, parent.getMotherID()); pstmt.setString(12, parent.getMotheroccupation()); pstmt.setString(13, parent.getRelativeName()); pstmt.setString(14, parent.getRelativePhone()); pstmt.executeUpdate(); } catch (SQLException e) { logger.error("SQL Exception trying to put StudentParent: " + parent); logger.error(ExceptionUtils.getStackTrace(e)); System.out.println(ExceptionUtils.getStackTrace(e)); success = false; } return success; }