Package com.atlassian.confluence.core
Class DefaultDataSourceFactory
- java.lang.Object
-
- com.atlassian.confluence.core.DefaultDataSourceFactory
-
- All Implemented Interfaces:
DataSourceFactory
,org.springframework.beans.factory.Aware
,org.springframework.web.context.ServletContextAware
public class DefaultDataSourceFactory extends Object implements DataSourceFactory, org.springframework.web.context.ServletContextAware
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DefaultDataSourceFactory.NamedDataSource
-
Constructor Summary
Constructors Constructor Description DefaultDataSourceFactory(UserProfilePictureAccessor userProfilePictureAccessor, AttachmentManager attachmentManager, javax.activation.FileTypeMap fileTypeMap, ThumbnailManager thumbnailManager, com.atlassian.plugin.PluginAccessor pluginAccessor, SpaceLogoManager spaceLogoManager)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description com.atlassian.fugue.Maybe<PluginDataSourceFactory>
forPlugin(String pluginKey)
Deprecated.since 7.0.1.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(String path, String name)
javax.activation.DataSource
getSpaceLogo(Space space)
Encapsulates the logo for the givenSpace
in aDataSource
.javax.activation.DataSource
getURLResource(URL url, String name)
//TODO caching datasourcevoid
setServletContext(javax.servlet.ServletContext servletContext)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.atlassian.confluence.core.DataSourceFactory
createForPlugin
-
-
-
-
Constructor Detail
-
DefaultDataSourceFactory
public DefaultDataSourceFactory(UserProfilePictureAccessor userProfilePictureAccessor, AttachmentManager attachmentManager, javax.activation.FileTypeMap fileTypeMap, ThumbnailManager thumbnailManager, com.atlassian.plugin.PluginAccessor pluginAccessor, SpaceLogoManager spaceLogoManager)
- Since:
- 7.16
-
-
Method Detail
-
getAvatar
public javax.activation.DataSource getAvatar(com.atlassian.user.User user)
Construct a DataSource for a user's profile picture. Always returns PNG version for default or anonymous profile picture- Specified by:
getAvatar
in interfaceDataSourceFactory
- 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 givenSpace
in aDataSource
.- Specified by:
getSpaceLogo
in interfaceDataSourceFactory
- Parameters:
space
- the space to retrieve the logo for- Returns:
- a
DataSource
encapsulating the ...- custom logo for a
Space
if configured - default
Space
logo if configured - default Confluence
Space
logo,SpaceLogo.DEFAULT_LOGO_PATH
DataSource.getName()
will return "<spacekey>-space-logo" - custom logo for a
-
getServletContainerResource
public javax.activation.DataSource getServletContainerResource(String path, String name)
- Specified by:
getServletContainerResource
in interfaceDataSourceFactory
- Parameters:
path
- a path that must begin with a "/" and is interpreted as relative to the current context rootname
- 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 {@param name}.
-
getDatasource
public javax.activation.DataSource getDatasource(Attachment attachment, boolean useThumbnail) throws IOException
- Specified by:
getDatasource
in interfaceDataSourceFactory
- Throws:
IOException
-
getURLResource
public javax.activation.DataSource getURLResource(URL url, String name)
//TODO caching datasource- Specified by:
getURLResource
in interfaceDataSourceFactory
-
setServletContext
public void setServletContext(javax.servlet.ServletContext servletContext)
- Specified by:
setServletContext
in interfaceorg.springframework.web.context.ServletContextAware
-
forPlugin
@Deprecated public com.atlassian.fugue.Maybe<PluginDataSourceFactory> forPlugin(String pluginKey)
Deprecated.since 7.0.1. UseDataSourceFactory.createForPlugin(String)
Description copied from interface:DataSourceFactory
Create a factory for a specific plugin.Allows the creation of
DataSources
from <resource> descriptors.- Specified by:
forPlugin
in interfaceDataSourceFactory
- Parameters:
pluginKey
- the key used to locate the plugin- Returns:
- maybe the factory for the plugin if it could be located
-
-