Commit 9b478d4257e0308f752dbbb5d23eb791de0ab36b

Authored by Luís Pedro
1 parent 67fec7b77b

New constructor added

src/main/java/org/um/dsi/gavea/orcid/client/BaseOrcidOAuthClient.java
@@ -24,7 +24,7 @@ public class BaseOrcidOAuthClient implements Serializable { @@ -24,7 +24,7 @@ public class BaseOrcidOAuthClient implements Serializable {
24 private static final Logger _log = LogManager.getLogger(BaseOrcidOAuthClient.class); 24 private static final Logger _log = LogManager.getLogger(BaseOrcidOAuthClient.class);
25 25
26 26
27 - private Client client; 27 + private Client restClient;
28 private WebTarget target; 28 private WebTarget target;
29 29
30 protected final String loginUri; 30 protected final String loginUri;
@@ -34,10 +34,11 @@ public class BaseOrcidOAuthClient implements Serializable { @@ -34,10 +34,11 @@ public class BaseOrcidOAuthClient implements Serializable {
34 protected final String redirectUri; 34 protected final String redirectUri;
35 35
36 36
37 - public BaseOrcidOAuthClient(String loginUri, String apiUri, String clientId, String clientSecret, String redirectUri) { 37 + public BaseOrcidOAuthClient(Client restClient, String loginUri, String apiUri, String clientId, String clientSecret, String redirectUri) {
38 if (loginUri == null || apiUri == null || clientId == null || clientSecret == null || redirectUri == null) 38 if (loginUri == null || apiUri == null || clientId == null || clientSecret == null || redirectUri == null)
39 throw new IllegalArgumentException("Cannot create OrcidOAuthClient - missing init parameters"); 39 throw new IllegalArgumentException("Cannot create OrcidOAuthClient - missing init parameters");
40 - 40 +
  41 + this.restClient = restClient;
41 this.loginUri = loginUri; 42 this.loginUri = loginUri;
42 this.apiUri = apiUri; 43 this.apiUri = apiUri;
43 this.clientId = clientId; 44 this.clientId = clientId;
@@ -133,13 +134,13 @@ public class BaseOrcidOAuthClient implements Serializable { @@ -133,13 +134,13 @@ public class BaseOrcidOAuthClient implements Serializable {
133 } 134 }
134 135
135 private void createConnection(final String endpoint, final String orcidId, final String putCode) { 136 private void createConnection(final String endpoint, final String orcidId, final String putCode) {
136 - if (client == null) {  
137 - client = ClientBuilder.newClient();  
138 - client.property(ClientProperties.CONNECT_TIMEOUT, OrcidConstants.CLIENT_CONNECT_TIMEOUT);  
139 - client.property(ClientProperties.READ_TIMEOUT, OrcidConstants.CLIENT_READ_TIMEOUT); 137 + if (restClient == null) {
  138 + restClient = ClientBuilder.newClient();
  139 + restClient.property(ClientProperties.CONNECT_TIMEOUT, OrcidConstants.CLIENT_CONNECT_TIMEOUT);
  140 + restClient.property(ClientProperties.READ_TIMEOUT, OrcidConstants.CLIENT_READ_TIMEOUT);
140 } 141 }
141 142
142 - target = client.target(apiUri).path(buildPath(endpoint, orcidId, putCode)); 143 + target = restClient.target(apiUri).path(buildPath(endpoint, orcidId, putCode));
143 } 144 }
144 145
145 private String buildPath(final String endpoint, final String orcidId, final String putCode) { 146 private String buildPath(final String endpoint, final String orcidId, final String putCode) {