Commit 1476f22d73332a030ade057c73f76ea0b1fc989c

Authored by Luis Pedro
1 parent a5611a7ad5
Exists in master and in 1 other branch API_v3.0

C5075

src/main/java/org/um/dsi/gavea/orcid/client/BaseOrcidOAuthClient.java
... ... @@ -7,17 +7,14 @@ import javax.ws.rs.client.Client;
7 7 import javax.ws.rs.client.ClientBuilder;
8 8 import javax.ws.rs.client.Entity;
9 9 import javax.ws.rs.client.WebTarget;
10   -import javax.ws.rs.core.MediaType;
11 10 import javax.ws.rs.core.MultivaluedMap;
12 11 import javax.ws.rs.core.Response;
13 12  
14 13 import org.glassfish.jersey.client.ClientProperties;
15   -import org.glassfish.jersey.jackson.JacksonFeature;
16 14 import org.slf4j.Logger;
17 15 import org.slf4j.LoggerFactory;
18 16 import org.um.dsi.gavea.orcid.client.constants.OrcidConstants;
19 17 import org.um.dsi.gavea.orcid.client.exception.OrcidClientException;
20   -import org.um.dsi.gavea.orcid.client.jackson.JacksonConfigurator;
21 18 import org.um.dsi.gavea.orcid.client.util.RecordUtil;
22 19 import org.um.dsi.gavea.orcid.model.error.Error;
23 20  
... ... @@ -76,14 +73,13 @@ public class BaseOrcidOAuthClient implements Serializable {
76 73 return response;
77 74 }
78 75  
79   - protected <T> Response post(final String authorizationCode, final MultivaluedMap<String, String> formData)
80   - throws OrcidClientException {
  76 + protected <T> Response post(final String authorizationCode, final MultivaluedMap<String, String> formData) throws OrcidClientException {
81 77 createConnection(OrcidConstants.ENDPOINT_OAUTH_TOKEN, null, null);
82 78  
83 79 if (debugMode || _log.isTraceEnabled()) {
84 80 _log.debug("[getAccessTokens][post].[Request.form] " + formData.toString());
85 81 }
86   - Response response = target.request(MediaType.APPLICATION_JSON_TYPE).post(Entity.form(formData));
  82 + Response response = target.request(OrcidConstants.APPLICATION_ORCID_XML).post(Entity.form(formData));
87 83 _log.debug("[getAccessTokens][post].[Response.Status] " + response.getStatus());
88 84 _log.debug("[getAccessTokens][post].[Response.Reason] " + response.getStatusInfo().getReasonPhrase());
89 85  
... ... @@ -165,8 +161,6 @@ public class BaseOrcidOAuthClient implements Serializable {
165 161 restClient = ClientBuilder.newClient();
166 162 restClient.property(ClientProperties.CONNECT_TIMEOUT, OrcidConstants.CLIENT_CONNECT_TIMEOUT);
167 163 restClient.property(ClientProperties.READ_TIMEOUT, OrcidConstants.CLIENT_READ_TIMEOUT);
168   - restClient.register(JacksonFeature.class);
169   - restClient.register(JacksonConfigurator.class);
170 164 }
171 165  
172 166 target = restClient.target(apiUri).path(buildPath(endpoint, orcidId, putCode));
... ...
src/main/java/org/um/dsi/gavea/orcid/client/OrcidOAuthClient.java
... ... @@ -116,7 +116,7 @@ public class OrcidOAuthClient extends BaseOrcidOAuthClient {
116 116 * @return
117 117 * @throws Exception
118 118 */
119   - private String getAuthorizeUri(final List<ScopePathType> scopes, final String state, final String orcidId, final String familyNames, final String givenNames, final String email, final String lang, final boolean login) throws Exception {
  119 + private String getAuthorizeUri(final List<ScopePathType> scopes, final String state, final String orcidId, final String familyNames, String givenNames, final String email, final String lang, final boolean login) throws Exception {
120 120  
121 121 if (scopes == null)
122 122 throw new Exception("Cannot create Authorize Uri - missing scopes");
... ...