File tree Expand file tree Collapse file tree 2 files changed +17
-7
lines changed
grails-app/resources/jsonblob Expand file tree Collapse file tree 2 files changed +17
-7
lines changed Original file line number Diff line number Diff line change 11package jsonblob
22
3+ import grails.converters.JSON
34import org.bson.types.ObjectId
5+ import org.codehaus.groovy.grails.web.converters.exceptions.ConverterException
46import org.grails.jaxrs.provider.DomainObjectNotFoundException
57
68import javax.ws.rs.*
@@ -19,12 +21,12 @@ class JsonBlobCollectionResource {
1921 @POST
2022 @Path (' /jsonBlob' )
2123 Response create (String json ) {
22- def newBlob = jsonBlobResourceService . create(json)
23- def objectId = newBlob[ " _id " ]
24- if (objectId) {
25- URI uri = UriBuilder . fromPath(objectId . toString()). build()
24+ try {
25+ JSON . parse(json)
26+ def newBlob = jsonBlobResourceService . create(json)
27+ URI uri = UriBuilder . fromPath(newBlob[ " _id " ] . toString()). build()
2628 Response . created(uri). entity(jsonService. writeValueAsString(newBlob?. blob)). build()
27- } else {
29+ } catch ( ConverterException ce) {
2830 Response . serverError(). build()
2931 }
3032 }
Original file line number Diff line number Diff line change 11package jsonblob
22
3+ import grails.converters.JSON
4+ import org.codehaus.groovy.grails.web.converters.exceptions.ConverterException
5+
36import javax.ws.rs.*
47import javax.ws.rs.core.Response
58
@@ -19,8 +22,13 @@ class JsonBlobResource {
1922
2023 @PUT
2124 Response update (String json ) {
22- def updatedBlob = jsonBlobResourceService. update(id, json)
23- Response . ok(jsonService. writeValueAsString(updatedBlob?. blob)). build()
25+ try {
26+ JSON . parse(json)
27+ def updatedBlob = jsonBlobResourceService. update(id, json)
28+ Response . ok(jsonService. writeValueAsString(updatedBlob?. blob)). build()
29+ } catch (ConverterException ce) {
30+ Response . serverError(). build()
31+ }
2432 }
2533
2634// @DELETE
You can’t perform that action at this time.
0 commit comments