getResponse().setEntity(new StringRepresentation(obj.toString(2), MediaType.APPLICATION_JSON));
getResponse().setStatus(Status.SUCCESS_OK);
}
JSONObject toJSON(ScriptSession session) {
PageInfo pageInfo = (PageInfo) getRequest().getAttributes().get(PageInfo.KEY);
JSONObject obj = new JSONObject();
obj.put("id", session.getId());
obj.put("engine", session.getEngineName());
obj.put("self", pageInfo.baseURI(
String.format("sessions/%s/%d", session.getExtension(), session.getId())));
return obj;
}