mhgrove/4Store-API — pull request #6 by peshkira (2012-01-30 14:15:05+00:00)
Title: More robust CheckResultsError + Delete BugFix

Hi again!

I added a cleaner solution to the error checking and found and fixed a new bug related to entity removal.

1.) I mark the first 20 (or less) bytes of the stream and read them. Then I convert the read byte array to a String and reset the position of the input stream to the beginning. Then a check if the string contains the token 'error' is performed. Unfortunately, I didn't find any specification of 4 store with all their errors, however from what I saw until now, the Responses are always 200 and the body contains "error: {...}" so it should be ok. If no error is found the method returns. If an error is found, then the whole stream is read (as before) and the exception is thrown.

2.) There was an error in the delete query, as it was missing a WHERE clause. There is an if before the insertion of 'delete where' that I marked with a comment. I am not sure if it works, as I wasn't able to test it.

However, all my other tests are green now.