Package org.dspace.disseminate.service
Interface CitationDocumentService
-
- All Known Implementing Classes:
CitationDocumentServiceImpl
public interface CitationDocumentServiceThe 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 Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleancanGenerateCitationVersion(Context context, Bitstream bitstream)intdrawStringWordWrap(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)voiddrawTable(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)StringgetAllMetadataSeparated(Item item, String metadataKey)Get metadata separated by value separator (semicolon)StringgetOwningCollection(Item item)Get name of owning collectionStringgetOwningCommunity(Context context, Item item)Get name of owning communityBooleanisCitationEnabledForBitstream(Bitstream bitstream, Context context)Repository policy can specify to have a custom citation cover/tail page to the document, which embeds metadata.org.apache.commons.lang3.tuple.Pair<InputStream,Long>makeCitedDocument(Context context, Bitstream bitstream)Creates a cited document from the given bitstream of the given item.
-
-
-
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 bitstreamcontext- DSpace context- Returns:
- true or false
- Throws:
SQLException- if error
-
canGenerateCitationVersion
boolean canGenerateCitationVersion(Context context, Bitstream bitstream) throws SQLException
- Parameters:
context- DSpace Contextbitstream- DSpace Bitstream- Returns:
- true or false
- Throws:
SQLException- if error
-
makeCitedDocument
org.apache.commons.lang3.tuple.Pair<InputStream,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:
- Load source file into PdfReader and create a Document to put our cover page into.
- Create cover page and add content to it.
- Concatenate the coverpage and the source document.
- Parameters:
context- DSpace contextbitstream- The source bitstream being cited. This must be a PDF.- Returns:
- The temporary File that is the finished, cited document.
- Throws:
IOException- if IO errorSQLException- if database errorAuthorizeException- 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- pagecontentStream- content streamtext- text to drawstartX- x-coordinate of wordstartY- y-coordinate of wordpdfFont- fontfontSize- 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 contextitem- DSpace Item- Returns:
- name
-
getOwningCollection
String getOwningCollection(Item item)
Get name of owning collection- Parameters:
item- DSpace Item- Returns:
- owning collection name
-
getAllMetadataSeparated
String getAllMetadataSeparated(Item item, String metadataKey)
Get metadata separated by value separator (semicolon)- Parameters:
item- DSpace ItemmetadataKey- metadata string- Returns:
- string
- See Also:
DSpaceObjectService.getMetadataByMetadataString(org.dspace.content .DSpaceObject, java.lang.String)
-
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- pagecontentStream- content streamy- the y-coordinate of the first rowmargin- the padding on left and right of tablecontent- a 2d array containing the table datafont- PDFontfontSize- size of font (int)cellBorders- whether to include cellBorders- Throws:
IOException- if error
-
-