}
protected void postProcessPage(HttpServletRequest request, Object command,
Errors errors, int page) throws Exception {
FolderForm ff = (FolderForm) command;
Folder folder = ff.getFolder();
Promodetail current = folder.getCurrentPromoDetail();
String delete = request.getParameter("del");
String edit = request.getParameter("edit");
String action = request.getParameter("action");
String todelete = request.getParameter("delCV");
if (page == 5) {
if (action != null) {
// recuperation du multipart
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
MultipartFile fichier = multipartRequest.getFile("data");
if (fichier.isEmpty()) {
errors.setNestedPath("folder.pi.cv");
errors.rejectValue("data", "cv.data.obligatoire",
"Le document est vide!");
errors.setNestedPath("");
return;
}
String nomDocument = fichier.getOriginalFilename();
if (!nomDocument.endsWith(".pdf")) {
errors.setNestedPath("folder.pi.cv");
errors.rejectValue("data", "data.invalid",
"Seuls les documents 'pdf' sont autoris�s!");
errors.setNestedPath("");
return;
}
if (nomDocument.equals("")) {
errors.setNestedPath("folder.pi.cv");
errors.rejectValue("data", "data.invalid",
"Sp�cifiez un chemin !");
errors.setNestedPath("");
return;
}
String chemin = null;
Document cv = folder.getPi().getCv();
if (!cv.getName().equals("")) {
errors.setNestedPath("folder.pi.cv");
errors.rejectValue("data", "data.invalid",
"Vous avez d�ja envoy� un cv: supprimez le avant!");
errors.setNestedPath("");
return;
}
String id = Generator.getRandomId();
chemin = request.getSession().getServletContext().getRealPath(
"/")
+ "uploads/CV/" + id + "_" + nomDocument;
enregistrer(fichier, chemin);
cv.setName(id + "_" + nomDocument);
} else if (todelete != null) {
System.out.println("DELETING RESUME");
Document cv = folder.getPi().getCv();
File f = new File(request.getSession().getServletContext()
.getRealPath("/")
+ "uploads/CV/" + cv.getName());
f.delete();
cv.setName("");
}
} else if (page == 3) {
if (request.getParameter("add") != null) {
errors.setNestedPath("folder.currentPromoDetail");
String university = request.getParameter("univs");
String diplome = request.getParameter("diplomes");
if (!current.getYear().equals("")) {
try {
Integer.parseInt(current.getYear());
} catch (NumberFormatException nfe) {
errors.rejectValue("year", "year.invalid",
"Type incorrect.");
errors.setNestedPath("");
return;
}
}
if (!current.getRegistered().equals("")) {
try {
Integer.parseInt(current.getRegistered());
} catch (NumberFormatException nfe) {
errors.rejectValue("registered", "registered.invalid",
"Type incorrect.");
errors.setNestedPath("");
return;
}
}
if (!current.getQualified().equals("")) {
try {
Integer.parseInt(current.getQualified());
} catch (NumberFormatException nfe) {
errors.rejectValue("qualified", "qualified.invalid",
"Type incorrect.");
errors.setNestedPath("");
return;
}
}
if (!current.getMark().equals("")) {
try {
Float.parseFloat(current.getMark());
} catch (NumberFormatException nfe) {
errors.rejectValue("mark", "mark.invalid",
"Éssayez xx.5.");
errors.setNestedPath("");
return;
}
}
if (!current.getRank().equals("")) {
try {
Integer.parseInt(current.getRank());
} catch (NumberFormatException nfe) {
errors.rejectValue("rank", "rank.invalid",
"Type incorrect.");
errors.setNestedPath("");
return;
}
}
if (current.isInComplete()) {
errors.setNestedPath("folder");
errors.rejectValue("promodetails", "promodetails.invalid",
"Remplissez tous les champs.");
errors.setNestedPath("");
return;
}
errors.setNestedPath("");
University u = umng.getUniversity(university);
Diplome d = dmng.getDiplomes(diplome);
if (!current.isEmpty()) {
current.setDiplome(d);
current.setUniversity(u);
folder.addPromodetail(current);
}
} else if (request.getParameter("adduniv") != null) {
String nouveau = request.getParameter("newuniv");
/*
* It is very difficult to check the validity of variable
* 'newuniv' Whe just check if 'nouveau' is not empty.
*/
if (!nouveau.equals("")) {
University university = new University();
university.setLabel(nouveau.toUpperCase());
umng.add(university);
}
} else if (request.getParameter("adddegree") != null) {
String nouveau = request.getParameter("newdegree");
/*
* It is very difficult to check the validity of variable
* 'newdegree' Whe just check if 'nouveau' is not empty.
*/
if (!nouveau.equals("")) {
Diplome diplome = new Diplome();
diplome.setLabel(nouveau.toUpperCase());
dmng.add(diplome);
}
} else if (delete != null) {
int index = Integer.parseInt(delete);
List promos = ff.getFolder().getPromodetails();
ff.getFolder().deletePromodetail(index);
} else if (edit != null) {
// folder.setCurrentPromoDetail((Promodetail)folder.getPromodetails().get(Integer.parseInt(edit)));
}
}