Interface DataSourceFactory


public interface DataSourceFactory
Since:
10.0
  • Method Details

    • getAvatar

      DataSource getAvatar(ConfluenceUser user)
      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

      DataSource getSpaceLogo(Space space) throws IOException
      Encapsulates the logo for the given Space in a DataSource.
      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"
      Throws:
      IOException
    • getServletContainerResource

      DataSource getServletContainerResource(String path, String name) throws IOException
      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 .
      Throws:
      IOException
    • getURLResource

      DataSource getURLResource(URL url, String name)
    • getDatasource

      DataSource getDatasource(Attachment attachment, boolean useThumbnail) throws IOException
      Throws:
      IOException
    • getDataSource

      DataSource getDataSource(InputStream inputStream, String mimeType) throws IOException
      Throws:
      IOException
    • getDataSource

      DataSource getDataSource(byte[] bytes, String mimeType)
    • getResourcesFromModules

      Iterable<DataSource> getResourcesFromModules(com.atlassian.plugin.ModuleCompleteKey moduleKey, @Nullable Predicate<ResourceModuleDescriptor> filter)
      Extract resources from a module and expose them as DataSources.
      Parameters:
      moduleKey - the key used to locate the module
      filter - 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 as DataSources.
      See Also:
      • invalid reference
        #getResourcesFromModules(String, Predicate)
    • getResourceFromModuleByName

      Optional<DataSource> getResourceFromModuleByName(com.atlassian.plugin.ModuleCompleteKey moduleKey, String resourceName)
      Extract a resource identified by name from a module and expose it as DataSource.
      Parameters:
      moduleKey - the key used to locate the module
      resourceName - the name of the resource
      Returns:
      maybe the DataSource if the module could be located and contained a resource with the given name