Gestion des attributs, on regarde le type de fichier envoyé..
This commit is contained in:
@@ -49,7 +49,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<form:label path="abstractText"><fmt:message key="form.submission.article.abstractText" /></form:label>
|
<form:label path="abstractText"><fmt:message key="form.submission.article.abstractText" /></form:label>
|
||||||
<form:textarea path="abstractText" cols="60" rows="10" />*<br />
|
<form:textarea path="abstractText" cols="60" rows="10" />*<br />
|
||||||
<span class="abstractText"><form:errors path="theme" /></span>
|
<span class="formError"><form:errors path="abstractText" /></span>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<form:label path="file"><fmt:message key="form.article.file" /></form:label>
|
<form:label path="file"><fmt:message key="form.article.file" /></form:label>
|
||||||
<input type="file" name="file" />*
|
<input type="file" name="file" />*
|
||||||
<span class="abstractText"><form:errors path="file" /></span>
|
<span class="formError"><form:errors path="file" /></span>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
<prop key="/login.htm">LogonController</prop>
|
<prop key="/login.htm">LogonController</prop>
|
||||||
<prop key="/listEvaluation.htm">ListEvaluationController</prop>
|
<prop key="/listEvaluation.htm">ListEvaluationController</prop>
|
||||||
<prop key="/download.htm">ArticleDownloadController</prop>
|
<prop key="/download.htm">ArticleDownloadController</prop>
|
||||||
<prop key="/delete.htm">ArticleDeleteController</prop>
|
<prop key="/deleteArticle.htm">ArticleDeleteController</prop>
|
||||||
<prop key="/listReport.htm">ListReportController</prop>
|
<prop key="/listReport.htm">ListReportController</prop>
|
||||||
<prop key="/forgotPassword.htm">ForgotPasswordController</prop>
|
<prop key="/forgotPassword.htm">ForgotPasswordController</prop>
|
||||||
<prop key="/detailArticle.htm">DetailArticleController</prop>
|
<prop key="/detailArticle.htm">DetailArticleController</prop>
|
||||||
|
|||||||
@@ -69,9 +69,58 @@ public class SArticleController extends SimpleFormController {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
|
String extension = file.getOriginalFilename().substring(file.getOriginalFilename().length() - 4).toLowerCase();
|
||||||
|
logger.info("The file extension is: " + extension);
|
||||||
|
|
||||||
|
boolean typePDF = conf.isTypePDF();
|
||||||
|
boolean typeLatec = conf.isTypeLatec();
|
||||||
|
boolean typeWord = conf.isTypeWord();
|
||||||
|
boolean typeODT = conf.isTypeODT();
|
||||||
|
boolean isOneSelected = false;
|
||||||
|
boolean extensionTrue = false;
|
||||||
|
String acceptedExt = "";
|
||||||
|
|
||||||
|
if (typePDF || typeLatec || typeWord || typeODT)
|
||||||
|
isOneSelected = true;
|
||||||
|
|
||||||
|
if (isOneSelected) {
|
||||||
|
if (typePDF) {
|
||||||
|
acceptedExt = acceptedExt + ".pdf ";
|
||||||
|
if (extension.equals(".pdf"))
|
||||||
|
extensionTrue = true;
|
||||||
|
}
|
||||||
|
if (typeLatec) {
|
||||||
|
acceptedExt = acceptedExt + ".tex ";
|
||||||
|
if (extension.equals(".tex"))
|
||||||
|
extensionTrue = true;
|
||||||
|
}
|
||||||
|
if (typeWord) {
|
||||||
|
acceptedExt = acceptedExt + ".doc .docx ";
|
||||||
|
String extension1 = file.getOriginalFilename().substring(file.getOriginalFilename().length() - 4).toLowerCase();
|
||||||
|
String extension2 = file.getOriginalFilename().substring(file.getOriginalFilename().length() - 5).toLowerCase();
|
||||||
|
if (extension1.equals(".doc"))
|
||||||
|
extensionTrue = true;
|
||||||
|
if (extension2.equals(".docx"))
|
||||||
|
extensionTrue = true;
|
||||||
|
}
|
||||||
|
if (typeODT) {
|
||||||
|
acceptedExt = acceptedExt + ".odt";
|
||||||
|
if (extension.equals(".odt"))
|
||||||
|
extensionTrue = true;
|
||||||
|
}
|
||||||
|
if (! extensionTrue) {
|
||||||
|
errors.rejectValue("file", null, "The file's extensions allowed are the following: " + acceptedExt);
|
||||||
|
try {
|
||||||
|
return showForm(request, response, errors);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Creates the article
|
// Creates the article
|
||||||
Article newArticle = articleManager.addArticle(
|
Article newArticle = articleManager.addArticle(
|
||||||
title, theme, abstractText, nomFile, user.getLogin(),
|
title, theme, abstractText, nomFile, user.getLogin(),
|
||||||
@@ -102,6 +151,7 @@ public class SArticleController extends SimpleFormController {
|
|||||||
articleManager.updateArticle(newArticle);
|
articleManager.updateArticle(newArticle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (FileNotFoundException e) {
|
catch (FileNotFoundException e) {
|
||||||
System.out.println(e);
|
System.out.println(e);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -130,6 +180,56 @@ public class SArticleController extends SimpleFormController {
|
|||||||
articleManager.updateArticle(old);
|
articleManager.updateArticle(old);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
|
String extension = file.getOriginalFilename().substring(file.getOriginalFilename().length() - 4).toLowerCase();
|
||||||
|
logger.info("The file extension is: " + extension);
|
||||||
|
|
||||||
|
boolean typePDF = conf.isTypePDF();
|
||||||
|
boolean typeLatec = conf.isTypeLatec();
|
||||||
|
boolean typeWord = conf.isTypeWord();
|
||||||
|
boolean typeODT = conf.isTypeODT();
|
||||||
|
boolean isOneSelected = false;
|
||||||
|
boolean extensionTrue = false;
|
||||||
|
String acceptedExt = "";
|
||||||
|
|
||||||
|
if (typePDF || typeLatec || typeWord || typeODT)
|
||||||
|
isOneSelected = true;
|
||||||
|
|
||||||
|
if (isOneSelected) {
|
||||||
|
if (typePDF) {
|
||||||
|
acceptedExt = acceptedExt + ".pdf ";
|
||||||
|
if (extension.equals(".pdf"))
|
||||||
|
extensionTrue = true;
|
||||||
|
}
|
||||||
|
if (typeLatec) {
|
||||||
|
acceptedExt = acceptedExt + ".tex ";
|
||||||
|
if (extension.equals(".tex"))
|
||||||
|
extensionTrue = true;
|
||||||
|
}
|
||||||
|
if (typeWord) {
|
||||||
|
acceptedExt = acceptedExt + ".doc .docx ";
|
||||||
|
String extension1 = file.getOriginalFilename().substring(file.getOriginalFilename().length() - 4).toLowerCase();
|
||||||
|
String extension2 = file.getOriginalFilename().substring(file.getOriginalFilename().length() - 5).toLowerCase();
|
||||||
|
if (extension1.equals(".doc"))
|
||||||
|
extensionTrue = true;
|
||||||
|
if (extension2.equals(".docx"))
|
||||||
|
extensionTrue = true;
|
||||||
|
}
|
||||||
|
if (typeODT) {
|
||||||
|
acceptedExt = acceptedExt + ".odt";
|
||||||
|
if (extension.equals(".odt"))
|
||||||
|
extensionTrue = true;
|
||||||
|
}
|
||||||
|
if (! extensionTrue) {
|
||||||
|
errors.rejectValue("file", null, "The file's extensions allowed are the following: " + acceptedExt);
|
||||||
|
try {
|
||||||
|
return showForm(request, response, errors);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
byte b[] = file.getBytes();
|
byte b[] = file.getBytes();
|
||||||
|
|
||||||
String path = "conference"+conf.getId()+"/";
|
String path = "conference"+conf.getId()+"/";
|
||||||
@@ -144,6 +244,7 @@ public class SArticleController extends SimpleFormController {
|
|||||||
|
|
||||||
old.setURL_article(path);
|
old.setURL_article(path);
|
||||||
articleManager.updateArticle(old);
|
articleManager.updateArticle(old);
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
throw new ModelAndViewDefiningException(new ModelAndView("404error"));
|
throw new ModelAndViewDefiningException(new ModelAndView("404error"));
|
||||||
@@ -183,7 +284,7 @@ public class SArticleController extends SimpleFormController {
|
|||||||
throw new ModelAndViewDefiningException(new ModelAndView("denied", "message", getMessageSourceAccessor().getMessage("submission.modify.denied")));
|
throw new ModelAndViewDefiningException(new ModelAndView("denied", "message", getMessageSourceAccessor().getMessage("submission.modify.denied")));
|
||||||
|
|
||||||
FormSubmission myArticle = new FormSubmission();
|
FormSubmission myArticle = new FormSubmission();
|
||||||
|
|
||||||
myArticle.setAbstractText(a.getAbstractText());
|
myArticle.setAbstractText(a.getAbstractText());
|
||||||
myArticle.setTitle(a.getTitle());
|
myArticle.setTitle(a.getTitle());
|
||||||
//myArticle.setListe(a.getSecondaryAuthors());
|
//myArticle.setListe(a.getSecondaryAuthors());
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import org.springframework.validation.Errors;
|
|||||||
import org.springframework.validation.Validator;
|
import org.springframework.validation.Validator;
|
||||||
import org.yacos.web.author.form.FormSubmission;
|
import org.yacos.web.author.form.FormSubmission;
|
||||||
|
|
||||||
|
|
||||||
public class ValidateSubmission implements Validator {
|
public class ValidateSubmission implements Validator {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@@ -14,30 +13,22 @@ public class ValidateSubmission implements Validator {
|
|||||||
|
|
||||||
public void validate(Object arg0, Errors arg1) {
|
public void validate(Object arg0, Errors arg1) {
|
||||||
|
|
||||||
FormSubmission sub=(FormSubmission)arg0;
|
FormSubmission sub = (FormSubmission)arg0;
|
||||||
|
|
||||||
String title=sub.getTitle();
|
String title = sub.getTitle();
|
||||||
String theme=sub.getTheme();
|
String theme = sub.getTheme();
|
||||||
String abs=sub.getAbstractText();
|
String abs = sub.getAbstractText();
|
||||||
|
|
||||||
if (title== null || title.trim().length() == 0) {
|
if (title == null || title.trim().length() == 0) {
|
||||||
arg1.rejectValue("title",
|
arg1.rejectValue("title", "submissionArticle.title", "The title should not be null");
|
||||||
"submissionArticle.title",
|
|
||||||
"Le title est n<><6E>cessaire !");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (theme == null || theme.trim().length()==0) {
|
||||||
if (theme==null|theme.trim().length()==0)
|
arg1.rejectValue("theme", "submissionArticle.theme", "The theme should not be null");
|
||||||
|
|
||||||
{
|
|
||||||
arg1.rejectValue("theme", "submissionArticle.theme");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (abs == null || abs.trim().length()==0) {
|
||||||
if (abs==null|abs.trim().length()==0)
|
arg1.rejectValue("abstractText", "submissionArticle.abstractText", "The abstract should not be null");
|
||||||
|
|
||||||
{ arg1.rejectValue("abstractText", "submissionArticle.abstractText", "text is not nullable");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -243,6 +243,7 @@ public class AddConferenceController extends AbstractWizardFormController {
|
|||||||
setPages(new String[] {"addConference", "addConference2", "addConference3", "addConference4", "addConference5"});
|
setPages(new String[] {"addConference", "addConference2", "addConference3", "addConference4", "addConference5"});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO : comment modifier la conf ?
|
||||||
@Secured({"ROLE_CONFERENCE_CREATOR"})
|
@Secured({"ROLE_CONFERENCE_CREATOR"})
|
||||||
protected Object formBackingObject(HttpServletRequest request) throws ModelAndViewDefiningException {
|
protected Object formBackingObject(HttpServletRequest request) throws ModelAndViewDefiningException {
|
||||||
logger.info(this.getClass().toString() + " dans le formBackingObject");
|
logger.info(this.getClass().toString() + " dans le formBackingObject");
|
||||||
@@ -384,14 +385,13 @@ public class AddConferenceController extends AbstractWizardFormController {
|
|||||||
conference.setDateStart(format.format(conf.getDateStart()));
|
conference.setDateStart(format.format(conf.getDateStart()));
|
||||||
conference.setDescription(conf.getDescription());
|
conference.setDescription(conf.getDescription());
|
||||||
conference.setOtherInformations(conf.getOtherInformations());
|
conference.setOtherInformations(conf.getOtherInformations());
|
||||||
|
conference.setPageNumberChecked(conf.getPageNumber());
|
||||||
// TODO : ajouter ca ds conf ejb...
|
conference.setPageNumber(conf.getPageNumber().toString());
|
||||||
/*conference.setPageNumber(pageNumber);
|
conference.setTypePDF(conf.isTypePDF());
|
||||||
conference.setSendInfo(sendInfo);
|
conference.setTypeLatec(conf.isTypeLatec());
|
||||||
conference.setTypeLatec(typeLatec);
|
conference.setTypeWord(conf.isTypeWord());
|
||||||
conference.setTypeODT(typeODT);
|
conference.setTypeODT(conf.isTypeODT());
|
||||||
conference.setTypePDF(typePDF);
|
conference.setSendInfo(conf.getSendInfo());
|
||||||
conference.setTypeWord(typeWord);*/
|
|
||||||
|
|
||||||
return conference;
|
return conference;
|
||||||
|
|
||||||
@@ -439,7 +439,13 @@ public class AddConferenceController extends AbstractWizardFormController {
|
|||||||
conference.getDateArticleParsed(),
|
conference.getDateArticleParsed(),
|
||||||
conference.getDateEvaluationParsed(),
|
conference.getDateEvaluationParsed(),
|
||||||
conference.getDateStartParsed(),
|
conference.getDateStartParsed(),
|
||||||
conference.getDateEndParsed());
|
conference.getDateEndParsed(),
|
||||||
|
conference.getPageNumberChecked(),
|
||||||
|
conference.isTypePDF(),
|
||||||
|
conference.isTypeLatec(),
|
||||||
|
conference.isTypeWord(),
|
||||||
|
conference.isTypeODT(),
|
||||||
|
conference.getSendInfo());
|
||||||
} catch (NoConferenceCreationTokenLeftException e1) {
|
} catch (NoConferenceCreationTokenLeftException e1) {
|
||||||
return new ModelAndView("denied","message",getMessageSourceAccessor().getMessage("conference.error.noTokenLeft"));
|
return new ModelAndView("denied","message",getMessageSourceAccessor().getMessage("conference.error.noTokenLeft"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class ConferenceValidator implements Validator {
|
|||||||
dateStart = format.parse(conference.getDateStart());
|
dateStart = format.parse(conference.getDateStart());
|
||||||
conference.setDateStartParsed(dateStart);
|
conference.setDateStartParsed(dateStart);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
errors.rejectValue("dateStart", "conference.errors.dateStartNonValid");
|
errors.reject("dateStart", "conference.errors.dateStartNonValid");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
dateEnd = format.parse(conference.getDateEnd());
|
dateEnd = format.parse(conference.getDateEnd());
|
||||||
|
|||||||
Reference in New Issue
Block a user