}else if(finalmail!=null){
List<Advancement> advancements = this.foldermanager.findFinalAdvancement();
Map<String,String> responsables = foldermanager.findAllResponsables();
String path = request.getSession().getServletContext().getRealPath("/");
MailSenDer mailSender = new MailSenDer(path+"mail.properties");
List nonReussit = mailSender.sendFinalMail(advancements, responsables);
if(nonReussit.isEmpty()){
page.add("Confirmation");
message = "L'envoie de mail reussit!";
model.put("page", page);
model.put("message", message);
}else{
page.add("Echec");
message = "Les mails n'ont pas pu etre envoy�s aux candidats suivants :";
model.put("page", page);
model.put("message", message);
model.put("nonReussit", nonReussit);
}
/* The action of removing a candidate from a principal list */
}else if(desistement!=null && formations.length > 0 ){
int id = Integer.parseInt(sId);
message ="";
boolean send = true;
int refuse = 0;
int beforeRefuse=0;
int remonte = 0;
List envoieNonReussit = new ArrayList();
/* For every formation that we want to remove */
for (int i = 0; i < formations.length; i++) {
String labelidf = formations[i];
String[] lesdeux = labelidf.split("_");
Formation f = new Formation();
f.setId(Integer.parseInt(lesdeux[1]));
f.setLabel(lesdeux[0]);
Etat e = new Etat();
e.setState(Folder.FOLDER_REFUSED);
beforeRefuse = refuse;
/* Refusing the candidate*/
refuse += foldermanager.storeAdvancement(id, e, f);
/*If correctly refused*/
if(beforeRefuse!=refuse){
/*Moving the first on the complementary list to the principal list */
int pi_first = foldermanager.findPersonalInfoByFormationAndComplementaryPosition(f.getId());
Etat newAdmit = new Etat();
newAdmit.setState(Folder.FOLDER_ACCEPTED);
remonte = foldermanager.storeAdvancement(pi_first, newAdmit, f);
/* If correctly transfered from complementary to principal list */
if(remonte != 0){
/* Sending email to the new accepted */
PersonalInfo personalInfo = foldermanager.findPersonalInfoById(pi_first);
String responsableEmail = (String)foldermanager.findResponsableEmailByFormation(f.getId()).get(0);
String path = request.getSession().getServletContext().getRealPath("/");
MailSenDer md = new MailSenDer(path + "mail.properties");
String mail = md.sendEvolutionComplementaryToPrincipalListMail(personalInfo.getEmail(),personalInfo.getLastname()+" "+personalInfo.getFirstname(), responsableEmail, f.getLabel());
if(!mail.equals("")){
envoieNonReussit.add(mail);
}
}
remonte = 0;
}
}
if(refuse==formations.length && envoieNonReussit.isEmpty()){
page.add("Confirmation");
}else{
page.add("Confirmations et Echecs");
}
if(refuse==formations.length){
message += "Le d�sistement du candidat a r�ussit. ";
}else{
message += "Le d�sistement du candidat n'a pas r�ussit correctement. ";
}
if(envoieNonReussit.isEmpty()){
message += "La notification des premiers sur les listes compl�mentaires a r�ussit. ";
}else{
message += "La notification des premiers sur les listes compl�mentaires n'a pas r�ussit pour les adresses suivantes : ";
for (Iterator iterMails = envoieNonReussit.iterator(); iterMails
.hasNext();) {
String email = (String) iterMails.next();
message += email+" ";
}
}
model.put("page",page);
model.put("message",message);
}else if (pieces != null && pieces.length > 0) {
int id = Integer.parseInt(sId);
boolean envoye = false;
Folder folder = foldermanager.findFolderById(id);
String path = request.getSession().getServletContext().getRealPath(
"/");
MailSenDer msd = new MailSenDer(path + "mail.properties");
//for (int i = 0; i < pieces.length; i++) {
envoye = msd.sentPiecesManquantes(pieces, folder.getPi().getEmail(), folder.getPi().getLastname() + " "+ folder.getPi().getFirstname());
if(envoye){
int update = this.foldermanager.updatePersonalInfoState(id,Folder.FOLDER_INCOMPLETE);
if(update == 0){
page.add("Confirmation et Echec");
message = "Le mail avec les pieces manquantes a �t� envoy� au candidat mais le dossier n\'a pas �t� marqu� incomplet.";