Mercurial > hg > LGServices
view src/main/java/de/mpiwg/gazetteer/rest/GetFullTextSearchHtmlFile.java @ 79:9fbdc98f81c6
Bug fix : comment out testing code for front end error handling.
author | Calvin Yeh <cyeh@mpiwg-berlin.mpg.de> |
---|---|
date | Wed, 03 May 2017 19:54:48 +0200 |
parents | 824b808a7481 |
children |
line wrap: on
line source
package de.mpiwg.gazetteer.rest; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.json.JSONObject; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; import de.mpiwg.gazetteer.bo.LGFile; import de.mpiwg.gazetteer.bo.LGFullTextSearchFile; import de.mpiwg.gazetteer.db.DBContents; import de.mpiwg.gazetteer.utils.DBService; import de.mpiwg.gazetteer.utils.DataProvider; import de.mpiwg.gazetteer.utils.FileManager; import de.mpiwg.gazetteer.utils.HTTPUtils; import de.mpiwg.gazetteer.utils.exceptions.GazetteerException; import de.mpiwg.web.jsp.FullTextSearchPage; public class GetFullTextSearchHtmlFile extends AbstractServletMethod { public static String name = "getFullTextSearchHtmlFile"; private static Logger logger = Logger.getLogger(GetFullTextSearchHtmlFile.class); public static void execute(HttpServletRequest request, HttpServletResponse response) throws Exception{ Long fileId = getQueryLongParam(request, "fileId"); logger.debug("getting full text search html file."); // get html file from /gazetteer-server/ftsearch-data/html/... if(fileId != null){ LGFullTextSearchFile file = DataProvider.getInstance().getFullTextSearchFile(fileId); if(file != null){ // we should only show the ones are not removed. removed them using javascript in LGService.js String html = FileManager.getFullTextSearchHtmlFileText(file); /* html = html.replaceAll("isRemoved", ""); html = html.replaceAll("true", ""); html = html.replaceAll("false", ""); */ PrintWriter out = response.getWriter(); out.print(html); out.flush(); response.setContentType("text/plain; charset=UTF-8"); }else{ response.setContentType("application/json"); JSONObject json = new JSONObject(); json.put("status", "error"); json.put("message", "File no found (" + fileId + ")"); json.put("code", GazetteerException.CODE); PrintWriter out = response.getWriter(); out.print(json.toString()); out.flush(); } }else{ response.setContentType("application/json"); JSONObject json = new JSONObject(); json.put("status", "error"); json.put("message", "Following parameters are mandatory: fileId, userId"); PrintWriter out = response.getWriter(); out.print(json.toString()); out.flush(); } } }