From 3102d8bce3426d9cf41aeaf201c360d342677770 Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Sat, 9 Apr 2016 14:22:20 -0700 Subject: Switching from Ivy+Ant to Maven. --- src/com/p4square/fmfacade/json/JsonResponse.java | 87 ------------------------ 1 file changed, 87 deletions(-) delete mode 100644 src/com/p4square/fmfacade/json/JsonResponse.java (limited to 'src/com/p4square/fmfacade/json/JsonResponse.java') diff --git a/src/com/p4square/fmfacade/json/JsonResponse.java b/src/com/p4square/fmfacade/json/JsonResponse.java deleted file mode 100644 index b9cb587..0000000 --- a/src/com/p4square/fmfacade/json/JsonResponse.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2013 Jesse Morgan - */ - -package com.p4square.fmfacade.json; - -import java.util.Map; - -import java.io.IOException; - -import org.restlet.data.Status; -import org.restlet.data.Reference; -import org.restlet.representation.Representation; -import org.restlet.Response; - -import org.restlet.ext.jackson.JacksonRepresentation; - -/** - * JsonResponse wraps a Restlet Response object and parses the entity, if any, - * as a JSON map. - * - * @author Jesse Morgan - */ -public class JsonResponse { - private final Response mResponse; - private final Representation mRepresentation; - - private Map mMap; - - JsonResponse(Response response) { - mResponse = response; - mRepresentation = response.getEntity(); - mMap = null; - - if (!response.getStatus().isSuccess()) { - if (mRepresentation != null) { - mRepresentation.release(); - } - } - } - - /** - * @return the Status info from the response. - */ - public Status getStatus() { - return mResponse.getStatus(); - } - - /** - * @return the Reference for a redirect. - */ - public Reference getRedirectLocation() { - return mResponse.getLocationRef(); - } - - /** - * Return the parsed json map from the response. - */ - public Map getMap() throws ClientException { - if (mMap == null) { - Representation representation = mRepresentation; - - // Parse response - if (representation == null) { - return null; - } - - JacksonRepresentation mapRepresentation; - if (representation instanceof JacksonRepresentation) { - mapRepresentation = (JacksonRepresentation) representation; - } else { - mapRepresentation = new JacksonRepresentation( - representation, Map.class); - } - - try { - mMap = (Map) mapRepresentation.getObject(); - - } catch (IOException e) { - throw new ClientException("Failed to parse response: " + e.getMessage(), e); - } - } - - return mMap; - } - -} -- cgit v1.2.3