Package org.dspace.content.packager
Class PDFPackager
java.lang.Object
org.dspace.core.SelfNamedPlugin
org.dspace.content.packager.PDFPackager
- All Implemented Interfaces:
PackageDisseminator,PackageIngester,NameAwarePlugin
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static String[]protected static final Stringprotected final BitstreamFormatServiceprotected final BitstreamServiceprotected final BundleServiceprotected final ItemServiceprotected final WorkspaceItemService -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddisseminate(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.disseminateAll(Context context, DSpaceObject dso, PackageParameters params, File pkgFile) disseminateAll() cannot be implemented for a PDF disseminator, because there's only one PDF to disseminategetMIMEType(PackageParameters params) Identifies the MIME-type of this package, i.e.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[]ingest(Context context, DSpaceObject parent, File pkgFile, PackageParameters params, String license) Create new Item out of the ingested package, in the indicated collection.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 ingestreplace(Context context, DSpaceObject dso, File pkgFile, PackageParameters params) Replace is not implemented.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 Details
-
BITSTREAM_FORMAT_NAME
- See Also:
-
aliases
-
bitstreamService
-
bundleService
-
bitstreamFormatService
-
itemService
-
workspaceItemService
-
-
Constructor Details
-
PDFPackager
public PDFPackager()
-
-
Method Details
-
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
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
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
-