Interface DataSourceFactory
public interface DataSourceFactory
- Since:
- 10.0
-
Method Summary
Modifier and TypeMethodDescriptiongetAvatar
(ConfluenceUser user) Construct a DataSource for a user's profile picture.getDatasource
(Attachment attachment, boolean useThumbnail) getDataSource
(byte[] bytes, String mimeType) getDataSource
(InputStream inputStream, String mimeType) getResourceFromModuleByName
(com.atlassian.plugin.ModuleCompleteKey moduleKey, String resourceName) Extract a resource identified by name from a module and expose it asDataSource
.default Iterable
<DataSource> getResourcesFromModules
(com.atlassian.plugin.ModuleCompleteKey moduleKey) Extract all resources from a module and expose them asDataSources
.getResourcesFromModules
(com.atlassian.plugin.ModuleCompleteKey moduleKey, @Nullable Predicate<ResourceModuleDescriptor> filter) Extract resources from a module and expose them asDataSources
.getServletContainerResource
(String path, String name) getSpaceLogo
(Space space) Encapsulates the logo for the givenSpace
in aDataSource
.getURLResource
(URL url, String name)
-
Method Details
-
getAvatar
Construct a DataSource for a user's profile picture.- 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
Encapsulates the logo for the givenSpace
in aDataSource
.- 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
- Throws:
IOException
-
getServletContainerResource
- 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 .
- Throws:
IOException
-
getURLResource
-
getDatasource
- Throws:
IOException
-
getDataSource
- Throws:
IOException
-
getDataSource
-
getResourcesFromModules
Iterable<DataSource> getResourcesFromModules(com.atlassian.plugin.ModuleCompleteKey moduleKey, @Nullable Predicate<ResourceModuleDescriptor> filter) Extract resources from a module and expose them asDataSources
.- Parameters:
moduleKey
- the key used to locate the modulefilter
- an optional filter for resources- Returns:
- maybe the
DataSources
if the module could be located, the container is empty if the filter did not match anything
-
getResourcesFromModules
default Iterable<DataSource> getResourcesFromModules(com.atlassian.plugin.ModuleCompleteKey moduleKey) Extract all resources from a module and expose them asDataSources
.- See Also:
-
getResourceFromModuleByName
Optional<DataSource> getResourceFromModuleByName(com.atlassian.plugin.ModuleCompleteKey moduleKey, String resourceName) Extract a resource identified by name from a module and expose it asDataSource
.- Parameters:
moduleKey
- the key used to locate the moduleresourceName
- the name of the resource- Returns:
- maybe the
DataSource
if the module could be located and contained a resource with the given name
-