YACOSTest: Correction du à l'ajout de abstractText dans article

YACOSWeb: Modification d'un article qui marche (réenvoie d'un fichier ou pas)
This commit is contained in:
Frederic Debuire
2008-02-16 22:32:30 +00:00
parent 4929caa9ce
commit fe73c608a3
5 changed files with 285 additions and 233 deletions

View File

@@ -33,7 +33,7 @@
</ul> </ul>
</td> </td>
<td><a id="articleURL${i.index}" title="Download" href="<c:url value="/download.htm"><c:param name="articleId" value="${article.id}"/></c:url>"><img src="./images/cc-download_manager-128x128.png" alt="Download" /></a></td> <td><a id="articleURL${i.index}" title="Download" href="<c:url value="/download.htm"><c:param name="articleId" value="${article.id}"/></c:url>"><img src="./images/cc-download_manager-128x128.png" alt="Download" /></a></td>
<td><a id="modifyArticle${i.index}" title="Modify" href="<c:url value="/submissionArticle.htm"><c:param name="action" value="modify"/><c:param name="articleID" value="${article.id}"/></c:url>"><img src="./images/cc-button_ok-128x128.png" alt="Modify" /></a></td> <td><a id="modifyArticle${i.index}" title="Modify" href="<c:url value="/submissionArticle.htm"><c:param name="action" value="modify"/><c:param name="articleID" value="${article.id}"/></c:url>"><img src="./images/cc-kedit-128x128.png" alt="Modify" /></a></td>
<td><a id="suppressArticle${i.index}" title="Delete" href="javascript:deleteArticle(${article.id});"><img src="./images/cc-button_cancel-128x128.png" alt="Delete"/></a></td> <td><a id="suppressArticle${i.index}" title="Delete" href="javascript:deleteArticle(${article.id});"><img src="./images/cc-button_cancel-128x128.png" alt="Delete"/></a></td>
</tr> </tr>
</tbody> </tbody>

View File

@@ -2,74 +2,78 @@
<html> <html>
<head> <head>
<script type='text/javascript' src='./javascripts/prototype.js'></script> <script type='text/javascript' src='./javascripts/prototype.js'></script>
<script type='text/javascript' src='./javascripts/scriptaculous.js'></script> <script type='text/javascript' src='./javascripts/scriptaculous.js'></script>
<script type='text/javascript' src='./javascripts/effects.js'></script> <script type='text/javascript' src='./javascripts/effects.js'></script>
<script type='text/javascript' src='./javascripts/yacos/submissionArticle.js'></script> <script type='text/javascript'
src='./javascripts/yacos/submissionArticle.js'></script>
</head> </head>
<body> <body>
<h4 class="title"> <h4 class="title"><c:choose>
<c:choose>
<c:when test="${param['action'] eq 'modify'}"> <c:when test="${param['action'] eq 'modify'}">
<fmt:message key="submission.modify" /> <fmt:message key="submission.modify" />
</c:when> </c:when>
<c:otherwise> <c:otherwise>
<fmt:message key="submission.title" /> <fmt:message key="submission.title" />
</c:otherwise> </c:otherwise>
</c:choose> </c:choose></h4>
</h4>
<form:form method="post" enctype="multipart/form-data" commandName="submissionArticle"> <form:form method="post" enctype="multipart/form-data" commandName="submissionArticle">
<fieldset> <table>
<tbody>
<tr>
<td class="formLabel"><fmt:message key="form.submission.article.title" /></td>
<td><form:input path="title" /> <span class="formError"><form:errors path="title" /></span></td>
</tr>
<tr>
<td class="formLabel"><fmt:message key="form.submission.article.theme" /></td>
<td><form:input path="theme" /> <span class="formError"><form:errors path="theme" /></span></td>
</tr>
<tr>
<td class="formLabel"><fmt:message key="form.submission.article.abstractText" /></td>
<td><form:textarea path="abstractText" cols="60" rows="10" /><span class="formError"><form:errors path="abstractText" /></span></td>
</tr>
<tr>
<td class="formLabel"><fmt:message key="form.submission.mainauthor" />:</td>
<td><b>${currentUser.firstName} ${currentUser.lastName}</b></td>
</tr>
<tr>
<td class="formLabel"><fmt:message key="form.submission.secondaryauthor" /></td>
<td><input id="newSecondaryAuthorInput" type="text" name="newSecondaryAuthor" />
<input type="button" id="addSecondaryButton" name="addSecondary" value="<fmt:message key="button.add" />">
<form:label path="title"><fmt:message key="form.submission.article.title" /></form:label> <form:input path="title"/> <span class="formError"><form:errors path="title"/></span> <br/><br /> <div id="secondaryAuthorList" class="dynamicList">
<div class="dynamicListHeader"><fmt:message key="form.submission.secondaryauthor" /></div>
<c:if test="${param['action'] eq 'modify'}">
<c:forEach items="${listSecondaryAuthors}" var="secAuthor" varStatus="i">
<div class="dynamicListItem" style="height: 0px; width: 0px;"
id="liste[${i.index}]">${secAuthor}<input type="hidden"
id="liste[${i.index}]" name="liste[${i.index}]"
value="${secAuthor}" /></div>
</c:forEach>
</c:if>
</div>
<input type="button" id="removeSecondaryButton" name="removeSecondary" value="<fmt:message key="button.removeSelected" />" /></td>
</tr>
<tr>
<td class="formLabel">File</td>
<td><input type="file" name="file" /><div class="formError"><form:errors path="file" /></div></td>
</tr>
</tbody>
<tfoot>
<tr>
<td>&nbsp;</td>
<td><input type="reset" value="<fmt:message key="button.reset" />" />
<input type="submit" value="<fmt:message key="button.OK" />" /></td>
</tr>
</tfoot>
</table>
<form:label path="theme"><fmt:message key="form.submission.article.theme" /></form:label> <form:input path="theme"/> <span class="formError"><form:errors path="theme"/></span><br/><br />
<form:label path="abstractText"><fmt:message key="form.submission.article.abstractText" /></form:label> <form:textarea path="abstractText" /><span class="formError"><form:errors path="abstractText"/></span><br/><br/>
<hr/> <br/>
</fieldset>
<fieldset>
<label for="listauthor"><fmt:message key="form.submission.listauthor" /></label> <br /><br />
<form:label path="mainauthor"><fmt:message key="form.submission.mainauthor" /></form:label>: <b>${currentUser.firstName} ${currentUser.lastName}</b>
<br/> <br/>
<label for="newSecondaryAuthor"><fmt:message key="form.submission.secondaryauthor" /></label>
<input id="newSecondaryAuthorInput" type="text" name="newSecondaryAuthor" />
<input type="button" id="addSecondaryButton" name="addSecondary" value="<fmt:message key="button.add" />">
<div id="secondaryAuthorList" class="dynamicList">
<div class="dynamicListHeader">
<fmt:message key="form.submission.secondaryauthor" />
</div>
<c:if test="${param['action'] eq 'modify'}">
<c:forEach items="${listSecondaryAuthors}" var="secAuthor" varStatus="i">
<div class="dynamicListItem" style="height: 0px; width: 0px;" id="liste[${i.index}]">${secAuthor}<input type="hidden" id="liste[${i.index}]" name="liste[${i.index}]" value="${secAuthor}"/></div>
</c:forEach>
</c:if>
</div>
<input type="button" id="removeSecondaryButton" name="removeSecondary" value="<fmt:message key="button.removeSelected" />"/>
<br /><br />
</fieldset>
<hr />
<fieldset>
<br />
<div class="formError"><form:errors path="file"/></div>
File <input type="file" name="file"/>
<br /><br />
<input type="reset" value="<fmt:message key="button.reset" />"/>
<input type="submit" value="<fmt:message key="button.OK" />"/> <br/><br/>
</fieldset>
</form:form> </form:form>
<a href="<c:url value="main.htm"/>">Home</a> <a href="<c:url value="main.htm"/>">Home</a>
</body> </body>
</html> </html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

View File

@@ -44,6 +44,7 @@ public class SArticleController extends SimpleFormController {
String title = ((FormSubmission) command).getTitle(); String title = ((FormSubmission) command).getTitle();
String theme = ((FormSubmission) command).getTheme(); String theme = ((FormSubmission) command).getTheme();
String abstractText = ((FormSubmission) command).getAbstractText();
ArrayList<String> listSecondaryAuthor = new ArrayList<String>(); ArrayList<String> listSecondaryAuthor = new ArrayList<String>();
// Removes null entries from the list // Removes null entries from the list
@@ -53,58 +54,109 @@ public class SArticleController extends SimpleFormController {
} }
} }
String nomFile=""; String action = request.getParameter("action");
if (action == null || action.equals(""))
{
try { String nomFile="";
MultipartFile file = ((FormSubmission) command).getFile();
if (file == null || file.isEmpty()) {
errors.rejectValue("file", "form.submitArticle.noFile");
try {
return showForm(request, response, errors);
} catch (Exception e) {
e.printStackTrace();
}
}
else {
// Creates the article try {
Article newArticle = articleManager.addArticle( MultipartFile file = ((FormSubmission) command).getFile();
title, theme, nomFile, user.getLogin(), if (file == null || file.isEmpty()) {
listSecondaryAuthor, Article.State.SUBMITED, conf.getId()); errors.rejectValue("file", "form.submitArticle.noFile");
if(newArticle==null){
errors.reject("article.errors.didNotSave");
try { try {
return showForm(request, response, errors); return showForm(request, response, errors);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
else {
byte b[] = file.getBytes(); // Creates the article
Article newArticle = articleManager.addArticle(
title, theme, abstractText, nomFile, user.getLogin(),
listSecondaryAuthor, Article.State.SUBMITED, conf.getId());
String path = "conference"+conf.getId()+"/"; if(newArticle==null){
(new File(downloadDirPath+path)).mkdirs(); errors.reject("article.errors.didNotSave");
path += newArticle.getId()+"_"+file.getOriginalFilename(); try {
File uploadedFile = new File(downloadDirPath+path); return showForm(request, response, errors);
} catch (Exception e) {
e.printStackTrace();
}
}
FileOutputStream fos = new FileOutputStream(uploadedFile); byte b[] = file.getBytes();
fos.write(b); String path = "conference"+conf.getId()+"/";
fos.close(); (new File(downloadDirPath+path)).mkdirs();
path += newArticle.getId()+"_"+file.getOriginalFilename();
File uploadedFile = new File(downloadDirPath+path);
newArticle.setURL_article(path); FileOutputStream fos = new FileOutputStream(uploadedFile);
articleManager.updateArticle(newArticle);
fos.write(b);
fos.close();
newArticle.setURL_article(path);
articleManager.updateArticle(newArticle);
}
}
catch (FileNotFoundException e) {
System.out.println(e);
} catch (IOException e) {
System.out.println(e);
} }
}
catch (FileNotFoundException e) {
System.out.println(e);
} catch (IOException e) {
System.out.println(e);
}
// The role author might have been added, refresh the credentials // The role author might have been added, refresh the credentials
SessionService.getInstance().refreshAuthentication(); SessionService.getInstance().refreshAuthentication();
}
else if (action.equals("modify")) {
String articleID = request.getParameter("articleID");
try {
Integer id = new Integer(articleID);
// TODO : v<>rifier que l'id de l'article appartient <20> l'auteur... vive les GET...
Article old = articleManager.getArticle(id);
old.setTitle(title);
old.setTopic(theme);
old.setSecondaryAuthors(listSecondaryAuthor);
old.setAbstractText(abstractText);
MultipartFile file = ((FormSubmission) command).getFile();
if (file == null || file.isEmpty()) {
articleManager.updateArticle(old);
}
else {
byte b[] = file.getBytes();
String path = "conference"+conf.getId()+"/";
(new File(downloadDirPath+path)).mkdirs();
path += old.getId()+"_"+file.getOriginalFilename();
File uploadedFile = new File(downloadDirPath+path);
FileOutputStream fos = new FileOutputStream(uploadedFile);
fos.write(b);
fos.close();
old.setURL_article(path);
articleManager.updateArticle(old);
}
} catch (NumberFormatException e) {
throw new ModelAndViewDefiningException(new ModelAndView("404error"));
} catch (FileNotFoundException e) {
System.out.println(e);
} catch (IOException e) {
System.out.println(e);
}
}
else {
throw new ModelAndViewDefiningException(new ModelAndView("404error"));
}
return new ModelAndView(new RedirectView(getSuccessView())); return new ModelAndView(new RedirectView(getSuccessView()));
} }
@@ -132,10 +184,7 @@ public class SArticleController extends SimpleFormController {
FormSubmission myArticle = new FormSubmission(); FormSubmission myArticle = new FormSubmission();
myArticle.setAbstractText(a.getAbstractText());
// FIXME : stocker l'abstract texte ds la BDD... et le r<>cup apr<70>s...
//myArticle.setAbstractText();
myArticle.setTitle(a.getTitle()); myArticle.setTitle(a.getTitle());
myArticle.setListe(a.getSecondaryAuthors()); myArticle.setListe(a.getSecondaryAuthors());
myArticle.setTheme(a.getTopic()); myArticle.setTheme(a.getTopic());

View File

@@ -424,67 +424,66 @@ public class AddConferenceController extends AbstractWizardFormController {
String action = request.getParameter("action"); String action = request.getParameter("action");
if (action == null || action.equals("")) { if (action == null || action.equals("")) {
Conference conf = null;
Conference conf = null;
try {
conf = conferenceManager.addConference(
conference.getTitle(),
SessionService.getInstance().getCurrentUserLogin(),
conference.getDescription(),
conference.getOtherInformations(),
conference.getDateArticleParsed(),
conference.getDateArticleParsed(),
conference.getDateEvaluationParsed(),
conference.getDateStartParsed(),
conference.getDateEndParsed());
} catch (NoConferenceCreationTokenLeftException e1) {
return new ModelAndView("denied","message",getMessageSourceAccessor().getMessage("conference.error.noTokenLeft"));
}
conference.setConferenceId(conf.getId());
SessionService.getInstance().setCurrentConference(conf);
for(CriterionBean criterion : criteria){
conferenceManager.addCriterionToConference(
conf.getId(),
criterion.getLabel(),
criterion.getMin(),
criterion.getMax());
}
for(PersonBean personBean : listPersonAdded){
conferenceManager.addPCMemberToConference(
conf.getId(),
personBean.getLogin());
}
String mailSubject = "YACOS "+conf.getTitle()+" invitation";
String mailBody = "Greetings,\n";
mailBody += "You've been invited to join the program comity of the conference :\n";
mailBody += conf.getTitle()+"/n";
mailBody += "You can register on this page : \n";
String baseUrl = request.getSession().getServletContext().getContextPath();
mailBody += baseUrl+"/registerUser.htm /n";
mailBody += "Please note that you MUST use this eMail address in the registration form in order to get the appropriate credentials.";
// TODO : use a template
for(String invitationEmail : listInvitations){
try { try {
conferenceManager.addInvitationToken(invitationEmail, RoleType.PCMEMBER, conf.getId()); conf = conferenceManager.addConference(
MailSenderService.getInstance().sendEMail(invitationEmail, mailSubject , mailBody); conference.getTitle(),
} catch (ConferenceDoesntExistException e) { SessionService.getInstance().getCurrentUserLogin(),
// Should never happen conference.getDescription(),
e.printStackTrace(); conference.getOtherInformations(),
} catch (MailSendException e) { conference.getDateArticleParsed(),
// TODO : see what we can do about this conference.getDateArticleParsed(),
e.printStackTrace(); conference.getDateEvaluationParsed(),
conference.getDateStartParsed(),
conference.getDateEndParsed());
} catch (NoConferenceCreationTokenLeftException e1) {
return new ModelAndView("denied","message",getMessageSourceAccessor().getMessage("conference.error.noTokenLeft"));
} }
}
conferenceManager.addRole(RoleType.CHAIRMAN, SessionService.getInstance().getCurrentUserLogin(), conf.getId()); conference.setConferenceId(conf.getId());
// Refresh the roles to take into account the chairman credentials SessionService.getInstance().setCurrentConference(conf);
SessionService.getInstance().refreshAuthentication();
} else { for(CriterionBean criterion : criteria){
conferenceManager.addCriterionToConference(
conf.getId(),
criterion.getLabel(),
criterion.getMin(),
criterion.getMax());
}
for(PersonBean personBean : listPersonAdded){
conferenceManager.addPCMemberToConference(
conf.getId(),
personBean.getLogin());
}
String mailSubject = "YACOS "+conf.getTitle()+" invitation";
String mailBody = "Greetings,\n";
mailBody += "You've been invited to join the program comity of the conference :\n";
mailBody += conf.getTitle()+"/n";
mailBody += "You can register on this page : \n";
String baseUrl = request.getSession().getServletContext().getContextPath();
mailBody += baseUrl+"/registerUser.htm /n";
mailBody += "Please note that you MUST use this eMail address in the registration form in order to get the appropriate credentials.";
// TODO : use a template
for(String invitationEmail : listInvitations){
try {
conferenceManager.addInvitationToken(invitationEmail, RoleType.PCMEMBER, conf.getId());
MailSenderService.getInstance().sendEMail(invitationEmail, mailSubject , mailBody);
} catch (ConferenceDoesntExistException e) {
// Should never happen
e.printStackTrace();
} catch (MailSendException e) {
// TODO : see what we can do about this
e.printStackTrace();
}
}
conferenceManager.addRole(RoleType.CHAIRMAN, SessionService.getInstance().getCurrentUserLogin(), conf.getId());
// Refresh the roles to take into account the chairman credentials
SessionService.getInstance().refreshAuthentication();
} else if (action.equals("modify")) {
Conference conf = SessionService.getInstance().getCurrentConference(); Conference conf = SessionService.getInstance().getCurrentConference();
conf.setTitle(conference.getTitle()); conf.setTitle(conference.getTitle());
conf.setDescription(conference.getDescription()); conf.setDescription(conference.getDescription());