重构28181信令结构,解决循环依赖导致的无法直接注入

This commit is contained in:
648540858
2021-11-05 18:27:41 +08:00
parent 341ea7110a
commit f1217682a9
62 changed files with 345 additions and 3589 deletions

View File

@@ -6,7 +6,7 @@ import java.util.Date;
import java.util.Locale;
/**
* @Description:时间工具类主要处理ISO 8601格式转换
* @description:时间工具类主要处理ISO 8601格式转换
* @author: swwheihei
* @date: 2020年5月8日 下午3:24:42
*/

View File

@@ -0,0 +1,28 @@
package com.genersoft.iot.vmp.gb28181.utils;
import gov.nist.javax.sip.address.AddressImpl;
import gov.nist.javax.sip.address.SipUri;
import javax.sip.header.FromHeader;
import javax.sip.message.Request;
/**
* @author panlinlin
* @version 1.0.0
* @description JAIN SIP的工具类
* @createTime 2021年09月27日 15:12:00
*/
public class SipUtils {
public static String getUserIdFromFromHeader(Request request) {
FromHeader fromHeader = (FromHeader)request.getHeader(FromHeader.NAME);
return getUserIdFromFromHeader(fromHeader);
}
public static String getUserIdFromFromHeader(FromHeader fromHeader) {
AddressImpl address = (AddressImpl)fromHeader.getAddress();
SipUri uri = (SipUri) address.getURI();
return uri.getUser();
}
}

View File

@@ -1,15 +1,7 @@
package com.genersoft.iot.vmp.gb28181.utils;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.dom4j.Attribute;
import org.dom4j.Document;
import org.dom4j.DocumentException;
@@ -19,6 +11,12 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;
import javax.sip.RequestEvent;
import javax.sip.message.Request;
import java.io.ByteArrayInputStream;
import java.io.StringReader;
import java.util.*;
/**
* 基于dom4j的工具包
*
@@ -161,4 +159,23 @@ public class XmlUtil {
}
}
}
public static Element getRootElement(RequestEvent evt) throws DocumentException {
return getRootElement(evt, "gb2312");
}
public static Element getRootElement(RequestEvent evt, String charset) throws DocumentException {
Request request = evt.getRequest();
return getRootElement(request.getRawContent(), charset);
}
public static Element getRootElement(byte[] content, String charset) throws DocumentException {
if (charset == null) {
charset = "gb2312";
}
SAXReader reader = new SAXReader();
reader.setEncoding(charset);
Document xml = reader.read(new ByteArrayInputStream(content));
return xml.getRootElement();
}
}