public class

BatchPluginResource

extends Object
implements DownloadableResource BatchResource PluginResource
java.lang.Object
   ↳ com.atlassian.plugin.webresource.BatchPluginResource

Class Overview

Represents a batch of plugin resources.

It provides methods to parse and generate urls to locate a batch of plugin resources.

Note BatchPluginResource is also a type of DownloadableResource. The underlying implementation simply keeps a list of DownloadableResource of which this batch represents and delegates method calls.

Summary

Public Constructors
BatchPluginResource(String moduleCompleteKey, String type, Map<StringString> params)
A constructor that creates a default resource name for the batch in the format: moduleCompleteKey.type For example: test.plugin:resources.js

Note that name of the batch does not identify what the batch includes and could have been static e.g.
Public Methods
void add(DownloadableResource resource)
boolean equals(Object o)
String getContentType()
Returns the content type for the resource.
String getModuleCompleteKey()
Map<StringString> getParams()
String getResourceName()
String getType()
String getUrl()
Returns a url string in the format: /download/batch/MODULE_COMPLETE_KEY/resourceName?PARAMS e.g.
String getVersion(WebResourceIntegration integration)
int hashCode()
boolean isCacheSupported()
boolean isEmpty()
boolean isResourceModified(HttpServletRequest request, HttpServletResponse response)
Returns true if the plugin resource has been modified.
static boolean matches(String url)
static BatchPluginResource parse(String url, Map<StringString> queryParams)
Parses the given url and query parameter map into a BatchPluginResource.
void serveResource(HttpServletRequest request, HttpServletResponse response)
Writes the resource content out into the response.
void streamResource(OutputStream out)
Write the resource to the supplied OutputStream.
String toString()
Protected Methods
void addParamsToUrl(StringBuilder sb, Map<StringString> params)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.atlassian.plugin.servlet.DownloadableResource
From interface com.atlassian.plugin.webresource.BatchResource
From interface com.atlassian.plugin.webresource.PluginResource

Public Constructors

public BatchPluginResource (String moduleCompleteKey, String type, Map<StringString> params)

A constructor that creates a default resource name for the batch in the format: moduleCompleteKey.type For example: test.plugin:resources.js

Note that name of the batch does not identify what the batch includes and could have been static e.g. batch.js

Public Methods

public void add (DownloadableResource resource)

public boolean equals (Object o)

public String getContentType ()

Returns the content type for the resource. May return null if it cannot resolve its own content type.

public String getModuleCompleteKey ()

public Map<StringString> getParams ()

public String getResourceName ()

public String getType ()

public String getUrl ()

Returns a url string in the format: /download/batch/MODULE_COMPLETE_KEY/resourceName?PARAMS e.g. /download/batch/example.plugin:webresources/example.plugin:webresources.css?ie=true

It is important for the url structure to be: 1. the same number of sectioned paths as the SinglePluginResource 2. include the module completey key in the path before the resource name This is due to css resources referencing other resources such as images in relative path forms.

public String getVersion (WebResourceIntegration integration)

public int hashCode ()

public boolean isCacheSupported ()

public boolean isEmpty ()

Returns
  • true if there are no resources included in this batch

public boolean isResourceModified (HttpServletRequest request, HttpServletResponse response)

Returns true if the plugin resource has been modified. The implementing class is responsible for setting any appropriate response codes or headers on the response. If the resource has been modified, the resource shouldn't be served.

public static boolean matches (String url)

public static BatchPluginResource parse (String url, Map<StringString> queryParams)

Parses the given url and query parameter map into a BatchPluginResource. Query paramters must be passed in through the map, any in the url String will be ignored.

Parameters
url the url to parse
queryParams a map of String key and value pairs representing the query parameters in the url
Returns
  • the parsed BatchPluginResource
Throws
UrlParseException if the url passed in is not a valid batch resource url

public void serveResource (HttpServletRequest request, HttpServletResponse response)

Writes the resource content out into the response.

public void streamResource (OutputStream out)

Write the resource to the supplied OutputStream. Note that the OutputStream will not be closed by this method.

Parameters
out the stream to write to

public String toString ()

Protected Methods

protected void addParamsToUrl (StringBuilder sb, Map<StringString> params)