From cb0a78131286b1a312351308d2cb6e59ed122fef Mon Sep 17 00:00:00 2001 From: Matt Windsor Date: Wed, 23 Mar 2011 15:16:34 +0000 Subject: common: Moved from json-simple to jackson as JSON backend; changes include less confusing decoder code and the possibility to migrate to decoding/encoding directly to object representations. backend: Fixed JSON encoding code which was directly calling JSON backend instead of using ProtocolUtils. --- src/uk/org/ury/backend/handlers/LibraryRequestHandler.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/uk/org/ury/backend/handlers') diff --git a/src/uk/org/ury/backend/handlers/LibraryRequestHandler.java b/src/uk/org/ury/backend/handlers/LibraryRequestHandler.java index 25423f6..b175485 100644 --- a/src/uk/org/ury/backend/handlers/LibraryRequestHandler.java +++ b/src/uk/org/ury/backend/handlers/LibraryRequestHandler.java @@ -16,7 +16,6 @@ import org.apache.http.HttpStatus; import org.apache.http.entity.StringEntity; import org.apache.http.protocol.HTTP; import org.apache.http.protocol.HttpContext; -import org.json.simple.JSONValue; import uk.org.ury.backend.database.DatabaseDriver; import uk.org.ury.backend.database.UserClass; @@ -35,7 +34,9 @@ import uk.org.ury.common.library.LibraryUtils; import uk.org.ury.common.library.exceptions.EmptySearchException; import uk.org.ury.common.library.item.LibraryItem; import uk.org.ury.common.protocol.Directive; +import uk.org.ury.common.protocol.ProtocolUtils; import uk.org.ury.common.protocol.Status; +import uk.org.ury.common.protocol.exceptions.EncodeFailureException; /** * A request handler for library queries. @@ -178,11 +179,13 @@ public class LibraryRequestHandler extends AbstractRequestHandler { StringEntity entity = null; try { - entity = new StringEntity(JSONValue.toJSONString(content)); + entity = new StringEntity(ProtocolUtils.encode(content)); } catch (UnsupportedEncodingException e) { throw new HandlerSetupFailureException(getClass().getName(), e); + } catch (EncodeFailureException e) { + throw new HandleFailureException(e); } - + entity.setContentType(HTTP.PLAIN_TEXT_TYPE); response.setEntity(entity); } -- cgit v1.2.3