//FIXME (need to be removed in later versions) HACK to fix 2 deleted nodes in users.xml and inline Adresses and sipData
private List<User> readUserList(InputSource xml, String listNodeName) throws Exception {
Registry registry = new Registry();
Strategy strategy = new RegistryStrategy(registry);
Serializer ser = new Persister(strategy);
registry.bind(Organisation.class, new OrganisationConverter(orgDao, organisationsMap));
registry.bind(State.class, new StateConverter(statemanagement));
registry.bind(Date.class, DateConverter.class);
DocumentBuilder dBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = dBuilder.parse(xml);
NodeList nl = getNode(getNode(doc, "root"), listNodeName).getChildNodes();
userEmailMap.clear();
//add existence email from database
List<User> users = usersDao.getAllUsers();
for (User u : users){
if (u.getAdresses() == null || u.getAdresses().getEmail() == null) {
continue;
}
userEmailMap.put(u.getAdresses().getEmail(), -1);
}
// one of the old OM version created 2 nodes "deleted" this code block handles this
for (int i = 0; i < nl.getLength(); ++i) {
Node user = nl.item(i);
NodeList nl1 = user.getChildNodes();
boolean deletedFound = false;
for (int j = 0; j < nl1.getLength(); ++j) {
Node node = nl1.item(j);
if (node.getNodeType() == Node.ELEMENT_NODE && "deleted".equals(node.getNodeName())) {
if (deletedFound) {
user.removeChild(node);
break;
}
deletedFound = true;
}
}
}
StringWriter sw = new StringWriter();
Transformer xformer = TransformerFactory.newInstance().newTransformer();
xformer.transform(new DOMSource(doc), new StreamResult(sw));
List<User> list = new ArrayList<User>();
InputNode root = NodeBuilder.read(new StringReader(sw.toString()));
InputNode root1 = NodeBuilder.read(new StringReader(sw.toString())); //HACK to handle Address inside user
InputNode root2 = NodeBuilder.read(new StringReader(sw.toString())); //HACK to handle old om_time_zone
InputNode listNode = root.getNext();
InputNode listNode1 = root1.getNext(); //HACK to handle Address inside user
InputNode listNode2 = root2.getNext(); //HACK to handle old om_time_zone
if (listNodeName.equals(listNode.getName())) {
InputNode item = listNode.getNext();
InputNode item1 = listNode1.getNext(); //HACK to handle Address inside user
InputNode item2 = listNode2.getNext(); //HACK to handle old om_time_zone
while (item != null) {
User u = ser.read(User.class, item, false);
boolean needToSkip1 = true;
//HACK to handle Address inside user
if (u.getAdresses() == null) {
Address a = ser.read(Address.class, item1, false);
u.setAdresses(a);
needToSkip1 = false;
}
if (needToSkip1) {
do {