View Javadoc

1   package com.atlassian.plugin.servlet;
2   
3   import javax.servlet.http.HttpServletRequest;
4   import javax.servlet.http.HttpServletResponse;
5   
6   /**
7    * Represents a plugin resource that can be downloaded.
8    *
9    * It is up to the calling class to check if the resource is modified before calling
10   * {@link #serveResource(HttpServletRequest, HttpServletResponse)} to serve the resource.
11   */
12  public interface DownloadableResource
13  {
14      /**
15       * Returns true if the plugin resource has been modified. The implementing class is responsible for
16       * setting any appropriate response codes or headers on the response.
17       *
18       * If the resource has been modified, the resource shouldn't be served. 
19       */
20      boolean isResourceModified(HttpServletRequest request, HttpServletResponse response);
21  
22      /**
23       * Writes the resource content out into the response.
24       * @throws DownloadException if there were errors writing to the response.
25       * @since 2.2
26       */
27      void serveResource(HttpServletRequest request, HttpServletResponse response) throws DownloadException;
28  
29      /**
30       * Returns the content type for the resource. May return null if it cannot resolve its own content type.
31       * @since 2.2
32       */
33      String getContentType();
34  }