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
        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

        public @NonNull String getContentType()
        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
        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
        true, if the attachment is hidden
      • setMinorEdit

        public void setMinorEdit​(boolean minorEdit)
      • getFileStoreId

        public String getFileStoreId()
        FileStore ID of the binary data of this attachment
      • setFileStoreId

        public void setFileStoreId​(String fileStoreId)
      • 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
        true, if the attachment is hidden
      • setHidden

        public void setHidden​(boolean hidden)
      • getFileSize

        public long getFileSize()
        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
        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
        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
        getDisplayTitle in class ContentEntityObject
        the display title
      • isUserProfilePicture

        public boolean isUserProfilePicture()
        Determines whether the Attachment is a user's profile picture
        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
        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.
      • 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.
        the file extension of the attachment in lower case
      • getDescriptionForMimeType

        public static String getDescriptionForMimeType​(String mimeType,
                                                       String fileExtension)
        mimeType - the mime type to be described. Should not be null
        fileExtension - the file extension to help with the deriving of the description.
        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
        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

        a copy instance