Class Controller

java.lang.Object
com.atlassian.plugin.webresource.impl.support.http.BaseController
com.atlassian.plugin.webresource.impl.http.Controller

public class Controller extends BaseController
Handles HTTP requests.

Intended to be used with one instance per request to handle

Since:
3.3
  • Constructor Details

  • Method Details

    • serveResource

      public void serveResource(String completeKey, String resourceName, ServingType servingType)
      Serves single Resource.
    • serveResourceSourceMap

      public void serveResourceSourceMap(String completeKey, String resourceName, ServingType servingType)
      Serves Source Map for single Resource.
    • serveBatch

      public void serveBatch(RawRequest raw, ServingType servingType, String type, boolean resolveDependencies, boolean withLegacyConditions, boolean isCachingEnabled, boolean verifyBundleHash)
      Serves Batch (all types of Batch - Web Resource Batch, Super Batch, Context Batch). Supports bundle hash verification. If verification fails, empty resource list is returned that results in empty content response and 404 code.
      Parameters:
      raw - all included and excluded Requestable.
      type - type of Batch.
      resolveDependencies - if dependencies should be resolved.
      verifyBundleHash - if bundle hash in the request url should be verified against what we currently have in the system
    • serveBatchSourceMap

      public void serveBatchSourceMap(RawRequest raw, ServingType servingType, String type, boolean resolveDependencies, boolean withLegacyConditions)
      Serves Source Map for Batch.
      Parameters:
      raw - all included and excluded Requestable.
      type - type of Batch.
      resolveDependencies - if dependencies should be resolved.
    • getBatchResources

      protected List<Resource> getBatchResources(RawRequest raw, String type, boolean resolveDependencies, boolean withLegacyConditions)
      Get Resources for Batch (all types of Batch - Web Resource Batch, Super Batch, Context Batch).
      Parameters:
      raw - all included and excluded Requestable.
      type - type of Batch.
      resolveDependencies - if dependencies should be resolved.
    • serveResourceRelativeToBatch

      public void serveResourceRelativeToBatch(RawRequest raw, String resourceName, ServingType servingType, boolean resolveDependencies, boolean withLegacyConditions)
      Serves Resource relative to Batch.
      Parameters:
      raw - all included and excluded Requestable.
      resourceName - name attribute of <resource> to be served from within a requested web-resource.
      resolveDependencies - if dependencies should be resolved.
    • serveResourceRelativeToBatchSourceMap

      public void serveResourceRelativeToBatchSourceMap(RawRequest raw, String resourceName, ServingType servingType, boolean resolveDependencies, boolean withLegacyConditions)
      Serves Source Map for Resource relative to Batch.
    • getResourceRelativeToBatch

      protected Resource getResourceRelativeToBatch(RawRequest raw, String resourceName, boolean resolveDependencies, boolean withLegacyConditions)
      Get Resource relative to Batch.
    • serveSource

      public void serveSource(String completeKey, String resourceName, ServingType servingType)
      Serves Source Code of the Resource.
    • serveResource

      protected void serveResource(RawRequest raw, Resource resource)
      Causes the content inside resource to be served in response.
      Parameters:
      raw - all included and excluded Requestable.
      resource - the tangible Resource whose content should be served and should exist somewhere in raw.
    • serveResource

      protected void serveResource(RawRequest raw, Resource resource, boolean applyTransformations, boolean isCachingEnabled)
    • serveResources

      protected void serveResources(RawRequest raw, Supplier<Collection<Resource>> resources, boolean isCachingEnabled)
      Causes all content inside every Resource provided by resources to be served in response.
      Parameters:
      raw - all included and excluded Requestable.
      resources - an ordered list of Resource whose content should be served. Each should be reachable via one of the Requestable referenced in raw.
    • serveSourceMap

      protected void serveSourceMap(RawRequest raw, Resource resource)
      Serves Source Map.
    • handleNotFoundRedirectAndNotModified

      protected boolean handleNotFoundRedirectAndNotModified(Resource resource)
      Handle not found resources, redirects and not modified resources.
      Returns:
      true if request has been handled and no further processing needed.
    • checkIfCachedAndNotModified

      protected boolean checkIfCachedAndNotModified(Date updatedAt)
      Check if resource is not modified and replies with not-modified response if so.
      Parameters:
      updatedAt - when resource has been updated.
      Returns:
      true if Resources is not modified and no further processing is needed.
    • sendCached

      protected void sendCached(Content content, Map<String,String> params, boolean isCachingEnabled)
    • buildCacheKey

      protected String buildCacheKey()
      Creates cache key for resource or batch.
    • isSourceMapEnabled

      protected boolean isSourceMapEnabled()
      If Source Map is enabled for the current Request.