diff options
author | Matt Windsor <mattwindsor@btinternet.com> | 2011-03-23 15:16:34 +0000 |
---|---|---|
committer | Matt Windsor <mattwindsor@btinternet.com> | 2011-03-23 15:16:34 +0000 |
commit | cb0a78131286b1a312351308d2cb6e59ed122fef (patch) | |
tree | 280ff409c85cc4e80e43a3ed14f648d15d077397 /src/uk/org/ury/backend/handlers/LibraryRequestHandler.java | |
parent | 5e6649f0524a28e5d53aea174da5e512e614f377 (diff) |
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.
Diffstat (limited to 'src/uk/org/ury/backend/handlers/LibraryRequestHandler.java')
-rw-r--r-- | src/uk/org/ury/backend/handlers/LibraryRequestHandler.java | 9 |
1 files changed, 6 insertions, 3 deletions
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); } |