I am trying to create a very simple REST server with Roo, and have it working - of sorts... What I am having problems with is incorporating urls into parameters such that I can pass them to my REST server.
In summary I am trying to create a Spring Roo app which responds to this REST request, does some work, and returns the value found in the database, should it be found.
http://localhost:8080/longurl/lookup...it.ly%2fp8TVYG
Should I be able to do this in Spring Roo, or Spring, or have I misunderstood something about REST GET calls?
======================
More detailed info:
I have a single table with an id number, a short url, and a long url.
I have generated web based screens as well as json so the following works:
http://localhost:8080/longurl/urlmaps?form
gives me a form to create my records,
http://localhost:8080/longurl/urlmaps?page=1&size=10
lists them, and so on.
I have created a second Spring Roo controller with a different url map annotation so the following also works as a REST GET call - Accept application/json
http://localhost:8080/longurl/lookup/aaa
("aaa" was inserted as a url into my database, but of course it is not a real url)
If I substitute a real url it doesn't work (of course)
http://localhost:8080/longurl/lookup.../bit.ly/p8TVYG
but what is interesting is that I get a "Resource not found" from Spring. It doesn't even call my code for "longurl/lookup". Is that correct behaviour? I would assume not...
So lets do some url encoding and try this
http://localhost:8080/longurl/lookup...it.ly%2fp8TVYG
That fails too - but in a different way... Error code 400, Bad Request.
Here is my log.roo with a few lines edited out for clarity
// Spring Roo 1.1.4.RELEASE [rev f787ce7] log opened at 2011-07-07 15:12:39
project --topLevelPackage me.longurl --java 6 --projectName longurl
persistence setup --provider HIBERNATE --database MYSQL --databaseName roo_longurl
database properties set --key database.username --value redacted
database properties set --key database.password --value redacted
entity --class ~.domain.UrlMap
field string --fieldName shortUrl --column SHORTURL --notNull
field string --fieldName longUrl --column LONGURL --notNull
web mvc setup
web mvc all --package ~.web
json all
web mvc install view --path ext --title "Ext JS WS" --viewName index
perform eclipse
controller scaffold --entity ~.domain.UrlMap --class ~.web.UrlLookupController
perform eclipse
finder list --class ~.domain.UrlMap
finder add --finderName findUrlMapsByShortUrlEquals
quit
PS I am using a library ExtJS WS from BTI360 to help me test my REST functionality.


Reply With Quote
