Class RelatedContentHandler

java.lang.Object
org.codelibs.fess.api.v2.handlers.RelatedContentHandler

public class RelatedContentHandler extends Object
Handles GET /api/v2/related-content.

Returns related HTML content for the given q parameter by delegating to RelatedContentHelper.getRelatedContents(String). When multiple content items are returned they are joined with a newline separator. When q is blank or absent the response contains an empty content string. The response shape is always a success envelope with status:0:


 { "status": 0, "content": "<html>...</html>", "content_type": "html" }
 

This handler is GET-only; other methods are rejected with V2ErrorCode.METHOD_NOT_ALLOWED.

  • Constructor Details

    • RelatedContentHandler

      public RelatedContentHandler()
      Default constructor. The handler is stateless and intended to be instantiated once by the API manager and shared across concurrent requests.
  • Method Details

    • handle

      public void handle(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res) throws IOException
      Processes one GET /api/v2/related-content request.

      Reads the q query parameter, delegates to RelatedContentHelper.getRelatedContents(String), and writes the result as a success envelope. Multiple content items are joined with a newline. An empty or absent q yields an empty content string rather than an error.

      Parameters:
      req - the incoming HTTP request
      res - the HTTP response to write to
      Throws:
      IOException - if writing the envelope fails