if (pathInfo == null) {
response.sendError(HttpServletResponse.SC_BAD_REQUEST, "No path");
return;
}
Iterator<String> pathComponents = SLASH.split(pathInfo).iterator();
FastIDSet itemIDSet = new FastIDSet();
try {
while (pathComponents.hasNext()) {
itemIDSet.add(Long.parseLong(pathComponents.next()));
}
} catch (NoSuchElementException nsee) {
response.sendError(HttpServletResponse.SC_BAD_REQUEST, nsee.toString());
return;
} catch (NumberFormatException nfe) {
response.sendError(HttpServletResponse.SC_BAD_REQUEST, nfe.toString());
return;
}
if (itemIDSet.isEmpty()) {
response.sendError(HttpServletResponse.SC_BAD_REQUEST, "No items");
return;
}
MyrrixRecommender recommender = getRecommender();
RescorerProvider rescorerProvider = getRescorerProvider();
try {
int howMany = getHowMany(request);
Iterable<RecommendedItem> similar;
if (rescorerProvider == null) {
similar = recommender.mostSimilarItems(itemIDSet.toArray(), howMany);
} else {
Rescorer<LongPair> rescorer =
rescorerProvider.getMostSimilarItemsRescorer(recommender, getRescorerParams(request));
similar = recommender.mostSimilarItems(itemIDSet.toArray(),
howMany,
rescorer);
}
output(request, response, similar);
} catch (NoSuchItemException nsie) {