Class CacheHandler

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

public class CacheHandler extends Object
Handles GET /api/v2/cache/{docId}.

Returns the cached HTML rendering of an indexed document, mirroring the v1 CacheAction#index behavior but emitting a v2 envelope instead of a StreamResponse. The cached content is embedded in the success payload alongside doc_id and mimetype so JS clients can render it inline without a second round-trip.

Order of checks:

  1. HTTP method must be GET. Other methods produce 405 method_not_allowed with an Allow: GET header.
  2. When app.login.required=true and no authenticated user is present, returns 401 auth_required — parity with v1 CacheAction:68-70.
  3. docId must be non-blank and match [A-Za-z0-9_-]+.
  4. The document must exist in the index (otherwise 404 not_found).
  5. ViewHelper.createCacheContent(java.util.Map<java.lang.String, java.lang.Object>, java.lang.String[]) must return a non-null body (otherwise 404 not_found with a "no cache for" message — same semantics as v1's addErrorsDocidNotFound).

The hq query parameter is multi-valued and passed straight through to ViewHelper.createCacheContent(Map, String[]). Null is acceptable.

  • Constructor Details

    • CacheHandler

      public CacheHandler()
      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, String docId) throws IOException
      Processes one /api/v2/cache/{docId} GET request.
      Parameters:
      req - the incoming HTTP request
      res - the HTTP response to write to
      docId - the document id extracted from the URL path
      Throws:
      IOException - if writing the envelope fails