long language_id, String userpass, Long adress_id, Date age,
String hash, Long externalUserId, String externalUserType,
boolean generateSipUserData, String email, String jNameTimeZone,
String pictureuri) {
try {
Users users = new Users();
users.setFirstname(firstname);
users.setLogin(login);
users.setLastname(lastname);
users.setAge(age);
if (adress_id != null && adress_id > 0) {
users.setAdresses(Addressmanagement.getInstance()
.getAdressbyId(adress_id));
} else {
adress_id = Addressmanagement.getInstance().saveAddress("", "",
"", 1L, "", "", "", "", email);
users.setAdresses(Addressmanagement.getInstance()
.getAdressbyId(adress_id));
}
users.setAvailible(availible);
users.setLastlogin(new Date());
users.setLasttrans(new Long(0));
users.setLevel_id(level_id);
users.setStatus(status);
users.setTitle_id(new Integer(1));
users.setStarttime(new Date());
users.setActivatehash(hash);
users.setPictureuri(pictureuri);
users.setOmTimeZone(OmTimeZoneDaoImpl.getInstance().getOmTimeZone(
jNameTimeZone));
if (generateSipUserData) {
UserSipData userSipData = OpenXGHttpClient
.getInstance()
.openSIPgUserCreateUser(firstname, "", lastname,
users.getAdresses().getEmail(), userpass, login);
Long userSipDataId = UserSipDataDaoImpl.getInstance()
.addUserSipData(userSipData);
users.setUserSipData(UserSipDataDaoImpl.getInstance()
.getUserSipDataById(userSipDataId));
} else {
UserSipData userSipData = new UserSipData();
userSipData.setUsername("");
userSipData.setUserpass("");
userSipData.setAuthId("");
Long userSipDataId = UserSipDataDaoImpl.getInstance()
.addUserSipData(userSipData);
users.setUserSipData(UserSipDataDaoImpl.getInstance()
.getUserSipDataById(userSipDataId));
}
users.setExternalUserId(externalUserId);
users.setExternalUserType(externalUserType);
// this is needed cause the language is not a needed data at
// registering
if (language_id != 0) {
users.setLanguage_id(new Long(language_id));
} else {
users.setLanguage_id(null);
}
users.setPassword(ManageCryptStyle.getInstance()
.getInstanceOfCrypt().createPassPhrase(userpass));
users.setRegdate(new Date());
users.setDeleted("false");
Object idf = PersistenceSessionUtil.createSession();
EntityManager session = PersistenceSessionUtil.getSession();
EntityTransaction tx = session.getTransaction();
tx.begin();
session.merge(users);
long user_id = users.getUser_id();
tx.commit();
PersistenceSessionUtil.closeSession(idf);
return user_id;