支持全局异常和统一返回结果,未完待续
This commit is contained in:
@@ -14,6 +14,7 @@ import org.dom4j.Element;
|
||||
import org.dom4j.io.SAXReader;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.sip.RequestEvent;
|
||||
@@ -118,12 +119,12 @@ public class XmlUtil {
|
||||
// 如果是属性
|
||||
for (Object o : element.attributes()) {
|
||||
Attribute attr = (Attribute) o;
|
||||
if (!StringUtils.isEmpty(attr.getValue())) {
|
||||
if (!ObjectUtils.isEmpty(attr.getValue())) {
|
||||
json.put("@" + attr.getName(), attr.getValue());
|
||||
}
|
||||
}
|
||||
List<Element> chdEl = element.elements();
|
||||
if (chdEl.isEmpty() && !StringUtils.isEmpty(element.getText())) {// 如果没有子元素,只有一个值
|
||||
if (chdEl.isEmpty() && !ObjectUtils.isEmpty(element.getText())) {// 如果没有子元素,只有一个值
|
||||
json.put(element.getName(), element.getText());
|
||||
}
|
||||
|
||||
@@ -154,7 +155,7 @@ public class XmlUtil {
|
||||
} else { // 子元素没有子元素
|
||||
for (Object o : element.attributes()) {
|
||||
Attribute attr = (Attribute) o;
|
||||
if (!StringUtils.isEmpty(attr.getValue())) {
|
||||
if (!ObjectUtils.isEmpty(attr.getValue())) {
|
||||
json.put("@" + attr.getName(), attr.getValue());
|
||||
}
|
||||
}
|
||||
@@ -197,7 +198,7 @@ public class XmlUtil {
|
||||
return null;
|
||||
}
|
||||
String channelId = channdelIdElement.getTextTrim();
|
||||
if (StringUtils.isEmpty(channelId)) {
|
||||
if (ObjectUtils.isEmpty(channelId)) {
|
||||
logger.warn("解析Catalog消息时发现缺少 DeviceID");
|
||||
return null;
|
||||
}
|
||||
@@ -316,7 +317,7 @@ public class XmlUtil {
|
||||
// 识别自带的目录标识
|
||||
String parental = XmlUtil.getText(itemDevice, "Parental");
|
||||
// 由于海康会错误的发送65535作为这里的取值,所以这里除非是0否则认为是1
|
||||
if (!StringUtils.isEmpty(parental) && parental.length() == 1 && Integer.parseInt(parental) == 0) {
|
||||
if (!ObjectUtils.isEmpty(parental) && parental.length() == 1 && Integer.parseInt(parental) == 0) {
|
||||
deviceChannel.setParental(0);
|
||||
}else {
|
||||
deviceChannel.setParental(1);
|
||||
@@ -332,14 +333,14 @@ public class XmlUtil {
|
||||
deviceChannel.setPassword(XmlUtil.getText(itemDevice, "Password"));
|
||||
|
||||
String safetyWay = XmlUtil.getText(itemDevice, "SafetyWay");
|
||||
if (StringUtils.isEmpty(safetyWay)) {
|
||||
if (ObjectUtils.isEmpty(safetyWay)) {
|
||||
deviceChannel.setSafetyWay(0);
|
||||
} else {
|
||||
deviceChannel.setSafetyWay(Integer.parseInt(safetyWay));
|
||||
}
|
||||
|
||||
String registerWay = XmlUtil.getText(itemDevice, "RegisterWay");
|
||||
if (StringUtils.isEmpty(registerWay)) {
|
||||
if (ObjectUtils.isEmpty(registerWay)) {
|
||||
deviceChannel.setRegisterWay(1);
|
||||
} else {
|
||||
deviceChannel.setRegisterWay(Integer.parseInt(registerWay));
|
||||
|
||||
Reference in New Issue
Block a user