Package org.dspace.content.packager
Class PDFPackager
- java.lang.Object
-
- org.dspace.core.SelfNamedPlugin
-
- org.dspace.content.packager.PDFPackager
-
- All Implemented Interfaces:
PackageDisseminator,PackageIngester
public class PDFPackager extends SelfNamedPlugin implements PackageIngester, PackageDisseminator
Accept a PDF file by itself as a SIP.This is mainly a proof-of-concept to demonstrate the flexibility of the packager and crosswalk plugins.
To import, open up the PDF and try to extract sufficient metadata from its InfoDict.
Export is a crude hack: if the item has a bitstream containing PDF, send that, otherwise it fails. Do not attempt to insert metadata.
- Version:
- $Revision$
- Author:
- Larry Stone
- See Also:
PackageIngester,PackageDisseminator
-
-
Field Summary
Fields Modifier and Type Field Description protected static String[]aliasesprotected static StringBITSTREAM_FORMAT_NAMEprotected BitstreamFormatServicebitstreamFormatServiceprotected BitstreamServicebitstreamServiceprotected BundleServicebundleServiceprotected ItemServiceitemServiceprotected WorkspaceItemServiceworkspaceItemService
-
Constructor Summary
Constructors Constructor Description PDFPackager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddisseminate(Context context, DSpaceObject dso, PackageParameters params, File pkgFile)VERY crude dissemination: just look for the first bitstream with the PDF package type, and toss it out.List<File>disseminateAll(Context context, DSpaceObject dso, PackageParameters params, File pkgFile)disseminateAll() cannot be implemented for a PDF disseminator, because there's only one PDF to disseminateStringgetMIMEType(PackageParameters params)Identifies the MIME-type of this package, i.e.StringgetParameterHelp()Returns a user help string which should describe the additional valid command-line options that this packager implementation will accept when using the-oor--optionflags with the Packager script.static String[]getPluginNames()DSpaceObjectingest(Context context, DSpaceObject parent, File pkgFile, PackageParameters params, String license)Create new Item out of the ingested package, in the indicated collection.List<String>ingestAll(Context context, DSpaceObject parent, File pkgFile, PackageParameters params, String license)IngestAll() cannot be implemented for a PDF ingester, because there's only one PDF to ingestDSpaceObjectreplace(Context context, DSpaceObject dso, File pkgFile, PackageParameters params)Replace is not implemented.List<String>replaceAll(Context context, DSpaceObject dso, File pkgFile, PackageParameters params)ReplaceAll() cannot be implemented for a PDF ingester, because there's only one PDF to ingestprotected voidsetFormatToMIMEType(Context context, Bitstream bs, String mimeType)-
Methods inherited from class org.dspace.core.SelfNamedPlugin
getPluginInstanceName, setPluginInstanceName
-
-
-
-
Field Detail
-
BITSTREAM_FORMAT_NAME
protected static final String BITSTREAM_FORMAT_NAME
- See Also:
- Constant Field Values
-
aliases
protected static String[] aliases
-
bitstreamService
protected final BitstreamService bitstreamService
-
bundleService
protected final BundleService bundleService
-
bitstreamFormatService
protected final BitstreamFormatService bitstreamFormatService
-
itemService
protected final ItemService itemService
-
workspaceItemService
protected final WorkspaceItemService workspaceItemService
-
-
Method Detail
-
getPluginNames
public static String[] getPluginNames()
-
setFormatToMIMEType
protected void setFormatToMIMEType(Context context, Bitstream bs, String mimeType) throws SQLException
- Throws:
SQLException
-
ingest
public DSpaceObject ingest(Context context, DSpaceObject parent, File pkgFile, PackageParameters params, String license) throws PackageValidationException, CrosswalkException, AuthorizeException, SQLException, IOException, WorkflowException
Create new Item out of the ingested package, in the indicated collection. It creates a workspace item, which the application can then install if it chooses to bypass Workflow.This is a VERY crude import of a single Adobe PDF (Portable Document Format) file, using the document's embedded metadata for package metadata. If the PDF file hasn't got the minimal metadata available, it is rejected.
- Specified by:
ingestin interfacePackageIngester- Parameters:
context- DSpace context.parent- collection under which to create new item.pkgFile- The package file to ingestparams- package parameters (none recognized)license- may be null, which takes default license.- Returns:
- workspace item created by ingest.
- Throws:
PackageValidationException- if package invalidCrosswalkException- if crosswalking failsAuthorizeException- if authorization errorSQLException- if database errorIOException- if IO errorWorkflowException- if workflow error
-
ingestAll
public List<String> ingestAll(Context context, DSpaceObject parent, File pkgFile, PackageParameters params, String license) throws PackageException, UnsupportedOperationException, CrosswalkException, AuthorizeException, SQLException, IOException
IngestAll() cannot be implemented for a PDF ingester, because there's only one PDF to ingest- Specified by:
ingestAllin interfacePackageIngester- Parameters:
context- DSpace context.parent- parent under which to create the initial object (may be null -- in which case ingester must determine parent from package or throw an error).pkgFile- The initial package file to ingestparams- Properties-style list of options (interpreted by each packager).license- may be null, which takes default license.- Returns:
- List of Identifiers of DSpaceObjects created
- Throws:
UnsupportedOperationException- if unsupported operationPackageException- if package errorIOException- if IO errorSQLException- if database errorAuthorizeException- if authorization errorCrosswalkException- if crosswalk error
-
replace
public DSpaceObject replace(Context context, DSpaceObject dso, File pkgFile, PackageParameters params) throws PackageException, UnsupportedOperationException, CrosswalkException, AuthorizeException, SQLException, IOException
Replace is not implemented.- Specified by:
replacein interfacePackageIngester- Parameters:
context- DSpace context.dso- existing DSpace Object to be replaced, may be null if object to replace can be determined from packagepkgFile- The package file to ingest.params- Properties-style list of options specific to this packager- Returns:
- DSpaceObject with contents replaced
- Throws:
UnsupportedOperationException- if unsupported operationPackageException- if package errorIOException- if IO errorSQLException- if database errorAuthorizeException- if authorization errorCrosswalkException- if crosswalk error
-
replaceAll
public List<String> replaceAll(Context context, DSpaceObject dso, File pkgFile, PackageParameters params) throws PackageException, UnsupportedOperationException, CrosswalkException, AuthorizeException, SQLException, IOException
ReplaceAll() cannot be implemented for a PDF ingester, because there's only one PDF to ingest- Specified by:
replaceAllin interfacePackageIngester- Parameters:
context- DSpace context.dso- initial existing DSpace Object to be replaced, may be null if object to replace can be determined from packagepkgFile- The package file to ingest.params- Properties-style list of options specific to this packager- Returns:
- List of Identifiers of DSpaceObjects replaced
- Throws:
UnsupportedOperationException- if unsupported operationPackageException- if package errorIOException- if IO errorSQLException- if database errorAuthorizeException- if authorization errorCrosswalkException- if crosswalk error
-
disseminate
public void disseminate(Context context, DSpaceObject dso, PackageParameters params, File pkgFile) throws PackageValidationException, CrosswalkException, AuthorizeException, SQLException, IOException
VERY crude dissemination: just look for the first bitstream with the PDF package type, and toss it out. Works on packages importer with this packager, and maybe some others.- Specified by:
disseminatein interfacePackageDisseminator- Parameters:
dso- DSpaceObjectcontext- DSpace context.params- Properties-style list of options specific to this packagerpkgFile- File where export package should be written- Throws:
CrosswalkException- if crosswalk errorAuthorizeException- if authorization errorSQLException- if database errorIOException- if IO errorPackageValidationException- if package cannot be created or there is a fatal error in creating it.
-
disseminateAll
public List<File> disseminateAll(Context context, DSpaceObject dso, PackageParameters params, File pkgFile) throws PackageException, CrosswalkException, AuthorizeException, SQLException, IOException
disseminateAll() cannot be implemented for a PDF disseminator, because there's only one PDF to disseminate- Specified by:
disseminateAllin interfacePackageDisseminator- Parameters:
context- DSpace context.dso- initial DSpace objectparams- Properties-style list of options specific to this packagerpkgFile- File where initial package should be written. All other packages will be written to the same directory as this File.- Returns:
- List of all package Files which were successfully disseminated
- Throws:
PackageException- if package errorCrosswalkException- if crosswalk errorAuthorizeException- if authorization errorSQLException- if database errorIOException- if IO error
-
getMIMEType
public String getMIMEType(PackageParameters params)
Identifies the MIME-type of this package, i.e. "application/pdf".- Specified by:
getMIMETypein interfacePackageDisseminator- Parameters:
params- package params- Returns:
- the MIME type (content-type header) of the package to be returned
-
getParameterHelp
public String getParameterHelp()
Returns a user help string which should describe the additional valid command-line options that this packager implementation will accept when using the-oor--optionflags with the Packager script.- Specified by:
getParameterHelpin interfacePackageDisseminator- Specified by:
getParameterHelpin interfacePackageIngester- Returns:
- a string describing additional command-line options available with this packager
-
-