Mercurial > hg > LGServices
annotate src/main/java/de/mpiwg/gazetteer/rest/GetFullTextSearchHtmlFile.java @ 58:b8ad346e39a0
new: modify based on doc 'Improving LGServices interface.docx': user workflow improvement, functions like adding task into a topic and search suggestions.
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Mon, 02 May 2016 12:03:30 +0200 |
parents | 37840afb7b80 |
children | 824b808a7481 |
rev | line source |
---|---|
39 | 1 package de.mpiwg.gazetteer.rest; |
2 | |
3 import java.io.PrintWriter; | |
58
b8ad346e39a0
new: modify based on doc 'Improving LGServices interface.docx': user workflow improvement, functions like adding task into a topic and search suggestions.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
4 import java.util.ArrayList; |
b8ad346e39a0
new: modify based on doc 'Improving LGServices interface.docx': user workflow improvement, functions like adding task into a topic and search suggestions.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
5 import java.util.List; |
39 | 6 |
7 import javax.servlet.http.HttpServletRequest; | |
8 import javax.servlet.http.HttpServletResponse; | |
9 | |
10 import org.apache.commons.lang.StringUtils; | |
11 import org.apache.log4j.Logger; | |
12 import org.json.JSONObject; | |
58
b8ad346e39a0
new: modify based on doc 'Improving LGServices interface.docx': user workflow improvement, functions like adding task into a topic and search suggestions.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
13 import org.jsoup.Jsoup; |
b8ad346e39a0
new: modify based on doc 'Improving LGServices interface.docx': user workflow improvement, functions like adding task into a topic and search suggestions.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
14 import org.jsoup.nodes.Document; |
b8ad346e39a0
new: modify based on doc 'Improving LGServices interface.docx': user workflow improvement, functions like adding task into a topic and search suggestions.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
15 import org.jsoup.nodes.Element; |
b8ad346e39a0
new: modify based on doc 'Improving LGServices interface.docx': user workflow improvement, functions like adding task into a topic and search suggestions.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
16 import org.jsoup.select.Elements; |
39 | 17 |
18 import de.mpiwg.gazetteer.bo.LGFile; | |
19 import de.mpiwg.gazetteer.bo.LGFullTextSearchFile; | |
58
b8ad346e39a0
new: modify based on doc 'Improving LGServices interface.docx': user workflow improvement, functions like adding task into a topic and search suggestions.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
20 import de.mpiwg.gazetteer.db.DBContents; |
39 | 21 import de.mpiwg.gazetteer.utils.DataProvider; |
22 import de.mpiwg.gazetteer.utils.FileManager; | |
23 import de.mpiwg.gazetteer.utils.HTTPUtils; | |
24 import de.mpiwg.gazetteer.utils.exceptions.GazetteerException; | |
25 import de.mpiwg.web.jsp.FullTextSearchPage; | |
26 | |
27 public class GetFullTextSearchHtmlFile extends AbstractServletMethod { | |
28 public static String name = "getFullTextSearchHtmlFile"; | |
29 | |
30 private static Logger logger = Logger.getLogger(GetFullTextSearchHtmlFile.class); | |
31 | |
32 | |
33 public static void execute(HttpServletRequest request, HttpServletResponse response) throws Exception{ | |
34 | |
35 Long fileId = getQueryLongParam(request, "fileId"); | |
36 | |
37 logger.debug("getting full text search html file."); | |
38 | |
39 // get html file from /gazetteer-server/ftsearch-data/html/... | |
40 if(fileId != null){ | |
41 | |
42 LGFullTextSearchFile file = DataProvider.getInstance().getFullTextSearchFile(fileId); | |
43 if(file != null){ | |
44 | |
58
b8ad346e39a0
new: modify based on doc 'Improving LGServices interface.docx': user workflow improvement, functions like adding task into a topic and search suggestions.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
45 String html = FileManager.getFullTextSearchHtmlFileText(file); |
b8ad346e39a0
new: modify based on doc 'Improving LGServices interface.docx': user workflow improvement, functions like adding task into a topic and search suggestions.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
46 |
b8ad346e39a0
new: modify based on doc 'Improving LGServices interface.docx': user workflow improvement, functions like adding task into a topic and search suggestions.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
47 // parse text so that it doesn't show the field "isRemoved", which has two values, true or false |
b8ad346e39a0
new: modify based on doc 'Improving LGServices interface.docx': user workflow improvement, functions like adding task into a topic and search suggestions.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
48 html = html.replaceAll("isRemoved", ""); |
b8ad346e39a0
new: modify based on doc 'Improving LGServices interface.docx': user workflow improvement, functions like adding task into a topic and search suggestions.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
49 html = html.replaceAll("true", ""); |
b8ad346e39a0
new: modify based on doc 'Improving LGServices interface.docx': user workflow improvement, functions like adding task into a topic and search suggestions.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
50 html = html.replaceAll("false", ""); |
b8ad346e39a0
new: modify based on doc 'Improving LGServices interface.docx': user workflow improvement, functions like adding task into a topic and search suggestions.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
51 |
39 | 52 PrintWriter out = response.getWriter(); |
58
b8ad346e39a0
new: modify based on doc 'Improving LGServices interface.docx': user workflow improvement, functions like adding task into a topic and search suggestions.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
53 out.print(html); |
39 | 54 out.flush(); |
55 response.setContentType("text/plain; charset=UTF-8"); | |
56 | |
57 }else{ | |
58 response.setContentType("application/json"); | |
59 JSONObject json = new JSONObject(); | |
60 json.put("status", "error"); | |
61 json.put("message", "File no found (" + fileId + ")"); | |
62 json.put("code", GazetteerException.CODE); | |
63 PrintWriter out = response.getWriter(); | |
64 out.print(json.toString()); | |
65 out.flush(); | |
66 } | |
67 | |
68 | |
69 }else{ | |
70 response.setContentType("application/json"); | |
71 JSONObject json = new JSONObject(); | |
72 json.put("status", "error"); | |
73 json.put("message", "Following parameters are mandatory: fileId, userId"); | |
74 PrintWriter out = response.getWriter(); | |
75 out.print(json.toString()); | |
76 out.flush(); | |
77 } | |
78 | |
79 } | |
80 | |
81 } |