Remove spurious references to org.json
This commit is contained in:
parent
f08f488006
commit
6ba3969d98
@ -11,8 +11,6 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.apache.velocity.VelocityContext;
|
import org.apache.velocity.VelocityContext;
|
||||||
import org.json.JSONException;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -42,30 +40,26 @@ abstract public class HttpUtilities {
|
|||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
Writer w = response.getWriter();
|
Writer w = response.getWriter();
|
||||||
try {
|
JsonGenerator writer = ParsingUtilities.mapper.getFactory().createGenerator(w);
|
||||||
JsonGenerator writer = ParsingUtilities.mapper.getFactory().createGenerator(w);
|
writer.writeStartObject();
|
||||||
writer.writeStartObject();
|
writer.writeStringField("status", status);
|
||||||
writer.writeStringField("status", status);
|
writer.writeStringField("message", message);
|
||||||
writer.writeStringField("message", message);
|
writer.writeEndObject();
|
||||||
writer.writeEndObject();
|
writer.flush();
|
||||||
writer.flush();
|
writer.close();
|
||||||
writer.close();
|
w.flush();
|
||||||
w.flush();
|
w.close();
|
||||||
w.close();
|
|
||||||
} catch (JSONException e) {
|
|
||||||
// This can never occue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static public void respondJSON(HttpServletResponse response, Object o)
|
static public void respondJSON(HttpServletResponse response, Object o)
|
||||||
throws IOException, JSONException {
|
throws IOException {
|
||||||
|
|
||||||
respondJSON(response, o, new Properties());
|
respondJSON(response, o, new Properties());
|
||||||
}
|
}
|
||||||
|
|
||||||
static public void respondJSON(
|
static public void respondJSON(
|
||||||
HttpServletResponse response, Object o, Properties options)
|
HttpServletResponse response, Object o, Properties options)
|
||||||
throws IOException, JSONException {
|
throws IOException {
|
||||||
|
|
||||||
response.setCharacterEncoding("UTF-8");
|
response.setCharacterEncoding("UTF-8");
|
||||||
response.setHeader("Content-Type", "application/json");
|
response.setHeader("Content-Type", "application/json");
|
||||||
@ -85,30 +79,26 @@ abstract public class HttpUtilities {
|
|||||||
throw new ServletException("Response object can't be null");
|
throw new ServletException("Response object can't be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
StringWriter sw = new StringWriter();
|
||||||
StringWriter sw = new StringWriter();
|
PrintWriter pw = new PrintWriter(sw);
|
||||||
PrintWriter pw = new PrintWriter(sw);
|
e.printStackTrace(pw);
|
||||||
e.printStackTrace(pw);
|
pw.flush();
|
||||||
pw.flush();
|
sw.flush();
|
||||||
sw.flush();
|
|
||||||
|
response.setCharacterEncoding("UTF-8");
|
||||||
response.setCharacterEncoding("UTF-8");
|
response.setHeader("Content-Type", "application/json");
|
||||||
response.setHeader("Content-Type", "application/json");
|
|
||||||
|
|
||||||
Writer w = response.getWriter();
|
Writer w = response.getWriter();
|
||||||
JsonGenerator writer = ParsingUtilities.mapper.getFactory().createGenerator(w);
|
JsonGenerator writer = ParsingUtilities.mapper.getFactory().createGenerator(w);
|
||||||
writer.writeStartObject();
|
writer.writeStartObject();
|
||||||
writer.writeStringField("code", "error");
|
writer.writeStringField("code", "error");
|
||||||
writer.writeStringField("message", e.getMessage());
|
writer.writeStringField("message", e.getMessage());
|
||||||
writer.writeStringField("stack", sw.toString());
|
writer.writeStringField("stack", sw.toString());
|
||||||
writer.writeEndObject();
|
writer.writeEndObject();
|
||||||
writer.flush();
|
writer.flush();
|
||||||
writer.close();
|
writer.close();
|
||||||
w.flush();
|
w.flush();
|
||||||
w.close();
|
w.close();
|
||||||
} catch (JSONException e1) {
|
|
||||||
e.printStackTrace(response.getWriter());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static public void redirect(HttpServletResponse response, String url) throws IOException {
|
static public void redirect(HttpServletResponse response, String url) throws IOException {
|
||||||
@ -127,21 +117,6 @@ abstract public class HttpUtilities {
|
|||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public JSONObject getJsonParameter(HttpServletRequest request, String name) {
|
|
||||||
if (request == null) {
|
|
||||||
throw new IllegalArgumentException("parameter 'request' should not be null");
|
|
||||||
}
|
|
||||||
String value = request.getParameter(name);
|
|
||||||
if (value != null) {
|
|
||||||
try {
|
|
||||||
return ParsingUtilities.evaluateJsonStringToObject(value);
|
|
||||||
} catch (JSONException e) {
|
|
||||||
logger.warn("Error getting json parameter", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
static public void respondWithErrorPage(
|
static public void respondWithErrorPage(
|
||||||
RefineServlet servlet,
|
RefineServlet servlet,
|
||||||
HttpServletRequest request,
|
HttpServletRequest request,
|
||||||
|
@ -35,17 +35,9 @@ package com.google.refine.model;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.json.JSONWriter;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
Loading…
Reference in New Issue
Block a user