1.增加hibernate会话绑定配置,修复new thread中数据库操作的session过期的问题
2.修复告警信息页面懒加载后显示异常的问题 3.任务列表中不显示非本机任务
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
|
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
|
||||||
<%@include file="/common/taglib.jsp"%>
|
<%@include file="/common/taglib.jsp"%>
|
||||||
|
|
||||||
<%
|
<%
|
||||||
String path = request.getContextPath();
|
String path = request.getContextPath();
|
||||||
String basePath = request.getScheme() + "://"
|
String basePath = request.getScheme() + "://"
|
||||||
@@ -8,7 +7,6 @@
|
|||||||
+ path + "/";
|
+ path + "/";
|
||||||
request.setAttribute("vEnter","\n");
|
request.setAttribute("vEnter","\n");
|
||||||
%>
|
%>
|
||||||
</script>
|
|
||||||
<c:set var="index" value="${1}" />
|
<c:set var="index" value="${1}" />
|
||||||
<c:choose>
|
<c:choose>
|
||||||
<c:when test="${fn:length(detecWarningList) > 0}">
|
<c:when test="${fn:length(detecWarningList) > 0}">
|
||||||
@@ -92,7 +90,6 @@ $(function(){
|
|||||||
$(".popover").remove();
|
$(".popover").remove();
|
||||||
var x = event.clientX;//鼠标位置
|
var x = event.clientX;//鼠标位置
|
||||||
var y = event.clientY;
|
var y = event.clientY;
|
||||||
//alert(tx + "," + ty + "," + x + "," + y);
|
|
||||||
if (y < ty/2) {
|
if (y < ty/2) {
|
||||||
var placement = "bottom";
|
var placement = "bottom";
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -555,6 +555,7 @@
|
|||||||
<c:set var="tdClass" value="color_3" />
|
<c:set var="tdClass" value="color_3" />
|
||||||
<c:set var="tdClassR" value="color_6" />
|
<c:set var="tdClassR" value="color_6" />
|
||||||
</c:if>
|
</c:if>
|
||||||
|
<c:if test="${missionstatetable.missionState ne -1}">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="${tdClass }" nowrap="nowrap" >
|
<td class="${tdClass }" nowrap="nowrap" >
|
||||||
<input type="hidden" id="yxbz${missionstatetable.missionId }" name="yxbz${missionstatetable.missionId }" value="${missionstatetable.missionState}" />
|
<input type="hidden" id="yxbz${missionstatetable.missionId }" name="yxbz${missionstatetable.missionId }" value="${missionstatetable.missionState}" />
|
||||||
@@ -634,6 +635,7 @@
|
|||||||
<td class="${tdClass }" nowrap="nowrap">${missionstatetable.userIdName}</td>
|
<td class="${tdClass }" nowrap="nowrap">${missionstatetable.userIdName}</td>
|
||||||
<td class="${tdClassR }" nowrap="nowrap"><fmt:formatDate value="${missionstatetable.createTime}" type="both" /></td>
|
<td class="${tdClassR }" nowrap="nowrap"><fmt:formatDate value="${missionstatetable.createTime}" type="both" /></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
</c:if>
|
||||||
<c:set var="index" value="${index + 1}" />
|
<c:set var="index" value="${index + 1}" />
|
||||||
</c:forEach>
|
</c:forEach>
|
||||||
</c:when>
|
</c:when>
|
||||||
|
|||||||
@@ -78,6 +78,7 @@
|
|||||||
<prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
|
<prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
|
||||||
<prop key="hibernate.jdbc.fetch_size">${hibernate.jdbc.fetch_size}</prop>
|
<prop key="hibernate.jdbc.fetch_size">${hibernate.jdbc.fetch_size}</prop>
|
||||||
<prop key="hibernate.jdbc.batch_size">${hibernate.jdbc.batch_size}</prop>
|
<prop key="hibernate.jdbc.batch_size">${hibernate.jdbc.batch_size}</prop>
|
||||||
|
<prop key="hibernate.current_session_context_class">thread</prop>
|
||||||
</props>
|
</props>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import org.hibernate.Criteria;
|
|||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
import org.hibernate.Query;
|
import org.hibernate.Query;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
|
import org.hibernate.SessionFactory;
|
||||||
import org.hibernate.Transaction;
|
import org.hibernate.Transaction;
|
||||||
import org.hibernate.criterion.CriteriaSpecification;
|
import org.hibernate.criterion.CriteriaSpecification;
|
||||||
import org.hibernate.criterion.Criterion;
|
import org.hibernate.criterion.Criterion;
|
||||||
@@ -36,6 +37,7 @@ import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
|||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.ReflectionUtils;
|
import org.springframework.util.ReflectionUtils;
|
||||||
|
|
||||||
|
import nis.nms.service.CommonService;
|
||||||
import nis.nms.util.BaseAction;
|
import nis.nms.util.BaseAction;
|
||||||
import nis.nms.util.BeanUtils;
|
import nis.nms.util.BeanUtils;
|
||||||
import nis.nms.util.GenericUtils;
|
import nis.nms.util.GenericUtils;
|
||||||
@@ -127,6 +129,12 @@ public class HibernateGeneralDaoImpl<T> extends HibernateDaoSupport implements H
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void save(Object entity, SessionFactory sessionFactory) throws Exception {
|
||||||
|
CommonService<T> c = new CommonService<T>();
|
||||||
|
c.setSessionFactory(sessionFactory);
|
||||||
|
c.save(entity);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save(Object entity) throws Exception {
|
public void save(Object entity) throws Exception {
|
||||||
if(txFlag){
|
if(txFlag){
|
||||||
@@ -178,6 +186,12 @@ public class HibernateGeneralDaoImpl<T> extends HibernateDaoSupport implements H
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void update(Object entity, SessionFactory sessionFactory) throws Exception {
|
||||||
|
CommonService<T> c = new CommonService<T>();
|
||||||
|
c.setSessionFactory(sessionFactory);
|
||||||
|
update(entity);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Object entity) throws Exception {
|
public void update(Object entity) throws Exception {
|
||||||
if(txFlag){
|
if(txFlag){
|
||||||
|
|||||||
@@ -53,6 +53,13 @@ import org.apache.poi.hssf.usermodel.HSSFRow;
|
|||||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
import org.apache.struts2.ServletActionContext;
|
import org.apache.struts2.ServletActionContext;
|
||||||
|
import org.hibernate.FlushMode;
|
||||||
|
import org.hibernate.Session;
|
||||||
|
import org.hibernate.SessionFactory;
|
||||||
|
import org.hibernate.cfg.Configuration;
|
||||||
|
import org.springframework.orm.hibernate3.SessionFactoryUtils;
|
||||||
|
import org.springframework.orm.hibernate3.SessionHolder;
|
||||||
|
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||||
|
|
||||||
import com.nms.thread.socket.SocketClientServeice;
|
import com.nms.thread.socket.SocketClientServeice;
|
||||||
import com.opensymphony.xwork2.ActionSupport;
|
import com.opensymphony.xwork2.ActionSupport;
|
||||||
@@ -1109,10 +1116,15 @@ public abstract class BaseAction extends ActionSupport implements Serializable
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
if (Constant.DC_NOTICE) {
|
||||||
try {
|
try {
|
||||||
new SocketClientServeice(st.getServerIp()).sendInfoToServer(WEB_NOTICE_SET_INFO_ALERT,jObject.toString());
|
new SocketClientServeice(st.getServerIp()).sendInfoToServer(WEB_NOTICE_SET_INFO_ALERT,jObject.toString());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
|
||||||
|
SessionFactory sessionFactory = commonService.getSessionFactory();
|
||||||
|
boolean participate = HibernateUtil.bindHibernateSessionToThread(sessionFactory);
|
||||||
|
|
||||||
EventRecordLibrary library = new EventRecordLibrary();
|
EventRecordLibrary library = new EventRecordLibrary();
|
||||||
library.setRecordCommand(WEB_NOTICE_SET_INFO_ALERT);
|
library.setRecordCommand(WEB_NOTICE_SET_INFO_ALERT);
|
||||||
library.setRecordContent(jObject.toString());
|
library.setRecordContent(jObject.toString());
|
||||||
@@ -1121,12 +1133,33 @@ public abstract class BaseAction extends ActionSupport implements Serializable
|
|||||||
library.setNmsserverId(st.getId());
|
library.setNmsserverId(st.getId());
|
||||||
library.setCreateTime(new Date());
|
library.setCreateTime(new Date());
|
||||||
try {
|
try {
|
||||||
commonService.save(library);
|
commonService.save(library, sessionFactory);
|
||||||
} catch (Exception e1) {
|
} catch (Exception e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
HibernateUtil.closeHibernateSessionFromThread(participate, sessionFactory);
|
||||||
}
|
}
|
||||||
logger.error("Monitoring setting to change communication anomalies: " + e.getMessage());
|
logger.error("Monitoring setting to change communication anomalies: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
SessionFactory sessionFactory = commonService.getSessionFactory();
|
||||||
|
boolean participate = HibernateUtil.bindHibernateSessionToThread(sessionFactory);
|
||||||
|
|
||||||
|
EventRecordLibrary library = new EventRecordLibrary();
|
||||||
|
library.setRecordCommand(WEB_NOTICE_SET_INFO_ALERT);
|
||||||
|
library.setRecordContent(jObject.toString());
|
||||||
|
library.setRecordType("W2S");
|
||||||
|
library.setState(1l);
|
||||||
|
library.setNmsserverId(st.getId());
|
||||||
|
library.setCreateTime(new Date());
|
||||||
|
try {
|
||||||
|
commonService.save(library, sessionFactory);
|
||||||
|
} catch (Exception e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
HibernateUtil.closeHibernateSessionFromThread(participate, sessionFactory);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}).start();
|
}).start();
|
||||||
@@ -1237,6 +1270,7 @@ public abstract class BaseAction extends ActionSupport implements Serializable
|
|||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
if (Constant.DC_NOTICE) {
|
||||||
try {
|
try {
|
||||||
new SocketClientServeice(st.getServerIp()).
|
new SocketClientServeice(st.getServerIp()).
|
||||||
sendFilesToServer(SEND_PLUGIN_SCRIPT_FILE, pluginFiles);
|
sendFilesToServer(SEND_PLUGIN_SCRIPT_FILE, pluginFiles);
|
||||||
@@ -1250,6 +1284,10 @@ public abstract class BaseAction extends ActionSupport implements Serializable
|
|||||||
}
|
}
|
||||||
String content = StringUtils.join(pluginFileNames.iterator(), ",");
|
String content = StringUtils.join(pluginFileNames.iterator(), ",");
|
||||||
recordContent.put("scriptNames", content);
|
recordContent.put("scriptNames", content);
|
||||||
|
|
||||||
|
SessionFactory sessionFactory = commonService.getSessionFactory();
|
||||||
|
boolean participate = HibernateUtil.bindHibernateSessionToThread(sessionFactory);
|
||||||
|
|
||||||
EventRecordLibrary library = new EventRecordLibrary();
|
EventRecordLibrary library = new EventRecordLibrary();
|
||||||
library.setRecordType("W2S");
|
library.setRecordType("W2S");
|
||||||
library.setRecordCommand(SEND_PLUGIN_SCRIPT_FILE);
|
library.setRecordCommand(SEND_PLUGIN_SCRIPT_FILE);
|
||||||
@@ -1258,12 +1296,41 @@ public abstract class BaseAction extends ActionSupport implements Serializable
|
|||||||
library.setNmsserverId(st.getId());
|
library.setNmsserverId(st.getId());
|
||||||
library.setCreateTime(new Date());
|
library.setCreateTime(new Date());
|
||||||
try {
|
try {
|
||||||
commonService.save(library);
|
commonService.save(library, sessionFactory);
|
||||||
} catch (Exception e1) {
|
} catch (Exception e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
HibernateUtil.closeHibernateSessionFromThread(participate, sessionFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Map<String, String> recordContent = new HashMap<String, String>();
|
||||||
|
HashSet<String> pluginFileNames = new HashSet<String>();
|
||||||
|
for (File pluginFile : pluginFiles) {
|
||||||
|
pluginFileNames.add(pluginFile.getName());
|
||||||
|
}
|
||||||
|
String content = StringUtils.join(pluginFileNames.iterator(), ",");
|
||||||
|
recordContent.put("scriptNames", content);
|
||||||
|
|
||||||
|
SessionFactory sessionFactory = commonService.getSessionFactory();
|
||||||
|
boolean participate = HibernateUtil.bindHibernateSessionToThread(sessionFactory);
|
||||||
|
|
||||||
|
EventRecordLibrary library = new EventRecordLibrary();
|
||||||
|
library.setRecordType("W2S");
|
||||||
|
library.setRecordCommand(SEND_PLUGIN_SCRIPT_FILE);
|
||||||
|
library.setRecordContent(JSONObject.fromObject(recordContent).toString());
|
||||||
|
library.setState(1L);
|
||||||
|
library.setNmsserverId(st.getId());
|
||||||
|
library.setCreateTime(new Date());
|
||||||
|
try {
|
||||||
|
commonService.save(library, sessionFactory);
|
||||||
|
} catch (Exception e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
HibernateUtil.closeHibernateSessionFromThread(participate, sessionFactory);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
@@ -1290,7 +1357,7 @@ public abstract class BaseAction extends ActionSupport implements Serializable
|
|||||||
+ " on ('0,' || dsi.node_groups_id || ',0' like '%,' || ngt.group_id || ',%')"
|
+ " on ('0,' || dsi.node_groups_id || ',0' like '%,' || ngt.group_id || ',%')"
|
||||||
+ " left join node_table nt"
|
+ " left join node_table nt"
|
||||||
+ " on ('0,' || dsi.node_ips_id || ',0' like '%,' || nt.node_id || ',%')"
|
+ " on ('0,' || dsi.node_ips_id || ',0' like '%,' || nt.node_id || ',%')"
|
||||||
+ " where and dsi.detection_set_state = 1 and dsi.is_control_start = 2"
|
+ " where dsi.detection_set_state = 1 and dsi.is_control_start = 2"
|
||||||
+ ")t"
|
+ ")t"
|
||||||
+ " where 1<>1";
|
+ " where 1<>1";
|
||||||
if(nodeId!=null) {
|
if(nodeId!=null) {
|
||||||
@@ -1298,12 +1365,12 @@ public abstract class BaseAction extends ActionSupport implements Serializable
|
|||||||
}
|
}
|
||||||
//@2018-3-9 fang 修改 首先查询符合条件的id,在拼接sql,适配mysql
|
//@2018-3-9 fang 修改 首先查询符合条件的id,在拼接sql,适配mysql
|
||||||
String groupIdSql = "select group_id from nodegroup_table t where 1=1 ";
|
String groupIdSql = "select group_id from nodegroup_table t where 1=1 ";
|
||||||
String ids = this.commonService.getGroupIdStartWith(groupIdSql, "t.group_id = " +nodeGroupId);
|
String ids = commonService.getGroupIdStartWith(groupIdSql, "t.group_id = " +nodeGroupId);
|
||||||
/*sql += " or(t.node_ips_id is null and t.node_group_id in(select group_id"
|
/*sql += " or(t.node_ips_id is null and t.node_group_id in(select group_id"
|
||||||
+ " from nodegroup_table t"
|
+ " from nodegroup_table t"
|
||||||
+ " start with t.group_id = " +nodeGroupId+ " connect by prior t.group_id = parent_group_id))"*/
|
+ " start with t.group_id = " +nodeGroupId+ " connect by prior t.group_id = parent_group_id))"*/
|
||||||
sql += " or ( t.node_ips_id is null and t.node_group_id in("+ids+")"
|
sql += " or ( t.node_ips_id is null and t.node_group_id in("+ids+")"
|
||||||
+ " or(t.node_ips_id is null and t.node_groups_id is null)"
|
+ " or(t.node_ips_id is null and t.node_groups_id is null))"
|
||||||
;
|
;
|
||||||
|
|
||||||
List<?> SetInfoIdList = commonService.executeSQL(sql);
|
List<?> SetInfoIdList = commonService.executeSQL(sql);
|
||||||
@@ -1322,6 +1389,7 @@ public abstract class BaseAction extends ActionSupport implements Serializable
|
|||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
if (Constant.DC_NOTICE) {
|
||||||
try {
|
try {
|
||||||
new SocketClientServeice(st.getServerIp()).
|
new SocketClientServeice(st.getServerIp()).
|
||||||
sendFilesToServer(SEND_PLUGIN_SCRIPT_FILE, pluginFiles);
|
sendFilesToServer(SEND_PLUGIN_SCRIPT_FILE, pluginFiles);
|
||||||
@@ -1336,6 +1404,9 @@ public abstract class BaseAction extends ActionSupport implements Serializable
|
|||||||
String content = StringUtils.join(pluginFileNames.iterator(), ",");
|
String content = StringUtils.join(pluginFileNames.iterator(), ",");
|
||||||
recordContent.put("scriptNames", content);
|
recordContent.put("scriptNames", content);
|
||||||
|
|
||||||
|
SessionFactory sessionFactory = commonService.getSessionFactory();
|
||||||
|
boolean participate = HibernateUtil.bindHibernateSessionToThread(sessionFactory);
|
||||||
|
|
||||||
EventRecordLibrary library = new EventRecordLibrary();
|
EventRecordLibrary library = new EventRecordLibrary();
|
||||||
library.setRecordType("W2S");
|
library.setRecordType("W2S");
|
||||||
library.setRecordCommand(SEND_PLUGIN_SCRIPT_FILE);
|
library.setRecordCommand(SEND_PLUGIN_SCRIPT_FILE);
|
||||||
@@ -1344,12 +1415,41 @@ public abstract class BaseAction extends ActionSupport implements Serializable
|
|||||||
library.setNmsserverId(st.getId());
|
library.setNmsserverId(st.getId());
|
||||||
library.setCreateTime(new Date());
|
library.setCreateTime(new Date());
|
||||||
try {
|
try {
|
||||||
commonService.save(library);
|
commonService.save(library, sessionFactory);
|
||||||
} catch (Exception e1) {
|
} catch (Exception e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
HibernateUtil.closeHibernateSessionFromThread(participate, sessionFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Map<String, String> recordContent = new HashMap<String, String>();
|
||||||
|
HashSet<String> pluginFileNames = new HashSet<String>();
|
||||||
|
for (File pluginFile : pluginFiles) {
|
||||||
|
pluginFileNames.add(pluginFile.getName());
|
||||||
|
}
|
||||||
|
String content = StringUtils.join(pluginFileNames.iterator(), ",");
|
||||||
|
recordContent.put("scriptNames", content);
|
||||||
|
|
||||||
|
SessionFactory sessionFactory = commonService.getSessionFactory();
|
||||||
|
boolean participate = HibernateUtil.bindHibernateSessionToThread(sessionFactory);
|
||||||
|
|
||||||
|
EventRecordLibrary library = new EventRecordLibrary();
|
||||||
|
library.setRecordType("W2S");
|
||||||
|
library.setRecordCommand(SEND_PLUGIN_SCRIPT_FILE);
|
||||||
|
library.setRecordContent(JSONArray.fromObject(recordContent).toString());
|
||||||
|
library.setState(1L);
|
||||||
|
library.setNmsserverId(st.getId());
|
||||||
|
library.setCreateTime(new Date());
|
||||||
|
try {
|
||||||
|
commonService.save(library, sessionFactory);
|
||||||
|
} catch (Exception e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
HibernateUtil.closeHibernateSessionFromThread(participate, sessionFactory);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
@@ -1390,10 +1490,15 @@ public abstract class BaseAction extends ActionSupport implements Serializable
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
if (Constant.DC_NOTICE) {
|
||||||
try {
|
try {
|
||||||
new SocketClientServeice(st.getServerIp()).sendInfoToServer(WEB_NOTICE_NODE_AND_GROUP_STATE_ALERT,str);
|
new SocketClientServeice(st.getServerIp()).sendInfoToServer(WEB_NOTICE_NODE_AND_GROUP_STATE_ALERT,str);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
|
SessionFactory sessionFactory = commonService.getSessionFactory();
|
||||||
|
boolean participate = HibernateUtil.bindHibernateSessionToThread(sessionFactory);
|
||||||
|
|
||||||
EventRecordLibrary library = new EventRecordLibrary();
|
EventRecordLibrary library = new EventRecordLibrary();
|
||||||
library.setRecordCommand(WEB_NOTICE_NODE_AND_GROUP_STATE_ALERT);
|
library.setRecordCommand(WEB_NOTICE_NODE_AND_GROUP_STATE_ALERT);
|
||||||
library.setRecordContent(str);
|
library.setRecordContent(str);
|
||||||
@@ -1401,10 +1506,33 @@ public abstract class BaseAction extends ActionSupport implements Serializable
|
|||||||
library.setState(1l);
|
library.setState(1l);
|
||||||
library.setNmsserverId(st.getId());
|
library.setNmsserverId(st.getId());
|
||||||
library.setCreateTime(new Date());
|
library.setCreateTime(new Date());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
commonService.save(library);
|
commonService.save(library, sessionFactory);
|
||||||
} catch (Exception e1) {
|
} catch (Exception e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
HibernateUtil.closeHibernateSessionFromThread(participate, sessionFactory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
SessionFactory sessionFactory = commonService.getSessionFactory();
|
||||||
|
boolean participate = HibernateUtil.bindHibernateSessionToThread(sessionFactory);
|
||||||
|
|
||||||
|
EventRecordLibrary library = new EventRecordLibrary();
|
||||||
|
library.setRecordCommand(WEB_NOTICE_NODE_AND_GROUP_STATE_ALERT);
|
||||||
|
library.setRecordContent(str);
|
||||||
|
library.setRecordType("W2S");
|
||||||
|
library.setState(1l);
|
||||||
|
library.setNmsserverId(st.getId());
|
||||||
|
library.setCreateTime(new Date());
|
||||||
|
|
||||||
|
try {
|
||||||
|
commonService.save(library, sessionFactory);
|
||||||
|
} catch (Exception e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
HibernateUtil.closeHibernateSessionFromThread(participate, sessionFactory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1443,11 +1571,15 @@ public abstract class BaseAction extends ActionSupport implements Serializable
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
if (Constant.DC_NOTICE) {
|
||||||
try {
|
try {
|
||||||
new SocketClientServeice(st.getServerIp()).sendInfoToServer(WEB_NOTICE_ACTIVE_ALARM_START_ALERT,jObject.toString());
|
new SocketClientServeice(st.getServerIp()).sendInfoToServer(WEB_NOTICE_ACTIVE_ALARM_START_ALERT,jObject.toString());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
|
SessionFactory sessionFactory = commonService.getSessionFactory();
|
||||||
|
boolean participate = HibernateUtil.bindHibernateSessionToThread(sessionFactory);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List list = commonService.find("from EventRecordLibrary where recordType='W2S' and recordCommand='"+WEB_NOTICE_ACTIVE_ALARM_START_ALERT+"' and nmsserverId="+st.getId());
|
List list = commonService.find("from EventRecordLibrary where recordType='W2S' and recordCommand='"+WEB_NOTICE_ACTIVE_ALARM_START_ALERT+"' and nmsserverId="+st.getId());
|
||||||
EventRecordLibrary library = new EventRecordLibrary();
|
EventRecordLibrary library = new EventRecordLibrary();
|
||||||
@@ -1461,7 +1593,7 @@ public abstract class BaseAction extends ActionSupport implements Serializable
|
|||||||
library.setNmsserverId(st.getId());
|
library.setNmsserverId(st.getId());
|
||||||
library.setCreateTime(new Date());
|
library.setCreateTime(new Date());
|
||||||
|
|
||||||
commonService.update(library);
|
commonService.update(library, sessionFactory);
|
||||||
}else {
|
}else {
|
||||||
library.setRecordCommand(WEB_NOTICE_ACTIVE_ALARM_START_ALERT);
|
library.setRecordCommand(WEB_NOTICE_ACTIVE_ALARM_START_ALERT);
|
||||||
library.setRecordContent(jObject.toString());
|
library.setRecordContent(jObject.toString());
|
||||||
@@ -1469,11 +1601,47 @@ public abstract class BaseAction extends ActionSupport implements Serializable
|
|||||||
library.setState(1l);
|
library.setState(1l);
|
||||||
library.setNmsserverId(st.getId());
|
library.setNmsserverId(st.getId());
|
||||||
library.setCreateTime(new Date());
|
library.setCreateTime(new Date());
|
||||||
commonService.save(library);
|
commonService.save(library, sessionFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e1) {
|
} catch (Exception e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
HibernateUtil.closeHibernateSessionFromThread(participate, sessionFactory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
SessionFactory sessionFactory = commonService.getSessionFactory();
|
||||||
|
boolean participate = HibernateUtil.bindHibernateSessionToThread(sessionFactory);
|
||||||
|
|
||||||
|
try {
|
||||||
|
List list = commonService.find("from EventRecordLibrary where recordType='W2S' and recordCommand='"+WEB_NOTICE_ACTIVE_ALARM_START_ALERT+"' and nmsserverId="+st.getId());
|
||||||
|
EventRecordLibrary library = new EventRecordLibrary();
|
||||||
|
if (list != null && list.size() > 0) {
|
||||||
|
library = (EventRecordLibrary)list.get(0);
|
||||||
|
|
||||||
|
library.setRecordCommand(WEB_NOTICE_ACTIVE_ALARM_START_ALERT);
|
||||||
|
library.setRecordContent(jObject.toString());
|
||||||
|
library.setRecordType("W2S");
|
||||||
|
library.setState(1l);
|
||||||
|
library.setNmsserverId(st.getId());
|
||||||
|
library.setCreateTime(new Date());
|
||||||
|
|
||||||
|
commonService.update(library, sessionFactory);
|
||||||
|
}else {
|
||||||
|
library.setRecordCommand(WEB_NOTICE_ACTIVE_ALARM_START_ALERT);
|
||||||
|
library.setRecordContent(jObject.toString());
|
||||||
|
library.setRecordType("W2S");
|
||||||
|
library.setState(1l);
|
||||||
|
library.setNmsserverId(st.getId());
|
||||||
|
library.setCreateTime(new Date());
|
||||||
|
commonService.save(library, sessionFactory);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
HibernateUtil.closeHibernateSessionFromThread(participate, sessionFactory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1506,10 +1674,15 @@ public abstract class BaseAction extends ActionSupport implements Serializable
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
if (Constant.DC_NOTICE) {
|
||||||
try {
|
try {
|
||||||
new SocketClientServeice(st.getServerIp()).sendInfoToServer(WEB_NOTICE_CHECK_TYPE_ALERT,checkTypeId);
|
new SocketClientServeice(st.getServerIp()).sendInfoToServer(WEB_NOTICE_CHECK_TYPE_ALERT,checkTypeId);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
|
SessionFactory sessionFactory = commonService.getSessionFactory();
|
||||||
|
boolean participate = HibernateUtil.bindHibernateSessionToThread(sessionFactory);
|
||||||
|
|
||||||
EventRecordLibrary library = new EventRecordLibrary();
|
EventRecordLibrary library = new EventRecordLibrary();
|
||||||
library.setRecordCommand(WEB_NOTICE_CHECK_TYPE_ALERT);
|
library.setRecordCommand(WEB_NOTICE_CHECK_TYPE_ALERT);
|
||||||
library.setRecordContent(checkTypeId);
|
library.setRecordContent(checkTypeId);
|
||||||
@@ -1518,9 +1691,30 @@ public abstract class BaseAction extends ActionSupport implements Serializable
|
|||||||
library.setCreateTime(new Date());
|
library.setCreateTime(new Date());
|
||||||
library.setNmsserverId(st.getId());
|
library.setNmsserverId(st.getId());
|
||||||
try {
|
try {
|
||||||
commonService.save(library);
|
commonService.save(library, sessionFactory);
|
||||||
} catch (Exception e1) {
|
} catch (Exception e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
HibernateUtil.closeHibernateSessionFromThread(participate, sessionFactory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
SessionFactory sessionFactory = commonService.getSessionFactory();
|
||||||
|
boolean participate = HibernateUtil.bindHibernateSessionToThread(sessionFactory);
|
||||||
|
|
||||||
|
EventRecordLibrary library = new EventRecordLibrary();
|
||||||
|
library.setRecordCommand(WEB_NOTICE_CHECK_TYPE_ALERT);
|
||||||
|
library.setRecordContent(checkTypeId);
|
||||||
|
library.setRecordType("W2S");
|
||||||
|
library.setState(1l);
|
||||||
|
library.setCreateTime(new Date());
|
||||||
|
library.setNmsserverId(st.getId());
|
||||||
|
try {
|
||||||
|
commonService.save(library, sessionFactory);
|
||||||
|
} catch (Exception e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
HibernateUtil.closeHibernateSessionFromThread(participate, sessionFactory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1552,10 +1746,15 @@ public abstract class BaseAction extends ActionSupport implements Serializable
|
|||||||
new Thread(new Runnable(){
|
new Thread(new Runnable(){
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
if (Constant.DC_NOTICE) {
|
||||||
try {
|
try {
|
||||||
new SocketClientServeice(st.getServerIp()).sendInfoToServer(WEB_NOTICE_MISSION_INFO_ALERT,str);
|
new SocketClientServeice(st.getServerIp()).sendInfoToServer(WEB_NOTICE_MISSION_INFO_ALERT,str);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
|
SessionFactory sessionFactory = commonService.getSessionFactory();
|
||||||
|
boolean participate = HibernateUtil.bindHibernateSessionToThread(sessionFactory);
|
||||||
|
|
||||||
EventRecordLibrary library = new EventRecordLibrary();
|
EventRecordLibrary library = new EventRecordLibrary();
|
||||||
library.setRecordCommand(WEB_NOTICE_MISSION_INFO_ALERT);
|
library.setRecordCommand(WEB_NOTICE_MISSION_INFO_ALERT);
|
||||||
library.setRecordContent(str);
|
library.setRecordContent(str);
|
||||||
@@ -1564,9 +1763,30 @@ public abstract class BaseAction extends ActionSupport implements Serializable
|
|||||||
library.setCreateTime(new Date());
|
library.setCreateTime(new Date());
|
||||||
library.setNmsserverId(st.getId());
|
library.setNmsserverId(st.getId());
|
||||||
try {
|
try {
|
||||||
commonService.save(library);
|
commonService.save(library, sessionFactory);
|
||||||
} catch (Exception e1) {
|
} catch (Exception e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
HibernateUtil.closeHibernateSessionFromThread(participate, sessionFactory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
SessionFactory sessionFactory = commonService.getSessionFactory();
|
||||||
|
boolean participate = HibernateUtil.bindHibernateSessionToThread(sessionFactory);
|
||||||
|
|
||||||
|
EventRecordLibrary library = new EventRecordLibrary();
|
||||||
|
library.setRecordCommand(WEB_NOTICE_MISSION_INFO_ALERT);
|
||||||
|
library.setRecordContent(str);
|
||||||
|
library.setRecordType("W2S");
|
||||||
|
library.setState(1l);
|
||||||
|
library.setCreateTime(new Date());
|
||||||
|
library.setNmsserverId(st.getId());
|
||||||
|
try {
|
||||||
|
commonService.save(library, sessionFactory);
|
||||||
|
} catch (Exception e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
HibernateUtil.closeHibernateSessionFromThread(participate, sessionFactory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1601,10 +1821,15 @@ public abstract class BaseAction extends ActionSupport implements Serializable
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
String content = "1";
|
String content = "1";
|
||||||
|
if (Constant.DC_NOTICE) {
|
||||||
try {
|
try {
|
||||||
new SocketClientServeice(ip).sendInfoToServer(WEB_NOTICE_DATACONTROLLER,content);
|
new SocketClientServeice(ip).sendInfoToServer(WEB_NOTICE_DATACONTROLLER,content);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
|
SessionFactory sessionFactory = commonService.getSessionFactory();
|
||||||
|
boolean participate = HibernateUtil.bindHibernateSessionToThread(sessionFactory);
|
||||||
|
|
||||||
EventRecordLibrary library = new EventRecordLibrary();
|
EventRecordLibrary library = new EventRecordLibrary();
|
||||||
library.setRecordCommand(WEB_NOTICE_DATACONTROLLER);
|
library.setRecordCommand(WEB_NOTICE_DATACONTROLLER);
|
||||||
library.setRecordContent(content);
|
library.setRecordContent(content);
|
||||||
@@ -1613,9 +1838,30 @@ public abstract class BaseAction extends ActionSupport implements Serializable
|
|||||||
library.setCreateTime(new Date());
|
library.setCreateTime(new Date());
|
||||||
library.setNmsserverId(dcId);
|
library.setNmsserverId(dcId);
|
||||||
try {
|
try {
|
||||||
commonService.save(library);
|
commonService.save(library, sessionFactory);
|
||||||
} catch (Exception e1) {
|
} catch (Exception e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
HibernateUtil.closeHibernateSessionFromThread(participate, sessionFactory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
SessionFactory sessionFactory = commonService.getSessionFactory();
|
||||||
|
boolean participate = HibernateUtil.bindHibernateSessionToThread(sessionFactory);
|
||||||
|
|
||||||
|
EventRecordLibrary library = new EventRecordLibrary();
|
||||||
|
library.setRecordCommand(WEB_NOTICE_DATACONTROLLER);
|
||||||
|
library.setRecordContent(content);
|
||||||
|
library.setRecordType("W2S");
|
||||||
|
library.setState(1l);
|
||||||
|
library.setCreateTime(new Date());
|
||||||
|
library.setNmsserverId(dcId);
|
||||||
|
try {
|
||||||
|
commonService.save(library, sessionFactory);
|
||||||
|
} catch (Exception e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
HibernateUtil.closeHibernateSessionFromThread(participate, sessionFactory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1673,4 +1919,6 @@ public abstract class BaseAction extends ActionSupport implements Serializable
|
|||||||
public void setThisPageUrl(String thisPageUrl) {
|
public void setThisPageUrl(String thisPageUrl) {
|
||||||
this.thisPageUrl = thisPageUrl;
|
this.thisPageUrl = thisPageUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -118,6 +118,8 @@ public class Constant {
|
|||||||
* */
|
* */
|
||||||
public static final String EMAIL_FLAG="emailFlag";
|
public static final String EMAIL_FLAG="emailFlag";
|
||||||
|
|
||||||
|
public static final boolean DC_NOTICE = "1".equals(rb.getString("dc.notice")) ? true : false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户部门功能
|
* 用户部门功能
|
||||||
* */
|
* */
|
||||||
|
|||||||
40
src/nis/nms/util/HibernateUtil.java
Normal file
40
src/nis/nms/util/HibernateUtil.java
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
package nis.nms.util;
|
||||||
|
|
||||||
|
import org.hibernate.FlushMode;
|
||||||
|
import org.hibernate.Session;
|
||||||
|
import org.hibernate.SessionFactory;
|
||||||
|
import org.springframework.orm.hibernate3.SessionFactoryUtils;
|
||||||
|
import org.springframework.orm.hibernate3.SessionHolder;
|
||||||
|
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||||
|
|
||||||
|
public class HibernateUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将hibernate的会话绑定给一个线程
|
||||||
|
* @param sessionFactory
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean bindHibernateSessionToThread(SessionFactory sessionFactory) {
|
||||||
|
if (TransactionSynchronizationManager.hasResource(sessionFactory)) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
Session session = sessionFactory.openSession();
|
||||||
|
session.setFlushMode(FlushMode.MANUAL);
|
||||||
|
SessionHolder sessionHolder = new SessionHolder(session);
|
||||||
|
TransactionSynchronizationManager.bindResource(sessionFactory, sessionHolder);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将线程上绑定的hibernate会话关闭
|
||||||
|
* @param participate
|
||||||
|
* @param sessionFactory
|
||||||
|
*/
|
||||||
|
public static void closeHibernateSessionFromThread(boolean participate, Object sessionFactory) {
|
||||||
|
if (!participate) {
|
||||||
|
SessionHolder sessionHolder = (SessionHolder)TransactionSynchronizationManager.unbindResource(sessionFactory);
|
||||||
|
SessionFactoryUtils.closeSession(sessionHolder.getSession());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user