package de.ddb.pdc.web;

import de.ddb.pdc.core.PublicDomainCalculatorFactory;
import de.ddb.pdc.metadata.MetaFetcher;
import de.ddb.pdc.metadata.DDBItem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SearchController {
  private MetaFetcher metaFetcher;

  @Autowired
  public SearchController(MetaFetcher metaFetcher) {
    this.metaFetcher = metaFetcher;
  }

  @RequestMapping("/search")
  public DDBItem[] search(
      @RequestParam(value = "q", required = true) String query,
      @RequestParam(value = "max", required = true) int maxResults) {
    return metaFetcher.searchForItems(query, maxResults);
  }
}

@@ -22,62 +22,8 @@
 b;%0A%0A
-import de.ddb.pdc.core.PublicDomainCalculatorFactory;%0A
 impo
@@ -161,69 +161,8 @@
 ed;%0A
-import org.springframework.web.bind.annotation.PathVariable;%0A
 impo
@@ -345,16 +345,76 @@
 oller;%0A%0A
+/**%0A * Provides an HTTP interface for DDB item search .%0A */%0A
 @RestCon
@@ -495,112 +495,739 @@
 %0A%0A  
-@Autowired%0A  public SearchController(MetaFetcher metaFetcher) %7B%0A    this.metaFetcher = metaFetcher;%0A  %7D%0A
+/**%0A   * Creates a SearchController.%0A   *%0A   * @param metaFetcher %7B@link MetaFetcher%7D to use for DBB API calls%0A   */%0A  @Autowired%0A  public SearchController(MetaFetcher metaFetcher) %7B%0A    this.metaFetcher = metaFetcher;%0A  %7D%0A%0A  /**%0A   * Searches the DDB and returns the found items as a JSON array of%0A   * item objects. Requests must be of the form%0A   *%0A   *   GET /search?q=QUERY&max=NUM%0A   *%0A   * where QUERY is the string to search for (e.g. part of a title)%0A   * and NUM the maximum number of items to return.%0A   *%0A   * @param query      string to search for in item metadata%0A   * @param maxResults maximum number of matching items to return%0A   *                   (must be larger than 0)%0A   * @return           found items%0A   */
 %0A  @

Add javadocs to SearchController