public String getContent() { try { return new String(content, "UTF-8"); } catch (UnsupportedEncodingException e) { Logger.error("内容编码异常", e); return ""; } }
@Override public void destroy() { Logger.info("destroyed token filter!"); } }
/** * @param msg */ public static void info(String msg) { if (!isInfoEnabled()) return; getLogger().info(msg); }
/** * @param msg * @param t */ public static void warn(String msg, Throwable t) { if (!isWarnEnabled()) return; getLogger().warn(msg, t); }
/** * @param msg */ public static void error(String msg) { if (!isErrorEnabled()) return; getLogger().error(msg); }
@Override public void onSmsMO(SmsMOReq req, SmsMORsp arg1) { // process mo message, 处理手机上行信息 try { String codeType = "GB2312"; if (req.getDataCoding() == 8) { codeType = "UTF-16BE"; } String content = new String(req.getContent(), codeType); Logger.info(content); } catch (Exception e1) { Logger.error("处理手机上行信息",e1); } }
try { Logger.info("start job '%s'", this.getClass().getSimpleName()); Long start = System.currentTimeMillis(); Result result = run(); Logger.info("成功完成 job '%s', 耗时 '%s' 毫秒.", this.getClass().getSimpleName(), System.currentTimeMillis() - start); } catch (Exception e) { Logger.error(se.getMessage(), se); Logger.warn("failure do job '%s'", this.getClass().getSimpleName());
@Override public void stop() { Logger.warn("can not stop client!"); }
/** * 债权标 流标后 更新债权信息 状态 * @param loan */ public void creditAutoBidDeal(Loan loan) { try { if (loan != null) { String status = CrediteInfo.Status.WAIT_ASSIGN; CrediteInfo creditInfo = creditInfoRepository.findOne(loan.getCreditIndex()); Date deadTime = creditInfo.getDeadTime(); if (deadTime != null) { if (deadTime.before(new Date())) { status = CrediteInfo.Status.FAIL_ASSIGNING; } } creditInfo.setStatus(status); } else { Logger.warn("债权标 流标后 更新债权信息状态:标信息为空"); } } catch (Exception e) { Logger.error("债权标 流标更新债权信息 状态异常:", e); } }
@Override public void decide(Authentication authentication, Object object, Collection<ConfigAttribute> configAttributes) throws AccessDeniedException, InsufficientAuthenticationException { // 判断目标是否在权限控制内 if (configAttributes == null) return; // 遍历权限 for (ConfigAttribute configAttribute: configAttributes) { // 将权限与用户角色进行匹配 String role = configAttribute.getAttribute(); for (GrantedAuthority grantedAuthority: authentication.getAuthorities()) { Logger.debug("match between %s and %s.", role, grantedAuthority.getAuthority()); if (Strings.equals(role, grantedAuthority.getAuthority())) { Logger.debug("matched! access allow."); return; } } } // 无法匹配权限抛出异常 Logger.info("denied!"); throw new AccessDeniedException("no authority."); }
/** * 构造函数 * * @param request * @param response */ public WebApp(HttpServletRequest request, HttpServletResponse response) { this.request = request; Flash.prepare(request); Logger.debug("request uri: " + request.getRequestURI()); }
/** * @param msg */ public static void debug(String msg) { if (!isDebugEnabled()) return; getLogger().debug(msg); }
/** * @param msg * @param t */ public static void trace(String msg, Throwable t) { if (!isTraceEnabled()) return; getLogger().trace(msg, t); }
/** * @return */ public static boolean isDebugEnabled() { return getLogger().isDebugEnabled(); }
/** * * @param para * @return 0成功 -1失败 */ public static int sendMessage(String content, String tel) { if (Strings.empty(tel) || tel.length() != 11) { errorMessage = "手机号码格式错误,tel=" + tel; Logger.error(errorMessage); return -1; } Logger.info("发送短信,手机号码:" + tel + " 短信内容\"" + content + "\""); return send(tel, content); // return 0; }
@Override public boolean safeSet(String key, Object value, int expiration) { try { set(key, value, expiration); return true; } catch (Exception e) { Logger.warn(e.getMessage()); return false; } }
@Override public Collection<ConfigAttribute> getAttributes(Object object) throws IllegalArgumentException { String uri = HttpServletRequest.class.cast(object).getRequestURI(); uri = uri.replaceFirst(WebApp.getAppPath(), ""); for (Entry<String, Collection<ConfigAttribute>> entry : getAttributesMap().entrySet()) { if (Strings.equals(uri, entry.getKey())) { Logger.debug("match uri '%s' with pattern '%s', the config attributes is: %s", uri, entry.getKey(), entry.getValue()); return entry.getValue(); } } Logger.debug("cannot match uri '%s'", uri); return null; }
/** * @param msg * @param t */ public static void info(String msg, Throwable t) { if (!isInfoEnabled()) return; getLogger().info(msg, t); }