com.atlassian.gadgets.util
Class GadgetSpecUrlBuilder

java.lang.Object
  extended by com.atlassian.gadgets.util.GadgetSpecUrlBuilder

public class GadgetSpecUrlBuilder
extends Object

Builds URLs to gadget specs that are hosted in plugins.


Constructor Summary
GadgetSpecUrlBuilder(com.atlassian.sal.api.ApplicationProperties applicationProperties)
          Constructs a new GadgetSpecUrlBuilder that uses the specified ApplicationProperties to determine the application base URL.
 
Method Summary
 String buildGadgetSpecFeedUrl()
          Builds a URL for the feed containing all the gadget specs published by this application.
 String buildGadgetSpecUrl(String pluginKey, String moduleKey, String location)
          Builds a URL for the gadget spec that can be found with the Plugin.
 PluginGadgetSpec.Key parseGadgetSpecUrl(String gadgetSpecUrl)
          Parses a gadget spec URL in the format returned from #buildGadgetSpecUrl(String, String) into a PluginResourceKey containing the plugin key and resource location specified by the URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GadgetSpecUrlBuilder

public GadgetSpecUrlBuilder(com.atlassian.sal.api.ApplicationProperties applicationProperties)
Constructs a new GadgetSpecUrlBuilder that uses the specified ApplicationProperties to determine the application base URL.

Parameters:
applicationProperties - ApplicationProperties implementation of the host application. Must not be null, or a NullPointerException will be thrown.
Throws:
NullPointerException - if applicationProperties is null
Method Detail

buildGadgetSpecFeedUrl

public String buildGadgetSpecFeedUrl()
Builds a URL for the feed containing all the gadget specs published by this application.

Returns:
URL for the feed containing all the gadget specs published by this application

buildGadgetSpecUrl

public String buildGadgetSpecUrl(String pluginKey,
                                 String moduleKey,
                                 String location)
Builds a URL for the gadget spec that can be found with the Plugin.

Parameters:
pluginKey - key of the Plugin in which the gadget spec can be found. Must not be null, or a NullPointerException will be thrown.
location - path to the gadget spec resource in the plugin. Must not be null, or a NullPointerException will be thrown.
moduleKey - key of the GadgetModuleDescriptor. Must not be null, or a NullPointerException will be thrown.
Returns:
URL that the gadget spec will be made available on
Throws:
NullPointerException - if any argument is null

parseGadgetSpecUrl

public PluginGadgetSpec.Key parseGadgetSpecUrl(String gadgetSpecUrl)
Parses a gadget spec URL in the format returned from #buildGadgetSpecUrl(String, String) into a PluginResourceKey containing the plugin key and resource location specified by the URL. The URL must contain the standard resource prefix, and both a plugin key and resource location in the path. It may contain a module key after the plugin key separated by a colon. If the URL is absolute, it must match the base URL for this application.

For example:

Parameters:
gadgetSpecUrl - a valid, URL-encoded gadget spec URL, as produced by #buildGadgetSpecUrl(String, String) or #buildGadgetSpecUrl(com.atlassian.gadgets.plugins.PluginGadgetSpec.Key). May be absolute, if the base URL matches the base URL retrieved from the ApplicationProperties instance this GadgetSpecUrlBuilder was initialized with. Must not be null, or a NullPointerException will be thrown.
Returns:
a PluginResourceKey built from the plugin key and resource location parsed and decoded from the URL
Throws:
GadgetSpecUriNotAllowedException - if the URL does not start with the prefix for gadget specs published from this application, or if either the plugin key or resource location is missing or blank
NullPointerException - if gadgetSpecUrl is null


Copyright © 2010 Atlassian. All Rights Reserved.