Skip to content

Commit 26f5e8c

Browse files
committed
Use the standard response handler
1 parent ba74a90 commit 26f5e8c

File tree

2 files changed

+47
-50
lines changed

2 files changed

+47
-50
lines changed

testwebapp/build.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,10 @@ deploy - Deploy the application directly into the Tomcat webapps directory.
9898
<target name="deploy"
9999
depends="compile"
100100
description="--> Build the app and install in Tomcat">
101+
<!-- <property name="webapp.deploy.home"
102+
value="${tomcat.home}/webapps/${webapp.name}" /> -->
101103
<property name="webapp.deploy.home"
102-
value="${tomcat.home}/webapps/${webapp.name}" />
104+
value="${tomcat.home}/webapps/orcivo" />
103105

104106
<mkdir dir="${webapp.deploy.home}" />
105107

testwebapp/src/edu/cornell/mannlib/orcidclient/testwebapp/CallbackController.java

Lines changed: 44 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,8 @@
2222
import org.apache.commons.logging.Log;
2323
import org.apache.commons.logging.LogFactory;
2424
import org.apache.http.Consts;
25-
import org.apache.http.HttpEntity;
26-
import org.apache.http.HttpResponse;
2725
import org.apache.http.NameValuePair;
28-
import org.apache.http.StatusLine;
2926
import org.apache.http.client.ClientProtocolException;
30-
import org.apache.http.client.HttpResponseException;
31-
import org.apache.http.client.ResponseHandler;
3227
import org.apache.http.client.entity.UrlEncodedFormEntity;
3328
import org.apache.http.client.methods.CloseableHttpResponse;
3429
import org.apache.http.client.methods.HttpPost;
@@ -140,50 +135,50 @@ private String dumpRequest(HttpServletRequest req) {
140135
return "Request: " + req.getRequestURL() + ", parameters=" + prettyMap;
141136
}
142137

143-
private static class AccessTokenResponseHandler implements
144-
ResponseHandler<AccessToken> {
145-
private int statusCode;
146-
private String reasonPhrase = "";
147-
private String content = "";
148-
149-
@Override
150-
public AccessToken handleResponse(HttpResponse response)
151-
throws ClientProtocolException, IOException {
152-
StatusLine statusLine = response.getStatusLine();
153-
this.statusCode = statusLine.getStatusCode();
154-
this.reasonPhrase = statusLine.getReasonPhrase();
155-
156-
if (statusCode >= 300) {
157-
throw new HttpResponseException(statusLine.getStatusCode(),
158-
statusLine.getReasonPhrase());
159-
}
160-
HttpEntity entity = response.getEntity();
161-
if (entity == null) {
162-
throw new ClientProtocolException(
163-
"Response contains no content");
164-
}
165-
this.content = EntityUtils.toString(entity);
166-
try {
167-
return new AccessToken(this.content);
168-
} catch (AccessTokenFormatException e) {
169-
throw new ClientProtocolException(
170-
"Failed to parse the access token", e);
171-
}
172-
}
173-
174-
public int getStatusCode() {
175-
return statusCode;
176-
}
177-
178-
public String getReasonPhrase() {
179-
return reasonPhrase;
180-
}
181-
182-
public String getContent() {
183-
return content;
184-
}
185-
186-
}
138+
// private static class AccessTokenResponseHandler implements
139+
// ResponseHandler<AccessToken> {
140+
// private int statusCode;
141+
// private String reasonPhrase = "";
142+
// private String content = "";
143+
//
144+
// @Override
145+
// public AccessToken handleResponse(HttpResponse response)
146+
// throws ClientProtocolException, IOException {
147+
// StatusLine statusLine = response.getStatusLine();
148+
// this.statusCode = statusLine.getStatusCode();
149+
// this.reasonPhrase = statusLine.getReasonPhrase();
150+
//
151+
// if (statusCode >= 300) {
152+
// throw new HttpResponseException(statusLine.getStatusCode(),
153+
// statusLine.getReasonPhrase());
154+
// }
155+
// HttpEntity entity = response.getEntity();
156+
// if (entity == null) {
157+
// throw new ClientProtocolException(
158+
// "Response contains no content");
159+
// }
160+
// this.content = EntityUtils.toString(entity);
161+
// try {
162+
// return new AccessToken(this.content);
163+
// } catch (AccessTokenFormatException e) {
164+
// throw new ClientProtocolException(
165+
// "Failed to parse the access token", e);
166+
// }
167+
// }
168+
//
169+
// public int getStatusCode() {
170+
// return statusCode;
171+
// }
172+
//
173+
// public String getReasonPhrase() {
174+
// return reasonPhrase;
175+
// }
176+
//
177+
// public String getContent() {
178+
// return content;
179+
// }
180+
//
181+
// }
187182

188183
private static class PostRequestBuilder {
189184
private final HttpPost post;

0 commit comments

Comments
 (0)