initial version of frontend layer
[opensuse:webpin2.git] / api / webpin.api / src / main / java / org / opensuse / webpin / api / ByContentQueryMethod.java
1 /*
2  * Created on Aug 3, 2010
3  */
4 package org.opensuse.webpin.api;
5
6 import java.util.List;
7
8 import org.apache.solr.client.solrj.SolrQuery;
9 import org.opensuse.webpin.api.SolrQueryRestlet.QueryMethod;
10 import org.restlet.Request;
11 import org.restlet.Response;
12
13 public class ByContentQueryMethod implements QueryMethod {
14
15         @Override public String configure(final Request request, final Response response, final SolrQueryRestlet rsc, final SolrQuery query, final List<String> filterQueries) {
16                 final String content = rsc.getStringAttribute(request, response, "content");
17                 if (content.contains("/")) {
18                         query.set("q.alt", "fqfile:" + content);
19                 } else {
20                         query.set("q.alt", "file:" + content);
21                 }
22                 return "by file: " + content;
23         }
24         
25 }