18
18
*/
19
19
20
20
/*
21
- * Copyright (c) 2014, 2016 Oracle and/or its affiliates. All rights reserved.
21
+ * Copyright (c) 2014, 2017 Oracle and/or its affiliates. All rights reserved.
22
22
*/
23
23
package org .opensolaris .opengrok .web ;
24
24
@@ -47,6 +47,7 @@ public class JSONSearchServlet extends HttpServlet {
47
47
private static final String PARAM_PATH = "path" ;
48
48
private static final String PARAM_HIST = "hist" ;
49
49
private static final String PARAM_MAXRESULTS = "maxresults" ;
50
+ private static final String PARAM_PROJECT = "project" ;
50
51
private static final String ATTRIBUTE_DIRECTORY = "directory" ;
51
52
private static final String ATTRIBUTE_FILENAME = "filename" ;
52
53
private static final String ATTRIBUTE_LINENO = "lineno" ;
@@ -70,6 +71,7 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
70
71
String symbol = req .getParameter (PARAM_SYMBOL );
71
72
String path = req .getParameter (PARAM_PATH );
72
73
String hist = req .getParameter (PARAM_HIST );
74
+ String projects [] = req .getParameterValues (PARAM_PROJECT );
73
75
74
76
if (freetext != null ) {
75
77
freetext = URLDecoder .decode (freetext );
@@ -112,7 +114,12 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
112
114
113
115
try {
114
116
long start = System .currentTimeMillis ();
115
- int numResults = engine .search (req );
117
+ int numResults ;
118
+ if (projects == null || projects .length == 0 ) {
119
+ numResults = engine .search (req );
120
+ } else {
121
+ numResults = engine .search (req , projects );
122
+ }
116
123
int maxResults = MAX_RESULTS ;
117
124
String maxResultsParam = req .getParameter (PARAM_MAXRESULTS );
118
125
if (maxResultsParam != null ) {
@@ -146,7 +153,7 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
146
153
result .put (ATTRIBUTE_RESULTS , resultsArray );
147
154
148
155
149
-
156
+ resp . setContentType ( "application/json" );
150
157
resp .getWriter ().write (result .toString ());
151
158
} finally {
152
159
engine .destroy ();
0 commit comments