}
dbfactory.setIgnoringComments(true);
Element el = null;
MsnContactListImpl contactList = (MsnContactListImpl) session
.getMessenger().getContactList();
MsnContactImpl contact = (MsnContactImpl)contactList.getContactById(id);
if(groupId != null)
{
mess.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
mess.append("<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"\r\n");
mess.append(" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n");
mess.append(" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\r\n");
mess.append(" xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\">\r\n");
mess.append("<soap:Header>\r\n");
mess.append("<ABApplicationHeader xmlns=\"http://www.msn.com/webservices/AddressBook\">\r\n");
mess.append("<ApplicationId>CFE80F9D-180F-4399-82AB-413F33A1FA11</ApplicationId>\r\n");
mess.append("<IsMigration>false</IsMigration>\r\n");
mess.append("<PartnerScenario>Timer</PartnerScenario>\r\n");
mess.append("</ABApplicationHeader>\r\n");
mess.append("<ABAuthHeader xmlns=\"http://www.msn.com/webservices/AddressBook\">\r\n");
mess.append("<ManagedGroupRequest>false</ManagedGroupRequest>\r\n");
mess.append("<TicketToken>" + sso.getContactTicket().replaceAll("&", "&") + "</TicketToken>\r\n");
mess.append("</ABAuthHeader>\r\n");
mess.append("</soap:Header>\r\n");
mess.append("<soap:Body>\r\n");
mess.append("<ABGroupContactDelete xmlns=\"http://www.msn.com/webservices/AddressBook\">\r\n");
mess.append("<abId>00000000-0000-0000-0000-000000000000</abId>\r\n");
mess.append("<contacts><Contact><contactId>" + id + "</contactId></Contact></contacts>\r\n");
mess.append("<groupFilter><groupIds>\r\n");
mess.append("<guid>" + groupId + "</guid>\r\n");
mess.append("</groupIds></groupFilter>\r\n");
mess.append("</ABGroupContactDelete>\r\n");
mess.append("</soap:Body>\r\n");
mess.append("</soap:Envelope>");
res = sendRequest(
mess.toString(), addressbook_url, addressbook_action_groupContactDelete, "POST");
try
{
ByteArrayInputStream in = new ByteArrayInputStream(res.getBytes());
doc = docBuilder.parse(in);
}
catch (SAXException ex)
{
logger.error("", ex);
return;
}
catch (IOException ex)
{
logger.error("", ex);
return;
}
el =
XmlUtils.locateElement(
doc.getDocumentElement(),
"ABGroupContactDeleteResponse",
"xmlns",
"http://www.msn.com/webservices/AddressBook");
// todo if something missing throw failed event
if(el == null || el.getChildNodes().getLength() > 0)
logger.error("some error in " + res);
else
{
contact.removeBelongGroup(groupId);
MsnGroup group = contactList.getGroup(groupId);
((AbstractMessenger) session.getMessenger())
.fireContactRemoveFromGroupCompleted(contact, group);
}
}
if(contact.getBelongGroups().length > 0)
return;
// remove from msn and addbook
mess = new StringBuilder();
mess.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
mess.append("<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"\r\n");
mess.append(" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n");
mess.append(" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\r\n");
mess.append(" xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\">\r\n");
mess.append("<soap:Header>\r\n");
mess.append("<ABApplicationHeader xmlns=\"http://www.msn.com/webservices/AddressBook\">\r\n");
mess.append("<ApplicationId>996CDE1E-AA53-4477-B943-2BE802EA6166</ApplicationId>\r\n");
mess.append("<IsMigration>false</IsMigration>\r\n");
mess.append("<PartnerScenario>Timer</PartnerScenario>\r\n");
mess.append("</ABApplicationHeader>\r\n");
mess.append("<ABAuthHeader xmlns=\"http://www.msn.com/webservices/AddressBook\">\r\n");
mess.append("<ManagedGroupRequest>false</ManagedGroupRequest>\r\n");
mess.append("<TicketToken>" + sso.getContactTicket().replaceAll("&", "&") + "</TicketToken>\r\n");
mess.append("</ABAuthHeader>\r\n");
mess.append("</soap:Header>\r\n");
mess.append("<soap:Body>\r\n");
mess.append("<ABContactDelete xmlns=\"http://www.msn.com/webservices/AddressBook\">\r\n");
mess.append("<abId>00000000-0000-0000-0000-000000000000</abId>\r\n");
mess.append("<contacts><Contact><contactId>" + id + "</contactId></Contact></contacts>\r\n");
mess.append("</ABContactDelete>\r\n");
mess.append("</soap:Body>\r\n");
mess.append("</soap:Envelope>");
res = sendRequest(
mess.toString(), addressbook_url, addressbook_action_contactdelete, "POST");
try
{
ByteArrayInputStream in = new ByteArrayInputStream(res.getBytes("UTF-8"));
doc = docBuilder.parse(in);
}
catch (SAXException ex)
{
logger.error("", ex);
return;
}
catch (IOException ex)
{
logger.error("", ex);
return;
}
el =
XmlUtils.locateElement(
doc.getDocumentElement(),
"ABContactDeleteResponse",
"xmlns",
"http://www.msn.com/webservices/AddressBook");
// todo if something missing throw failed event
if(el == null || el.getChildNodes().getLength() > 0)
return;
contactList.removeContactById(id);
// remove from list
AbstractMessenger messenger = (AbstractMessenger)session.getMessenger();
OutgoingRML message = new OutgoingRML(messenger.getActualMsnProtocol());
message.setRemoveFromList(list, contact);