for (Iterator<Element> innerIter = itemObject.elementIterator( "user" ); innerIter.hasNext(); ) {
Element itemUsers = innerIter.next();
Users us = new Users();
us.setUser_id(Long.valueOf(unformatString(itemUsers.element("user_id").getText())));
us.setAge(CalendarPatterns.parseDate(unformatString(itemUsers.element("age").getText())));
us.setAvailible(importIntegerType(unformatString(itemUsers.element("availible").getText())));
us.setDeleted(unformatString(itemUsers.element("deleted").getText()));
us.setFirstname(unformatString(itemUsers.element("firstname").getText()));
us.setLastname(unformatString(itemUsers.element("lastname").getText()));
us.setLogin(unformatString(itemUsers.element("login").getText()));
us.setPassword(unformatString(itemUsers.element("pass").getText()));
us.setDeleted(itemUsers.element("deleted").getText());
if (itemUsers.element("activatehash") != null) {
us.setActivatehash(unformatString(itemUsers.element("activatehash").getText()));
} else {
us.setActivatehash("");
}
if (itemUsers.element("externalUserType") != null) {
us.setExternalUserType(unformatString(itemUsers.element("externalUserType").getText()));
} else {
us.setExternalUserType("");
}
if (itemUsers.element("externalUserId") != null) {
us.setExternalUserId(importLongType(unformatString(itemUsers.element("externalUserId").getText())));
} else {
us.setExternalUserId(null);
}
if (itemUsers.element("resethash") != null) {
us.setResethash(unformatString(itemUsers.element("resethash").getText()));
} else {
us.setResethash(null);
}
if (itemUsers.element("userOffers") != null) {
us.setUserOffers(unformatString(itemUsers.element("userOffers").getText()));
} else {
us.setUserOffers("");
}
if (itemUsers.element("userSearchs") != null) {
us.setUserSearchs(unformatString(itemUsers.element("userSearchs").getText()));
} else {
us.setUserSearchs("");
}
if (itemUsers.element("forceTimeZoneCheck") != null) {
us.setForceTimeZoneCheck(importBooleanType(unformatString(itemUsers.element("forceTimeZoneCheck").getText())));
} else {
us.setForceTimeZoneCheck(null);
}
if (itemUsers.element("lasttrans") != null) {
us.setLasttrans(importLongType(unformatString(itemUsers.element("lasttrans").getText())));
} else {
us.setLasttrans(null);
}
if (itemUsers.element("showContactData") != null) {
us.setShowContactData(importBooleanType(unformatString(itemUsers.element("showContactData").getText())));
} else {
us.setShowContactData(null);
}
if (itemUsers.element("showContactDataToContacts") != null) {
us.setShowContactDataToContacts(importBooleanType(unformatString(itemUsers.element("showContactDataToContacts").getText())));
} else {
us.setShowContactDataToContacts(null);
}
us.setPictureuri(unformatString(itemUsers.element("pictureuri").getText()));
if (unformatString(itemUsers.element("language_id").getText()).length()>0)
us.setLanguage_id(Long.valueOf(unformatString(itemUsers.element("language_id").getText())));
us.setStatus(importIntegerType(unformatString(itemUsers.element("status").getText())));
us.setRegdate(CalendarPatterns.parseDate(unformatString(itemUsers.element("regdate").getText())));
us.setTitle_id(importIntegerType(unformatString(itemUsers.element("title_id").getText())));
us.setLevel_id(importLongType(unformatString(itemUsers.element("level_id").getText())));
//UserSIP Data
if (itemUsers.element("sip_username") != null
&& itemUsers.element("sip_userpass") != null
&& itemUsers.element("sip_authid") != null) {
UserSipData userSipData = new UserSipData();
userSipData.setUsername(unformatString(itemUsers.element("sip_username").getText()));
userSipData.setUsername(unformatString(itemUsers.element("sip_userpass").getText()));
userSipData.setUsername(unformatString(itemUsers.element("sip_authid").getText()));
us.setUserSipData(userSipData);
}
String additionalname = unformatString(itemUsers.element("additionalname").getText());
String comment = unformatString(itemUsers.element("comment").getText());
// A User can not have a deleted Adress, you cannot delete the
// Adress of an User
// String deleted = u.getAdresses().getDeleted()
// Phone Number not done yet
String fax = unformatString(itemUsers.element("fax").getText());
Long state_id = importLongType(unformatString(itemUsers.element("state_id").getText()));
String street = unformatString(itemUsers.element("street").getText());
String town = unformatString(itemUsers.element("town").getText());
String zip = unformatString(itemUsers.element("zip").getText());
if (itemUsers.element("omTimeZone") != null) {
OmTimeZone omTimeZone = OmTimeZoneDaoImpl.getInstance().getOmTimeZone(unformatString(itemUsers.element("omTimeZone").getText()));
us.setOmTimeZone(omTimeZone);
us.setForceTimeZoneCheck(false);
} else {
Configuration conf = Configurationmanagement.getInstance().getConfKey(3L, "default.timezone");
if (conf != null) {
String jNameTimeZone = conf.getConf_value();
OmTimeZone omTimeZone = OmTimeZoneDaoImpl.getInstance().getOmTimeZone(jNameTimeZone);
us.setOmTimeZone(omTimeZone);
}
us.setForceTimeZoneCheck(true);
}
String phone = "";
if (itemUsers.element("phone") != null) {
phone = unformatString(itemUsers.element("phone").getText());
}
String email = "";
if (itemUsers.element("mail") != null) {
email = unformatString(itemUsers.element("mail").getText());
}
States st = Statemanagement.getInstance().getStateById(state_id);
if (st == null) {
Statemanagement.getInstance().getStateById(1L);
}
Adresses adr = new Adresses();
adr.setAdditionalname(additionalname);
adr.setComment(comment);
adr.setStarttime(new Date());
adr.setFax(fax);
adr.setStreet(street);
adr.setTown(town);
adr.setZip(zip);
adr.setStates(st);
adr.setPhone(phone);
adr.setEmail(email);
us.setAdresses(adr);
HashSet<Organisation_Users> orgUsers = new HashSet<Organisation_Users>();
for (Iterator<Element> organisationsIterator = itemUsers.elementIterator( "organisations" ); organisationsIterator.hasNext(); ) {
Element organisations = organisationsIterator.next();
for (Iterator<Element> organisationIterator = organisations.elementIterator( "user_organisation" ); organisationIterator.hasNext(); ) {
Element organisationObject = organisationIterator.next();
Long organisation_id = importLongType(unformatString(organisationObject.element("organisation_id").getText()));
Long user_id = importLongType(unformatString(organisationObject.element("user_id").getText()));
Boolean isModerator = importBooleanType(unformatString(organisationObject.element("isModerator").getText()));
String commentOrg = unformatString(organisationObject.element("comment").getText());
String deleted = unformatString(organisationObject.element("deleted").getText());
Organisation_Users orgUser = new Organisation_Users();
orgUser.setOrganisation(Organisationmanagement.getInstance().getOrganisationByIdBackup(organisation_id));
orgUser.setUser_id(user_id);
orgUser.setIsModerator(isModerator);
orgUser.setComment(commentOrg);
orgUser.setStarttime(new Date());
orgUser.setDeleted(deleted);
orgUsers.add(orgUser);
}
}
Long userId = us.getUser_id();
//check if login does already exists, but only for users that have been created in the OpenMeetings Administration
//maybe we should check status too
/*
if ((us.getExternalUserId() == null || us.getExternalUserId() == 0) && email != null && email.length() > 0){
Users storedUser = Usermanagement.getInstance().getUserByLoginOrEmail(us.getLogin());
if (storedUser != null) {
log.info("A user with the given login does already exist "+us.getLogin());
} else {
storedUser = Usermanagement.getInstance().getUserByLoginOrEmail(email);
if (storedUser != null) {
log.info("A user with the given email as login does already exist "+email);
}
}
if (storedUser != null) {
usersMap.put(userId, storedUser.getUser_id());
continue;
}
}
*/
log.debug("Import User ID "+userId);
us.setUser_id(null);
us.setStarttime(new Date());
Long actualNewUserId = Usermanagement.getInstance().addUserBackup(us);
usersMap.put(userId, actualNewUserId);
for (Iterator<Organisation_Users> orgUserIterator = orgUsers.iterator();orgUserIterator.hasNext();) {