Skip to content

Commit e3586d8

Browse files
author
Arjen Poutsma
committed
Merge pull request spring-attic#28 from ramnivas/fix-RestTemple
Removed conflicting overloaded methods from RestTemplate
2 parents fbfc885 + 4ba7314 commit e3586d8

File tree

1 file changed

+1
-138
lines changed

1 file changed

+1
-138
lines changed

src/main/scala/org/springframework/scala/web/client/RestTemplate.scala

Lines changed: 1 addition & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import scala.reflect.ClassTag
3030
* advantage of functions and Scala types.
3131
*
3232
* @author Arjen Poutsma
33+
* @author Ramnivas Laddad
3334
* @since 1.0
3435
* @constructor Creates a `RestTemplate` that wraps the given Java template, defaulting to the standard `RestTemplate`
3536
* @param javaTemplate the Java `RestTemplate` to wrap
@@ -75,17 +76,6 @@ class RestTemplate(val javaTemplate: org.springframework.web.client.RestOperatio
7576
Option(javaTemplate.getForObject(url, typeToClass[T], uriVariables.asJava))
7677
}
7778

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-
8979
/**
9080
* Retrieve an entity by doing a GET on the specified URL.
9181
* The response is converted and stored in an `ResponseEntity`.
@@ -112,15 +102,6 @@ class RestTemplate(val javaTemplate: org.springframework.web.client.RestOperatio
112102
javaTemplate.getForEntity(url, typeToClass[T], uriVariables.asJava)
113103
}
114104

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-
}
124105

125106
// HEAD
126107
/**
@@ -149,14 +130,6 @@ class RestTemplate(val javaTemplate: org.springframework.web.client.RestOperatio
149130
javaTemplate.headForHeaders(url, uriVariables.asJava)
150131
}
151132

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-
}
160133

161134
// POST
162135
/**
@@ -199,22 +172,6 @@ class RestTemplate(val javaTemplate: org.springframework.web.client.RestOperatio
199172
javaTemplate.postForLocation(url, request.orNull, uriVariables.asJava)
200173
}
201174

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-
218175
/**
219176
* Create a new resource by POSTing the given object to the URI template, and returns the representation found in
220177
* the response.
@@ -253,22 +210,6 @@ class RestTemplate(val javaTemplate: org.springframework.web.client.RestOperatio
253210
Option(javaTemplate.postForObject(url, request.orNull, typeToClass[T], uriVariables.asJava))
254211
}
255212

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-
272213
/**
273214
* Create a new resource by POSTing the given object to the URI template, and returns the response as
274215
* [[org.springframework.http.ResponseEntity]].
@@ -307,23 +248,6 @@ class RestTemplate(val javaTemplate: org.springframework.web.client.RestOperatio
307248
javaTemplate.postForEntity(url, request.orNull, typeToClass[T], uriVariables.asJava)
308249
}
309250

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-
327251
// PUT
328252
/**
329253
* 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
359283
javaTemplate.put(url, request.orNull, uriVariables.asJava)
360284
}
361285

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-
}
375286

376287
// DELETE
377288
/**
@@ -397,14 +308,6 @@ class RestTemplate(val javaTemplate: org.springframework.web.client.RestOperatio
397308
javaTemplate.delete(url, uriVariables.asJava)
398309
}
399310

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-
}
408311

409312
// OPTIONS
410313
/**
@@ -433,16 +336,6 @@ class RestTemplate(val javaTemplate: org.springframework.web.client.RestOperatio
433336
javaTemplate.optionsForAllow(url, uriVariables.asJava).asScala
434337
}
435338

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-
446339
// exchange
447340
/**
448341
* 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
477370
javaTemplate.exchange(url, method, requestEntity.orNull, typeToClass[T], uriVariables.asJava)
478371
}
479372

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-
}
492373

493374
// general execution
494375
/**
@@ -533,24 +414,6 @@ class RestTemplate(val javaTemplate: org.springframework.web.client.RestOperatio
533414
uriVariables.asJava))
534415
}
535416

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-
554417
private def asInstanceOfAnyRef(seq: Seq[Any]) = {
555418
seq.map(_.asInstanceOf[AnyRef])
556419
}

0 commit comments

Comments
 (0)