Class AttachmentLink


  • public class AttachmentLink
    extends FileLink
    A Web link to an attachment of a contribution in Silverpeas to render in a notification message. It extends the FileLink class by providing useful methods for templates.
    Author:
    mmoquillon
    • Constructor Detail

      • AttachmentLink

        public AttachmentLink​(String linkUrl,
                              String linkLabel,
                              long linkSize,
                              String language)
        Constructs a new link with the specified URL, labels and file size.
        Parameters:
        linkUrl - the URL of the linked file.
        linkLabel - the label to render for that link.
        linkSize - the size in byte of the linked file.
        language - the language of the attachment.
    • Method Detail

      • getForContribution

        public static List<AttachmentLink> getForContribution​(ResourceReference resource,
                                                              String language)
        Gets all the web links to all of the documents attached to the specified contribution in Silverpeas and for the given language.
        Parameters:
        resource - a reference to the contribution in Silverpeas.
        language - the ISO 631-1 code of the language in which the attachments have to be get.
        Returns:
        a list of Web links to the attachments. If the contribution have no attachments, then an empty list is returned.
      • getFormattedLinkSize

        public String getFormattedLinkSize()
        Gets the size of the file referred by this link in text format. This method is used by templates to indicate the size of the attached document targeted by this link.
        Returns:
        the size of the linked file expressed into the more suitable size unit.