view src/main/java/de/mpiwg/itgroup/diva/utils/JSONArrayParam.java @ 71:38dc1f0e2451

show instance name on public (publicCodex, publicWitness) pages.
author casties
date Thu, 17 Dec 2015 17:31:07 +0100
parents 2e911857a759
children
line wrap: on
line source

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;
	}
}