1 package com.atlassian.plugin.webresource;
2
3 import com.atlassian.plugin.servlet.DownloadableResource;
4
5 import java.util.List;
6 import java.util.Map;
7
8 /**
9 * Assists in locating plugin resources in different ways.
10 * @since 2.2
11 */
12 public interface PluginResourceLocator
13 {
14 /**
15 * Returns true if this locator can parse the given url.
16 */
17 boolean matches(String url);
18
19 /**
20 * Returns a {@link DownloadableResource} represented by the given url and query params.
21 * {@link #matches(String)} should be called before invoking this method. If the url is
22 * not understood by the locator, null will be returned.
23 */
24 DownloadableResource getDownloadableResource(String url, Map<String, String> queryParams);
25
26 /**
27 * Returns a list of {@link PluginResource}s for a given plugin module's complete key. If
28 * the plugin the module belongs to is not enabled or does not exist, an empty list is returned.
29 */
30 List<PluginResource> getPluginResources(String moduleCompleteKey);
31
32 /**
33 * Constructs and returns url for the given resource.
34 * This method is not responsible for adding any static caching url prefixes.
35 *
36 * @param pluginModuleKey a plugin module's complete key
37 * @param resourceName the name of the resource described in the module
38 */
39 String getResourceUrl(String pluginModuleKey, String resourceName);
40 }