Class Attachment

    • Constructor Detail

      • Attachment

        public Attachment()
      • Attachment

        public Attachment​(@NonNull String fileName,
                          @NonNull String mediaType,
                          long fileSize,
                          String versionComment,
                          boolean minorEdit)
      • Attachment

        public Attachment​(@NonNull String fileName,
                          @NonNull String mediaType,
                          long fileSize,
                          String versionComment)
        Constructs a new Attachment.
    • Method Detail

      • getFileName

        public @NonNull String getFileName()
        Description copied from interface: SearchableAttachment
        Gets the filename of this attachment. If there is no filename, return the empty string. This method should never return null.
        Specified by:
        getFileName in interface SearchableAttachment
        Returns:
        the filename of this attachment, or the empty string if there is no filename
      • setFileName

        public void setFileName​(@NonNull String fileName)
      • getMediaType

        public @NonNull String getMediaType()
      • setMediaType

        public void setMediaType​(@NonNull String mediaType)
      • getContentType

        @Deprecated
        public @NonNull String getContentType()
        Deprecated.
        Since 5.7. Use getMediaType() instead
        Description copied from interface: SearchableAttachment
        Gets the MIME content-type of this attachment. If there is no content-type, return "application/x-unknown". Should never return null.
        Specified by:
        getContentType in interface SearchableAttachment
        Returns:
        the MIME content-type of the attachment, or "application/x-unknown" if the MIME type is unknown
      • isMinorEdit

        public boolean isMinorEdit()
        Indicates whether this attachment is supposed to be hidden under normal circumstances. At the moment this is only used to avoid sending notifications and to hide them in the activity stream. Future usages should be hiding them by default in the attachment macro output
        Returns:
        true, if the attachment is hidden
      • setMinorEdit

        public void setMinorEdit​(boolean minorEdit)
      • getFileStoreId

        public String getFileStoreId()
        Returns:
        FileStore ID of the binary data of this attachment
        Since:
        5.9
      • setFileStoreId

        public void setFileStoreId​(String fileStoreId)
        Since:
        5.9
      • isHidden

        public boolean isHidden()
        Indicates whether this attachment is supposed to be strictly hidden from displaying and searching Hidden attachment is not indexable Hidden attachment manipulation will not trigger external notification events
        Returns:
        true, if the attachment is hidden
      • setHidden

        public void setHidden​(boolean hidden)
      • getFileSize

        public long getFileSize()
        Returns:
        The size (in bytes) of the attachment's raw binary data
      • setFileSize

        public void setFileSize​(long fileSize)
      • getNiceType

        public String getNiceType()
        Specified by:
        getNiceType in interface SearchableAttachment
        Returns:
        A nice type for this file if possible (eg "PDF" or "Word") - or null if no nice type can be recognised
      • getType

        public String getType()
        Description copied from class: ContentEntityObject
        An easy name for the type of this content: makes it easy for things like the #contentLink macro to work out what to draw.

        This is a bit of a hack, but it saves heaps of code elsewhere, especially since we tend to get back these objects wrapped in all sorts of Hibernate CGLIB stuff.

        Specified by:
        getType in interface ContentTypeAware
        Specified by:
        getType in class ContentEntityObject
        Returns:
        the content type
      • getDisplayTitle

        public String getDisplayTitle()
        Description copied from class: ContentEntityObject
        Returns the display title. Some entities don't have titles for identification. For example, personal information objects use the user's fullname. Override this method to provide a custom title.
        Specified by:
        getDisplayTitle in interface Addressable
        Overrides:
        getDisplayTitle in class ContentEntityObject
        Returns:
        the display title
      • isUserProfilePicture

        public boolean isUserProfilePicture()
        Determines whether the Attachment is a user's profile picture
        Returns:
        true if it is attached to a PersonalInformation object and has the correct comment
      • isIndexable

        public boolean isIndexable()
        Only the current version of a non-hidden attachment is indexable (until we can deal with old objects in search results) We also don't want to index attachments associated with drafts or global descriptions or hidden attachments
        Specified by:
        isIndexable in interface Searchable
        Overrides:
        isIndexable in class SpaceContentEntityObject
      • getDownloadPathWithoutVersion

        public String getDownloadPathWithoutVersion()
        Returns the download path without any version info.
      • getDownloadPathWithoutVersionOrApiRevision

        public String getDownloadPathWithoutVersionOrApiRevision()
        Returns the download path without any version info or API revision.
        Since:
        5.10
      • getDownloadPath

        public String getDownloadPath​(String attachmentPath,
                                      boolean addVersionInfo)
        Returns the download path of the attachment for a given attachmentPath prefix. It basically appends the filename and some meta info to form the path.
      • getDownloadPathWithoutEncoding

        public String getDownloadPathWithoutEncoding()
      • getExportPath

        public String getExportPath()
      • getExportPathForThumbnail

        public String getExportPathForThumbnail()
      • getFileExtension

        public String getFileExtension()
        Returns the file extension of the attachment. If there is no extension, an empty string is returned.
        Returns:
        the file extension of the attachment in lower case
      • getDescriptionForMimeType

        public static String getDescriptionForMimeType​(String mimeType,
                                                       String fileExtension)
        Parameters:
        mimeType - the mime type to be described. Should not be null
        fileExtension - the file extension to help with the deriving of the description.
        Returns:
        A more displayable description for the supplied mime type. If a blank String is supplied then null will be returned.
      • getImageDetailsDTO

        protected Collection getImageDetailsDTO()
        accessor methods provided for hibernate proxy use only. use ImageDetailsManager.getImageDetails(Attachment attachment)
      • setImageDetailsDTO

        protected void setImageDetailsDTO​(Set imageDetailDTOs)
      • shouldConvertToContent

        public boolean shouldConvertToContent()
        Specified by:
        shouldConvertToContent in interface ContentConvertible
        Returns:
        true if the implementer wants to be part of the core API (default value), false otherwise
      • copyLatestVersion

        public Attachment copyLatestVersion()
        Will copy all detail information of an attachment including : - Content Properties - File Name - File Size - Content Type - And set version is 1

        NOTE: it won't copy content history

        Returns:
        a copy instance
        Since:
        5.10