Class DefaultThumbnailManager
- java.lang.Object
-
- com.atlassian.confluence.pages.thumbnail.DefaultThumbnailManager
-
- All Implemented Interfaces:
ThumbnailManagerInternal
,ThumbnailManager
public class DefaultThumbnailManager extends Object implements ThumbnailManagerInternal
-
-
Field Summary
-
Fields inherited from interface com.atlassian.confluence.pages.thumbnail.ThumbnailManager
THUMBNAIL_IMAGE_DARK_FEATURE, THUMBNAIL_PATH_SUFFIX
-
Fields inherited from interface com.atlassian.confluence.impl.pages.thumbnail.ThumbnailManagerInternal
THUMBNAIL_DIR_NAME
-
-
Constructor Summary
Constructors Constructor Description DefaultThumbnailManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description com.atlassian.core.util.thumbnail.Thumbnail
getThumbnail(@NonNull Attachment attachment)
Returns a thumbnail for this attachment having ensured the thumbnail exists in the filesystem, generating it only if it doesn't already exist.com.atlassian.core.util.thumbnail.Thumbnail
getThumbnail(@NonNull Attachment attachment, @Nullable ImageDimensions imageDimensions)
Returns a thumbnail for this attachment having ensured the thumbnail exists in the filesystem, generating it only if it doesn't already exist.InputStream
getThumbnailData(@NonNull Attachment attachment)
Retrieves the thumbnail data (as a stream) of the latest version from where it was stored in the file system.InputStream
getThumbnailData(@NonNull Attachment attachment, @Nullable ImageDimensions imageDimensions)
Retrieves the thumbnail data (as a stream) of the latest version from where it was stored in the file system.ThumbnailInfo
getThumbnailInfo(@NonNull Attachment attachment)
Return the details of a thumbnail for a given attachment without actually creating the thumbnail file on disk.ThumbnailInfo
getThumbnailInfo(@NonNull Attachment attachment, @Nullable ImageDimensions imageDimensions)
Return the details of a thumbnail for a given attachment without actually creating the thumbnail file on disk.ThumbnailInfo
getThumbnailInfo(@NonNull Attachment attachment, @Nullable String remoteAttachmentPath)
Return the details of a thumbnail for a given attachment without actually creating the thumbnail file on disk.ThumbnailInfo
getThumbnailInfo(@NonNull Attachment attachment, @Nullable String remoteAttachmentPath, @Nullable ImageDimensions imageDimensions)
Return the details of a thumbnail for a given attachment without actually creating the thumbnail file on disk.com.atlassian.dc.filestore.api.compat.FilesystemPath
getThumbnailPath(long attachmentId, int version, long contentId)
com.atlassian.dc.filestore.api.compat.FilesystemPath
getThumbnailPath(@NonNull Attachment attachment, @Nullable ImageDimensions imageDimensions)
protected File
getThumbnailsFolder(Attachment attachment)
Deprecated.since 7.14boolean
isThumbnailable(@NonNull ThumbnailInfo info)
Check the thumbnail information to determine whether a thumbnail can be created from itboolean
isThumbnailable(@Nullable Attachment attachment)
Checks the content type/mime type of the attachment to determine whether a thumbnail can be created from itstatic boolean
isThumbnailable(String mimeType)
boolean
removeThumbnail(@NonNull Attachment attachment)
Removes the thumbnail for the specified attachmentvoid
setBootstrapManager(BootstrapManager bootstrapManager)
void
setConfluenceHome(com.atlassian.dc.filestore.api.compat.FilesystemPath confluenceHome)
void
setImageDetailsManager(ImageDetailsManager imageDetailsManager)
void
setSettingsManager(GlobalSettingsManager settingsManager)
void
setSettingsManager(SettingsManager settingsManager)
Deprecated.since 7.20 UsesetSettingsManager(GlobalSettingsManager)
void
setThumbnailRenderer(DelegatingThumbnailRenderer thumbnailRenderer)
-
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.impl.pages.thumbnail.ThumbnailManagerInternal
getThumbnailFile, getThumbnailFile, getThumbnailFile
-
-
-
-
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 interfaceThumbnailManager
- 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 interfaceThumbnailManager
- 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 interfaceThumbnailManager
- 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 interfaceThumbnailManager
- Parameters:
attachment
- the attachmentimageDimensions
- 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) 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 by the application's configuration.- Specified by:
getThumbnail
in interfaceThumbnailManager
- Parameters:
attachment
- the attachment- Returns:
- the thumbnail if the attachment
- Throws:
IllegalArgumentException
- if the attachment is an inappropriate type for thumbnailing, i.e.ThumbnailManager.isThumbnailable(Attachment)
returns false
-
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 interfaceThumbnailManager
- Parameters:
attachment
- the attachmentimageDimensions
- 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 interfaceThumbnailManager
- 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 interfaceThumbnailManager
- Parameters:
attachment
- the attachmentimageDimensions
- 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
-
getThumbnailInfo
public ThumbnailInfo getThumbnailInfo(@NonNull Attachment attachment, @Nullable String remoteAttachmentPath) 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 interfaceThumbnailManager
- Parameters:
attachment
- the attachmentremoteAttachmentPath
- path to the thumbnail, excepting the thumbnail itself. Eg the value returned byConfluenceRenderUtils.getAttachmentRemotePath(com.atlassian.confluence.pages.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 String remoteAttachmentPath, @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 interfaceThumbnailManager
- Parameters:
attachment
- the attachmentremoteAttachmentPath
- path to the thumbnail, excepting the thumbnail itself. Eg the value returned byConfluenceRenderUtils.getAttachmentRemotePath(com.atlassian.confluence.pages.Attachment)
.imageDimensions
- image dimensions of the thumbnail- Returns:
- thumbnail information for 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)
-
getThumbnailsFolder
@Deprecated protected File getThumbnailsFolder(Attachment attachment)
Deprecated.since 7.14
-
getThumbnailPath
public com.atlassian.dc.filestore.api.compat.FilesystemPath getThumbnailPath(@NonNull Attachment attachment, @Nullable ImageDimensions imageDimensions)
- Specified by:
getThumbnailPath
in interfaceThumbnailManagerInternal
-
getThumbnailPath
public com.atlassian.dc.filestore.api.compat.FilesystemPath getThumbnailPath(long attachmentId, int version, long contentId)
- Specified by:
getThumbnailPath
in interfaceThumbnailManagerInternal
-
removeThumbnail
public boolean removeThumbnail(@NonNull Attachment attachment)
Removes the thumbnail for the specified attachment- Specified by:
removeThumbnail
in interfaceThumbnailManager
- 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
-
setThumbnailRenderer
public void setThumbnailRenderer(DelegatingThumbnailRenderer thumbnailRenderer)
-
setSettingsManager
@Deprecated public void setSettingsManager(SettingsManager settingsManager)
Deprecated.since 7.20 UsesetSettingsManager(GlobalSettingsManager)
-
setSettingsManager
public void setSettingsManager(GlobalSettingsManager settingsManager)
- Since:
- 7.20
-
setImageDetailsManager
public void setImageDetailsManager(ImageDetailsManager imageDetailsManager)
-
-