String point = req.queryParams("point");
String fname = req.queryParams("fname");
String lname = req.queryParams("lname");
String email = req.queryParams("email");
PointRequest pr = new PointRequest();
// check node
try {
FtnAddress a = new FtnAddress(node);
if (!MainHandler.getCurrentInstance().getInfo().getAddressList()
.contains(a)) {
code = "NOTNODE";
}
} catch (NumberFormatException e) {
code = "NOTNODE";
}
if (code == null) {
try {
FtnAddress a = new FtnAddress(node + "." + point);
if (null != FtnTools.getLinkByFtnAddress(a)) {
code = "EXISTS";
}
pr.setAddr(a.toString());
} catch (NumberFormatException e) {
code = "NOTPOINT";
}
}
if (code == null) {
if (fname != null && lname != null && fname.length() > 3
&& lname.length() >= 3) {
pr.setName(fname + " " + lname);
} else {
code = "NOTNAME";
}
}
if (code == null) {
if (email != null
&& email.matches("^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$")) {
pr.setEmail(email);
} else {
code = "NOTEMAIL";
}
}
if (code == null) {
String password = FtnTools.generate8d();
pr.setPassword(password);
synchronized (PointRequest.class) {
if (null != ORMManager.get(PointRequest.class).getFirstAnd(
"addr", "=", pr.getAddr())) {
code = "EXISTS";
} else {
ORMManager.get(PointRequest.class).save(pr);
writeRequestNetmail(pr);
writeConfirmEmail(req, pr);