-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
/delete throws a 500 #211
Labels
Comments
Obj to delete: http://store.rerum.io/v1/id/6104404cffce846a83e700f0
delete approved? true
We had a previous id in the object but could not find it in the store
Here is the error response json object to return with status 500
{"code":500,"message":"We could not update the history tree correctly. The delete failed."} |
Fails to delete b/c We had a previous id in the history object but could not find it in the store. The previous for that object is if(detectedPrevious){
//The object being deleted had a previous. That previous object next[] must be updated with the deleted object's next[].
System.out.println("The object being deleted had a previous. That previous object next[] must be updated with the deleted object's next[]");
BasicDBObject query2 = new BasicDBObject();
BasicDBObject objToUpdate2;
BasicDBObject objWithUpdate2;
query2.append("@id", previous_id);
objToUpdate2 = (BasicDBObject) mongoDBService.findOneByExample(Constant.COLLECTION_ANNOTATION, query2);
if(null != objToUpdate2){
JSONObject fixHistory2 = JSONObject.fromObject(objToUpdate2);
JSONArray origNextArray = fixHistory2.getJSONObject("__rerum").getJSONObject("history").getJSONArray("next");
JSONArray newNextArray = new JSONArray();
//JSONArray does not have splice, but we can code our own. This will splice out obj["@id"].
for (int i=0; i<origNextArray.size(); i++){
if (!origNextArray.getString(i).equals(obj.getString("@id"))){
//So long as the value is not the deleted id, add it to the newNextArray (this is the splice).
newNextArray.add(origNextArray.get(i));
}
}
newNextArray.addAll(next_ids); //Adds next array of deleted object to the end of this array in order.
fixHistory2.getJSONObject("__rerum").getJSONObject("history").element("next", newNextArray); //Rewrite the next[] array to fix the history
Object forMongo2 = JSON.parse(fixHistory2.toString()); //JSONObject cannot be converted to BasicDBObject
objWithUpdate2 = (BasicDBObject)forMongo2;
mongoDBService.update(Constant.COLLECTION_ANNOTATION, objToUpdate2, objWithUpdate2);
}
else{
//Yikes this is an error. We had a previous id in the object but could not find it in the store.
System.out.println("We had a previous id in the object but could not find it in the store");
success = false;
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We noticed this in the Glossing Matthew project. To reproduce, go to http://glossing.rerum.io/ms.html#http://devstore.rerum.io/v1/id/61040f4d0634984db99592fa and attempt to
Drop from Collection
for this entry. There is an error in RERUM's updateHistoryTree() function. We believe this has something to do with the "update that is a fork", where a prime may in fact have a previous.The text was updated successfully, but these errors were encountered: