Mercurial > hg > LGServices
annotate src/main/java/de/mpiwg/gazetteer/rest/GetFullTextSearchHtmlFile.java @ 62:824b808a7481
improvements and bug fixed
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Mon, 18 Jul 2016 17:35:32 +0200 |
parents | b8ad346e39a0 |
children |
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; |
62
824b808a7481
improvements and bug fixed
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
58
diff
changeset
|
5 import java.util.Collections; |
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
|
6 import java.util.List; |
39 | 7 |
8 import javax.servlet.http.HttpServletRequest; | |
9 import javax.servlet.http.HttpServletResponse; | |
10 | |
11 import org.apache.commons.lang.StringUtils; | |
12 import org.apache.log4j.Logger; | |
13 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
|
14 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
|
15 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
|
16 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
|
17 import org.jsoup.select.Elements; |
39 | 18 |
19 import de.mpiwg.gazetteer.bo.LGFile; | |
20 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
|
21 import de.mpiwg.gazetteer.db.DBContents; |
62
824b808a7481
improvements and bug fixed
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
58
diff
changeset
|
22 import de.mpiwg.gazetteer.utils.DBService; |
39 | 23 import de.mpiwg.gazetteer.utils.DataProvider; |
24 import de.mpiwg.gazetteer.utils.FileManager; | |
25 import de.mpiwg.gazetteer.utils.HTTPUtils; | |
26 import de.mpiwg.gazetteer.utils.exceptions.GazetteerException; | |
27 import de.mpiwg.web.jsp.FullTextSearchPage; | |
28 | |
29 public class GetFullTextSearchHtmlFile extends AbstractServletMethod { | |
30 public static String name = "getFullTextSearchHtmlFile"; | |
31 | |
32 private static Logger logger = Logger.getLogger(GetFullTextSearchHtmlFile.class); | |
33 | |
34 | |
35 public static void execute(HttpServletRequest request, HttpServletResponse response) throws Exception{ | |
36 | |
37 Long fileId = getQueryLongParam(request, "fileId"); | |
38 | |
39 logger.debug("getting full text search html file."); | |
40 | |
41 // get html file from /gazetteer-server/ftsearch-data/html/... | |
42 if(fileId != null){ | |
43 | |
44 LGFullTextSearchFile file = DataProvider.getInstance().getFullTextSearchFile(fileId); | |
45 if(file != null){ | |
46 | |
62
824b808a7481
improvements and bug fixed
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
58
diff
changeset
|
47 // we should only show the ones are not removed. removed them using javascript in LGService.js |
824b808a7481
improvements and bug fixed
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
58
diff
changeset
|
48 |
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
|
49 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
|
50 |
62
824b808a7481
improvements and bug fixed
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
58
diff
changeset
|
51 /* |
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
|
52 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
|
53 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
|
54 html = html.replaceAll("false", ""); |
62
824b808a7481
improvements and bug fixed
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
58
diff
changeset
|
55 */ |
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
|
56 |
39 | 57 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
|
58 out.print(html); |
39 | 59 out.flush(); |
60 response.setContentType("text/plain; charset=UTF-8"); | |
61 | |
62 }else{ | |
63 response.setContentType("application/json"); | |
64 JSONObject json = new JSONObject(); | |
65 json.put("status", "error"); | |
66 json.put("message", "File no found (" + fileId + ")"); | |
67 json.put("code", GazetteerException.CODE); | |
68 PrintWriter out = response.getWriter(); | |
69 out.print(json.toString()); | |
70 out.flush(); | |
71 } | |
72 | |
73 | |
74 }else{ | |
75 response.setContentType("application/json"); | |
76 JSONObject json = new JSONObject(); | |
77 json.put("status", "error"); | |
78 json.put("message", "Following parameters are mandatory: fileId, userId"); | |
79 PrintWriter out = response.getWriter(); | |
80 out.print(json.toString()); | |
81 out.flush(); | |
82 } | |
83 | |
84 } | |
85 | |
86 } |