setEditDetail(request);
request.getDocument().getRoot().writeTo("json", cwriter);
String json = new String(cwriter.toCharArray());
JSONObject obj = JSONObject.fromObject(json);
String key = createKey(request);
Document doc = null;
try {
doc = db.getDocument(key);
} catch (Exception e) {
// error if the doc isn't found, we deal with the null result below
}
if (doc != null) {
return ProviderHelper.conflict(request, "Entry with that key already exists");
} else {
doc = new Document(obj);
doc.setId(key);
db.saveDocument(doc);
doc = db.getDocument(key);
if (doc != null) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("feed", feed);
params.put("entry", key);
String urlFor = request.absoluteUrlFor("entry", params);
return new JsonObjectResponseContext(request.getAbdera(), config, doc).setStatus(201)
.setEntityTag(doc.getRev()).setLocation(urlFor);
} else {
return ProviderHelper.servererror(request, null);
}
}
} catch (IOException e) {