com.atlassian.gadgets.publisher.internal.impl
Class PublishedGadgetSpecStoreImpl

java.lang.Object
  extended by com.atlassian.gadgets.publisher.internal.impl.PublishedGadgetSpecStoreImpl
All Implemented Interfaces:
GadgetSpecProvider, LocalGadgetSpecProvider, PluginGadgetSpecEventListener, PublishedGadgetSpecWriter

public class PublishedGadgetSpecStoreImpl
extends Object
implements LocalGadgetSpecProvider, PluginGadgetSpecEventListener, PublishedGadgetSpecWriter

A fairly naive implementation that processes gadget spec file and substitutes values into it on the fly.


Constructor Summary
PublishedGadgetSpecStoreImpl(GadgetSpecUrlBuilder urlBuilder, GadgetSpecValidator validator, GadgetProcessor gadgetProcessor, PluginGadgetSpecProviderPermission permission, com.atlassian.sal.api.ApplicationProperties applicationProperties)
           
 
Method Summary
 boolean contains(URI gadgetSpecUri)
          Returns true if the URI is in the store, false otherwise.
 Iterable<URI> entries()
          Returns all the gadget URIs contained by this store.
 Date getLastModified(URI gadgetSpecUri)
          Return the date the gadget spec was last modified.
 void pluginGadgetSpecDisabled(PluginGadgetSpec pluginGadgetSpec)
          Called when a gadget spec is disabled from a plugin.
 void pluginGadgetSpecEnabled(PluginGadgetSpec pluginGadgetSpec)
          Called when a gadget spec is enabled from a plugin.
 String toString()
           
 void writeGadgetSpecTo(String pluginKey, String location, OutputStream output)
          Writes the gadget spec from the specified plugin, with the specified resource location within the plugin, to the specified OutputStream.
 void writeGadgetSpecTo(URI gadgetSpecUri, OutputStream output)
          Writes the gadget spec found at the specified URI, to the specified OutputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PublishedGadgetSpecStoreImpl

public PublishedGadgetSpecStoreImpl(GadgetSpecUrlBuilder urlBuilder,
                                    GadgetSpecValidator validator,
                                    GadgetProcessor gadgetProcessor,
                                    PluginGadgetSpecProviderPermission permission,
                                    com.atlassian.sal.api.ApplicationProperties applicationProperties)
Method Detail

contains

public boolean contains(URI gadgetSpecUri)
Description copied from interface: GadgetSpecProvider
Returns true if the URI is in the store, false otherwise.

Specified by:
contains in interface GadgetSpecProvider
Parameters:
gadgetSpecUri - URI to check is in the store
Returns:
true if the URI is in the store, false otherwise

entries

public Iterable<URI> entries()
Description copied from interface: GadgetSpecProvider
Returns all the gadget URIs contained by this store.

Specified by:
entries in interface GadgetSpecProvider
Returns:
all the gadget URIs contained by this store.

writeGadgetSpecTo

public void writeGadgetSpecTo(String pluginKey,
                              String location,
                              OutputStream output)
                       throws IOException
Description copied from interface: PublishedGadgetSpecWriter
Writes the gadget spec from the specified plugin, with the specified resource location within the plugin, to the specified OutputStream. Output will be buffered internally, so there is no need for the calling code to wrap the OutputStream with a BufferedOutputStream.

Specified by:
writeGadgetSpecTo in interface PublishedGadgetSpecWriter
Parameters:
pluginKey - the plugin key of the Plugin that contains the gadget spec to store. Must not be null, or a NullPointerException will be thrown.
location - the location of the gadget spec XML file resource within the plugin. Must not be null, or a NullPointerException will be thrown.
output - the OutputStream to write the gadget spec XML to. Must not be null, or a NullPointerException will be thrown.
Throws:
IOException - if an error occurs in I/O processing

writeGadgetSpecTo

public void writeGadgetSpecTo(URI gadgetSpecUri,
                              OutputStream output)
                       throws IOException
Description copied from interface: LocalGadgetSpecProvider
Writes the gadget spec found at the specified URI, to the specified OutputStream. It is assumed that the caller has already checked that the URI is provided by this provider by calling the GadgetSpecProvider.contains(java.net.URI) method. If not, this method will throw a com.atlassian.gadgets.GadgetSpecUriNotAllowedException.

Specified by:
writeGadgetSpecTo in interface LocalGadgetSpecProvider
Parameters:
gadgetSpecUri - URI of the gadget spec to write. Must not be null or a NullPointerException will be thrown.
output - the OutputStream to write the gadget spec XML to. Must not be null, or a NullPointerException will be thrown.
Throws:
IOException - if an error occurs in I/O processing

getLastModified

public Date getLastModified(URI gadgetSpecUri)
Description copied from interface: LocalGadgetSpecProvider
Return the date the gadget spec was last modified.

Specified by:
getLastModified in interface LocalGadgetSpecProvider

pluginGadgetSpecEnabled

public void pluginGadgetSpecEnabled(PluginGadgetSpec pluginGadgetSpec)
                             throws GadgetParsingException
Description copied from interface: PluginGadgetSpecEventListener
Called when a gadget spec is enabled from a plugin.

Specified by:
pluginGadgetSpecEnabled in interface PluginGadgetSpecEventListener
Parameters:
pluginGadgetSpec - the gadget spec that was enabled. Must not be null, or a NullPointerException will be thrown.
Throws:
GadgetParsingException

pluginGadgetSpecDisabled

public void pluginGadgetSpecDisabled(PluginGadgetSpec pluginGadgetSpec)
Description copied from interface: PluginGadgetSpecEventListener
Called when a gadget spec is disabled from a plugin.

Specified by:
pluginGadgetSpecDisabled in interface PluginGadgetSpecEventListener
Parameters:
pluginGadgetSpec - the gadget spec that was enabled. Must not be null, or a NullPointerException will be thrown.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2010 Atlassian. All Rights Reserved.