uid = getParam("uid","");
passw = getParam("pwd","");
changepassw = passw.length()>0;
if (id.length()==0)
return new RedirectResolution("/error.jsp?e=usernotfound");
if (uid.length()==0 && passw.length()==0)
return new RedirectResolution("/error.jsp?e=userdatanotfound");
try {
oSessionInfo = Cache.getEntryMap(id+"activationinfo");
} catch (Exception xcpt) {
oSessionInfo = null;
}
if (oSessionInfo!=null) {
setSessionAttributes(oSessionInfo);
email = (String) oSessionInfo.get("email");
hasorders = ((Boolean) oSessionInfo.get("hasorders")).booleanValue();
if (!changepassw) {
try {
connect();
oUser = new User(getSession(), id);
oUser.activate();
oUser.save(getSession());
DAO.log(User.class, "ACTIVATE USER", AtrilEvent.Level.INFO, email+";"+id+";"+uid);
disconnect();
} catch (StorageException stge) {
Log.out.error("ActivateUser.form() "+stge.getClass().getName()+" "+stge.getMessage(), stge);
} finally {
close();
}
}
try {
Cache.deleteEntry(id+"activationinfo");
} catch (SQLException ignore) { }
} else {
try {
connect();
oUser = new User(getSession(), id);
if (!oUser.getNickName().equals(uid) && !oUser.getPassword().equals(passw))
throw new AuthenticationException("User Id. does not match UUID or Password");
email = oUser.getEmail();
if (!changepassw) {
oUser.activate();
oUser.save(getSession());
DAO.log(User.class, "ACTIVATE USER", AtrilEvent.Level.INFO, email+";"+id+";"+uid);
}
CustomerAccount oCacc = new CustomerAccount(getSession(), oUser);
Employee oEmpl = new Employee();
String sEmpl = null;
if (oEmpl.exists(getSession(), "employee_uuid", oUser.getNickName())!=null)
sEmpl = oUser.getNickName();
setSessionAttributes(oUser, oCacc, oCacc.taxpayers(getSession()).byDefault(getSession(),oUser),sEmpl);
hasorders = (oCacc.orders(getSession()).count()>0);
disconnect();
} catch (AuthenticationException acpt) {
DAO.log(User.class, "ACTIVATE USER", AtrilEvent.Level.WARNING, email+";"+id+";"+uid);
Log.out.warn("ActivateUser.form() "+acpt.getClass().getName()+" "+acpt.getMessage(), acpt);
return new RedirectResolution("/error.jsp?e=systemsecurity");
} catch (StorageException stge) {
Log.out.error("ActivateUser.form() "+stge.getClass().getName()+" "+stge.getMessage(), stge);
return new RedirectResolution("/error.jsp?e=errorindatabaseaccess");
} finally {
close();
}
}