@GET
  @Path("/{name}/{version}")
  @ApiOperation(
      value = "Documents by name and version",
      notes = "Documents always have a name and a version",
      response = DocumentDTO.class,
      responseContainer = "List")
  public List<DocumentDTO> documentByNameAndVersion(
      @ApiParam(value = "Name of documents to fetch", required = true) @PathParam("name")
          String name,
      @ApiParam(value = "Version of named documents", required = true) @PathParam("version")
          String version,
      @ApiParam(value = "Whether to re-index document", required = false, defaultValue = "false")
          @DefaultValue("false")
          @QueryParam("reindex")
          boolean reindex) {

    List<Document> documents = documentRepository.findDocumentsByNameAndVersion(name, version);

    if (reindex) {
      documents.stream().forEach(document -> documentationService.reindexDocument(document));
    }

    return documents
        .stream()
        .map(Transformations::convertDocumentToDTO)
        .collect(Collectors.toList());
  }
 @GET
 @Path("/")
 @ApiOperation(
     value = "Get all documents",
     notes = "All documents that are avaliable",
     response = DocumentDTO.class,
     responseContainer = "List")
 public List<DocumentDTO> documentIndex() {
   return documentRepository
       .getAllDocuments()
       .stream()
       .map(Transformations::convertDocumentToDTO)
       .collect(Collectors.toList());
 }
  @DELETE
  @Path("/{name}/{version}")
  @ApiOperation(
      value = "Documents by name and version",
      notes = "Documents always have a name and a version",
      response = DocumentDTO.class)
  public DocumentDTO deleteDocument(
      @ApiParam(value = "Name of document", required = true) @PathParam("name") String name,
      @ApiParam(value = "Version of document", required = true) @PathParam("version")
          String version) {

    Document document = new Document(name, version);
    documentRepository.deleteDocument(document);
    return Transformations.convertDocumentToDTO(document);
  }
 @GET
 @Path("/{name}")
 @ApiOperation(
     value = "Documents by name",
     notes = "All documents that have the passed in name",
     response = DocumentDTO.class,
     responseContainer = "List")
 public List<DocumentDTO> documentsByName(
     @ApiParam(value = "Name of documents to fetch", required = true) @PathParam("name")
         String name) {
   return documentRepository
       .findDocumentsByName(name)
       .stream()
       .map(Transformations::convertDocumentToDTO)
       .collect(Collectors.toList());
 }
  @GET
  @Path("/documentation")
  @ApiOperation(
      value = "Documentation for specific documents",
      notes = "Gets all documentation in all documents with matching name and version",
      response = DocumentationItemDTO.class,
      responseContainer = "List")
  public List<DocumentationItemDTO> searchDocumentation(
      @ApiParam(value = "Max number of results", required = false, defaultValue = "50")
          @DefaultValue("50")
          @QueryParam("maxResults")
          int maxResults,
      @ApiParam(value = "Search Term for documentation", required = false)
          @DefaultValue("")
          @QueryParam("searchTerm")
          String searchTerm) {
    List<Document> allDocs = documentRepository.getAllDocuments();

    return getDocumentation(allDocs, searchTerm, maxResults);
  }
  @GET
  @Path("/{name}/{version}/documentation")
  @ApiOperation(
      value = "Documentation for specific documents",
      notes = "Gets all documentation in all documents with matching name and version",
      response = DocumentationItemDTO.class,
      responseContainer = "List")
  public List<DocumentationItemDTO> documentationByNameAndVersion(
      @ApiParam(value = "Name of documents to fetch", required = true) @PathParam("name")
          String name,
      @ApiParam(value = "Version of named documents", required = true) @PathParam("version")
          String version,
      @ApiParam(value = "Max number of results", required = false, defaultValue = "50")
          @DefaultValue("50")
          @QueryParam("maxResults")
          int maxResults,
      @ApiParam(value = "Search Term for documentation", required = false)
          @DefaultValue("")
          @QueryParam("searchTerm")
          String searchTerm) {
    List<Document> docs = documentRepository.findDocumentsByNameAndVersion(name, version);

    return getDocumentation(docs, searchTerm, maxResults);
  }