| | |
| | | |
| | | import javax.sip.InvalidArgumentException; |
| | | import javax.sip.RequestEvent; |
| | | import javax.sip.ServerTransaction; |
| | | import javax.sip.SipException; |
| | | import javax.sip.message.Request; |
| | | import javax.sip.message.Response; |
| | |
| | | if (device == null) { |
| | | return; |
| | | } |
| | | rootElement = getRootElement(evt, device.getCharset()); |
| | | DeviceAlarm deviceAlarm = new DeviceAlarm(); |
| | | deviceAlarm.setDeviceId(deviceId); |
| | | deviceAlarm.setAlarmPriority(XmlUtil.getText(rootElement, "AlarmPriority")); |
| | |
| | | Element rootElement = getRootElement(evt); |
| | | Element deviceIdElement = rootElement.element("DeviceID"); |
| | | String deviceId = deviceIdElement.getText(); |
| | | Device device = storager.queryVideoDevice(deviceId); |
| | | if (device != null ) { |
| | | rootElement = getRootElement(evt, device.getCharset()); |
| | | } |
| | | Element deviceListElement = rootElement.element("DeviceList"); |
| | | if (deviceListElement == null) { |
| | | return; |
| | | } |
| | | Iterator<Element> deviceListIterator = deviceListElement.elementIterator(); |
| | | if (deviceListIterator != null) { |
| | | Device device = storager.queryVideoDevice(deviceId); |
| | | if (device == null) { |
| | | return; |
| | | } |
| | |
| | | // 回复200 OK |
| | | response200Ok(evt); |
| | | if (offLineDetector.isOnline(deviceId)) { |
| | | publisher.onlineEventPublish(deviceId, VideoManagerConstants.EVENT_ONLINE_KEEPLIVE); |
| | | publisher.onlineEventPublish(device, VideoManagerConstants.EVENT_ONLINE_MESSAGE); |
| | | } |
| | | } |
| | | } catch (DocumentException | SipException | InvalidArgumentException | ParseException e) { |
| | |
| | | */ |
| | | private void response200Ok(RequestEvent evt) throws SipException, InvalidArgumentException, ParseException { |
| | | Response response = getMessageFactory().createResponse(Response.OK, evt.getRequest()); |
| | | getServerTransaction(evt).sendResponse(response); |
| | | ServerTransaction serverTransaction = getServerTransaction(evt); |
| | | serverTransaction.sendResponse(response); |
| | | if (serverTransaction.getDialog() != null) serverTransaction.getDialog().delete(); |
| | | } |
| | | |
| | | private Element getRootElement(RequestEvent evt) throws DocumentException { |
| | | return getRootElement(evt, "gb2312"); |
| | | } |
| | | private Element getRootElement(RequestEvent evt, String charset) throws DocumentException { |
| | | if (charset == null) charset = "gb2312"; |
| | | Request request = evt.getRequest(); |
| | | SAXReader reader = new SAXReader(); |
| | | reader.setEncoding("gbk"); |
| | | reader.setEncoding(charset); |
| | | Document xml = reader.read(new ByteArrayInputStream(request.getRawContent())); |
| | | return xml.getRootElement(); |
| | | } |