Class Controller
java.lang.Object
com.atlassian.plugin.webresource.impl.support.http.BaseController
com.atlassian.plugin.webresource.impl.http.Controller
Handles HTTP requests.
Intended to be used with one instance per request to handle
- Since:
- 3.3
-
Field Summary
Fields inherited from class com.atlassian.plugin.webresource.impl.support.http.BaseController
globals, request, response -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringCreates cache key for resource or batch.protected booleancheckIfCachedAndNotModified(Date updatedAt) Check if resource is not modified and replies with not-modified response if so.getBatchResources(RawRequest raw, String type, boolean resolveDependencies, boolean withLegacyConditions) Get Resources for Batch (all types of Batch - Web Resource Batch, Super Batch, Context Batch).protected ResourcegetResourceRelativeToBatch(RawRequest raw, String resourceName, boolean resolveDependencies, boolean withLegacyConditions) Get Resource relative to Batch.protected booleanhandleNotFoundRedirectAndNotModified(Resource resource) Handle not found resources, redirects and not modified resources.protected booleanIf Source Map is enabled for the current Request.protected voidsendCached(Content content, Map<String, String> params, boolean isCachingEnabled) voidserveBatch(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).voidserveBatchSourceMap(RawRequest raw, ServingType servingType, String type, boolean resolveDependencies, boolean withLegacyConditions) Serves Source Map for Batch.protected voidserveResource(RawRequest raw, Resource resource) Causes the content inside resource to be served in response.protected voidserveResource(RawRequest raw, Resource resource, boolean applyTransformations, boolean isCachingEnabled) voidserveResource(String completeKey, String resourceName, ServingType servingType) Serves single Resource.voidserveResourceRelativeToBatch(RawRequest raw, String resourceName, ServingType servingType, boolean resolveDependencies, boolean withLegacyConditions) Serves Resource relative to Batch.voidserveResourceRelativeToBatchSourceMap(RawRequest raw, String resourceName, ServingType servingType, boolean resolveDependencies, boolean withLegacyConditions) Serves Source Map for Resource relative to Batch.protected voidserveResources(RawRequest raw, Supplier<Collection<Resource>> resources, boolean isCachingEnabled) Causes all content inside everyResourceprovided by resources to be served in response.voidserveResourceSourceMap(String completeKey, String resourceName, ServingType servingType) Serves Source Map for single Resource.voidserveSource(String completeKey, String resourceName, ServingType servingType) Serves Source Code of the Resource.protected voidserveSourceMap(RawRequest raw, Resource resource) Serves Source Map.
-
Constructor Details
-
Controller
-
-
Method Details
-
serveResource
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 excludedRequestable.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 excludedRequestable.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 excludedRequestable.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 excludedRequestable.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
Serves Source Code of the Resource. -
serveResource
Causes the content inside resource to be served in response.- Parameters:
raw- all included and excludedRequestable.resource- the tangibleResourcewhose 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 everyResourceprovided by resources to be served in response.- Parameters:
raw- all included and excludedRequestable.resources- an ordered list ofResourcewhose content should be served. Each should be reachable via one of theRequestablereferenced in raw.
-
serveSourceMap
Serves Source Map. -
handleNotFoundRedirectAndNotModified
Handle not found resources, redirects and not modified resources.- Returns:
- true if request has been handled and no further processing needed.
-
checkIfCachedAndNotModified
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
-
buildCacheKey
Creates cache key for resource or batch. -
isSourceMapEnabled
protected boolean isSourceMapEnabled()If Source Map is enabled for the current Request.
-