Interface CitationDocumentService

  • All Known Implementing Classes:
    CitationDocumentServiceImpl

    public interface CitationDocumentService
    The Citation Document produces a dissemination package (DIP) that is different that the archival package (AIP). In this case we append the descriptive metadata to the end (configurable) of the document. i.e. last page of PDF. So instead of getting the original PDF, you get a cPDF (with citation information added).
    Author:
    Peter Dietz (peter@longsight.com)
    • Method Detail

      • isCitationEnabledForBitstream

        Boolean isCitationEnabledForBitstream​(Bitstream bitstream,
                                              Context context)
                                       throws SQLException
        Repository policy can specify to have a custom citation cover/tail page to the document, which embeds metadata. We need to determine if we will intercept this bitstream download, and give out a citation dissemination rendition. What will trigger a redirect/intercept? Citation enabled globally (all citable bitstreams will get "watermarked") modules/disseminate-citation: enable_globally OR The container is this object is "allow list" enabled. - community: modules/disseminate-citation: enabled_communities - collection: modules/disseminate-citation: enabled_collections AND This User is not an admin. (Admins need to be able to view the "raw" original instead.) AND This object is citation-able (presently, just PDF) The module must be enabled, before the permission level checks happen.
        Parameters:
        bitstream - DSpace bitstream
        context - DSpace context
        Returns:
        true or false
        Throws:
        SQLException - if error
      • canGenerateCitationVersion

        boolean canGenerateCitationVersion​(Context context,
                                           Bitstream bitstream)
                                    throws SQLException
        Parameters:
        context - DSpace Context
        bitstream - DSpace Bitstream
        Returns:
        true or false
        Throws:
        SQLException - if error
      • makeCitedDocument

        org.apache.commons.lang3.tuple.Pair<byte[],​Long> makeCitedDocument​(Context context,
                                                                                 Bitstream bitstream)
                                                                          throws IOException,
                                                                                 SQLException,
                                                                                 AuthorizeException
        Creates a cited document from the given bitstream of the given item. This requires that bitstream is contained in item.

        The Process for adding a cover page is as follows:

        1. Load source file into PdfReader and create a Document to put our cover page into.
        2. Create cover page and add content to it.
        3. Concatenate the coverpage and the source document.
        Parameters:
        context - DSpace context
        bitstream - The source bitstream being cited. This must be a PDF.
        Returns:
        The temporary File that is the finished, cited document.
        Throws:
        IOException - if IO error
        SQLException - if database error
        AuthorizeException - if authorization error
      • drawStringWordWrap

        int drawStringWordWrap​(org.apache.pdfbox.pdmodel.PDPage page,
                               org.apache.pdfbox.pdmodel.PDPageContentStream contentStream,
                               String text,
                               int startX,
                               int startY,
                               org.apache.pdfbox.pdmodel.font.PDFont pdfFont,
                               float fontSize)
                        throws IOException
        Parameters:
        page - page
        contentStream - content stream
        text - text to draw
        startX - x-coordinate of word
        startY - y-coordinate of word
        pdfFont - font
        fontSize - size of font
        Returns:
        integer
        Throws:
        IOException - if IO error
      • getOwningCommunity

        String getOwningCommunity​(Context context,
                                  Item item)
        Get name of owning community
        Parameters:
        context - DSpace context
        item - DSpace Item
        Returns:
        name
      • getOwningCollection

        String getOwningCollection​(Item item)
        Get name of owning collection
        Parameters:
        item - DSpace Item
        Returns:
        owning collection name
      • drawTable

        void drawTable​(org.apache.pdfbox.pdmodel.PDPage page,
                       org.apache.pdfbox.pdmodel.PDPageContentStream contentStream,
                       float y,
                       float margin,
                       String[][] content,
                       org.apache.pdfbox.pdmodel.font.PDFont font,
                       int fontSize,
                       boolean cellBorders)
                throws IOException
        Parameters:
        page - page
        contentStream - content stream
        y - the y-coordinate of the first row
        margin - the padding on left and right of table
        content - a 2d array containing the table data
        font - PDFont
        fontSize - size of font (int)
        cellBorders - whether to include cellBorders
        Throws:
        IOException - if error