Skip to content

Commit 179d985

Browse files
committed
Merge tag 'v1.5.7' into development
Tag hotfix
2 parents 1bfe1b1 + b0baf70 commit 179d985

3 files changed

Lines changed: 57 additions & 16 deletions

File tree

pom.xml

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<parent>
3030
<groupId>org.springframework.boot</groupId>
3131
<artifactId>spring-boot-starter-parent</artifactId>
32-
<version>2.6.14</version>
32+
<version>2.6.15</version>
3333
</parent>
3434

3535
<dependencies>
@@ -114,7 +114,7 @@
114114
<dependency>
115115
<groupId>org.springdoc</groupId>
116116
<artifactId>springdoc-openapi-webmvc-core</artifactId>
117-
<version>1.6.14</version>
117+
<version>1.6.15</version>
118118
</dependency>
119119

120120
<!-- Database Migration -->
@@ -140,13 +140,13 @@
140140
<dependency>
141141
<groupId>commons-io</groupId>
142142
<artifactId>commons-io</artifactId>
143-
<version>2.11.0</version>
143+
<version>2.13.0</version>
144144
</dependency>
145145

146146
<dependency>
147147
<groupId>org.apache.commons</groupId>
148148
<artifactId>commons-csv</artifactId>
149-
<version>1.9.0</version>
149+
<version>1.10.0</version>
150150
</dependency>
151151

152152
<dependency>
@@ -205,7 +205,7 @@
205205
<dependency>
206206
<groupId>org.json</groupId>
207207
<artifactId>json</artifactId>
208-
<version>20230227</version>
208+
<version>20230618</version>
209209
<scope>test</scope>
210210
</dependency>
211211
</dependencies>
@@ -226,10 +226,30 @@
226226
</resource>
227227
</resources>
228228
<plugins>
229+
<plugin>
230+
<groupId>org.apache.maven.plugins</groupId>
231+
<artifactId>maven-enforcer-plugin</artifactId>
232+
<version>1.4.1</version>
233+
<executions>
234+
<execution>
235+
<id>enforce-maven</id>
236+
<goals>
237+
<goal>enforce</goal>
238+
</goals>
239+
<configuration>
240+
<rules>
241+
<requireMavenVersion>
242+
<version>[3.0.5,)</version>
243+
</requireMavenVersion>
244+
</rules>
245+
</configuration>
246+
</execution>
247+
</executions>
248+
</plugin>
229249
<plugin>
230250
<groupId>org.codehaus.mojo</groupId>
231251
<artifactId>exec-maven-plugin</artifactId>
232-
<version>1.6.0</version>
252+
<version>3.0.0</version>
233253
<executions>
234254
<execution>
235255
<id>npm-install-dependencies</id>

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,32 @@
11
package ubc.pavlab.rdp;
22

33
import lombok.extern.apachecommons.CommonsLog;
4+
import org.springframework.boot.info.BuildProperties;
45
import org.springframework.context.annotation.Bean;
56
import org.springframework.context.annotation.Configuration;
67
import org.springframework.core.task.SimpleAsyncTaskExecutor;
78
import org.springframework.http.client.SimpleClientHttpRequestFactory;
89
import org.springframework.web.client.AsyncRestTemplate;
910
import ubc.pavlab.rdp.settings.ApplicationSettings;
1011

12+
import java.io.IOException;
13+
import java.net.HttpURLConnection;
14+
1115
@CommonsLog
1216
@Configuration
1317
public class RemoteResourceConfig {
1418

1519
@Bean
16-
public AsyncRestTemplate remoteResourceRestTemplate( ApplicationSettings applicationSettings ) {
17-
SimpleClientHttpRequestFactory httpRequestFactory = new SimpleClientHttpRequestFactory();
20+
public AsyncRestTemplate remoteResourceRestTemplate( ApplicationSettings applicationSettings, BuildProperties buildProperties ) {
21+
SimpleClientHttpRequestFactory httpRequestFactory = new SimpleClientHttpRequestFactory() {
22+
@Override
23+
protected void prepareConnection( HttpURLConnection connection, String httpMethod ) throws IOException {
24+
super.prepareConnection( connection, httpMethod );
25+
connection.setRequestProperty( "User-Agent", buildProperties.getArtifact() + "/" + buildProperties.getVersion() );
26+
}
27+
};
1828
httpRequestFactory.setTaskExecutor( new SimpleAsyncTaskExecutor() );
29+
//noinspection deprecation
1930
if ( applicationSettings.getIsearch().getRequestTimeout() != null ) {
2031
log.warn( "The 'rdp.settings.isearch.request-timeout' configuration is deprecated, use 'rdp.settings.isearch.connect-timeout' and 'rdp.settings.isearch.read-timeout' instead." );
2132
httpRequestFactory.setConnectTimeout( 1000 );

src/main/java/ubc/pavlab/rdp/services/RemoteResourceServiceImpl.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public void afterPropertiesSet() {
102102
.handle( ( rr, ex ) -> {
103103
if ( ex == null ) {
104104
if ( !rr.getOriginUrl().equals( expectedOriginUrl ) ) {
105-
log.warn( String.format( "Partner registry %s's origin URL %s differs from API URL in the configuration: %s.", rr.getOrigin(), rr.getOriginUrl(), apiUri ) );
105+
log.warn( String.format( "Partner registry %s's origin URL %s differs from API URL in the configuration: %s.", rr.getOrigin(), rr.getOriginUrl(), prepareApiUri( apiUri, false ) ) );
106106
}
107107
} else {
108108
log.warn( String.format( "Failed to reach partner registry %s: %s", expectedOriginUrl, ExceptionUtils.getRootCauseMessage( ex ) ) );
@@ -264,7 +264,7 @@ public List<User> findUsersByLikeNameAndDescription( String nameLike, boolean pr
264264
try {
265265
apiVersion = remoteResourceService.getApiVersion( apiUri );
266266
} catch ( RemoteException e ) {
267-
log.warn( String.format( "Failed to retrieve API version from %s: %s.", apiUri, ExceptionUtils.getRootCauseMessage( e ) ) );
267+
log.warn( String.format( "Failed to retrieve API version from %s: %s.", prepareApiUri( apiUri, false ), ExceptionUtils.getRootCauseMessage( e ) ) );
268268
return null;
269269
}
270270
if ( VersionUtils.satisfiesVersion( apiVersion, "1.5.0" ) ) {
@@ -403,11 +403,11 @@ public Future<List<RemoteOntologyTermInfo>> getTermsByOntologyNameAndTerms( Onto
403403
if ( ex instanceof HttpClientErrorException && ( (HttpClientErrorException) ex ).getStatusCode() == HttpStatus.NOT_FOUND ) {
404404
return null;
405405
} else {
406-
log.warn( String.format( "Failed to retrieve ontology terms from %s: %s", uri, ExceptionUtils.getRootCauseMessage( ex ) ) );
406+
log.warn( String.format( "Failed to retrieve ontology terms from %s: %s", prepareApiUri( uri, false ), ExceptionUtils.getRootCauseMessage( ex ) ) );
407407
throw new RuntimeException( ex );
408408
}
409409
} else if ( re.getBody() == null ) {
410-
log.warn( String.format( "Invalid response for %s: the body is null.", uri ) );
410+
log.warn( String.format( "Invalid response for %s: the body is null.", prepareApiUri( uri, false ) ) );
411411
return null;
412412
} else {
413413
return Arrays.asList( re.getBody() );
@@ -458,9 +458,9 @@ private <T> Collection<T> getRemoteEntities( Class<T[]> arrCls, String path, Mul
458458
if ( isMissingOntologyException( remoteException ) ) {
459459
// this is producing a 400 Bad Request, but we can safely ignore it and treat it as producing no
460460
// results
461-
log.debug( String.format( "Partner API %s is missing some of the requested ontologies: %s", f.getLeft(), remoteException.getMessage() ) );
461+
log.debug( String.format( "Partner API %s is missing some of the requested ontologies: %s", prepareApiUri( f.getLeft(), false ), remoteException.getMessage() ) );
462462
} else {
463-
log.warn( String.format( "Failed to retrieve entity from %s : %s", f.getLeft(), ExceptionUtils.getRootCauseMessage( remoteException ) ) );
463+
log.warn( String.format( "Failed to retrieve entity from %s : %s", prepareApiUri( f.getLeft(), false ), ExceptionUtils.getRootCauseMessage( remoteException ) ) );
464464
}
465465
}
466466
}
@@ -511,13 +511,23 @@ private URI getApiUri( URI remoteHost, boolean authenticate ) throws UnknownRemo
511511
return prepareApiUri( apiUri, authenticate );
512512
}
513513

514-
public List<URI> getApiUris( boolean authenticate ) {
514+
/**
515+
* Obtain a list of all partner APIs URIs.
516+
*
517+
* @param authenticate if true and the current user is an administrator, add an authentication token for a remote
518+
* administrator
519+
*/
520+
private List<URI> getApiUris( boolean authenticate ) {
515521
return Arrays.stream( applicationSettings.getIsearch().getApis() )
516522
.map( apiUri -> prepareApiUri( apiUri, authenticate ) )
517523
.collect( Collectors.toList() );
518524
}
519525

526+
/**
527+
* Prepare a given API URI, optionally adding authentication details for a remote administrator.
528+
*/
520529
private URI prepareApiUri( URI apiUri, boolean authenticate ) {
530+
// strip authentication information, it will be added later if authenticate is true
521531
UriComponentsBuilder uri = UriComponentsBuilder.fromUri( apiUri )
522532
.replaceQueryParam( "auth" )
523533
.replaceQueryParam( "noauth" );
@@ -579,7 +589,7 @@ private <T> RequestFilter<T> satisfiesVersion( String minimumVersion ) {
579589
try {
580590
apiVersion = remoteResourceService.getApiVersion( apiUri );
581591
} catch ( RemoteException e ) {
582-
log.warn( String.format( "Failed to retrieve API version from %s: %s", apiUri, ExceptionUtils.getRootCauseMessage( e ) ) );
592+
log.warn( String.format( "Failed to retrieve API version from %s: %s", prepareApiUri( apiUri, false ), ExceptionUtils.getRootCauseMessage( e ) ) );
583593
return null;
584594
}
585595
if ( VersionUtils.satisfiesVersion( apiVersion, minimumVersion ) ) {

0 commit comments

Comments
 (0)