Skip to content

Commit 50d5ff7

Browse files
committed
Merge branch 'hotfix-1.4.2'
2 parents 84485de + 17233ea commit 50d5ff7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+414
-199
lines changed

docs/customization.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ This feature can be disabled by setting the following configuration key to `fals
256256
rdp.settings.privacy.enable-anonymized-search-results=false
257257
```
258258

259-
## Customaxing the application's messages
259+
## Customizing the application's messages
260260

261261
Some text displayed in RDP can be customized and/or internationalized. To do so, copy a provided `messages.properties` file in the working directory of the Web application and edit it. The file is found in
262262
[messages.properties](https://github.com/PavlidisLab/rgr/blob/master/src/main/resources/messages.properties)

docs/deployment.md

+23-15
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,36 @@
11
# Deployment
22

3-
This section expands the process of deploying in a production environment. Make
4-
sure you are familiarized with the [installation](/installation) procedure
5-
first before attempting the described steps.
3+
This section expands the process of deploying in a production environment. Make sure you are familiarized with the
4+
[installation](/installation) procedure first before attempting the described steps.
65

76
## Web server
87

9-
There a few options you will likely want to specify when deploying your RDP
10-
instance.
8+
There a few options you will likely want to specify when deploying your RDP instance.
119

12-
* `-Dserver.port=<port>`: Port for the webserver to listen on.
13-
* `-Dspring.config.location=file:<faq location>`: Location to find the FAQ question & answers
14-
* `-Djava.security.egd=file:/dev/./urandom`: Specify this if you receive logs such as:
15-
_"Creation of SecureRandom instance for session ID generation using
16-
[SHA1PRNG] took [235,853] milliseconds."_ The secure random calls may be
17-
blocking as there is not enough entropy to feed them in `/dev/random`.
10+
### Server port
11+
12+
Set `-Dserver.port=<port>` to adjust the port the embedded webserver is listening on.
13+
14+
### Fast random number generation
15+
16+
Specify `-Djava.security.egd=file:/dev/urandom` this if you receive logs such as: _"Creation of SecureRandom instance for
17+
session ID generation using [SHA1PRNG] took [235,853] milliseconds."_ The secure random calls may be blocking as there is
18+
not enough entropy to feed them in `/dev/random`.
19+
20+
### Proxy configuration
21+
22+
Set `-Dhttp.proxyHost` and `-Dhttp.proxyPort` to perform HTTP accesses through a proxy.
23+
24+
Likewise, you can set up a proxy for FTP connections with `-Dftp.proxyHost` and `-Dftp.proxyPort`.
1825

1926
## General steps
2027

2128
1. Create a working directory for the web service: `mkdir -p /project/directory`
2229
2. Move into that directory: `cd /project/directory`
23-
3. Download the latest release: `wget https://github.com/PavlidisLab/modinvreg/releases/download/vx.x/rdp-x.x.x.jar`
24-
4. Create `application.properties`, `faq.properties` and optionally `messages.properties`
25-
5. Test your setup: `java -jar rdp-x.x.x.jar`
30+
3. Download the latest release: `wget -O rdp-{{ config.extra.rdp_version }}.jar https://github.com/PavlidisLab/rdp/releases/download/v{{ config.extra.rdp_version }}/rdp-{{ config.extra.rdp_version }}.jar`
31+
4. Create `application.properties`, and optionally `faq.properties` and
32+
`messages.properties` if you want to [customize messages](customization.md#customizing-the-applications-messages).
33+
5. Test your setup: `java -jar rdp-{{ config.extra.rdp_version }}.jar`
2634
6. Log into the database and activate other organisms and organ systems (optional)
2735
7. Deploy using Systemd (see below) or a Docker container
2836

@@ -43,7 +51,7 @@ After=syslog.target
4351
User=tomcat
4452
Group=tomcat
4553
WorkingDirectory=/project/directory
46-
ExecStart=/bin/java -Xms256m -Xmx3g -Dserver.port=<port> -Djava.security.egd=file:/dev/./urandom -jar rdp-x.x.x.jar
54+
ExecStart=/bin/java -Xms256m -Xmx3g -Dserver.port=<port> -Djava.security.egd=file:/dev/urandom -jar rdp-{{ config.extra.rdp_version }}.jar
4755
SuccessExitStatus=143
4856

4957
[Install]

docs/installation.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ This section describes the essential steps to deploy an RDP registry.
55
## Requirements
66

77
- Java 8+
8-
- MySQL 5.5+ or equivalent
8+
- MySQL 5.7+ or equivalent
99
- SMTP mail server
1010

1111
## Obtain a distribution of RDP
1212

1313
Download the [latest jar distribution](https://github.com/PavlidisLab/rgr/releases/latest) from GitHub.
1414

1515
```bash
16-
wget -O rdp.jar https://github.com/PavlidisLab/rgr/releases/download/v1.3.2/rdp-1.3.2.jar
16+
wget https://github.com/PavlidisLab/rgr/releases/download/v{{ config.extra.rdp_version }}/rdp-{{ config.extra.rdp_version }}.jar
1717
```
1818

1919
The jar contains the core application, including an embedded webserver (Tomcat 8.5.x),
@@ -25,11 +25,15 @@ Create the database and an associated user that the application will use to
2525
store and retrieve data.
2626

2727
```sql
28-
create database <database name> character set utf8mb4 collate utf8mb4_unicode_ci;
28+
create database <database name> character set utf8mb4 collate utf8mb4_general_ci;
2929
create user '<database username>'@'%' identified by '<database password>';
3030
grant all on rdp.* to '<database username>'@'%';
3131
```
3232

33+
If you're using MySQL 5.6 or prior, use the `utf8` character set and `utf8_general_ci` collate. It is a 3 bytes subset
34+
of the typical 4-bytes UTF-8 character encoding. Otherwise, you will face issues with the index size limit of 767 bytes
35+
due to some of our indexed columns containing 255 characters (4 * 255 = 1020 > 767, but 3 * 255 = 765).
36+
3337
## Setup application.properties
3438

3539
In the working directory of the Web application, create an `application.properties`
@@ -60,7 +64,7 @@ That should be enough to get the Web service started. Now you can launch it by
6064
issuing the following command:
6165

6266
```bash
63-
java -jar rdp.jar
67+
java -jar rdp-{{ config.extra.rdp_version }}.jar
6468
```
6569

6670
If your email server is not properly configured, you will see an error from the

docs/release-notes.md

+23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
# Release Notes
22

3+
## 1.4.2
4+
5+
Restore rdp.site.shortname and rdp.site.fullname in `application.properties` since they're still being used in the user
6+
FAQ.
7+
8+
Fix missing TaskExecutor when using an HTTP proxy. It now uses native`-Dhttp.proxyHost` and `-Dhttp.proxyPort` JVM flags;
9+
the proxy settings in `SiteSettings` and `InternationalSearchSetings` have been simply removed.
10+
11+
Interpolate shortname and URLs in messages.
12+
13+
Move all email text into messages.properties so they can be adjusted and translated
14+
15+
Fix missing flash messages after confirming registration and contact email.
16+
17+
Fix /api/users API endpoint for registries that are not using gene-level privacy. In this case, the gene privacy level
18+
is always set to `null` and the value in the profile must be used instead as a fallback.
19+
20+
Require MySQL 5.7+ and add instructions for using MySQL 5.6 and prior. This is due to a index size limit that is busted
21+
with access and verification token when 4-bytes character encoding is used (i.e. utf8mb4).
22+
23+
Fix incorrect primary key for researcher categories that resulted in the impossibility of adding more than one category to
24+
a given user profile.
25+
326
## 1.4.1
427

528
This patch release fix some issues encountered while running the 1.4.0 in a production setup.

mkdocs.yml

+4
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ nav:
99
- migration.md
1010
- api.md
1111
- release-notes.md
12+
plugins:
13+
- macros
14+
extra:
15+
rdp_version: 1.4.2

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>ubc.pavlab</groupId>
77
<artifactId>rdp</artifactId>
8-
<version>1.4.1</version>
8+
<version>1.4.2</version>
99

1010
<developers>
1111
<developer>

src/main/java/ubc/pavlab/rdp/RemoteResourceConfig.java

+2-17
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,15 @@
33
import lombok.extern.apachecommons.CommonsLog;
44
import org.springframework.context.annotation.Bean;
55
import org.springframework.context.annotation.Configuration;
6-
import org.springframework.http.client.SimpleClientHttpRequestFactory;
76
import org.springframework.web.client.AsyncRestTemplate;
8-
import org.springframework.web.client.RestTemplate;
9-
import ubc.pavlab.rdp.settings.ApplicationSettings;
10-
11-
import java.net.InetSocketAddress;
12-
import java.net.Proxy;
137

148
@CommonsLog
159
@Configuration
1610
public class RemoteResourceConfig {
1711

1812
@Bean
19-
public AsyncRestTemplate asyncRestTemplate( ApplicationSettings applicationSettings ) {
20-
String proxyHost = applicationSettings.getIsearch().getHost();
21-
Integer proxyPort = applicationSettings.getIsearch().getPort();
22-
if ( proxyHost != null && proxyPort != null && !proxyHost.equals( "" ) ) {
23-
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
24-
Proxy proxy = new Proxy( Proxy.Type.HTTP, new InetSocketAddress( proxyHost, proxyPort ) );
25-
requestFactory.setProxy( proxy );
26-
return new AsyncRestTemplate( requestFactory );
27-
} else {
28-
return new AsyncRestTemplate();
29-
}
13+
public AsyncRestTemplate asyncRestTemplate() {
14+
return new AsyncRestTemplate();
3015
}
3116

3217
}

src/main/java/ubc/pavlab/rdp/controllers/LoginController.java

+10-5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import ubc.pavlab.rdp.services.UserService;
2626
import ubc.pavlab.rdp.settings.ApplicationSettings;
2727

28+
import java.util.Locale;
29+
2830
/**
2931
* Created by mjacobson on 16/01/18.
3032
*/
@@ -69,7 +71,8 @@ public ModelAndView registration() {
6971
@PostMapping("/registration")
7072
public ModelAndView createNewUser( @Validated(User.ValidationUserAccount.class) User user,
7173
BindingResult bindingResult,
72-
RedirectAttributes redirectAttributes ) {
74+
RedirectAttributes redirectAttributes,
75+
Locale locale ) {
7376
ModelAndView modelAndView = new ModelAndView( "registration" );
7477
User userExists = userService.findUserByEmailNoAuth( user.getEmail() );
7578

@@ -92,7 +95,7 @@ public ModelAndView createNewUser( @Validated(User.ValidationUserAccount.class)
9295
} else {
9396
user = userService.create( user );
9497
VerificationToken token = userService.createVerificationTokenForUser( user );
95-
eventPublisher.publishEvent( new OnRegistrationCompleteEvent( user, token ) );
98+
eventPublisher.publishEvent( new OnRegistrationCompleteEvent( user, token, locale ) );
9699
redirectAttributes.addFlashAttribute( "message", "Your user account was registered successfully. Please check your email for completing the completing the registration process." );
97100
modelAndView.setViewName( "redirect:/login" );
98101
}
@@ -107,7 +110,7 @@ public ModelAndView resendConfirmation() {
107110

108111
@Transactional
109112
@PostMapping(value = "/resendConfirmation")
110-
public ModelAndView resendConfirmation( @RequestParam("email") String email ) {
113+
public ModelAndView resendConfirmation( @RequestParam("email") String email, Locale locale ) {
111114
ModelAndView modelAndView = new ModelAndView( "resendConfirmation" );
112115
User user = userService.findUserByEmailNoAuth( email );
113116

@@ -123,19 +126,21 @@ public ModelAndView resendConfirmation( @RequestParam("email") String email ) {
123126
return modelAndView;
124127
} else {
125128
VerificationToken token = userService.createVerificationTokenForUser( user );
126-
eventPublisher.publishEvent( new OnRegistrationCompleteEvent( user, token ) );
129+
eventPublisher.publishEvent( new OnRegistrationCompleteEvent( user, token, locale ) );
127130
modelAndView.addObject( "message", "Confirmation email sent." );
128131
}
129132

130133
return modelAndView;
131134
}
132135

133136
@GetMapping(value = "/registrationConfirm")
134-
public ModelAndView confirmRegistration( @RequestParam("token") String token ) {
137+
public ModelAndView confirmRegistration( @RequestParam("token") String token,
138+
RedirectAttributes redirectAttributes ) {
135139
ModelAndView modelAndView = new ModelAndView();
136140

137141
try {
138142
userService.confirmVerificationToken( token );
143+
redirectAttributes.addFlashAttribute( "message", "Your account has been enabled successfully, and you can now proceed to login." );
139144
modelAndView.setViewName( "redirect:/login" );
140145
} catch ( TokenException e ) {
141146
log.error( "Could not confirm registration token.", e );

src/main/java/ubc/pavlab/rdp/controllers/UserController.java

+8-7
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,16 @@ public ModelAndView support() {
149149
public ModelAndView supportPost( HttpServletRequest request,
150150
@RequestParam String name,
151151
@RequestParam String message,
152-
@RequestParam(required = false) MultipartFile attachment ) {
152+
@RequestParam(required = false) MultipartFile attachment,
153+
Locale locale ) {
153154
ModelAndView modelAndView = new ModelAndView( "user/support" );
154155
User user = userService.findCurrentUser();
155156
modelAndView.addObject( "user", user );
156157

157158
log.info( MessageFormat.format( "{0} is attempting to contact support.", user ) );
158159

159160
try {
160-
emailService.sendSupportMessage( message, name, user, request, attachment );
161+
emailService.sendSupportMessage( message, name, user, request.getHeader( "User-Agent" ), attachment, locale );
161162
modelAndView.addObject( "message", "Sent. We will get back to you shortly." );
162163
modelAndView.addObject( "success", Boolean.TRUE );
163164
} catch ( MessagingException e ) {
@@ -222,13 +223,13 @@ public ModelAndView changePassword( @Valid PasswordChange passwordChange, Bindin
222223

223224
@Transactional
224225
@PostMapping("/user/resend-contact-email-verification")
225-
public Object resendContactEmailVerification( RedirectAttributes redirectAttributes ) {
226+
public Object resendContactEmailVerification( RedirectAttributes redirectAttributes, Locale locale ) {
226227
User user = userService.findCurrentUser();
227228
if ( user.getProfile().isContactEmailVerified() ) {
228229
return ResponseEntity.badRequest().body( "Contact email is already verified." );
229230
}
230231
VerificationToken token = userService.createContactEmailVerificationTokenForUser( user );
231-
eventPublisher.publishEvent( new OnContactEmailUpdateEvent( user, token ) );
232+
eventPublisher.publishEvent( new OnContactEmailUpdateEvent( user, token, locale ) );
232233
redirectAttributes.addFlashAttribute( "message", MessageFormat.format( "We will send an email to {0} with a link to verify your contact email.", user.getProfile().getContactEmail() ) );
233234
return "redirect:/user/profile";
234235
}
@@ -237,7 +238,7 @@ public Object resendContactEmailVerification( RedirectAttributes redirectAttribu
237238
public String verifyContactEmail( @RequestParam String token, RedirectAttributes redirectAttributes ) {
238239
try {
239240
userService.confirmVerificationToken( token );
240-
redirectAttributes.addFlashAttribute( "Your contact email has been successfully verified." );
241+
redirectAttributes.addFlashAttribute( "message", "Your contact email has been successfully verified." );
241242
} catch ( TokenException e ) {
242243
log.error( MessageFormat.format( "{0} attempt to confirm verification token failed.", userService.findCurrentUser() ), e );
243244
redirectAttributes.addFlashAttribute( "message", e.getMessage() );
@@ -255,9 +256,9 @@ static class ProfileWithOrganUberonIds {
255256

256257
@ResponseBody
257258
@PostMapping(value = "/user/profile", produces = MediaType.TEXT_PLAIN_VALUE)
258-
public String saveProfile( @RequestBody ProfileWithOrganUberonIds profileWithOrganUberonIds ) {
259+
public String saveProfile( @RequestBody ProfileWithOrganUberonIds profileWithOrganUberonIds, Locale locale ) {
259260
User user = userService.findCurrentUser();
260-
userService.updateUserProfileAndPublicationsAndOrgans( user, profileWithOrganUberonIds.profile, profileWithOrganUberonIds.profile.getPublications(), profileWithOrganUberonIds.organUberonIds );
261+
userService.updateUserProfileAndPublicationsAndOrgans( user, profileWithOrganUberonIds.profile, profileWithOrganUberonIds.profile.getPublications(), profileWithOrganUberonIds.organUberonIds, locale );
261262
return "Saved.";
262263
}
263264

src/main/java/ubc/pavlab/rdp/events/OnContactEmailUpdateEvent.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import ubc.pavlab.rdp.model.User;
77
import ubc.pavlab.rdp.model.VerificationToken;
88

9+
import java.util.Locale;
10+
911
@Getter
1012
@EqualsAndHashCode(callSuper = true)
1113
public class OnContactEmailUpdateEvent extends ApplicationEvent {
@@ -14,9 +16,12 @@ public class OnContactEmailUpdateEvent extends ApplicationEvent {
1416

1517
private final VerificationToken token;
1618

17-
public OnContactEmailUpdateEvent( User user, VerificationToken token ) {
19+
private final Locale locale;
20+
21+
public OnContactEmailUpdateEvent( User user, VerificationToken token, Locale locale ) {
1822
super( user );
1923
this.user = user;
2024
this.token = token;
25+
this.locale = locale;
2126
}
2227
}

src/main/java/ubc/pavlab/rdp/events/OnRegistrationCompleteEvent.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import ubc.pavlab.rdp.model.User;
88
import ubc.pavlab.rdp.model.VerificationToken;
99

10+
import java.util.Locale;
11+
1012
/**
1113
* Created by mjacobson on 22/01/18.
1214
*/
@@ -18,9 +20,12 @@ public class OnRegistrationCompleteEvent extends ApplicationEvent {
1820

1921
private final VerificationToken token;
2022

21-
public OnRegistrationCompleteEvent( User user, VerificationToken token ) {
23+
private final Locale locale;
24+
25+
public OnRegistrationCompleteEvent( User user, VerificationToken token, Locale locale ) {
2226
super( user );
2327
this.user = user;
2428
this.token = token;
29+
this.locale = locale;
2530
}
2631
}

src/main/java/ubc/pavlab/rdp/listeners/UserListener.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
import lombok.extern.apachecommons.CommonsLog;
44
import org.springframework.beans.factory.annotation.Autowired;
5-
import org.springframework.context.event.EventListener;
6-
import org.springframework.http.HttpStatus;
75
import org.springframework.stereotype.Component;
86
import org.springframework.transaction.event.TransactionalEventListener;
97
import ubc.pavlab.rdp.events.OnContactEmailUpdateEvent;
@@ -37,7 +35,7 @@ public void onRegistrationComplete( OnRegistrationCompleteEvent event ) {
3735
}
3836

3937
try {
40-
emailService.sendRegistrationMessage( event.getUser(), event.getToken() );
38+
emailService.sendRegistrationMessage( event.getUser(), event.getToken(), event.getLocale() );
4139
} catch ( MessagingException e ) {
4240
log.error( MessageFormat.format( "Could not send registration email to {0}.", event.getUser() ), e );
4341
}
@@ -46,7 +44,7 @@ public void onRegistrationComplete( OnRegistrationCompleteEvent event ) {
4644
@TransactionalEventListener
4745
public void onContactEmailUpdate( OnContactEmailUpdateEvent event ) {
4846
try {
49-
emailService.sendContactEmailVerificationMessage( event.getUser(), event.getToken() );
47+
emailService.sendContactEmailVerificationMessage( event.getUser(), event.getToken(), event.getLocale() );
5048
} catch ( MessagingException e ) {
5149
log.error( MessageFormat.format( "Could not send contact email verification to {0}.", event.getUser() ), e );
5250
}

src/main/java/ubc/pavlab/rdp/model/Profile.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public String getFullName() {
8484
private ResearcherPosition researcherPosition;
8585

8686
@Enumerated(EnumType.STRING)
87-
@Column(name = "researcher_category")
87+
@Column(name = "researcher_category", nullable = false)
8888
@ElementCollection
8989
@CollectionTable(name = "user_researcher_category", joinColumns = { @JoinColumn(name = "user_id") })
9090
private final Set<ResearcherCategory> researcherCategories = new HashSet<>();

0 commit comments

Comments
 (0)