private static int indexOfXML(byte[] buf, int offset, int maxIndex) { for(int index = offset, xmlDeclIndex = -1; index <= maxIndex; index++) { if (buf[index] != '<') continue; if (isAuditMessage(buf, index) || isIHEYr4(buf, index)) return xmlDeclIndex == -1 ? index : xmlDeclIndex; else if (xmlDeclIndex == -1 && isXMLDecl(buf, index)) xmlDeclIndex = index; } return -1; }
private static void onMessage(AuditRecordRepository arr, byte[] data, int offset, int length, Connection conn, InetAddress from) { if (LOG.isDebugEnabled()) { LOG.debug(prompt(data, MSG_PROMPT_LEN)); } int xmlOffset = indexOfXML(data, offset, Math.min(MAX_MSG_PREFIX, length)); if (xmlOffset != -1) { int xmlLength = length - xmlOffset + offset; arr.onMessage(data, xmlOffset, xmlLength, conn, from); } else { LOG.warn("Ignore unexpected message from {}: {}", from, prompt(data, MAX_MSG_PREFIX)); } }
private static void onMessage(AuditRecordRepository arr, byte[] data, int offset, int length, Connection conn, InetAddress from) { if (LOG.isDebugEnabled()) { LOG.debug(prompt(data, MSG_PROMPT_LEN)); } int xmlOffset = indexOfXML(data, offset, Math.min(MAX_MSG_PREFIX, length)); if (xmlOffset != -1) { int xmlLength = length - xmlOffset + offset; arr.onMessage(data, xmlOffset, xmlLength, conn, from); } else { LOG.warn("Ignore unexpected message from {}: {}", from, prompt(data, MAX_MSG_PREFIX)); } }
private static int indexOfXML(byte[] buf, int offset, int maxIndex) { for(int index = offset, xmlDeclIndex = -1; index <= maxIndex; index++) { if (buf[index] != '<') continue; if (isAuditMessage(buf, index) || isIHEYr4(buf, index)) return xmlDeclIndex == -1 ? index : xmlDeclIndex; else if (xmlDeclIndex == -1 && isXMLDecl(buf, index)) xmlDeclIndex = index; } return -1; }