Skip to content

Commit

Permalink
Merge branch 'release-1.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
mbelmadani committed Jul 9, 2019
2 parents 13b63f0 + 2810910 commit 1a9759d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>ubc.pavlab</groupId>
<artifactId>rdp</artifactId>
<version>1.2.10</version>
<version>1.3.0</version>

<parent>
<groupId>org.springframework.boot</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import ubc.pavlab.rdp.repositories.RoleRepository;
import ubc.pavlab.rdp.settings.ApplicationSettings;

import javax.ws.rs.client.Client;
import javax.ws.rs.core.Response;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
Expand Down Expand Up @@ -117,7 +118,23 @@ private <T> Collection<T> getRemoteEntities( Class<T[]> arrCls, String uri, Map<
}

private <T> T remoteRequest( Class<T> cls, String remoteUrl, Map<String, String> args ) throws RemoteException {
ResteasyClient client = new ResteasyClientBuilder().build();

String proxyHost = applicationSettings.getIsearch().getHost();
String proxyPort = applicationSettings.getIsearch().getPort();
ResteasyClient client = null;

if (proxyHost != null && proxyPort != null &&
!proxyHost.equals("") && !proxyPort.equals("") ) {
client = new ResteasyClientBuilder().defaultProxy(
proxyHost,
Integer.parseInt( proxyPort )
).build();
log.info( "Using " +proxyHost + ":" + proxyPort+ " as proxy for rest client." );
} else {
client = new ResteasyClientBuilder().build();
log.info( "Using default proxy for rest client." );
}

ResteasyWebTarget target = client.target( remoteUrl + encodeParams( args ) );
Response response = target.request().get();
if ( response.getStatus() != 200 ) {
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/ubc/pavlab/rdp/settings/ApplicationSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.URL;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import ubc.pavlab.rdp.services.UserService;
Expand Down Expand Up @@ -53,6 +54,9 @@ public static class InternationalSearchSettings {
private String[] apis;
private List<String> authTokens;
private String searchToken;
@URL
private String host = null;
private String port = null;
}

private InternationalSearchSettings isearch;
Expand All @@ -61,4 +65,13 @@ public static class InternationalSearchSettings {
private boolean sendEmailOnRegistration;
private int goTermSizeLimit = 100;

// @Getter
// @Setter
// public static class ProxySettings {
// @URL
// private String host = null;
// private String port = null;
// }
// private ProxySettings proxy;

}
4 changes: 4 additions & 0 deletions src/main/java/ubc/pavlab/rdp/settings/SiteSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,8 @@ public String getFullUrl() {
return host + context + (context.endsWith( "/" ) ? "" : "/");
}

@URL
private String proxyHost;
private String proxyPort;

}

0 comments on commit 1a9759d

Please sign in to comment.