Skip to content

Commit c25b961

Browse files
committed
error if the blob doesn't have an _id since this means it was probably not persisted
1 parent 389eb43 commit c25b961

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

grails-app/resources/jsonblob/JsonBlobCollectionResource.groovy

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@ class JsonBlobCollectionResource {
2424
try {
2525
JSON.parse(json)
2626
def newBlob = jsonBlobResourceService.create(json)
27-
URI uri = UriBuilder.fromPath(newBlob["_id"].toString()).build()
28-
Response.created(uri).entity(jsonService.writeValueAsString(newBlob?.blob)).build()
27+
if (!newBlob["_id"]) {
28+
Response.serverError().build()
29+
} else {
30+
URI uri = UriBuilder.fromPath(newBlob["_id"].toString()).build()
31+
Response.created(uri).entity(jsonService.writeValueAsString(newBlob?.blob)).build()
32+
}
2933
} catch (ConverterException ce) {
3034
Response.serverError().build()
3135
}

0 commit comments

Comments
 (0)