Revision 32293
Added by Katerina Iatropoulou over 9 years ago
SearchRequestController.java | ||
---|---|---|
12 | 12 |
import org.springframework.stereotype.Controller; |
13 | 13 |
import org.springframework.web.bind.annotation.RequestMapping; |
14 | 14 |
import org.springframework.web.bind.annotation.RequestMethod; |
15 |
import org.springframework.ui.ModelMap; |
|
15 | 16 |
|
16 | 17 |
import javax.annotation.Resource; |
17 | 18 |
import javax.servlet.http.HttpServletRequest; |
... | ... | |
158 | 159 |
} |
159 | 160 |
} |
160 | 161 |
|
162 |
|
|
163 |
@RequestMapping(value="/search/openSearchDescriptor", method = RequestMethod.GET) |
|
164 |
public String printOpenSearchDescriptor(ModelMap model) { |
|
165 |
return "openSearchDescriptor"; |
|
166 |
} |
|
167 |
|
|
161 | 168 |
@RequestMapping(value = "/api/publications", method = RequestMethod.GET) |
162 | 169 |
public void searchPublications(HttpServletRequest request, HttpServletResponse response) { |
163 | 170 |
|
... | ... | |
181 | 188 |
|
182 | 189 |
String model = request.getParameter("model"); |
183 | 190 |
checkModelParameter(PUB_N_DATASET_MODELS, model); |
184 |
String sTransformer = defineTransformer(model); |
|
191 |
String sTransformer = defineTransformer(model,format);
|
|
185 | 192 |
String newFormat = defineFormatter(model, true); |
186 | 193 |
|
187 | 194 |
StringBuilder queryBuilder = new StringBuilder(); |
... | ... | |
234 | 241 |
|
235 | 242 |
String model = request.getParameter("model"); |
236 | 243 |
checkModelParameter(PUB_N_DATASET_MODELS, model); |
237 |
String sTransformer = defineTransformer(model); |
|
244 |
String sTransformer = defineTransformer(model,format);
|
|
238 | 245 |
String newFormat = defineFormatter(model, false); |
239 | 246 |
|
240 | 247 |
String locale = request.getParameter("locale"); |
... | ... | |
340 | 347 |
} |
341 | 348 |
} |
342 | 349 |
|
350 |
private String defineTransformer(String model, String format) { |
|
351 |
if (model!=null && !model.trim().isEmpty()) { |
|
352 |
if (model.equals("openaire")) { |
|
353 |
return null; |
|
354 |
|
|
355 |
} else if (model.equals("sygma")) { |
|
356 |
return "results_openaire"; |
|
357 |
} |
|
358 |
else if (model.equals("dc")) { |
|
359 |
return "dc"; |
|
360 |
} |
|
361 |
|
|
362 |
throw new IllegalArgumentException("model '" + model + "' is not supported."); |
|
363 |
|
|
364 |
} else if (format!=null && !format.trim().isEmpty()){ |
|
365 |
if (format.equals("rss")){ |
|
366 |
return "results_openaire"; |
|
367 |
} |
|
368 |
} |
|
369 |
return null; |
|
370 |
|
|
371 |
} |
|
372 |
|
|
343 | 373 |
private String defineFormatter(String model, boolean isPublications) { |
344 | 374 |
if( model != null && !model.trim().isEmpty() ) { |
345 | 375 |
if (model.equals("sygma")) { |
Also available in: Unified diff
Closing #348 - added descriptor for opensearch and produce the correct result