0

I need to generate a Json response for a POST made with parameters in form data, not in Json.

Example: My request:

curl -X POST -H "Accept: application/json" -H "Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW" -F "firstName=Manolete" -F "lastName=Manolón" -F "address=villa arriba" -F "city=meryville" -F "telephone=666666666" -F "homepage=alguna.homepage.es" -F "email=alguno@hotmail.com" -F "birthday=1314595427866" "http://localhost:8080/PetClinicRoo/owners"

Current request:

curl -X POST -H "Accept: application/json" -d '{firstName: "Manolete", lastName:"Manolón", address:"villa arriba", city: "Meryville", telephone:"66666666", homepage:"alguna.homepage.es", email:"alguno@hotmail.com", birthDay: 1314596527943, }' "http://localhost:8080/PetClinicRoo/owners"

I could handwrite the code but this implies getting out of spring roo management all the application web tier, and further modifications wouldn't be automatically made.

mmartinez
  • 33
  • 7

2 Answers2

0

You can push-in the controller method and you modify it as needed, Spring Roo management will work.

eruiz
  • 1,963
  • 1
  • 14
  • 22
  • Unfortunately we have a lot of entities in our aplication. Pushing in all of the post methods its a huge work. Also, further modifications on our entities wuldn't be automatically managed by Spring Roo – mmartinez Aug 02 '16 at 10:08
  • Another option is to handwrite the needed code directly in your .java files, if the method exists in the .aj file, Roo will remove the code in the .aj file. – eruiz Aug 02 '16 at 10:45
0

We have several options:

1.- Use spring roo and then pushing in the methods

  • Generate all the web tier using spring roo

  • Pushing-in all the post methods

  • Modify the response

Inconvenients: once you push-in the methods, spring roo doesn’t manage them, so further modifications woldn’t be made automatically

2.-Handwrite the web tier.

  • Use spring ro to generate entities

  • Handwrite the web layer

Inconvenients: implies more work than the previous option.

3.- Extend Spring Roo in order to generate the method automatically.

I think this is our best option because he have a lot of entities.

mmartinez
  • 33
  • 7
  • I agree that the 3º option is the best, but instead _modify_ Spring Roo you should _extend_ it by creating an add-on (your own Roo annotation) which generate whatever you need in your controller. Look at ``addon create advanced`` command. Good luck! – jmvivo Aug 04 '16 at 08:48
  • Thanks for your help! You are right, extending is better. I will edit the response. – mmartinez Aug 04 '16 at 09:54