magoffin.matt.ma2.biz.impl
Class SystemBizImpl

java.lang.Object
  extended by magoffin.matt.ma2.biz.impl.SystemBizImpl
All Implemented Interfaces:
java.util.EventListener, SystemBiz, org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationListener

public class SystemBizImpl
extends java.lang.Object
implements SystemBiz, org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationListener

Standard implementation of UserBiz.

Note: the init() method should be called after configuring this class but before calling any other methods; the finish() should be called when finished using.

The init() method will attempt to populate the backend database with all available time zones if none are found in the database already.

cacheDirectory
The directory for creating and storing cached media items.
collectionRootDirectory
The root directory for storing collections, i.e. the root directory for all media items.
defaultTimeZoneCode
The default TimeZone code to use. Defaults to TimeZone.getDefault()'s getID().
domainObjectFactory
The DomainObjectFactory implementation to use for creating instances of our domain objects.
externalThemeDirectory
The path to the directory for storing external theme resources.
themeDao
The ThemeDao implementation to use.
timeZoneDao
The TimeZoneDao implementation to use.

Version:
$Revision: 176 $ $Date: 2008-12-28 14:33:18 +1300 (Sun, 28 Dec 2008) $
Author:
Matt Magoffin (spamsqr@msqr.us)

Field Summary
static java.lang.String PLUGIN_CONFIG_KEY
          The plugin configuration key.
static java.lang.String SHARED_ALBUM_TEMPLATE_KEY
          The model key where the shared Album is placed.
static java.lang.String THEME_PROPERTY_CREATED_DATE_FORMAT
          The theme created date property date format.
 
Fields inherited from interface magoffin.matt.ma2.biz.SystemBiz
SETTING_KEY_SETUP_COMPLETE, SETTING_KEY_SETUP_REQUIRE_ADMIN, THEME_PROPERTIES_FILE_NAME, THEME_PROPERTY_AUTHOR, THEME_PROPERTY_AUTHOR_EMAIL, THEME_PROPERTY_CREATED_DATE, THEME_PROPERTY_NAME, THEME_XSLT_FILE_NAME
 
Constructor Summary
SystemBizImpl()
           
 
Method Summary
 void deleteTheme(Theme theme, BizContext context)
          Delete a Theme.
 void exportTheme(Theme theme, java.io.OutputStream out, java.io.File baseDirectory, BizContext context)
          Export a Theme, and associated resources.
 void finish()
          Call to release any class resources when finished using.
 AlbumDao getAlbumDao()
           
 java.util.List<Locale> getAvailableLocales()
          Get a list of available locales.
 java.util.List<Theme> getAvailableThemes()
          Get a list of available themes.
 java.util.List<TimeZone> getAvailableTimeZones()
          Get a list of available time zones.
 java.io.File getCacheDirectory()
          Get a directory for caching items in.
 java.io.File getCollectionRootDirectory()
          Get the root directory to store all collections within.
 Theme getDefaultTheme()
          Get a default theme.
 java.lang.String getDefaultThemeName()
           
 java.util.Map<java.lang.String,java.lang.Object> getDefaultThemeTemplate()
           
 TimeZone getDefaultTimeZone()
          Get the system's default time zone.
 java.lang.String getDefaultTimeZoneCode()
           
 DomainObjectFactory getDomainObjectFactory()
           
 java.lang.String getExternalThemeDirectory()
           
 magoffin.matt.xweb.util.MessagesSource getMessages()
           
<T extends Plugin>
java.util.List<T>
getPluginsOfType(java.lang.Class<T> pluginType)
          Get all registered plugins of a specific type.
 java.io.File getResourceDirectory()
          Get a directory for storing user resources in.
 magoffin.matt.xweb.util.XwebParamDao getSettingsDao()
           
 java.lang.String getSharedAlbumUrl(Album album, BizContext context)
          Get the Matte URL for a shared album.
 java.lang.String getSharedAlbumUrlTemplate()
           
 Theme getThemeById(java.lang.Long themeId)
          Get a Theme by its ID.
 ThemeDao getThemeDao()
           
 org.springframework.core.io.Resource getThemeResource(Theme theme, java.lang.String path, BizContext context)
          Get a Theme resource.
 TimeZoneDao getTimeZoneDao()
           
 TimeZone getTimeZoneForCode(java.lang.String code)
          Get a specific TimeZone instance based on its code.
 void init()
          Call to initialize the class after configuring properties.
 boolean isApplicationConfigured()
          Return the status of the overall application configuration.
 void onApplicationEvent(org.springframework.context.ApplicationEvent event)
           
 void setAlbumDao(AlbumDao albumDao)
           
 void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
           
 void setCacheDirectory(java.io.File cacheDirectory)
           
 void setCollectionRootDirectory(java.io.File collectionRootDirectory)
           
 void setDefaultThemeName(java.lang.String defaultThemeName)
           
 void setDefaultThemeTemplate(java.util.Map<java.lang.String,java.lang.Object> defaultThemeTemplate)
           
 void setDefaultTimeZoneCode(java.lang.String defaultTimeZoneCode)
           
 void setDomainObjectFactory(DomainObjectFactory domainObjectFactory)
           
 void setExternalThemeDirectory(java.lang.String externalThemeDirectory)
           
 void setMessages(magoffin.matt.xweb.util.MessagesSource messages)
           
 void setResourceDirectory(java.io.File resourceDirectory)
           
 void setSettingsDao(magoffin.matt.xweb.util.XwebParamDao settingsDao)
           
 void setSharedAlbumUrlTemplate(java.lang.String sharedAlbumUrlTemplate)
           
 void setThemeDao(ThemeDao themeDao)
           
 void setTimeZoneDao(TimeZoneDao timeZoneDao)
           
 java.lang.Long storeTheme(AddThemeCommand themeCommand, BizContext context)
          Store a Theme, and associated resources, in the back end.
 java.lang.Long storeTheme(Theme theme, BizContext context)
          Store a Theme in the back end.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

THEME_PROPERTY_CREATED_DATE_FORMAT

public static final java.lang.String THEME_PROPERTY_CREATED_DATE_FORMAT
The theme created date property date format.

See Also:
Constant Field Values

SHARED_ALBUM_TEMPLATE_KEY

public static final java.lang.String SHARED_ALBUM_TEMPLATE_KEY
The model key where the shared Album is placed.

See Also:
Constant Field Values

PLUGIN_CONFIG_KEY

public static final java.lang.String PLUGIN_CONFIG_KEY
The plugin configuration key.

See Also:
Constant Field Values
Constructor Detail

SystemBizImpl

public SystemBizImpl()
Method Detail

setApplicationContext

public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
                           throws org.springframework.beans.BeansException
Specified by:
setApplicationContext in interface org.springframework.context.ApplicationContextAware
Throws:
org.springframework.beans.BeansException

onApplicationEvent

public void onApplicationEvent(org.springframework.context.ApplicationEvent event)
Specified by:
onApplicationEvent in interface org.springframework.context.ApplicationListener

init

public void init()
Call to initialize the class after configuring properties.


getPluginsOfType

public <T extends Plugin> java.util.List<T> getPluginsOfType(java.lang.Class<T> pluginType)
Description copied from interface: SystemBiz
Get all registered plugins of a specific type.

Specified by:
getPluginsOfType in interface SystemBiz
Type Parameters:
T - the plugin class to get
Parameters:
pluginType - the type of plugins to get
Returns:
a read-only list of registred plugins, or an empty list if none available

finish

public void finish()
Call to release any class resources when finished using.


isApplicationConfigured

public boolean isApplicationConfigured()
Description copied from interface: SystemBiz
Return the status of the overall application configuration.

This configuration setting means the application has been started at least once and subsequently configured for the first time, and properly set up. Some other services may not want to start up if the application is not configured.

Specified by:
isApplicationConfigured in interface SystemBiz
Returns:
boolean

getAvailableThemes

public java.util.List<Theme> getAvailableThemes()
Description copied from interface: SystemBiz
Get a list of available themes.

Specified by:
getAvailableThemes in interface SystemBiz
Returns:
list of themes

getThemeById

public Theme getThemeById(java.lang.Long themeId)
Description copied from interface: SystemBiz
Get a Theme by its ID.

Specified by:
getThemeById in interface SystemBiz
Parameters:
themeId - the Theme ID
Returns:
the Theme, or null if not found

getAvailableTimeZones

public java.util.List<TimeZone> getAvailableTimeZones()
Description copied from interface: SystemBiz
Get a list of available time zones.

Specified by:
getAvailableTimeZones in interface SystemBiz
Returns:
list of time zones

getAvailableLocales

public java.util.List<Locale> getAvailableLocales()
Description copied from interface: SystemBiz
Get a list of available locales.

Specified by:
getAvailableLocales in interface SystemBiz
Returns:
list of locales

getTimeZoneForCode

public TimeZone getTimeZoneForCode(java.lang.String code)
Description copied from interface: SystemBiz
Get a specific TimeZone instance based on its code.

Specified by:
getTimeZoneForCode in interface SystemBiz
Parameters:
code - the time zone code
Returns:
the TimeZone if available, null if not found

getDefaultTimeZone

public TimeZone getDefaultTimeZone()
Description copied from interface: SystemBiz
Get the system's default time zone.

Specified by:
getDefaultTimeZone in interface SystemBiz
Returns:
default time zone

getCollectionRootDirectory

public java.io.File getCollectionRootDirectory()
Description copied from interface: SystemBiz
Get the root directory to store all collections within.

Specified by:
getCollectionRootDirectory in interface SystemBiz
Returns:
a file representing the directory to store collections in

getThemeResource

public org.springframework.core.io.Resource getThemeResource(Theme theme,
                                                             java.lang.String path,
                                                             BizContext context)
Description copied from interface: SystemBiz
Get a Theme resource.

Specified by:
getThemeResource in interface SystemBiz
Parameters:
theme - the theme
path - the path of the resource to get
context - the current context
Returns:
the Resource

getCacheDirectory

public java.io.File getCacheDirectory()
Description copied from interface: SystemBiz
Get a directory for caching items in.

Specified by:
getCacheDirectory in interface SystemBiz
Returns:
a file representing the directory to cache items in

getDefaultTheme

public Theme getDefaultTheme()
Description copied from interface: SystemBiz
Get a default theme.

Specified by:
getDefaultTheme in interface SystemBiz
Returns:
theme

storeTheme

public java.lang.Long storeTheme(Theme theme,
                                 BizContext context)
Description copied from interface: SystemBiz
Store a Theme in the back end.

This method will accept new Theme instances as well as updates to existing themes.

Specified by:
storeTheme in interface SystemBiz
Parameters:
theme - the theme to store
context - the current context
Returns:
the stored theme's primary key

getSharedAlbumUrl

public java.lang.String getSharedAlbumUrl(Album album,
                                          BizContext context)
Description copied from interface: SystemBiz
Get the Matte URL for a shared album.

Specified by:
getSharedAlbumUrl in interface SystemBiz
Parameters:
album - the album to get the URL for
context - the current context
Returns:
the URL as a String

storeTheme

public java.lang.Long storeTheme(AddThemeCommand themeCommand,
                                 BizContext context)
Description copied from interface: SystemBiz
Store a Theme, and associated resources, in the back end.

Specified by:
storeTheme in interface SystemBiz
Parameters:
themeCommand - the theme command data
context - the current context
Returns:
the stored theme's primary key

exportTheme

public void exportTheme(Theme theme,
                        java.io.OutputStream out,
                        java.io.File baseDirectory,
                        BizContext context)
Description copied from interface: SystemBiz
Export a Theme, and associated resources.

Calling this method will write a Zip archive of the theme and all it's associated resources to the supplied OutputStream. This method shall not close the OutputStream when finished.

Specified by:
exportTheme in interface SystemBiz
Parameters:
theme - the theme to export
out - the stream to output the theme to
baseDirectory - the base directory the Theme is stored in, or if null use the default external theme directory
context - the currenent context

deleteTheme

public void deleteTheme(Theme theme,
                        BizContext context)
Description copied from interface: SystemBiz
Delete a Theme.

Note that internal themes cannot be deleted.

Specified by:
deleteTheme in interface SystemBiz
Parameters:
theme - the Theme to delete
context - the current context

getDomainObjectFactory

public DomainObjectFactory getDomainObjectFactory()
Returns:
Returns the domainObjectFactory.

setDomainObjectFactory

public void setDomainObjectFactory(DomainObjectFactory domainObjectFactory)
Parameters:
domainObjectFactory - The domainObjectFactory to set.

getTimeZoneDao

public TimeZoneDao getTimeZoneDao()
Returns:
Returns the timeZoneDao.

setTimeZoneDao

public void setTimeZoneDao(TimeZoneDao timeZoneDao)
Parameters:
timeZoneDao - The timeZoneDao to set.

getDefaultTimeZoneCode

public java.lang.String getDefaultTimeZoneCode()
Returns:
Returns the defaultTimeZoneCode.

setDefaultTimeZoneCode

public void setDefaultTimeZoneCode(java.lang.String defaultTimeZoneCode)
Parameters:
defaultTimeZoneCode - The defaultTimeZoneCode to set.

setCollectionRootDirectory

public void setCollectionRootDirectory(java.io.File collectionRootDirectory)
Parameters:
collectionRootDirectory - The collectionRootDirectory to set.

setCacheDirectory

public void setCacheDirectory(java.io.File cacheDirectory)
Parameters:
cacheDirectory - The cacheDirectory to set.

getThemeDao

public ThemeDao getThemeDao()
Returns:
Returns the themeDao.

setThemeDao

public void setThemeDao(ThemeDao themeDao)
Parameters:
themeDao - The themeDao to set.

getDefaultThemeName

public java.lang.String getDefaultThemeName()
Returns:
Returns the defaultThemeName.

setDefaultThemeName

public void setDefaultThemeName(java.lang.String defaultThemeName)
Parameters:
defaultThemeName - The defaultThemeName to set.

getDefaultThemeTemplate

public java.util.Map<java.lang.String,java.lang.Object> getDefaultThemeTemplate()
Returns:
Returns the defaultThemeTemplate.

setDefaultThemeTemplate

public void setDefaultThemeTemplate(java.util.Map<java.lang.String,java.lang.Object> defaultThemeTemplate)
Parameters:
defaultThemeTemplate - The defaultThemeTemplate to set.

getSharedAlbumUrlTemplate

public java.lang.String getSharedAlbumUrlTemplate()
Returns:
Returns the sharedAlbumUrlTemplate.

setSharedAlbumUrlTemplate

public void setSharedAlbumUrlTemplate(java.lang.String sharedAlbumUrlTemplate)
Parameters:
sharedAlbumUrlTemplate - The sharedAlbumUrlTemplate to set.

getExternalThemeDirectory

public java.lang.String getExternalThemeDirectory()
Returns:
the externalThemeDirectory

setExternalThemeDirectory

public void setExternalThemeDirectory(java.lang.String externalThemeDirectory)
Parameters:
externalThemeDirectory - the externalThemeDirectory to set

getAlbumDao

public AlbumDao getAlbumDao()
Returns:
the albumDao

setAlbumDao

public void setAlbumDao(AlbumDao albumDao)
Parameters:
albumDao - the albumDao to set

getSettingsDao

public magoffin.matt.xweb.util.XwebParamDao getSettingsDao()
Returns:
the settingsDao

setSettingsDao

public void setSettingsDao(magoffin.matt.xweb.util.XwebParamDao settingsDao)
Parameters:
settingsDao - the settingsDao to set

getResourceDirectory

public java.io.File getResourceDirectory()
Description copied from interface: SystemBiz
Get a directory for storing user resources in.

Specified by:
getResourceDirectory in interface SystemBiz
Returns:
the resourceDirectory

setResourceDirectory

public void setResourceDirectory(java.io.File resourceDirectory)
Parameters:
resourceDirectory - the resourceDirectory to set

getMessages

public magoffin.matt.xweb.util.MessagesSource getMessages()
Returns:
the messages

setMessages

public void setMessages(magoffin.matt.xweb.util.MessagesSource messages)
Parameters:
messages - the messages to set