com.atlassian.confluence.core
Class DefaultDataSourceFactory

java.lang.Object
  extended by com.atlassian.confluence.core.DefaultDataSourceFactory
All Implemented Interfaces:
DataSourceFactory, org.springframework.web.context.ServletContextAware

public class DefaultDataSourceFactory
extends java.lang.Object
implements DataSourceFactory, org.springframework.web.context.ServletContextAware


Nested Class Summary
static class DefaultDataSourceFactory.NamedDataSource
           
 
Constructor Summary
DefaultDataSourceFactory(UserAccessor userAccessor, AttachmentManager attachmentManager, ContentEntityObjectDao contentEntityObjectDao, javax.activation.FileTypeMap fileTypeMap, ThumbnailManager thumbnailManager, com.atlassian.plugin.PluginAccessor pluginAccessor, SpaceLogoManager spaceLogoManager, com.atlassian.plugin.webresource.WebResourceIntegration webResourceIntegration)
           
 
Method Summary
 com.atlassian.fugue.Maybe<PluginDataSourceFactory> forPlugin(java.lang.String pluginKey)
          Create a factory for a specific plugin.
 javax.activation.DataSource getAvatar(com.atlassian.user.User user)
          Construct a DataSource for a user's profile picture.
 javax.activation.DataSource getDatasource(Attachment attachment, boolean useThumbnail)
           
 javax.activation.DataSource getServletContainerResource(java.lang.String path, java.lang.String name)
           
 javax.activation.DataSource getSpaceLogo(Space space)
          Encapsulates the logo for the given Space in a DataSource.
 javax.activation.DataSource getURLResource(java.net.URL url, java.lang.String name)
          //TODO caching datasource
 void setServletContext(javax.servlet.ServletContext servletContext)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultDataSourceFactory

public DefaultDataSourceFactory(UserAccessor userAccessor,
                                AttachmentManager attachmentManager,
                                ContentEntityObjectDao contentEntityObjectDao,
                                javax.activation.FileTypeMap fileTypeMap,
                                ThumbnailManager thumbnailManager,
                                com.atlassian.plugin.PluginAccessor pluginAccessor,
                                SpaceLogoManager spaceLogoManager,
                                com.atlassian.plugin.webresource.WebResourceIntegration webResourceIntegration)
Method Detail

getAvatar

public javax.activation.DataSource getAvatar(com.atlassian.user.User user)
Description copied from interface: DataSourceFactory
Construct a DataSource for a user's profile picture.

Specified by:
getAvatar in interface DataSourceFactory
Parameters:
user - The user to retrieve the avatar for. If null, "Anonymous" will be assumed.
Returns:
A DataSource containing the user's profile picture. DataSource.getName() will return the string "avatar_[hash]", where [hash] is an md5 hash of the user's name plus the avatar's filename.

getSpaceLogo

public javax.activation.DataSource getSpaceLogo(Space space)
Description copied from interface: DataSourceFactory
Encapsulates the logo for the given Space in a DataSource.

Specified by:
getSpaceLogo in interface DataSourceFactory
Parameters:
space - the space to retrieve the logo for
Returns:
a DataSource encapsulating the ...

  1. custom logo for a Space if configured
  2. default Space logo if configured
  3. default Confluence Space logo, SpaceLogo.DEFAULT_LOGO_PATH
DataSource.getName() will return "<spacekey>-space-logo"

getServletContainerResource

public javax.activation.DataSource getServletContainerResource(java.lang.String path,
                                                               java.lang.String name)
Specified by:
getServletContainerResource in interface DataSourceFactory
Parameters:
path - a path that must begin with a "/" and is interpreted as relative to the current context root
name - a custom name for the DataSource that will be returned.
Returns:
a DataSource containing the resource located at the path. DataSource.getName() will return the value of .

getDatasource

public javax.activation.DataSource getDatasource(Attachment attachment,
                                                 boolean useThumbnail)
                                          throws java.io.IOException
Specified by:
getDatasource in interface DataSourceFactory
Throws:
java.io.IOException

getURLResource

public javax.activation.DataSource getURLResource(java.net.URL url,
                                                  java.lang.String name)
//TODO caching datasource

Specified by:
getURLResource in interface DataSourceFactory

setServletContext

public void setServletContext(javax.servlet.ServletContext servletContext)
Specified by:
setServletContext in interface org.springframework.web.context.ServletContextAware

forPlugin

public com.atlassian.fugue.Maybe<PluginDataSourceFactory> forPlugin(java.lang.String pluginKey)
Description copied from interface: DataSourceFactory
Create a factory for a specific plugin.

Allows the creation of DataSources from <resource> descriptors.

Specified by:
forPlugin in interface DataSourceFactory
Parameters:
pluginKey - the key used to locate the plugin
Returns:
maybe the factory for the plugin if it could be located


Copyright © 2003-2014 Atlassian. All Rights Reserved.