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 Object
implements DataSourceFactory, org.springframework.web.context.ServletContextAware


Nested Class Summary
static class DefaultDataSourceFactory.NamedDataSource
           
 
Constructor Summary
DefaultDataSourceFactory(UserAccessor userAccessor, AttachmentManager attachmentManager, FileTypeMap fileTypeMap, ThumbnailManager thumbnailManager, com.atlassian.plugin.PluginAccessor pluginAccessor, SpaceLogoManager spaceLogoManager)
           
 
Method Summary
 com.atlassian.fugue.Maybe<PluginDataSourceFactory> forPlugin(String pluginKey)
          Create a factory for a specific plugin.
 DataSource getAvatar(com.atlassian.user.User user)
          Construct a DataSource for a user's profile picture.
 DataSource getDatasource(Attachment attachment, boolean useThumbnail)
           
 DataSource getServletContainerResource(String path, String name)
           
 DataSource getSpaceLogo(Space space)
          Encapsulates the logo for the given Space in a DataSource.
 DataSource getURLResource(URL url, 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,
                                FileTypeMap fileTypeMap,
                                ThumbnailManager thumbnailManager,
                                com.atlassian.plugin.PluginAccessor pluginAccessor,
                                SpaceLogoManager spaceLogoManager)
Method Detail

getAvatar

public 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 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 DataSource getServletContainerResource(String path,
                                              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 DataSource getDatasource(Attachment attachment,
                                boolean useThumbnail)
                         throws IOException
Specified by:
getDatasource in interface DataSourceFactory
Throws:
IOException

getURLResource

public DataSource getURLResource(URL url,
                                 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(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–2015 Atlassian. All rights reserved.