Changeset 414
- Timestamp:
- 03/15/12 12:53:14 (12 years ago)
- Location:
- tapas/web
- Files:
-
- 22 added
- 11 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
tapas/web/WEB-INF/servlet-context.xml
r409 r414 38 38 <property name="mappings"> 39 39 <props> 40 <prop key="/project">controller</prop> 40 <prop key="/data">controller</prop> 41 <prop key="/project">controllerEponge</prop> 41 42 <prop key="/backoffice">controllerBackoffice</prop> 42 43 </props> … … 62 63 63 64 <bean id="controller" class="com.ether.Controller" parent="controllerEther"/> 65 64 66 <bean id="controllerBackoffice" class="com.ether.ControllerBackoffice" parent="controllerEther"> 65 67 <property name="backofficeService" ref="backofficeService"/> 66 68 </bean> 69 70 <bean id="controllerEponge" class="com.ether.ControllerEponge" parent="controllerEther"></bean> 67 71 </beans> -
tapas/web/WEB-INF/web.xml
r382 r414 71 71 </servlet-mapping> 72 72 73 <servlet-mapping> 74 <servlet-name>eponge</servlet-name> 75 <url-pattern>/data</url-pattern> 76 </servlet-mapping> 77 73 78 <session-config> 74 79 <session-timeout>60</session-timeout> -
tapas/web/backoffice/user.jsp
r409 r414 180 180 interfaceTexts["bo.field.password"] = '<spring:message code="bo.field.password"/>'; 181 181 182 interfaceTexts["<%=UserRole.ADMINISTRATOR%>"] = '<spring:message code=" bo.user.administrator"/>';183 interfaceTexts["<%=UserRole.USER%>"] = '<spring:message code=" bo.user.user"/>';182 interfaceTexts["<%=UserRole.ADMINISTRATOR%>"] = '<spring:message code="label.role.administrator"/>'; 183 interfaceTexts["<%=UserRole.USER%>"] = '<spring:message code="label.role.user"/>'; 184 184 185 185 interfaceTexts["<%=WebException.WebCode.USER_ALREADY_EXISTS%>"] = '<spring:message code="login.dataProtocol.alreadyExist"/>'; -
tapas/web/resources/templates/templateBackoffice.jsp
r409 r414 110 110 loginTexts["login.error.failed"] = "<spring:message code='login.error.failed'/>"; 111 111 loginTexts["login.error.notAccepted"] = "<spring:message code='login.error.notAccepted'/>"; 112 loginTexts["<%=UserRole.ADMINISTRATOR%>"] = '<spring:message code="app.administrator"/>'; 112 113 loginTexts["<%=UserRole.ADMINISTRATOR%>"] = '<spring:message code="label.role.administrator"/>'; 114 loginTexts["<%=UserRole.USER%>"] = '<spring:message code="label.role.user"/>'; 113 115 114 116 var interfaceTemplate = new InterfaceTemplate(); -
tapas/web/resources/templates/templateBackoffice_script.jsp
r413 r414 1 1 <%@ page import="com.ether.WebHelper" %> 2 2 3 <script type="text/javascript"> 3 4 var InterfaceTemplate = Class.create( { … … 12 13 13 14 /** *********** VARIABLES *********** **/ 14 this.path = "<%=request.getContextPath()%>";15 15 this.webmaster = "rboipsl@ipsl.jussieu.fr"; 16 16 this.jSONUser = <%=WebHelper.getJSONUser( request )%> ? <%=WebHelper.getJSONUser( request )%> : false; -
tapas/web/resources/templates/templateEther.jsp
r409 r414 1 <%@ page import="com.ether.user.UserRole" %> 1 2 <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 3 <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> … … 17 18 <ether:htmlCss cssFile="jquery-ui-1.8.16.custom/jquery-ui-1.8.16.custom"/> 18 19 <ether:htmlCss cssFile="button"/> 20 <ether:htmlCss cssFile="complexButton"/> 21 <ether:htmlCss cssFile="TwitterLogin/front"/> 19 22 <ether:htmlCss cssFile="mainEther"/> 20 23 <ether:htmlCss cssFile="tapas"/> … … 25 28 <ether:htmlJs jsFile="classesForJQuery/etherHelper"/> 26 29 <ether:htmlJs jsFile="classesForJQuery/Button"/> 30 <ether:htmlJs jsFile="classesForJQuery/ComplexButton"/> 31 <ether:htmlJs jsFile="classesForJQuery/LoginButton"/> 32 <ether:htmlJs jsFile="TwitterLogin/javascripts/jquery.tipsy"/> 27 33 <ether:htmlJs jsFile="apycom.com-5-red/menu"/> 28 34 … … 61 67 <div id="menu" class="containerMenu"> 62 68 <ul class="menu"> 63 <li><a href=" project?methodName=viewForm" class="parent"><span>Formulaire</span></a>69 <li><a href="data?methodName=viewForm" class="parent"><span>Formulaire</span></a> 64 70 65 71 <div> … … 130 136 templateTexts["label.backoffice"] = '<spring:message code="label.backoffice"/>'; 131 137 138 // Needed texts if you use the library LoginButton.js 139 var loginTexts = $A( "" ); 140 loginTexts["app.connexion"] = '<spring:message code="app.connexion"/>'; 141 loginTexts["login"] = '<spring:message code="login"/>'; 142 loginTexts["login.password"] = '<spring:message code="login.password"/>'; 143 loginTexts["login.sign"] = '<spring:message code="login.sign"/>'; 144 loginTexts["login.pwdForget"] = '<spring:message code="login.pwdForget"/>'; 145 loginTexts["login.loginForget"] = '<spring:message code="login.loginForget"/>'; 146 loginTexts["login.loginForget.help"] = '<spring:message code="login.loginForget.help"/>'; 147 loginTexts["login.inscription"] = '<spring:message code="login.inscription"/>'; 148 loginTexts["login.error.notFound"] = "<spring:message code='login.error.notFound'/>"; 149 loginTexts["login.error.wrongPassword"] = "<spring:message code='login.error.wrongPassword'/>"; 150 loginTexts["login.error.failed"] = "<spring:message code='login.error.failed'/>"; 151 loginTexts["login.error.notAccepted"] = "<spring:message code='login.error.notAccepted'/>"; 152 loginTexts["login.text"] = "<spring:message code='login.text'/>"; 153 154 loginTexts["<%=UserRole.ADMINISTRATOR%>"] = '<spring:message code="label.role.administrator"/>'; 155 loginTexts["<%=UserRole.USER%>"] = '<spring:message code="label.role.user"/>'; 156 132 157 var interfaceTemplate = new InterfaceTemplate(); 133 158 </script> -
tapas/web/resources/templates/templateEther_script.jsp
r409 r414 1 <%@ page import="com.ether.WebHelper" %> 2 1 3 <script type="text/javascript"> 2 4 var InterfaceTemplate = Class.create( { … … 12 14 // TODO : vérifier cette adresse de webmaster !!!! 13 15 this.webmaster = "rboipsl@ipsl.jussieu.fr"; 16 this.jSONUser = <%=WebHelper.getJSONUser( request )%> ? <%=WebHelper.getJSONUser( request )%> : false; 14 17 15 18 /** ************ CREATE ************ **/ 19 this.createLogin(); 16 20 this.createTools(); 17 21 }, … … 25 29 var languageButton = new Button( {value:templateTexts["label.language.to.switch"], parent:this.containerTools, id:"button_language", className: "red_button", classNameText:"red_button_text", onClick:jQuery.proxy( this.onClickLanguage, this )} ); 26 30 var homeButton = new Button( {value:templateTexts["label.home"], parent:this.containerTools, id:"button_home", className: "red_button", classNameText:"red_button_text", onClick:this.onClickHome} ); 31 }, 32 33 createLogin: function() 34 { 35 var loginModule = new LoginButton( {parent:this.containerLogin, urlLogin:"project?methodName=login", urlLogout:"project?methodName=logout", webmaster: this.webmaster, isNeededInscription:true, anotherOnClickLogin:this.updateLoginOrLogout, anotherOnClickLogout:this.updateLoginOrLogout } ); 36 loginModule.setJSONUser( this.jSONUser ); 37 loginModule.display(); 38 // setLoginModule( this.loginModule ); 27 39 }, 28 40 -
tapas/web/src/com/ether/Controller.java
r411 r414 9 9 import org.apache.commons.logging.Log; 10 10 import org.apache.commons.logging.LogFactory; 11 import org.jetbrains.annotations.NotNull;12 import org.springframework.beans.factory.annotation.Required;13 11 14 12 import java.util.HashMap; … … 26 24 /** *********************** VIEWS ***************************** **/ 27 25 /** *********************************************************** **/ 28 @ControllerMethod(view = VIEW_INIT)public Map<String, Object> home() 26 @ControllerMethod(view = VIEW_FORM_TAPAS) 27 public Map<String, Object> viewForm() 29 28 throws WebException 30 29 { 31 return new HashMap<String, Object>();32 }33 34 @ControllerMethod(view = VIEW_FORM_TAPAS)35 public Map<String, Object> viewForm()36 throws WebException{37 30 return new HashMap<String, Object>(); 38 31 } … … 58 51 private static final Log LOGGER = LogFactory.getLog( Controller.class ); 59 52 60 private static final String VIEW_INIT = "init";61 53 private static final String VIEW_FORM_TAPAS = "project/formTapas"; 62 54 } -
tapas/web/src/com/ether/ControllerEponge.java
r366 r414 5 5 import com.ether.user.User; 6 6 import com.ether.user.UserRole; 7 import com.ether.user.UserState;8 import com.medias.Constantes;9 import com.medias.Context;10 import com.medias.annuaire.Personne;11 import com.medias.mail.Mail;12 import com.medias.mail.MailFactory;13 7 import net.sf.json.JSONObject; 14 8 import org.apache.commons.logging.Log; … … 17 11 import org.jetbrains.annotations.Nullable; 18 12 19 import javax.mail.MessagingException;20 13 import javax.servlet.http.HttpServletRequest; 21 14 import java.security.DigestException; 22 15 import java.security.NoSuchAlgorithmException; 23 import java.util.ArrayList;24 16 import java.util.Date; 25 17 import java.util.HashMap; … … 28 20 /** 29 21 * @author vmipsl 30 * @date 1 2 nov 201122 * @date 15 march 2012 31 23 */ 32 24 public class ControllerEponge … … 36 28 /** *********************** VIEWS ***************************** **/ 37 29 /** *********************************************************** **/ 38 @ControllerMethod(view = VIEW_ ERRORS)39 public Map<String, Object> viewErrors()40 throws ServiceException30 @ControllerMethod(view = VIEW_INIT) 31 public Map<String, Object> home() 32 throws WebException 41 33 { 42 34 return new HashMap<String, Object>(); 43 35 } 44 36 45 @ControllerMethod(view = VIEW_ LOGIN)46 public Map<String, Object> view Login()37 @ControllerMethod(view = VIEW_ERRORS) 38 public Map<String, Object> viewErrors() 47 39 throws ServiceException 48 40 { … … 56 48 final MethodDescription methodDescription = getMethods().get( "viewHomeDataProtocol" ); 57 49 58 if( Context.getLangue( request ).equals( Constantes.french_language ) )59 methodDescription.setView( VIEW_DATA_PROTOCOL_FR );60 else61 methodDescription.setView( VIEW_DATA_PROTOCOL_EN );50 // if( Context.getLangue( request ).equals( Constantes.french_language ) ) 51 // methodDescription.setView( VIEW_DATA_PROTOCOL_FR ); 52 // else 53 // methodDescription.setView( VIEW_DATA_PROTOCOL_EN ); 62 54 return new HashMap<String, Object>(); 63 55 } … … 66 58 /** *********************** CALLS ***************************** **/ 67 59 /** *********************************************************** **/ 60 /** 61 * This method logs a user 62 * 63 * @param login 64 * @param password 65 * @param request 66 * @return 67 * @throws ServiceException 68 */ 68 69 @ControllerMethod(requestMandatory = true, jsonResult = true) 69 70 public JSONObject login( @ParamName(ParameterConstants.PARAMETER_LOGIN) final String login, … … 72 73 throws ServiceException 73 74 { 74 final JSONObject jSON People= new JSONObject();75 final JSONObject jSONUser = new JSONObject(); 75 76 final JSONObject result = new JSONObject(); 76 77 … … 79 80 try 80 81 { 81 final User user = get EtherService().getUserByEmail( login );82 final User user = getTapasService().getUserByEmail( login ); 82 83 final String encryptedPassword = EtherHelper.encryptPassword( password ); 83 84 if( user == null ) … … 85 86 else if( !encryptedPassword.equals( user.getPassword() ) ) 86 87 result.put( "errors", "login.error.wrongPassword" ); 87 else if( !UserState.ACCEPTED.equals( user.getState() ) )88 result.put( "errors", "login.error.notAccepted" );89 88 else 90 89 { 91 Personne person = getEtherService().getPeopleByEmail( user.getEmail() ); 92 if( person == null ) 93 { 94 // This is a simple user with no set of data _ Personne in session is used for tests in .jsp 95 person = new Personne(); 96 person.setNom( user.getLastName() ); 97 person.setPrenom( user.getFirstName() ); 98 person.setMail( user.getEmail() ); 99 person.setRoles( user.getRole().name() ); 100 // Can't be null because of the tests in .jsp (upload.jsp by example) 101 person.setJeux( new ArrayList<String>() ); 102 } 103 104 request.getSession().setAttribute( "SES_USER", person ); 105 jSONPeople.put( "name", user.getLastName() ); 106 jSONPeople.put( "firstName", user.getFirstName() ); 107 jSONPeople.put( "role", user.getRole().name() ); 90 request.getSession().setAttribute( "SES_USER", user ); 91 jSONUser.put( "name", user.getLastName() ); 92 jSONUser.put( "firstName", user.getFirstName() ); 93 jSONUser.put( "role", user.getRole().name() ); 108 94 } 109 95 } … … 114 100 } 115 101 116 if( !jSON People.isEmpty() )117 result.put( "jSON People", jSONPeople);102 if( !jSONUser.isEmpty() ) 103 result.put( "jSONUser", jSONUser ); 118 104 return result; 119 105 } … … 129 115 } 130 116 117 131 118 @ControllerMethod(jsonResult = true) 132 119 public JSONObject createAccount( @NotNull @ParamName(ParameterConstants.PARAMETER_NAME) final String lastName, … … 138 125 try 139 126 { 140 final User existingUser = get EtherService().getUserByEmail( email );127 final User existingUser = getTapasService().getUserByEmail( email ); 141 128 if( null == existingUser ) 142 129 { … … 144 131 145 132 final String encryptedPassword = EtherHelper.encryptPassword( password ); 146 final User user = new User( lastName, firstName, email, encryptedPassword, UserRole. COORDINATOR, UserState.WAITING, false, creationDate );133 final User user = new User( lastName, firstName, email, encryptedPassword, UserRole.USER, false, creationDate ); 147 134 148 get EtherService().createUser( user );135 getTapasService().createUser( user ); 149 136 150 137 // Send email to administrator to inform there is a new account … … 175 162 throws WebException 176 163 { 177 try178 {179 final MailFactory mailFactory = (MailFactory) getServletContext().getAttribute( "APP_MAILFACTORY" );180 final String from = (String) getServletContext().getAttribute( "APP_WEBMASTER" );181 final String toPI = (String) getServletContext().getAttribute( "APP_PI" );182 final String subject = "[MEGAPOLI] Nouvelle demande de compte utilisateur";183 final String content = "Hello Matthias,\n\nUne nouvelle demande de compte vient d'arriver.\n\n" +184 " - Nom : " + user.getLastName() + '\n' +185 " - Prénom : " + user.getFirstName() + '\n' +186 " - Email : " + user.getEmail() + "\n\n" +187 "Tu peux accepter ou refuser son inscription via le BO : http://ether.ipsl.jussieu.fr/megapoli/backoffice\n\n" +188 "Bonne soirée,\nLe serveur masqué";189 190 final Mail mailAdministrator = new Mail( from, from, null, content, subject );191 mailFactory.sendMail( mailAdministrator );192 final Mail mailPI = new Mail( from, toPI, null, content, subject );193 mailFactory.sendMail( mailPI );194 }195 catch( MessagingException e )196 {197 throw new WebException( WebException.WebCode.ERROR_EMAIL_CANNOT_BE_SEND, "The email cannot be send to the megapoli administrator" );198 }164 // try 165 // { 166 // final MailFactory mailFactory = (MailFactory) getServletContext().getAttribute( "APP_MAILFACTORY" ); 167 // final String from = (String) getServletContext().getAttribute( "APP_WEBMASTER" ); 168 // final String toPI = (String) getServletContext().getAttribute( "APP_PI" ); 169 // final String subject = "[MEGAPOLI] Nouvelle demande de compte utilisateur"; 170 // final String content = "Hello Matthias,\n\nUne nouvelle demande de compte vient d'arriver.\n\n" + 171 // " - Nom : " + user.getLastName() + '\n' + 172 // " - Prénom : " + user.getFirstName() + '\n' + 173 // " - Email : " + user.getEmail() + "\n\n" + 174 // "Tu peux accepter ou refuser son inscription via le BO : http://ether.ipsl.jussieu.fr/megapoli/backoffice\n\n" + 175 // "Bonne soirée,\nLe serveur masqué"; 176 // 177 // final Mail mailAdministrator = new Mail( from, from, null, content, subject ); 178 // mailFactory.sendMail( mailAdministrator ); 179 // final Mail mailPI = new Mail( from, toPI, null, content, subject ); 180 // mailFactory.sendMail( mailPI ); 181 // } 182 // catch( MessagingException e ) 183 // { 184 // throw new WebException( WebException.WebCode.ERROR_EMAIL_CANNOT_BE_SEND, "The email cannot be send to the megapoli administrator" ); 185 // } 199 186 } 200 187 201 188 private static final Log LOGGER = LogFactory.getLog( ControllerEponge.class ); 202 189 190 private static final String VIEW_INIT = "init"; 203 191 private static final String VIEW_ERRORS = "project/errors"; 204 private static final String VIEW_LOGIN = "project/login";205 192 private static final String VIEW_DATA_PROTOCOL_EN = "project/home_dataProtocol_en"; 206 193 private static final String VIEW_DATA_PROTOCOL_FR = "project/home_dataProtocol_fr"; -
tapas/web/src/com/ether/ControllerEther.java
r412 r414 47 47 throws WebException 48 48 { 49 }50 51 /**52 * This method logs a user53 *54 * @param login55 * @param password56 * @param request57 * @return58 * @throws ServiceException59 */60 @ControllerMethod(requestMandatory = true, jsonResult = true)61 public JSONObject login( @ParamName(ParameterConstants.PARAMETER_LOGIN) final String login,62 @ParamName(ParameterConstants.PARAMETER_PWD) final String password,63 @NotNull final HttpServletRequest request )64 throws ServiceException65 {66 final JSONObject jSONUser = new JSONObject();67 final JSONObject result = new JSONObject();68 69 if( login != null && password != null )70 {71 try72 {73 final User user = _tapasService.getUserByEmail( login );74 final String encryptedPassword = EtherHelper.encryptPassword( password );75 if( user == null )76 result.put( "errors", "login.error.notFound" );77 else if( !encryptedPassword.equals( user.getPassword() ) )78 result.put( "errors", "login.error.wrongPassword" );79 else80 {81 request.getSession().setAttribute( "SES_USER", user );82 jSONUser.put( "name", user.getLastName() );83 jSONUser.put( "firstName", user.getFirstName() );84 jSONUser.put( "role", user.getRole().name() );85 }86 }87 catch( Exception e )88 {89 result.put( "errors", "login.error.failed" );90 }91 }92 93 if( !jSONUser.isEmpty() )94 result.put( "jSONUser", jSONUser );95 return result;96 }97 98 @ControllerMethod(requestMandatory = true, jsonResult = true)99 public JSONObject logout( @NotNull final HttpServletRequest request )100 throws ServiceException101 {102 request.getSession().setAttribute( "SES_USER", null );103 request.getSession().invalidate();104 105 return new JSONObject();106 49 } 107 50 -
tapas/web/src/messages_en.properties
r409 r414 17 17 label.mail=Email 18 18 label.backoffice=Backoffice 19 20 label.role.administrator=Administrateur 21 label.role.user=Utilisateur 19 22 20 23 error.ERROR_JSON_TAPAS_IS_NULL=Error to create the form … … 93 96 bo.user.remove.confirm=Do you really want to remove the user 94 97 95 bo.user.accepted=Accepted96 bo.user.refused=Refused97 bo.user.waiting=Waiting98 bo.user.administrator=Administrator99 bo.user.user=User100 101 98 bo.field.lastName=The field lastName must be filled 102 99 bo.field.email=The field email must be filled -
tapas/web/src/messages_fr.properties
r409 r414 17 17 label.mail=Email 18 18 label.backoffice=Backoffice 19 20 label.role.administrator=Administrator 21 label.role.user=User 19 22 20 23 error.ERROR_JSON_TAPAS_IS_NULL=Erreur de création du formulaire Tapas … … 92 95 bo.user.remove.confirm=Do you really want to remove the user 93 96 94 bo.user.accepted=Accepted95 bo.user.refused=Refused96 bo.user.waiting=Waiting97 bo.user.administrator=Administrator98 bo.user.user=User99 100 97 bo.field.lastName=The field lastName must be filled 101 98 bo.field.email=The field email must be filled
Note: See TracChangeset
for help on using the changeset viewer.