Correction de choose preference en rapport avec les corrections du core de la révision 141

This commit is contained in:
2008-01-14 01:31:36 +00:00
parent b19e6e154a
commit 2c76cb27c7
9 changed files with 62 additions and 21 deletions

View File

@@ -3,6 +3,7 @@
<name>YACOSWeb</name> <name>YACOSWeb</name>
<comment></comment> <comment></comment>
<projects> <projects>
<project>YACOSCore</project>
</projects> </projects>
<buildSpec> <buildSpec>
<buildCommand> <buildCommand>

View File

@@ -3,6 +3,9 @@
<wb-module deploy-name="YACOSWeb"> <wb-module deploy-name="YACOSWeb">
<wb-resource deploy-path="/" source-path="/WebContent"/> <wb-resource deploy-path="/" source-path="/WebContent"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/YACOSCore/YACOSCore">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="context-root" value="YACOSWeb"/> <property name="context-root" value="YACOSWeb"/>
<property name="java-output-path" value="build/classes"/> <property name="java-output-path" value="build/classes"/>
</wb-module> </wb-module>

View File

@@ -10,6 +10,20 @@ form.submission.mainauthor=Main author
form.submission.secondaryauthor=Secondary author form.submission.secondaryauthor=Secondary author
form.submission.file=File form.submission.file=File
register.title=User Registration
form.register.user.login=Login
form.register.user.email=eMail
form.register.user.password=Password
form.register.user.passwordConfirm=Confirm password
form.register.user.firstName=First Name
form.register.user.lastName=Last Name
form.register.user.organization=Organization
form.register.error.loginTooShort=Login must be at least 3 characters long
form.register.error.loginInvalid=
form.register.error.passwordsDontMatches=The password doesn't match the confirmation
form.register.error.firstNameEmpty=First name is required
form.register.error.lastNameEmpty=Last name is required
button.add=Add button.add=Add
button.browse=Browse button.browse=Browse
button.reset=Reset button.reset=Reset

View File

@@ -23,7 +23,7 @@
<h2 align="center"><fmt:message key="preference.title" /></h2> <h2 align="center"><fmt:message key="preference.title" /></h2>
<c:if test="${message}"> <c:if test="${message}">
<fmt:message key="${message}"/> <fmt:message key="message"/>
</c:if> </c:if>
<form:form method="post" commandName="choosePreference"> <form:form method="post" commandName="choosePreference">

View File

@@ -5,7 +5,7 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html> <html>
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><fmt:message key="title"/></title> <title><fmt:message key="title"/></title>
<link rel="stylesheet" href="./stylesheets/base.css" type="text/css" /> <link rel="stylesheet" href="./stylesheets/base.css" type="text/css" />
</head> </head>
@@ -22,7 +22,7 @@
<div id="main_content"> <div id="main_content">
<h2 align="center"><fmt:message key="register.title" /></h2> <h2><fmt:message key="register.title" /></h2>
<form:form method="post" commandName="registerUser"> <form:form method="post" commandName="registerUser">
@@ -39,7 +39,6 @@
<input type="reset" value="<fmt:message key="button.reset" />"/> <input type="reset" value="<fmt:message key="button.reset" />"/>
<input type="submit" value="<fmt:message key="button.OK" />"/> <br/><br/> <input type="submit" value="<fmt:message key="button.OK" />"/> <br/><br/>
</form:form> </form:form>

View File

@@ -25,6 +25,15 @@
<property name="articleManager" ref="articleManager" /> <property name="articleManager" ref="articleManager" />
</bean> </bean>
<bean name="/registerUser.htm" class="org.yacos.web.system.controller.SUserRegistrationController">
<property name="sessionForm" value="true"/>
<property name="commandName" value="registerUser"/>
<property name="commandClass" value="org.yacos.web.system.form.FormUser"/>
<property name="formView" value="registerUser"/>
<property name="successView" value="listArticle.htm" />
<property name="usersManager" ref="usersManager" />
</bean>
<bean name="/submissionArticle.htm" class="org.yacos.web.author.controller.SArticleController"> <bean name="/submissionArticle.htm" class="org.yacos.web.author.controller.SArticleController">
<property name="sessionForm" value="true" /> <property name="sessionForm" value="true" />
<property name="commandName" value="submissionArticle" /> <property name="commandName" value="submissionArticle" />
@@ -76,7 +85,6 @@
<property name="successView" value="addConference2.htm" /> <property name="successView" value="addConference2.htm" />
<property name="conferenceManager" ref="conferenceManager" /> <property name="conferenceManager" ref="conferenceManager" />
</bean> --> </bean> -->
</bean>
<!-- List all conference --> <!-- List all conference -->
<bean name="/listConference.htm" class="org.yacos.web.system.controller.ListConferenceController"> <bean name="/listConference.htm" class="org.yacos.web.system.controller.ListConferenceController">

View File

@@ -3,6 +3,7 @@ package org.yacos.web.PCmember.controller;
import java.util.*; import java.util.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@@ -10,6 +11,7 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.validation.BindException; import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController; import org.springframework.web.servlet.mvc.SimpleFormController;
import org.springframework.web.servlet.view.RedirectView;
import org.yacos.core.article.*; import org.yacos.core.article.*;
import org.yacos.core.users.IUserManager; import org.yacos.core.users.IUserManager;
@@ -23,7 +25,7 @@ public class ChoosePreferenceController extends SimpleFormController {
protected final Log logger = LogFactory.getLog(getClass()); protected final Log logger = LogFactory.getLog(getClass());
private IArticleManager articleManager; private IArticleManager articleManager;
private IUserManager usersManager; private IUserManager userManager;
@Override @Override
protected Object formBackingObject(HttpServletRequest request) protected Object formBackingObject(HttpServletRequest request)
@@ -33,11 +35,15 @@ public class ChoosePreferenceController extends SimpleFormController {
getServletContext().setAttribute("articleList", articleList); getServletContext().setAttribute("articleList", articleList);
User toto = usersManager.getUser("toto"); // TODO : mock object, replace with real user management
User toto = userManager.getUser("toto");
if(toto == null){
toto = userManager.addUser("toto", "toto", "Toto", "Toto", "Toto corp.", "toto@totocorp.com");
}
ArrayList<Preference> preferencesList = new ArrayList<Preference>(); ArrayList<Preference> preferencesList = new ArrayList<Preference>();
Preference pref; Preference pref;
for(Article article : articleList){ for(Article article : articleList){
pref = articleManager.getArticlePreferenceForUser(article, toto.getLogin()); pref = articleManager.getArticlePreferenceForUser(article.getId(), toto.getLogin());
if(pref == null){ if(pref == null){
pref = new Preference(); pref = new Preference();
pref.setArticle(article); pref.setArticle(article);
@@ -63,13 +69,15 @@ public class ChoosePreferenceController extends SimpleFormController {
List<Preference> listPreference=fp.getPreferences(); List<Preference> listPreference=fp.getPreferences();
for(Preference preference : listPreference){ for(Preference preference : listPreference){
articleManager.addArticlePreference( articleManager.addOrUpdatePreference(
preference.getArticle().getId(), preference.getArticle().getId(),
preference.getPcMember().getLogin(), preference.getPcMember().getLogin(),
preference.getPreference()); preference.getPreference());
} }
return new ModelAndView("choosePreferenceOK"); Map<String, String> model = new HashMap<String, String>();
model.put("message", "preference.ok");
return new ModelAndView(new RedirectView(getSuccessView()),model);
} }
@@ -82,10 +90,10 @@ public class ChoosePreferenceController extends SimpleFormController {
} }
public IUserManager getUsersManager() { public IUserManager getUsersManager() {
return usersManager; return userManager;
} }
public void setUsersManager(IUserManager usersManager) { public void setUsersManager(IUserManager usersManager) {
this.usersManager = usersManager; this.userManager = usersManager;
} }
} }

View File

@@ -9,6 +9,7 @@ import javax.servlet.http.HttpServletResponse;
import org.springframework.validation.BindException; import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController; import org.springframework.web.servlet.mvc.SimpleFormController;
import org.springframework.web.servlet.view.RedirectView;
import org.yacos.core.article.IArticleManager; import org.yacos.core.article.IArticleManager;
import org.yacos.core.users.IUserManager; import org.yacos.core.users.IUserManager;
import org.yacos.core.users.User; import org.yacos.core.users.User;
@@ -23,9 +24,9 @@ import org.yacos.web.system.form.FormUser;
* @author christiancorsano * @author christiancorsano
* *
*/ */
public class SUserController extends SimpleFormController { public class SUserRegistrationController extends SimpleFormController {
private IUserManager userManager; private IUserManager usersManager;
/** /**
* @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.Object, org.springframework.validation.BindException) * @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.Object, org.springframework.validation.BindException)
*/ */
@@ -36,7 +37,7 @@ public class SUserController extends SimpleFormController {
FormUser userCommand = (FormUser) command; FormUser userCommand = (FormUser) command;
User user = (User) request.getSession().getAttribute("currentUser"); User user = (User) request.getSession().getAttribute("currentUser");
if((user == null) && (userManager.getUser(userCommand.getLogin()) != null)){ if((user == null) && (usersManager.getUser(userCommand.getLogin()) != null)){
// TODO : we have an "already registered" error here, handle it // TODO : we have an "already registered" error here, handle it
} }
@@ -55,7 +56,7 @@ public class SUserController extends SimpleFormController {
} }
// TODO Auto-generated method stub // TODO Auto-generated method stub
return super.onSubmit(request, response, command, errors); return new ModelAndView(new RedirectView(getSuccessView()));
} }
/** /**
@@ -83,4 +84,11 @@ public class SUserController extends SimpleFormController {
return super.formBackingObject(request); return super.formBackingObject(request);
} }
public void setUsersManager(IUserManager usersManager) {
this.usersManager = usersManager;
}
public IUserManager getUsersManager() {
return usersManager;
}
} }

View File

@@ -1,11 +1,8 @@
package org.yacos.web.system.form; package org.yacos.web.system.form;
import java.sql.Time;
import java.util.Date; import java.util.Date;
import java.util.Random; import java.util.Random;
import sun.security.krb5.internal.Ticket;
/** /**
* *
* @author christiancorsano * @author christiancorsano
@@ -124,6 +121,9 @@ public class FormUser {
public boolean passwordWasModified() { public boolean passwordWasModified() {
return this.passwordPlaceholderValue.equals(this.getPassword()); return this.passwordPlaceholderValue.equals(this.getPassword());
} }
public boolean passwordsMatches() {
return this.password.equals(this.passwordConfirm);
}
} }