View Javadoc

1   package com.atlassian.plugin.webresource;
2   
3   import com.atlassian.plugin.servlet.DownloadException;
4   import com.atlassian.plugin.servlet.DownloadableResource;
5   
6   import javax.servlet.http.HttpServletRequest;
7   import javax.servlet.http.HttpServletResponse;
8   import java.io.OutputStream;
9   import java.util.Collections;
10  import java.util.List;
11  import java.util.Map;
12  
13  /**
14   * Represents a plugin resource that is a subordinate of a batch.
15   *
16   * This is typically the case for CSS in the superbatch or context batch with relative urls to images. For example:
17   * <code>/download/superbatch/css/images/foo.png</code>
18   * <code>/download/contextbatch/css/contexta/images/foo.png</code>
19   * @since 2.9.0
20   */
21  public class BatchSubResource implements DownloadableResource
22  {
23      private BatchPluginResource delegate;
24      private String resourceName;
25  
26      public BatchSubResource(String resourceName, String type, Map<String, String> params)
27      {
28          this(resourceName, type, params, Collections.<DownloadableResource>emptyList());
29      }
30  
31      public BatchSubResource(String resourceName, String type, Map<String, String> params, List<DownloadableResource> resources)
32      {
33          this.resourceName = resourceName;
34          this.delegate = new BatchPluginResource(resourceName, type, params, resources);
35      }
36  
37      public boolean isResourceModified(HttpServletRequest request, HttpServletResponse response)
38      {
39          return delegate.isResourceModified(request, response);
40      }
41  
42      public void serveResource(HttpServletRequest request, HttpServletResponse response) throws DownloadException
43      {
44          delegate.serveResource(request, response);
45      }
46  
47      public void streamResource(OutputStream out) throws DownloadException
48      {
49          delegate.streamResource(out);
50      }
51  
52      public String getContentType()
53      {
54          return delegate.getContentType();
55      }
56  
57      public boolean isEmpty()
58      {
59          return delegate.isEmpty();
60      }
61  
62      public String getResourceName()
63      {
64          return resourceName;
65      }
66  
67      @Override
68      public String toString()
69      {
70          return "[Subbatch module=" + delegate.getModuleCompleteKey() + " name=" + resourceName + "]";
71      }
72  }