Mercurial > hg > ismi-richfaces
diff src/main/java/de/mpiwg/itgroup/diva/utils/JSONArrayParam.java @ 1:2e911857a759
(none)
author | jurzua |
---|---|
date | Wed, 29 Oct 2014 14:00:28 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/mpiwg/itgroup/diva/utils/JSONArrayParam.java Wed Oct 29 14:00:28 2014 +0000 @@ -0,0 +1,28 @@ +package de.mpiwg.itgroup.diva.utils; + +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; + +import org.json.JSONArray; +import org.json.JSONException; + +public class JSONArrayParam { + + private JSONArray json; + + public JSONArrayParam(String string) throws WebApplicationException { + + try { + json = new JSONArray(string); + } catch (JSONException e) { + throw new WebApplicationException(Response.status(Status.BAD_REQUEST) + .entity("Couldn't parse JSON string: " + e.getMessage()) + .build()); + } + } + + public JSONArray getArray() { + return json; + } +}