@@ -30,6 +30,7 @@ import scala.reflect.ClassTag
30
30
* advantage of functions and Scala types.
31
31
*
32
32
* @author Arjen Poutsma
33
+ * @author Ramnivas Laddad
33
34
* @since 1.0
34
35
* @constructor Creates a `RestTemplate` that wraps the given Java template, defaulting to the standard `RestTemplate`
35
36
* @param javaTemplate the Java `RestTemplate` to wrap
@@ -75,17 +76,6 @@ class RestTemplate(val javaTemplate: org.springframework.web.client.RestOperatio
75
76
Option (javaTemplate.getForObject(url, typeToClass[T ], uriVariables.asJava))
76
77
}
77
78
78
- /**
79
- * Retrieve a representation by doing a GET on the URL.
80
- * The response (if any) is converted and returned.
81
- *
82
- * @param url the URL
83
- * @return the converted object
84
- */
85
- def getForAny [T : ClassTag ](url : URI ): Option [T ] = {
86
- Option (javaTemplate.getForObject(url, typeToClass[T ]))
87
- }
88
-
89
79
/**
90
80
* Retrieve an entity by doing a GET on the specified URL.
91
81
* The response is converted and stored in an `ResponseEntity`.
@@ -112,15 +102,6 @@ class RestTemplate(val javaTemplate: org.springframework.web.client.RestOperatio
112
102
javaTemplate.getForEntity(url, typeToClass[T ], uriVariables.asJava)
113
103
}
114
104
115
- /**
116
- * Retrieve a representation by doing a GET on the URL .
117
- * The response is converted and stored in an [[org.springframework.http.ResponseEntity ]]}.
118
- * @param url the URL
119
- * @return the converted object
120
- */
121
- def getForEntity [T : ClassTag ](url : URI ): ResponseEntity [T ] = {
122
- javaTemplate.getForEntity(url, typeToClass[T ])
123
- }
124
105
125
106
// HEAD
126
107
/**
@@ -149,14 +130,6 @@ class RestTemplate(val javaTemplate: org.springframework.web.client.RestOperatio
149
130
javaTemplate.headForHeaders(url, uriVariables.asJava)
150
131
}
151
132
152
- /**
153
- * Retrieve all headers of the resource specified by the URL.
154
- * @param url the URL
155
- * @return all HTTP headers of that resource
156
- */
157
- def headForHeaders (url : URI ): HttpHeaders = {
158
- javaTemplate.headForHeaders(url)
159
- }
160
133
161
134
// POST
162
135
/**
@@ -199,22 +172,6 @@ class RestTemplate(val javaTemplate: org.springframework.web.client.RestOperatio
199
172
javaTemplate.postForLocation(url, request.orNull, uriVariables.asJava)
200
173
}
201
174
202
- /**
203
- * Create a new resource by POSTing the given object to the URL, and returns the value of the `Location` header.
204
- * This header typically indicates where the new resource is stored.
205
- *
206
- * The `request` parameter can be a [[org.springframework.http.HttpEntity ]] in order to add additional HTTP headers
207
- * to the request.
208
- *
209
- * @param url the URL
210
- * @param request the Object to be POSTed
211
- * @return the value for the `Location` header
212
- * @see HttpEntity
213
- */
214
- def postForLocation (url : URI , request : Option [Any ]): URI = {
215
- javaTemplate.postForLocation(url, request.orNull)
216
- }
217
-
218
175
/**
219
176
* Create a new resource by POSTing the given object to the URI template, and returns the representation found in
220
177
* the response.
@@ -253,22 +210,6 @@ class RestTemplate(val javaTemplate: org.springframework.web.client.RestOperatio
253
210
Option (javaTemplate.postForObject(url, request.orNull, typeToClass[T ], uriVariables.asJava))
254
211
}
255
212
256
- /**
257
- * Create a new resource by POSTing the given object to the URL, and returns the representation found in the
258
- * response.
259
- *
260
- * The `request` parameter can be a [[org.springframework.http.HttpEntity ]] in order to add additional HTTP headers
261
- * to the request.
262
- *
263
- * @param url the URL
264
- * @param request the Object to be POSTed
265
- * @return the converted object
266
- * @see HttpEntity
267
- */
268
- def postForObject [T : ClassTag ](url : URI , request : Option [Any ]): Option [T ] = {
269
- Option (javaTemplate.postForObject(url, request.orNull, typeToClass[T ]))
270
- }
271
-
272
213
/**
273
214
* Create a new resource by POSTing the given object to the URI template, and returns the response as
274
215
* [[org.springframework.http.ResponseEntity ]].
@@ -307,23 +248,6 @@ class RestTemplate(val javaTemplate: org.springframework.web.client.RestOperatio
307
248
javaTemplate.postForEntity(url, request.orNull, typeToClass[T ], uriVariables.asJava)
308
249
}
309
250
310
- /**
311
- * Create a new resource by POSTing the given object to the URL, and returns the response as
312
- * [[org.springframework.http.ResponseEntity ]].
313
- *
314
- * The `request` parameter can be a [[org.springframework.http.HttpEntity ]] in order to add additional HTTP headers
315
- * to the request.
316
- *
317
- * @param url the URL
318
- * @param request the Object to be POSTed, may be `null`
319
- * @return the converted object
320
- * @see HttpEntity
321
- * @since 3.0.2
322
- */
323
- def postForEntity [T : ClassTag ](url : URI , request : Option [Any ]): ResponseEntity [T ] = {
324
- javaTemplate.postForEntity(url, request.orNull, typeToClass[T ])
325
- }
326
-
327
251
// PUT
328
252
/**
329
253
* Create or update a resource by PUTting the given object to the URI.
@@ -359,19 +283,6 @@ class RestTemplate(val javaTemplate: org.springframework.web.client.RestOperatio
359
283
javaTemplate.put(url, request.orNull, uriVariables.asJava)
360
284
}
361
285
362
- /**
363
- * Creates a new resource by PUTting the given object to URL.
364
- *
365
- * The `request` parameter can be a [[org.springframework.http.HttpEntity ]] in order to add additional HTTP headers
366
- * to the request.
367
- *
368
- * @param url the URL
369
- * @param request the Object to be PUT
370
- * @see HttpEntity
371
- */
372
- def put (url : URI , request : Option [Any ]) {
373
- javaTemplate.put(url, request.orNull)
374
- }
375
286
376
287
// DELETE
377
288
/**
@@ -397,14 +308,6 @@ class RestTemplate(val javaTemplate: org.springframework.web.client.RestOperatio
397
308
javaTemplate.delete(url, uriVariables.asJava)
398
309
}
399
310
400
- /**
401
- * Delete the resources at the specified URL.
402
- *
403
- * @param url the URL
404
- */
405
- def delete (url : URI ) {
406
- javaTemplate.delete(url)
407
- }
408
311
409
312
// OPTIONS
410
313
/**
@@ -433,16 +336,6 @@ class RestTemplate(val javaTemplate: org.springframework.web.client.RestOperatio
433
336
javaTemplate.optionsForAllow(url, uriVariables.asJava).asScala
434
337
}
435
338
436
- /**
437
- * Return the value of the Allow header for the given URL.
438
- *
439
- * @param url the URL
440
- * @return the value of the allow header
441
- */
442
- def optionsForAllow (url : URI ): Set [HttpMethod ] = {
443
- javaTemplate.optionsForAllow(url).asScala
444
- }
445
-
446
339
// exchange
447
340
/**
448
341
* Execute the HTTP method to the given URI template, writing the given request entity to the request, and
@@ -477,18 +370,6 @@ class RestTemplate(val javaTemplate: org.springframework.web.client.RestOperatio
477
370
javaTemplate.exchange(url, method, requestEntity.orNull, typeToClass[T ], uriVariables.asJava)
478
371
}
479
372
480
- /**
481
- * Execute the HTTP method to the given URI template, writing the given request entity to the request, and
482
- * returns the response as `ResponseEntity`.
483
- *
484
- * @param url the URL
485
- * @param method the HTTP method (GET, POST, etc)
486
- * @param requestEntity the entity (headers and/or body) to write to the request
487
- * @return the response as entity
488
- */
489
- def exchange [T : ClassTag ](url : URI , method : HttpMethod , requestEntity : Option [HttpEntity [_]]): ResponseEntity [T ] = {
490
- javaTemplate.exchange(url, method, requestEntity.orNull, typeToClass[T ])
491
- }
492
373
493
374
// general execution
494
375
/**
@@ -533,24 +414,6 @@ class RestTemplate(val javaTemplate: org.springframework.web.client.RestOperatio
533
414
uriVariables.asJava))
534
415
}
535
416
536
- /**
537
- * Execute the HTTP method to the given URL, preparing the request with the given function, and reading the response
538
- * with a function.
539
- *
540
- * @param url the URL
541
- * @param method the HTTP method (GET, POST, etc)
542
- * @param requestFunction function that prepares the request
543
- * @param responseFunction function that extracts the return value from the response
544
- * @return an arbitrary object, as returned by the response object
545
- */
546
- def execute [T ](url : URI , method : HttpMethod )
547
- (requestFunction : ClientHttpRequest => Unit )
548
- (responseFunction : ClientHttpResponse => T ): Option [T ] = {
549
- Option (javaTemplate.execute(url, method, functionToRequestCallback(requestFunction),
550
- functionToResponseExtractor(responseFunction)))
551
-
552
- }
553
-
554
417
private def asInstanceOfAnyRef (seq : Seq [Any ]) = {
555
418
seq.map(_.asInstanceOf [AnyRef ])
556
419
}
0 commit comments