@@ -38,18 +38,13 @@ private HttpClient(Builder builder) {
38
38
}
39
39
40
40
public String createSession (Map <String , Collection <String >> params ) throws RequestException {
41
- Future <Response > request = null ;
42
41
String responseString = null ;
43
42
Response response = null ;
44
43
FluentStringsMap paramsString = new FluentStringsMap ().addAll (params );
45
44
46
- try {
47
- request = this .preparePost (this .apiUrl + "/session/create" )
48
- .setParameters (paramsString )
49
- .execute ();
50
- } catch (IOException e ) {
51
- throw new RequestException ("Could not create an OpenTok Session" , e );
52
- }
45
+ Future <Response > request = this .preparePost (this .apiUrl + "/session/create" )
46
+ .setFormParams (paramsString )
47
+ .execute ();
53
48
54
49
try {
55
50
response = request .get ();
@@ -75,14 +70,8 @@ public String createSession(Map<String, Collection<String>> params) throws Reque
75
70
76
71
public String getArchive (String archiveId ) throws RequestException {
77
72
String responseString = null ;
78
- Future <Response > request = null ;
79
73
String url = this .apiUrl + "/v2/partner/" + this .apiKey + "/archive/" + archiveId ;
80
-
81
- try {
82
- request = this .prepareGet (url ).execute ();
83
- } catch (IOException e ) {
84
- throw new RequestException ("Could not get an OpenTok Archive" , e );
85
- }
74
+ Future <Response > request = this .prepareGet (url ).execute ();
86
75
87
76
try {
88
77
Response response = request .get ();
@@ -116,7 +105,6 @@ public String getArchive(String archiveId) throws RequestException {
116
105
117
106
public String getArchives (int offset , int count ) throws RequestException {
118
107
String responseString = null ;
119
- Future <Response > request = null ;
120
108
// TODO: maybe use a StringBuilder?
121
109
String url = this .apiUrl + "/v2/partner/" + this .apiKey + "/archive" ;
122
110
if (offset != 0 || count != 1000 ) {
@@ -129,11 +117,7 @@ public String getArchives(int offset, int count) throws RequestException {
129
117
}
130
118
}
131
119
132
- try {
133
- request = this .prepareGet (url ).execute ();
134
- } catch (IOException e ) {
135
- throw new RequestException ("Could not get OpenTok Archives" , e );
136
- }
120
+ Future <Response > request = this .prepareGet (url ).execute ();
137
121
138
122
try {
139
123
Response response = request .get ();
@@ -165,7 +149,6 @@ public String getArchives(int offset, int count) throws RequestException {
165
149
public String startArchive (String sessionId , ArchiveProperties properties )
166
150
throws OpenTokException {
167
151
String responseString = null ;
168
- Future <Response > request = null ;
169
152
String requestBody = null ;
170
153
// TODO: maybe use a StringBuilder?
171
154
String url = this .apiUrl + "/v2/partner/" + this .apiKey + "/archive" ;
@@ -185,14 +168,10 @@ public String startArchive(String sessionId, ArchiveProperties properties)
185
168
} catch (JsonProcessingException e ) {
186
169
throw new OpenTokException ("Could not start an OpenTok Archive. The JSON body encoding failed." , e );
187
170
}
188
- try {
189
- request = this .preparePost (url )
190
- .setBody (requestBody )
191
- .setHeader ("Content-Type" , "application/json" )
192
- .execute ();
193
- } catch (IOException e ) {
194
- throw new RequestException ("Could not start an OpenTok Archive." , e );
195
- }
171
+ Future <Response > request = this .preparePost (url )
172
+ .setBody (requestBody )
173
+ .setHeader ("Content-Type" , "application/json" )
174
+ .execute ();
196
175
197
176
try {
198
177
Response response = request .get ();
@@ -228,15 +207,9 @@ public String startArchive(String sessionId, ArchiveProperties properties)
228
207
229
208
public String stopArchive (String archiveId ) throws RequestException {
230
209
String responseString = null ;
231
- Future <Response > request = null ;
232
210
// TODO: maybe use a StringBuilder?
233
211
String url = this .apiUrl + "/v2/partner/" + this .apiKey + "/archive/" + archiveId + "/stop" ;
234
-
235
- try {
236
- request = this .preparePost (url ).execute ();
237
- } catch (IOException e ) {
238
- throw new RequestException ("Could not stop an OpenTok Archive. archiveId = " + archiveId , e );
239
- }
212
+ Future <Response > request = this .preparePost (url ).execute ();
240
213
241
214
try {
242
215
Response response = request .get ();
@@ -276,14 +249,8 @@ public String stopArchive(String archiveId) throws RequestException {
276
249
277
250
public String deleteArchive (String archiveId ) throws RequestException {
278
251
String responseString = null ;
279
- Future <Response > request = null ;
280
252
String url = this .apiUrl + "/v2/partner/" + this .apiKey + "/archive/" + archiveId ;
281
-
282
- try {
283
- request = this .prepareDelete (url ).execute ();
284
- } catch (IOException e ) {
285
- throw new RequestException ("Could not delete an OpenTok Archive. archiveId = " + archiveId , e );
286
- }
253
+ Future <Response > request = this .prepareDelete (url ).execute ();
287
254
288
255
try {
289
256
Response response = request .get ();
0 commit comments