Skip to content

Commit

Permalink
fix small bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
muhammad-sayed-mahdy committed Jul 1, 2020
1 parent a5749a9 commit aaa2ed8
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion search/src/main/java/AddSuggestionsServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
}
}

PrintWriter out = response.getWriter();
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();

boolean result = adapter.addQuery(query);

Expand Down
2 changes: 1 addition & 1 deletion search/src/main/java/FetchAllSuggestionsServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
Gson gson = new Gson();
IndexerDbAdapter adapter = new IndexerDbAdapter();
adapter.open();
PrintWriter out = response.getWriter();
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();

ArrayList<String> result = adapter.fetchAllQueries();

Expand Down
24 changes: 12 additions & 12 deletions search/src/main/java/Indexer.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,18 @@ private void HTMLParser() {
* This function get last modified date stored by server
**/
public String getLastModified() {
// try {
// String date = connection.execute().header("Last-Modified");
// ArrayList<String> dateArrayList = new ArrayList<>();
// if (date == null)
// return "1 jan 1990";
// else {
// dateArrayList = WordsExtractionProcess.SplitStrings(date);
// return dateArrayList.get(1) +" "+ dateArrayList.get(2) + " " + dateArrayList.get(3);
// }
// } catch (IOException e) {
// e.printStackTrace();
// }
try {
String date = connection.execute().header("Last-Modified");
ArrayList<String> dateArrayList = new ArrayList<>();
if (date == null)
return "1 jan 1990";
else {
dateArrayList = WordsExtractionProcess.SplitStrings(date);
return dateArrayList.get(1) +" "+ dateArrayList.get(2) + " " + dateArrayList.get(3);
}
} catch (IOException e) {
e.printStackTrace();
}
return "1 jan 1990";
}

Expand Down
2 changes: 1 addition & 1 deletion search/src/main/java/QueryServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
String query = request.getParameter("query");
String image = request.getParameter("img");
int page = Integer.parseInt(request.getParameter("page"));
PrintWriter out = response.getWriter();
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();
Gson gson = new Gson();
boolean isImage = (image != null && image.equals("1")) ? true : false;

Expand Down
2 changes: 1 addition & 1 deletion search/src/main/java/TrendsServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
adapter.open();

String region = request.getParameter("region");
PrintWriter out = response.getWriter();
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();
Gson gson = new Gson();


Expand Down

0 comments on commit aaa2ed8

Please sign in to comment.