log.error("Not XML: [{}]", firstLine);
return;
}
XMLResponseConferenceListParser confXML = new XMLResponseConferenceListParser();
//get a factory
SAXParserFactory spf = SAXParserFactory.newInstance();
try {
//get a new instance of parser
SAXParser sp = spf.newSAXParser();
//Hack turning body lines back into string then to ByteStream.... BLAH!
String responseBody = org.springframework.util.StringUtils.collectionToDelimitedString(response.getBodyLines(), "\n");
log.debug("xml_list responce\n{}\nEND", responseBody);
//http://mark.koli.ch/2009/02/resolving-orgxmlsaxsaxparseexception-content-is-not-allowed-in-prolog.html
//This Sux!
responseBody = responseBody.trim().replaceFirst("^([\\W]+)<","<");
ByteArrayInputStream bs = new ByteArrayInputStream(responseBody.getBytes());
sp.parse(bs, confXML);
//Maybe move this to XMLResponseConferenceListParser, sendConfrenceEvents ?
VoiceUserJoinedEvent pj;
for(ConferenceMember member : confXML.getConferenceList()) {
log.debug("conf list member [{}] for room [{}].", member.getId(), confXML.getConferenceRoom());
//Foreach found member in conference create a JoinedEvent
String callerId = member.getCallerId();
String callerIdName = member.getCallerIdName();
String voiceUserId = callerIdName;
Matcher matcher = CALLERNAME_PATTERN.matcher(callerIdName);
if (matcher.matches()) {
voiceUserId = matcher.group(1).trim();
callerIdName = matcher.group(2).trim();
}
pj = new VoiceUserJoinedEvent(voiceUserId, member.getId().toString(), confXML.getConferenceRoom(),
callerId, callerIdName, member.getMuted(), member.getSpeaking());
eventListener.handleConferenceEvent(pj);
}
}catch(SAXException se) {