@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { super.doGet(req, resp); resp.setContentType("application/json"); VitroRequest vreq = new VitroRequest(req); try { if (vreq.getParameter("query") != null || vreq.getParameter("queries") != null) { JSONObject qJson = getResult(vreq, req, resp); log.debug("result: " + qJson.toString()); String responseStr = (vreq.getParameter("callback") == null) ? qJson.toString() : vreq.getParameter("callback") + "(" + qJson.toString() + ")"; // System.out.println("JSONReconcileServlet result: " + responseStr); ServletOutputStream out = resp.getOutputStream(); out.print(responseStr); } else { // metadata String defaultNamespace = null; String defaultTypeList = null; String serverName = null; int serverPort = req.getServerPort(); if (vreq.getWebappDaoFactory() != null) { defaultNamespace = vreq.getWebappDaoFactory().getDefaultNamespace(); } defaultTypeList = ConfigurationProperties.getBean(req).getProperty("Vitro.reconcile.defaultTypeList"); serverName = req.getServerName(); JSONObject metaJson = getMetadata(req, resp, defaultNamespace, defaultTypeList, serverName, serverPort); String callbackStr = (vreq.getParameter("callback") == null) ? "" : vreq.getParameter("callback"); ServletOutputStream out = resp.getOutputStream(); out.print(callbackStr + "(" + metaJson.toString() + ")"); } } catch (Exception ex) { log.warn(ex, ex); } }
@Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // resp.setContentType("application/json"); super.doPost(req, resp); }