Changeset 422
- Timestamp:
- 03/19/12 18:39:02 (12 years ago)
- Location:
- tapas
- Files:
-
- 6 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
tapas/common/implementation/com/ether/EtherHelper.java
r417 r422 4 4 import org.jetbrains.annotations.NotNull; 5 5 import org.jetbrains.annotations.Nullable; 6 6 import org.springframework.mail.javamail.JavaMailSenderImpl; 7 import org.springframework.mail.javamail.MimeMessageHelper; 8 9 import javax.mail.MessagingException; 10 import javax.mail.internet.MimeMessage; 7 11 import java.io.BufferedWriter; 8 12 import java.io.FileWriter; … … 216 220 } 217 221 } 222 223 /** 224 * This method sends a message 225 * host (see in properties) : mailhost.ipsl.jussieu.fr 226 * 227 * @param host 228 * @param to 229 * @param from 230 * @param subject 231 * @param text 232 * @throws FormattedException 233 */ 234 public static void sendMessage( @NotNull final String host, @NotNull final String from, @NotNull final String to, @NotNull final String subject, @NotNull final String text ) 235 throws FormattedException 236 { 237 try 238 { 239 final JavaMailSenderImpl sender = new JavaMailSenderImpl(); 240 sender.setHost( host ); 241 242 final MimeMessage message = sender.createMimeMessage(); 243 final MimeMessageHelper helper = new MimeMessageHelper( message ); 244 helper.setFrom( from ); 245 helper.setTo( to ); 246 helper.setSubject( subject ); 247 helper.setText( text ); 248 sender.send( message ); 249 } 250 catch( MessagingException e ) 251 { 252 throw new FormattedException( FormattedException.FormattedCode.ERROR_TO_SEND_MESSAGE, e ); 253 } 254 } 218 255 } -
tapas/common/interface/com/ether/FormattedException.java
r417 r422 90 90 { 91 91 ERROR_IO_TO_EXECUTE_PROCESS, 92 ERROR_TO_SEND_MESSAGE, 92 93 } 93 94 -
tapas/domain/interface/com/ether/tapas/Observatory.java
r421 r422 9 9 public class Observatory 10 10 { 11 @NotNull12 11 public Integer getId() 13 12 { … … 15 14 } 16 15 17 public void setId( @NotNullfinal Integer id )16 public void setId( final Integer id ) 18 17 { 19 18 _id = id; … … 64 63 } 65 64 66 @NotNull67 65 private Integer _id; 68 66 @NotNull -
tapas/web/src/com/ether/ControllerEponge.java
r416 r422 10 10 import org.jetbrains.annotations.NotNull; 11 11 import org.jetbrains.annotations.Nullable; 12 12 import org.springframework.mail.javamail.JavaMailSenderImpl; 13 import org.springframework.mail.javamail.MimeMessageHelper; 14 15 import javax.mail.MessagingException; 16 import javax.mail.internet.MimeMessage; 13 17 import javax.servlet.http.HttpServletRequest; 14 18 import java.security.DigestException; … … 124 128 125 129 // Send email to administrator to inform there is a new account 126 sendEmailToAdministrator ( user );130 sendEmailToAdministratorAndUser( user ); 127 131 } 128 132 else … … 142 146 143 147 /** 144 * This method create and send an email to the administrator to inform there is a new account to validate 148 * This method create and send an email to : 149 * - the administrator to inform there is a new created account 150 * - the user to inform his account is created 145 151 * 146 152 * @param user 147 153 * @throws WebException 148 154 */ 149 private void sendEmailToAdministrator ( @NotNull final User user )155 private void sendEmailToAdministratorAndUser( @NotNull final User user ) 150 156 throws WebException 151 157 { 152 // try 153 // { 154 // final MailFactory mailFactory = (MailFactory) getServletContext().getAttribute( "APP_MAILFACTORY" ); 155 // final String from = (String) getServletContext().getAttribute( "APP_WEBMASTER" ); 156 // final String toPI = (String) getServletContext().getAttribute( "APP_PI" ); 157 // final String subject = "[MEGAPOLI] Nouvelle demande de compte utilisateur"; 158 // final String content = "Hello Matthias,\n\nUne nouvelle demande de compte vient d'arriver.\n\n" + 159 // " - Nom : " + user.getLastName() + '\n' + 160 // " - Prénom : " + user.getFirstName() + '\n' + 161 // " - Email : " + user.getEmail() + "\n\n" + 162 // "Tu peux accepter ou refuser son inscription via le BO : http://ether.ipsl.jussieu.fr/megapoli/backoffice\n\n" + 163 // "Bonne soirée,\nLe serveur masqué"; 164 // 165 // final Mail mailAdministrator = new Mail( from, from, null, content, subject ); 166 // mailFactory.sendMail( mailAdministrator ); 167 // final Mail mailPI = new Mail( from, toPI, null, content, subject ); 168 // mailFactory.sendMail( mailPI ); 169 // } 170 // catch( MessagingException e ) 171 // { 172 // throw new WebException( WebException.WebCode.ERROR_EMAIL_CANNOT_BE_SEND, "The email cannot be send to the megapoli administrator" ); 173 // } 158 try 159 { 160 final String host = getProperty( "mail.host" ); 161 final String webMaster = getProperty( "mail.webmaster" ); 162 final JavaMailSenderImpl sender = new JavaMailSenderImpl(); 163 sender.setHost( host ); 164 165 final MimeMessage message = sender.createMimeMessage(); 166 final MimeMessageHelper helper = new MimeMessageHelper( message ); 167 168 // Mail Admin 169 final String subjectAdmin = "[TAPAS] Nouveau compte utilisateur"; 170 final String contentAdmin = "Nouvelle création de compte : \n\n" + 171 " - Nom : " + user.getLastName() + '\n' + 172 " - Prénom : " + user.getFirstName() + '\n' + 173 " - Email : " + user.getEmail() + "\n\n" + 174 "Le serveur de mail masqué"; 175 176 helper.setFrom( webMaster ); 177 helper.setTo( webMaster ); 178 helper.setSubject( subjectAdmin ); 179 helper.setText( contentAdmin ); 180 sender.send( message ); 181 182 // Mail User 183 final String subjectUser = "[TAPAS] New account"; 184 final String contentUser = "Dear " + user.getLastName() + "\n\n" + 185 "Your account on TAPAS is now created. You can access to the website with your email as login and your password.\n\n" + 186 "The TAPAS Administrator"; 187 188 helper.setFrom( webMaster ); 189 helper.setTo( user.getEmail() ); 190 helper.setSubject( subjectUser ); 191 helper.setText( contentUser ); 192 sender.send( message ); 193 } 194 catch( MessagingException e ) 195 { 196 throw new WebException( WebException.WebCode.ERROR_EMAIL_CANNOT_BE_SEND, "The email cannot be send to the TAPAS administrator or USER" ); 197 } 174 198 } 175 199 -
tapas/web/src/com/ether/ControllerEther.java
r416 r422 39 39 import java.util.List; 40 40 import java.util.Map; 41 import java.util.Properties; 41 42 42 43 public class ControllerEther … … 52 53 throws WebException 53 54 { 55 } 56 57 /** 58 * @return 59 * @throws WebException 60 */ 61 public String getProperty( @NotNull final String property ) 62 throws WebException 63 { 64 try 65 { 66 final String webInfPath = getServletContext().getRealPath( "WEB-INF" ); 67 final Properties prop = new Properties(); 68 prop.load( new FileInputStream( webInfPath + "/classes/tapas.properties" ) ); 69 return prop.getProperty( property ); 70 } 71 catch( IOException e ) 72 { 73 throw new WebException( WebException.WebCode.ERROR_TO_READ_FILE_PROPERTIES, e ); 74 } 54 75 } 55 76 -
tapas/web/src/com/ether/WebException.java
r419 r422 45 45 ERROR_ENCRYPT_PASSWORD, 46 46 ERROR_EMAIL_CANNOT_BE_SEND, 47 ERROR_NO_OBSERVATORY_FOUND 47 ERROR_NO_OBSERVATORY_FOUND, 48 ERROR_TO_READ_FILE_PROPERTIES 48 49 } 49 50 -
tapas/web/src/tapas.properties
r416 r422 1 inWork=Work in progress.. 2 language=en 3 label.language.to.switch=French 4 label.language.value.to.switch=fr 5 6 app.title=Tapas 7 app.fulltitle=Full title de Tapas 8 app.connexion=Connection 9 app.administrator=Administrator 10 app.yes=Yes 11 app.no=No 12 13 title.home=Tapas data 14 15 label.home=Home 16 label.map=Map 17 label.mail=Email 18 label.backoffice=Backoffice 19 20 label.role.administrator=Administrateur 21 label.role.user=Utilisateur 22 23 error.ERROR_JSON_TAPAS_IS_NULL=Error to create the form 24 25 label.submitButton=RUN 26 27 ################################################################ 28 ####################### ERRORS ################################# 29 ################################################################ 30 USER_ALREADY_EXISTS=This email is already used, you have to give another one 31 32 33 ################################################################ 34 ####################### LOGIN ################################## 35 ################################################################ 36 login.authentification=Authentification 37 login.intro=Please login to access the protected areas of this website. 38 login=Login 39 login.password=Password 40 login.sign=Sign in 41 login.loginForget=Forgot your username ? 42 login.loginForget.help=If you remember your password, try logging in with your email 43 login.pwdForget=Forgot your password ? 44 login.inscription=New inscription 45 login.text=Please login to access the protected areas of this website. 46 47 login.dataProtocolAccept=You have to accept the data protocol to ask for an account 48 login.dataProtocolFields=Fields 'LastName', 'Email' and 'Password' must be filled 49 login.dataProtocol.account=Your account is now activated. You can login with your email and password. 50 51 login.error.notAccepted=You are not allowed to access to protected areas. 52 login.error.bo.notAccepted=You are not authorized to access to backoffice. 53 login.error.notFound=Unknown login.<br> To register and access the protected areas of this site, please click on 'New inscription'.<br> 54 login.error.wrongPassword=Wrong password. 55 login.error.failed=The logon transaction failed. Please contact the <a href\='mailto\:{0}?subject\=[TAPAS]'>webmaster</a> to report this problem.<br> 56 login.error.unknown=You are not authentified or you lost your session, please register. 57 58 59 60 ################################################################ 61 ##################### BACKOFFICE ############################### 62 ################################################################ 63 bo.fulltitle=TAPAS Backoffice 64 bo.site=Tapas 65 bo.id=Id 66 bo.action=Action 67 bo.actions=Actions 68 bo.modify=Modify 69 bo.remove=Remove 70 bo.add=Add 71 bo.accept=Accept 72 bo.refuse=Refuse 73 bo.init=Init 74 bo.go=Go 75 bo.all=All 76 bo.total.number=Total number 77 bo.previous=Previous 78 bo.next=Next 79 bo.sortBy=Sort by 80 bo.viewBy=View by 81 bo.sort.asc=Sort asc by 82 bo.user=Users 83 bo.user.waitinglist=List of users waiting to have an access to data 84 bo.user.waitinglist.help=(an email will be sent to the user with your choice (accept or refuse)) 85 bo.user.list=List of users 86 bo.noUser=No user 87 bo.user.lastName=Lastname 88 bo.user.firstName=Firstname 89 bo.user.email=Email 90 bo.user.password=Password 91 bo.user.password.same=Keep same password 92 bo.user.password.same.help=(only to modify a password) 93 bo.user.role=Role 94 bo.user.laboratory=Laboratory 95 bo.user.country=Country 96 bo.user.creationDate=Creation date 97 bo.user.state=State 98 bo.user.state.help=Inscription state (can be removed, unactif, refused, ...) 99 bo.user.boAccess=BO 100 bo.user.boAccess.help=Access to the backoffice 101 bo.user.add=Add a new user 102 bo.user.modify=Modify the user 103 bo.user.remove.confirm=Do you really want to remove the user 104 105 bo.field.lastName=The field lastName must be filled 106 bo.field.email=The field email must be filled 107 bo.field.password=The field password must be filled 108 109 bo.user.emailNotSend=The email to the user cannot be sent, the email seems not valid : 1 mail.host=mailhost.ipsl.jussieu.fr 2 mail.webmaster=rboipsl@ipsl.jussieu.fr
Note: See TracChangeset
for help on using the changeset viewer.