Class DownloadableWebResource

java.lang.Object
com.atlassian.plugin.servlet.DownloadableWebResource
All Implemented Interfaces:
DownloadableResource

public class DownloadableWebResource extends Object
A DownloadableResource that will serve the resource via the web application's ServletContext.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final String
     
    protected final Plugin
     
    protected final com.atlassian.plugin.elements.ResourceLocation
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    DownloadableWebResource(Plugin plugin, com.atlassian.plugin.elements.ResourceLocation resourceLocation, String extraPath, jakarta.servlet.ServletContext servletContext, boolean disableMinification)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the content type for the resource.
    protected String
    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(jakarta.servlet.http.HttpServletRequest httpServletRequest, jakarta.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(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
    Writes the resource content out into the response.
    void
    Write the resource to the supplied OutputStream.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • plugin

      protected final Plugin plugin
    • extraPath

      protected final String extraPath
    • resourceLocation

      protected final com.atlassian.plugin.elements.ResourceLocation resourceLocation
  • Constructor Details

    • DownloadableWebResource

      public DownloadableWebResource(Plugin plugin, com.atlassian.plugin.elements.ResourceLocation resourceLocation, String extraPath, jakarta.servlet.ServletContext servletContext, boolean disableMinification)
  • Method Details

    • 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(jakarta.servlet.http.HttpServletRequest request, jakarta.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(jakarta.servlet.http.HttpServletRequest httpServletRequest, jakarta.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