Class DefaultThumbnailManager

    • Constructor Detail

      • DefaultThumbnailManager

        public DefaultThumbnailManager()
    • Method Detail

      • isThumbnailable

        public boolean isThumbnailable​(@Nullable Attachment attachment)
        Description copied from interface: ThumbnailManager
        Checks the content type/mime type of the attachment to determine whether a thumbnail can be created from it
        Specified by:
        isThumbnailable in interface ThumbnailManager
        Parameters:
        attachment - the attachment
        Returns:
        true if the attachment can have thumbnail, otherwise false
      • isThumbnailable

        public static boolean isThumbnailable​(String mimeType)
      • isThumbnailable

        public boolean isThumbnailable​(@NonNull ThumbnailInfo info)
        Description copied from interface: ThumbnailManager
        Check the thumbnail information to determine whether a thumbnail can be created from it
        Specified by:
        isThumbnailable in interface ThumbnailManager
        Parameters:
        info - the thumbnail information
        Returns:
        true if it can have thumbnail, otherwise false
      • getThumbnailData

        public InputStream getThumbnailData​(@NonNull Attachment attachment)
                                     throws FileNotFoundException
        Description copied from interface: ThumbnailManager
        Retrieves the thumbnail data (as a stream) of the latest version from where it was stored in the file system. This function assumes that the thumbnail has been created i.e getThumbnail has been called.
        Specified by:
        getThumbnailData in interface ThumbnailManager
        Parameters:
        attachment - the attachment
        Returns:
        the input stream of the thumbnail
        Throws:
        FileNotFoundException - if the thumbnail file is not found
      • getThumbnailData

        public InputStream getThumbnailData​(@NonNull Attachment attachment,
                                            @Nullable ImageDimensions imageDimensions)
                                     throws FileNotFoundException
        Description copied from interface: ThumbnailManager
        Retrieves the thumbnail data (as a stream) of the latest version from where it was stored in the file system. This function assumes that the thumbnail has been created. i.e getThumbnail has been called.
        Specified by:
        getThumbnailData in interface ThumbnailManager
        Parameters:
        attachment - the attachment
        imageDimensions - image dimensions of the thumbnail
        Returns:
        the input stream of the thumbnail
        Throws:
        FileNotFoundException - if the thumbnail file is not found
      • getThumbnail

        public com.atlassian.core.util.thumbnail.Thumbnail getThumbnail​(@NonNull Attachment attachment,
                                                                        @Nullable ImageDimensions imageDimensions)
                                                                 throws IllegalArgumentException
        Description copied from interface: ThumbnailManager
        Returns a thumbnail for this attachment having ensured the thumbnail exists in the filesystem, generating it only if it doesn't already exist. The size of the thumbnail is set in parameters, if it doesn't exist, then use the application's configuration.
        Specified by:
        getThumbnail in interface ThumbnailManager
        Parameters:
        attachment - the attachment
        imageDimensions - image dimensions of the thumbnail
        Returns:
        the thumbnail of the attachment
        Throws:
        IllegalArgumentException - if the attachment is an inappropriate type for thumbnailing, i.e. ThumbnailManager.isThumbnailable(Attachment) returns false
      • getThumbnailInfo

        public ThumbnailInfo getThumbnailInfo​(@NonNull Attachment attachment)
                                       throws CannotGenerateThumbnailException
        Description copied from interface: ThumbnailManager
        Return the details of a thumbnail for a given attachment without actually creating the thumbnail file on disk. The address of the thumbnail will be rooted at the context path, rather than the base url. The thumbnail maximum size is taken from the global settings.
        Specified by:
        getThumbnailInfo in interface ThumbnailManager
        Parameters:
        attachment - the attachment
        Returns:
        the thumbnail information of the attachment, never null
        Throws:
        CannotGenerateThumbnailException - if no thumbnail information can be generated for this thumbnail
      • getThumbnailInfo

        public ThumbnailInfo getThumbnailInfo​(@NonNull Attachment attachment,
                                              @Nullable ImageDimensions imageDimensions)
                                       throws CannotGenerateThumbnailException
        Description copied from interface: ThumbnailManager
        Return the details of a thumbnail for a given attachment without actually creating the thumbnail file on disk. The address of the thumbnail will be rooted at the context path, rather than the base url. The thumbnail maximum size is set in parameters, if it doesn't exist, then taken from the global settings.
        Specified by:
        getThumbnailInfo in interface ThumbnailManager
        Parameters:
        attachment - the attachment
        imageDimensions - image dimensions of the thumbnail
        Returns:
        the thumbnail information of the attachment, never null
        Throws:
        CannotGenerateThumbnailException - if no thumbnail information can be generated for this thumbnail
      • setBootstrapManager

        public void setBootstrapManager​(BootstrapManager bootstrapManager)
      • setConfluenceHome

        public void setConfluenceHome​(com.atlassian.dc.filestore.api.compat.FilesystemPath confluenceHome)
      • getThumbnailPath

        public com.atlassian.dc.filestore.api.compat.FilesystemPath getThumbnailPath​(long attachmentId,
                                                                                     int version,
                                                                                     long contentId)
        Specified by:
        getThumbnailPath in interface ThumbnailManagerInternal
      • removeThumbnail

        public boolean removeThumbnail​(@NonNull Attachment attachment)
        Removes the thumbnail for the specified attachment
        Specified by:
        removeThumbnail in interface ThumbnailManager
        Parameters:
        attachment - the attachment
        Returns:
        true if the thumbnail was found and was successfully removed, false if no thumbnail was found or the thumbnail could not be removed
      • setSettingsManager

        public void setSettingsManager​(GlobalSettingsManager settingsManager)
        Since:
        7.20
      • setImageDetailsManager

        public void setImageDetailsManager​(ImageDetailsManager imageDetailsManager)