com.atlassian.plugin.servlet
Class EmptyDownloadableResource

java.lang.Object
  extended by com.atlassian.plugin.servlet.EmptyDownloadableResource
All Implemented Interfaces:
DownloadableResource

public class EmptyDownloadableResource
extends Object

A DownloadableResource with no content

Since:
v3.0

Field Summary
protected  String extraPath
           
protected  Plugin plugin
           
protected  ResourceLocation resourceLocation
           
 
Constructor Summary
EmptyDownloadableResource(Plugin plugin, ResourceLocation resourceLocation)
           
 
Method Summary
 String getContentType()
          Returns the content type for the resource.
protected  String getLocation()
          This is called to return the location of the resource that this object represents.
protected  InputStream getResourceAsStream(String resourceLocation)
          Returns an InputStream to stream the resource from based on resource name.
 boolean isResourceModified(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse)
          Checks any "If-Modified-Since" header from the request against the plugin's loading time, since plugins can't be modified after they've been loaded this is a good way to determine if a plugin resource has been modified or not.
 void serveResource(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Writes the resource content out into the response.
 void streamResource(OutputStream out)
          Write the resource to the supplied OutputStream.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

plugin

protected final Plugin plugin

extraPath

protected final String extraPath

resourceLocation

protected final ResourceLocation resourceLocation
Constructor Detail

EmptyDownloadableResource

public EmptyDownloadableResource(Plugin plugin,
                                 ResourceLocation resourceLocation)
Parameters:
plugin - used to find last modified date and plugin key
resourceLocation - used to get content type for the resource
Method Detail

getResourceAsStream

protected InputStream getResourceAsStream(String resourceLocation)
Returns an InputStream to stream the resource from based on resource name.

Parameters:
resourceLocation - the location of the resource to try and load
Returns:
an InputStream if the resource can be found or null if cant be found

serveResource

public void serveResource(javax.servlet.http.HttpServletRequest request,
                          javax.servlet.http.HttpServletResponse response)
                   throws DownloadException
Description copied from interface: DownloadableResource
Writes the resource content out into the response.

Specified by:
serveResource in interface DownloadableResource
Throws:
DownloadException - if there were errors writing to the response.

streamResource

public void streamResource(OutputStream out)
                    throws DownloadException
Description copied from interface: DownloadableResource
Write the resource to the supplied OutputStream. Note that the OutputStream will not be closed by this method.

Specified by:
streamResource in interface DownloadableResource
Parameters:
out - the stream to write to
Throws:
DownloadException - if there were errors writing to the response. Since 2.3.

isResourceModified

public boolean isResourceModified(javax.servlet.http.HttpServletRequest httpServletRequest,
                                  javax.servlet.http.HttpServletResponse httpServletResponse)
Checks any "If-Modified-Since" header from the request against the plugin's loading time, since plugins can't be modified after they've been loaded this is a good way to determine if a plugin resource has been modified or not. If this method returns true, don't do any more processing on the request -- the response code has already been set to "304 Not Modified" for you, and you don't need to serve the file.

Specified by:
isResourceModified in interface DownloadableResource

getContentType

public String getContentType()
Description copied from interface: DownloadableResource
Returns the content type for the resource. May return null if it cannot resolve its own content type.

Specified by:
getContentType in interface DownloadableResource

getLocation

protected String getLocation()
This is called to return the location of the resource that this object represents.

Returns:
the location of the resource that this object represents.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2015 Atlassian. All rights reserved.