Commit df85524c by WeiCong

版本继续整合

parent 1860e3a6
......@@ -3,7 +3,7 @@
<groupId>cn.com.brilliance</groupId>
<artifactId>eibs-springmvc-support</artifactId>
<packaging>jar</packaging>
<version>1.0.0</version>
<version>1.0.1</version>
<name>eibs-springmvc-support</name>
<repositories><!-- 代码库 -->
<repository>
......
package org.sss.presentation.noui.common;
public class Constants {
public final static String PARAMS = "params";
public final static String DATA = "data";
public final static String DISPLAY = "display";
public final static String ENCODING = "UTF-8";
public final static String USERNAME = "username";
public final static String PASSWORD = "password";
public final static String DNCODE = "dncode";
public final static String SENDCODE = "sendcode";
public final static String VERIFYCODE = "verifycode";
public final static String DISPLAY_FILE_NAME = "fileName";
public final static String MAPPING_PRE = "_";
public final static String SESSION = "session";
public final static String BACKGROUND_FLAG = "BackGroundRequest-";
public static final String PAGINATION = "pagination";
public static final String PAGINATION_INDEX = "index";
public static final String PAGINATION_PAGESIZE = "pageSize";
public static final String PAGINATION_TOTAL = "total";
}
package org.sss.presentation.noui.common;
public class Constants {
public final static String PARAMS = "params";
public final static String DATA = "data";
public final static String DISPLAY = "display";
public final static String ENCODING = "UTF-8";
public final static String USERNAME = "username";
public final static String PASSWORD = "password";
public final static String DNCODE = "dncode";
public final static String SENDCODE = "sendcode";
public final static String VERIFYCODE = "verifycode";
public final static String DISPLAY_FILE_NAME = "fileName";
public final static String MAPPING_PRE = "_";
public final static String SESSION = "session";
public final static String BACKGROUND_FLAG = "BackGroundRequest-";
public final static String APP_FLAG = "AppRequest-";
public static final String PAGINATION = "pagination";
public static final String PAGINATION_INDEX = "index";
public static final String PAGINATION_PAGESIZE = "pageSize";
public static final String PAGINATION_TOTAL = "total";
}
package org.sss.presentation.noui.context;
import log.Log;
import log.LogFactory;
import org.apache.commons.io.IOUtils;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.engine.spi.SessionImplementor;
import org.sss.module.hibernate.HibernateUtils;
import org.sss.module.pojo.DatabaseUtils;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.Date;
import java.util.Optional;
import java.util.stream.Stream;
public class TxInfo {
protected static final Log log = LogFactory.getLog(TxInfo.class);
public static ThreadLocal<TxInfo> txInfoHolder = new ThreadLocal<>();
public String txCode;
public String url;
public String target;
public static void putTxInfo(String txCode,String url,String target)
{
TxInfo txInfo = new TxInfo();
txInfo.txCode = txCode;
txInfo.url = url;
txInfo.target = target;
txInfoHolder.set(txInfo);
}
public static TxInfo getTxInfo()
{
return txInfoHolder.get();
}
public static void releaseCurrTxInfo()
{
txInfoHolder.remove();
}
/**
* 记录异常信息
* @param e
*/
public static void recordException(Throwable e) {
TxInfo txInfo = getTxInfo();
Session session = HibernateUtils.openSession(null);
long count = DatabaseUtils.executeCounter(((SessionImplementor) session).connection(),"dealog");
String inr = String.format("%08d",count);
Transaction transaction = session.beginTransaction();
SQLQuery sqlQuery = session.createSQLQuery("insert into dealog(INR,CREDATTIM,SRVCOD,SRVNAM,INIFRM,RTNMSG,LOGLEV) values(?,?,?,?,?,?,?)");
sqlQuery.setString(0,inr);
sqlQuery.setTimestamp(1,new Date());
String srvcod = txInfo.url.replace("/_","-");
sqlQuery.setString(2,srvcod);
sqlQuery.setString(3,srvcod);
sqlQuery.setString(4,txInfo.txCode);
sqlQuery.setString(5,genMessage(e));
sqlQuery.setString(6,"error");
sqlQuery.executeUpdate();
transaction.commit();
session.close();
log.debug("完成异常日志记录");
}
private static String genMessage(Throwable e)
{
while(e.getCause() != null)
e = e.getCause();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(bos);
e.printStackTrace(ps);
String mesg = bos.toString();
IOUtils.closeQuietly(ps);
IOUtils.closeQuietly(bos);
String[] lines = mesg.split("[\r\n]{1,2}");
Optional<String> rs = Stream.of(lines).filter(str->{
return str.charAt(0) != '\t' || (str.indexOf("brilliance")>0 || str.indexOf(".noui.")>0);
}).reduce((acc,item)->{
return acc+'\n'+item;
});
return rs.get();
}
}
package org.sss.presentation.noui.context;
import log.Log;
import log.LogFactory;
import org.apache.commons.io.IOUtils;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.Optional;
import java.util.stream.Stream;
public class TxInfo {
protected static final Log log = LogFactory.getLog(TxInfo.class);
public static ThreadLocal<TxInfo> txInfoHolder = new ThreadLocal<>();
public String txCode;
public String url;
public String target;
public static void putTxInfo(String txCode,String url,String target)
{
TxInfo txInfo = new TxInfo();
txInfo.txCode = txCode;
txInfo.url = url;
txInfo.target = target;
txInfoHolder.set(txInfo);
}
public static TxInfo getTxInfo()
{
return txInfoHolder.get();
}
public static void releaseCurrTxInfo()
{
txInfoHolder.remove();
}
/**
* 记录异常信息
* @param e
*/
public static void recordException(Throwable e) {
/*TxInfo txInfo = getTxInfo();
Session session = HibernateUtils.openSession(null);
long count = DatabaseUtils.executeCounter(((SessionImplementor) session).connection(),"dealog");
String inr = String.format("%08d",count);
Transaction transaction = session.beginTransaction();
SQLQuery sqlQuery = session.createSQLQuery("insert into dealog(INR,CREDATTIM,SRVCOD,SRVNAM,INIFRM,RTNMSG,LOGLEV) values(?,?,?,?,?,?,?)");
sqlQuery.setString(0,inr);
sqlQuery.setTimestamp(1,new Date());
String srvcod = txInfo.url.replace("/_","-");
sqlQuery.setString(2,srvcod);
sqlQuery.setString(3,srvcod);
sqlQuery.setString(4,txInfo.txCode);
sqlQuery.setString(5,genMessage(e));
sqlQuery.setString(6,"error");
sqlQuery.executeUpdate();
transaction.commit();
session.close();
log.debug("完成异常日志记录");*/
}
private static String genMessage(Throwable e)
{
while(e.getCause() != null)
e = e.getCause();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(bos);
e.printStackTrace(ps);
String mesg = bos.toString();
IOUtils.closeQuietly(ps);
IOUtils.closeQuietly(bos);
String[] lines = mesg.split("[\r\n]{1,2}");
Optional<String> rs = Stream.of(lines).filter(str->{
return str.charAt(0) != '\t' || (str.indexOf("brilliance")>0 || str.indexOf(".noui.")>0);
}).reduce((acc,item)->{
return acc+'\n'+item;
});
return rs.get();
}
}
......@@ -72,8 +72,10 @@ public abstract class AbstractCommonController {
}
// 设置old sysmod
RedisLoginInfo redisLoginInfo = null;
if (!StringUtils.isEmpty(noUiRequest.getUserId())) //开放模式下
if (!StringUtils.isEmpty(noUiRequest.getUserId())){
//开放模式下
redisLoginInfo = (RedisLoginInfo) EhcacheUtils.get(StringUtil.userUniqueId(noUiRequest));
}
if (redisLoginInfo != null) {
NoUiPresentationUtil.setSysmod(context, (byte[]) redisLoginInfo.getSysmod());
context.setRedisLoginInfo(redisLoginInfo);
......
......@@ -25,6 +25,7 @@ public class ResourceAccessFilter implements Filter {
private static final String _403_JSON = "{\"code\": \"403\", \"msg\": \"Access Forbidden, Unauthorized!\"}";
private static final String _403_HTML = "<html><body><div style='text-align:center'><h1 style='margin-top: 10px;'>Access Forbidden, Unauthorized!</h1></div></body></html>";
private static final String DSPPTH = "/data/dsp/";
private static final String[] empty_array = new String[0];
public static String[] pdfpth;
public static String[] exclude;
......@@ -113,7 +114,6 @@ public class ResourceAccessFilter implements Filter {
}
private String needPdfsFilter(String uri) {
for (String pdf : pdfpth) {
if (uri.contains(pdf)) {
......@@ -175,11 +175,15 @@ public class ResourceAccessFilter implements Filter {
}
public void init(FilterConfig filterConfig) {
if (filterConfig.getInitParameter("pdfpth") != null) {
if (!StringUtil.isEmpty(filterConfig.getInitParameter("pdfpth"))) {
pdfpth = filterConfig.getInitParameter("pdfpth").split(";");
} else {
pdfpth = empty_array;
}
if (!StringUtil.isEmpty(filterConfig.getInitParameter("exclude"))) {
exclude = filterConfig.getInitParameter("exclude").split(";");
} else {
exclude = empty_array;
}
}
......
......@@ -51,6 +51,11 @@ public class TokenInterceptor implements HandlerInterceptor {
if (token.startsWith(Constants.BACKGROUND_FLAG)) {
return true;
}
//服务调用
if (token.startsWith(Constants.APP_FLAG)) {
return true;
}
JwtLogin login = JWT.unsign(token, JwtLogin.class);
if (login == null || (!userId.equals((login.getUserId())))) {
......
......@@ -44,7 +44,7 @@ public class EhcacheUtils {
EhCacheCacheManager ehCacheCacheManager = null;
try {
if (cacheManager == null) {
ehCacheCacheManager = SpringContextHolder.getBean(EhCacheCacheManager.class);
ehCacheCacheManager = SpringContextHolder.getBean("ehcacheManager");
cacheManager = ehCacheCacheManager.getCacheManager();
}
} catch (Exception e) {
......
......@@ -14,6 +14,15 @@
</property>
</bean>
<!--cacheManager工厂类,指定ehcache.xml的位置-->
<bean id="ehcacheManagerFactory" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<property name="configLocation" value="classpath:ehcache.xml"/>
</bean>
<!--声明cacheManager-->
<bean id="ehcacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
<property name="cacheManager" ref="ehcacheManagerFactory"/>
</bean>
<bean id="springContextHolder" class="org.sss.presentation.noui.util.SpringContextHolder"/>
</beans>
\ No newline at end of file
......@@ -39,15 +39,7 @@
<property name="rootFilePath" value="" />
</bean>
<!--cacheManager工厂类,指定ehcache.xml的位置-->
<bean id="ehcacheManagerFactory" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<property name="configLocation" value="classpath:ehcache.xml"/>
</bean>
<!--声明cacheManager-->
<bean id="ehcacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
<property name="cacheManager" ref="ehcacheManagerFactory"/>
</bean>
<mvc:default-servlet-handler />
<mvc:interceptors>
......
package.base=com.brilliance.eibs.etrade
subpackage.trans=trans
subpackage.module=module
......@@ -82,8 +82,7 @@
</init-param>
<init-param>
<param-name>exclude</param-name>
<param-value>
</param-value>
<param-value></param-value>
</init-param>
</filter>
<filter-mapping>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment