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/server/AbstractRequestHandler.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/server/AbstractRequestHandler.java')
-rw-r--r-- | src/uk/org/ury/backend/server/AbstractRequestHandler.java | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/uk/org/ury/backend/server/AbstractRequestHandler.java b/src/uk/org/ury/backend/server/AbstractRequestHandler.java index 53517d7..e545651 100644 --- a/src/uk/org/ury/backend/server/AbstractRequestHandler.java +++ b/src/uk/org/ury/backend/server/AbstractRequestHandler.java @@ -18,7 +18,6 @@ import org.apache.http.entity.StringEntity; import org.apache.http.protocol.HTTP; import org.apache.http.protocol.HttpContext; import org.apache.http.protocol.HttpRequestHandler; -import org.json.simple.JSONValue; import uk.org.ury.backend.server.exceptions.BadRequestException; import uk.org.ury.backend.server.exceptions.HandleFailureException; @@ -28,7 +27,9 @@ import uk.org.ury.backend.server.exceptions.HandlingException; import uk.org.ury.backend.server.exceptions.NotAHandlerException; import uk.org.ury.backend.server.exceptions.UnknownFunctionException; 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; /** * An abstract request handler for HttpCore, providing basic functionality such @@ -138,10 +139,13 @@ public abstract class AbstractRequestHandler implements HttpRequestHandler { content.put(Directive.STATUS.toString(), Status.ERROR.toString()); content.put(Directive.REASON.toString(), reason); - entity = new StringEntity(JSONValue.toJSONString(content)); + entity = new StringEntity(ProtocolUtils.encode(content)); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); + } catch (EncodeFailureException e) { + // TODO Auto-generated catch block + e.printStackTrace(); } if (entity != null) { |