package org.cacert.gigi.pages.account;
-import java.io.InputStreamReader;
import java.io.PrintWriter;
-import java.sql.SQLException;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.cacert.gigi.dbObjects.User;
import org.cacert.gigi.localisation.Language;
import org.cacert.gigi.output.DateSelector;
-import org.cacert.gigi.output.Form;
+import org.cacert.gigi.output.template.Form;
import org.cacert.gigi.output.template.Template;
import org.cacert.gigi.pages.Page;
import org.cacert.gigi.util.HTMLEncoder;
private static Template templ;
static {
- templ = new Template(new InputStreamReader(MyDetailsForm.class.getResourceAsStream("MyDetailsForm.templ")));
+ templ = new Template(MyDetailsForm.class.getResource("MyDetailsForm.templ"));
}
private User target;
String newLname = req.getParameter("lname").trim();
String newMname = req.getParameter("mname").trim();
String newSuffix = req.getParameter("suffix").trim();
- if ((newFname.isEmpty() && !target.getFname().isEmpty()) || (newLname.isEmpty() && !target.getLname().isEmpty()) || (newMname.isEmpty() && !target.getMname().isEmpty()) || (newSuffix.isEmpty() && !target.getSuffix().isEmpty())) {
- throw new GigiApiException("Names couldn't be removed.");
+ if (newLname.isEmpty()) {
+ throw new GigiApiException("Last name cannot be empty.");
}
target.setFname(newFname);
target.setLname(newLname);
} else {
throw new GigiApiException("No change after assurance allowed.");
}
- } catch (SQLException e) {
- new GigiApiException(e).format(out, Page.getLanguage(req));
- return false;
} catch (GigiApiException e) {
e.format(out, Page.getLanguage(req));
return false;
vars.put("lname", HTMLEncoder.encodeHTML(target.getLname()));
vars.put("suffix", target.getSuffix() == null ? "" : HTMLEncoder.encodeHTML(target.getSuffix()));
vars.put("details", "");
- try {
- if (target.getAssurancePoints() == 0) {
- vars.put("DoB", ds);
- templ.output(out, l, vars);
- } else {
- vars.put("DoB", DateSelector.getDateFormat().format(target.getDob()));
- assured.output(out, l, vars);
- }
- } catch (SQLException e) {
- e.printStackTrace();
+ if (target.getAssurancePoints() == 0) {
+ vars.put("DoB", ds);
+ templ.output(out, l, vars);
+ } else {
+ vars.put("DoB", DateSelector.getDateFormat().format(target.getDob()));
+ assured.output(out, l, vars);
}
}