Skip to content

Commit 443f201

Browse files
committed
move OpenTokHttpClient to util.HttpClient. fixes #21
1 parent 96336b4 commit 443f201

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

src/main/java/com/opentok/api/Archive.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public void setUrl(String url) {
179179
// public Archive stop() throws OpenTokException {
180180
// HashMap<String, String> headers = new HashMap<String, String>();
181181
// headers.put("content-type", "application/json");
182-
// String archive = OpenTokHttpClient.makePostRequest("/v2/partner/" + this.partnerId + "/archive/" + id, headers, null,
182+
// String archive = HttpClient.makePostRequest("/v2/partner/" + this.partnerId + "/archive/" + id, headers, null,
183183
// "{ \"action\" : \"stop\" }");
184184
// ObjectMapper mapper = new ObjectMapper();
185185
// try {
@@ -192,7 +192,7 @@ public void setUrl(String url) {
192192
// }
193193

194194
// public void delete() throws OpenTokException {
195-
// OpenTokHttpClient.makeDeleteRequest("/v2/partner/" + partnerId + "/archive/" + id);
195+
// HttpClient.makeDeleteRequest("/v2/partner/" + partnerId + "/archive/" + id);
196196
// }
197197

198198
@Override

src/main/java/com/opentok/api/OpenTok.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.opentok.api.constants.SessionProperties;
2424
import com.opentok.exception.OpenTokException;
2525
import com.opentok.exception.OpenTokInvalidArgumentException;
26+
import com.opentok.util.HttpClient;
2627
import org.xml.sax.InputSource;
2728

2829
/**
@@ -39,7 +40,7 @@ public class OpenTok {
3940

4041
private int apiKey;
4142
private String apiSecret;
42-
protected OpenTokHttpClient client;
43+
protected HttpClient client;
4344

4445
/**
4546
* Creates an OpenTokSDK object.
@@ -56,7 +57,7 @@ public OpenTok(int apiKey, String apiSecret) {
5657
public OpenTok(int apiKey, String apiSecret, String apiUrl) {
5758
this.apiKey = apiKey;
5859
this.apiSecret = apiSecret.trim();
59-
this.client = new OpenTokHttpClient.Builder(apiKey, apiSecret)
60+
this.client = new HttpClient.Builder(apiKey, apiSecret)
6061
.apiUrl(apiUrl)
6162
.build();
6263
}
@@ -320,7 +321,7 @@ private static String readXml(String xpathQuery, String xml) throws XPathExpress
320321
*/
321322
// public Archive getArchive(String archiveId) throws OpenTokException {
322323
// ObjectMapper mapper = new ObjectMapper();
323-
// String archive = OpenTokHttpClient.makeGetRequest("/v2/partner/" + this.apiKey + "/archive/" + archiveId);
324+
// String archive = HttpClient.makeGetRequest("/v2/partner/" + this.apiKey + "/archive/" + archiveId);
324325
// try {
325326
// return mapper.readValue(archive, Archive.class);
326327
// } catch (Exception e) {
@@ -352,7 +353,7 @@ private static String readXml(String xpathQuery, String xml) throws XPathExpress
352353
*/
353354
// public List<Archive> listArchives(int offset, int count) throws OpenTokException {
354355
// ObjectMapper mapper = new ObjectMapper();
355-
// String archive = OpenTokHttpClient.makeGetRequest("/v2/partner/" + this.apiKey + "/archive?offset=" + offset + "&count="
356+
// String archive = HttpClient.makeGetRequest("/v2/partner/" + this.apiKey + "/archive?offset=" + offset + "&count="
356357
// + count);
357358
// try {
358359
// JsonNode node = mapper.readTree(archive);
@@ -384,7 +385,7 @@ private static String readXml(String xpathQuery, String xml) throws XPathExpress
384385
// }
385386
// HashMap<String, String> headers = new HashMap<String, String>();
386387
// headers.put("content-type", "application/json");
387-
// String archive = OpenTokHttpClient.makePostRequest("/v2/partner/" + this.apiKey + "/archive", headers, null,
388+
// String archive = HttpClient.makePostRequest("/v2/partner/" + this.apiKey + "/archive", headers, null,
388389
// "{ \"sessionId\" : \"" + sessionId + "\", \"name\": \"" + name + "\" }");
389390
// ObjectMapper mapper = new ObjectMapper();
390391
// try {
@@ -406,7 +407,7 @@ private static String readXml(String xpathQuery, String xml) throws XPathExpress
406407
// public Archive stopArchive(String archiveId) throws OpenTokException {
407408
// HashMap<String, String> headers = new HashMap<String, String>();
408409
// headers.put("content-type", "application/json");
409-
// String archive = OpenTokHttpClient.makePostRequest("/v2/partner/" + this.apiKey + "/archive/" + archiveId + "/stop", headers, null,
410+
// String archive = HttpClient.makePostRequest("/v2/partner/" + this.apiKey + "/archive/" + archiveId + "/stop", headers, null,
410411
// "");
411412
// ObjectMapper mapper = new ObjectMapper();
412413
// try {
@@ -426,6 +427,6 @@ private static String readXml(String xpathQuery, String xml) throws XPathExpress
426427
* @param archiveId The archive ID of the archive you want to delete.
427428
*/
428429
// public void deleteArchive(String archiveId) throws OpenTokException {
429-
// OpenTokHttpClient.makeDeleteRequest("/v2/partner/" + this.apiKey + "/archive/" + archiveId);
430+
// HttpClient.makeDeleteRequest("/v2/partner/" + this.apiKey + "/archive/" + archiveId);
430431
// }
431432
}

src/main/java/com/opentok/api/OpenTokHttpClient.java renamed to src/main/java/com/opentok/util/HttpClient.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.opentok.api;
1+
package com.opentok.util;
22

33
import java.io.IOException;
44
import java.util.Collection;
@@ -13,14 +13,14 @@
1313

1414
import com.opentok.api.constants.Version;
1515

16-
public class OpenTokHttpClient extends AsyncHttpClient {
16+
public class HttpClient extends AsyncHttpClient {
1717

1818
private final String apiUrl;
1919
// NOTE: do we even need these since we now have the PartnerAuthRequestFilter?
2020
private final int apiKey;
2121
private final String apiSecret;
2222

23-
private OpenTokHttpClient(Builder builder) {
23+
private HttpClient(Builder builder) {
2424
super(builder.config);
2525
this.apiKey = builder.apiKey;
2626
this.apiSecret = builder.apiSecret;
@@ -145,13 +145,13 @@ public Builder apiUrl(String apiUrl) {
145145
return this;
146146
}
147147

148-
public OpenTokHttpClient build() {
148+
public HttpClient build() {
149149
this.config = new AsyncHttpClientConfig.Builder()
150150
.setUserAgent("Opentok-Java-SDK/"+Version.VERSION)
151151
.addRequestFilter(new PartnerAuthRequestFilter(this.apiKey, this.apiSecret))
152152
.build();
153153
// NOTE: not thread-safe, config could be modified by another thread here?
154-
OpenTokHttpClient client = new OpenTokHttpClient(this);
154+
HttpClient client = new HttpClient(this);
155155
return client;
156156
}
157157
}

0 commit comments

Comments
 (0)