public class PDFPackager extends SelfNamedPlugin implements PackageIngester, PackageDisseminator
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.
PackageIngester,
PackageDisseminator| Modifier and Type | Field and Description |
|---|---|
protected static String[] |
aliases |
protected static String |
BITSTREAM_FORMAT_NAME |
protected BitstreamFormatService |
bitstreamFormatService |
protected BitstreamService |
bitstreamService |
protected BundleService |
bundleService |
protected ItemService |
itemService |
protected WorkspaceItemService |
workspaceItemService |
| Constructor and Description |
|---|
PDFPackager() |
| Modifier and Type | Method and Description |
|---|---|
void |
disseminate(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 disseminate
|
String |
getMIMEType(PackageParameters params)
Identifies the MIME-type of this package, i.e.
|
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
-o or
--option flags with the Packager script. |
static String[] |
getPluginNames() |
DSpaceObject |
ingest(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 ingest
|
DSpaceObject |
replace(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 ingest
|
protected void |
setFormatToMIMEType(Context context,
Bitstream bs,
String mimeType) |
getPluginInstanceName, setPluginInstanceNameprotected static final String BITSTREAM_FORMAT_NAME
protected static String[] aliases
protected final BitstreamService bitstreamService
protected final BundleService bundleService
protected final BitstreamFormatService bitstreamFormatService
protected final ItemService itemService
protected final WorkspaceItemService workspaceItemService
public static String[] getPluginNames()
protected void setFormatToMIMEType(Context context, Bitstream bs, String mimeType) throws SQLException
SQLExceptionpublic DSpaceObject ingest(Context context, DSpaceObject parent, File pkgFile, PackageParameters params, String license) throws PackageValidationException, CrosswalkException, AuthorizeException, SQLException, IOException, WorkflowException
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.
ingest in interface PackageIngestercontext - 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.PackageValidationException - if package invalidCrosswalkException - if crosswalking failsAuthorizeException - if authorization errorSQLException - if database errorIOException - if IO errorWorkflowException - if workflow errorpublic List<String> ingestAll(Context context, DSpaceObject parent, File pkgFile, PackageParameters params, String license) throws PackageException, UnsupportedOperationException, CrosswalkException, AuthorizeException, SQLException, IOException
ingestAll in interface PackageIngestercontext - 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.UnsupportedOperationException - if unsupported operationPackageException - if package errorIOException - if IO errorSQLException - if database errorAuthorizeException - if authorization errorCrosswalkException - if crosswalk errorpublic DSpaceObject replace(Context context, DSpaceObject dso, File pkgFile, PackageParameters params) throws PackageException, UnsupportedOperationException, CrosswalkException, AuthorizeException, SQLException, IOException
replace in interface PackageIngestercontext - 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 packagerUnsupportedOperationException - if unsupported operationPackageException - if package errorIOException - if IO errorSQLException - if database errorAuthorizeException - if authorization errorCrosswalkException - if crosswalk errorpublic List<String> replaceAll(Context context, DSpaceObject dso, File pkgFile, PackageParameters params) throws PackageException, UnsupportedOperationException, CrosswalkException, AuthorizeException, SQLException, IOException
replaceAll in interface PackageIngestercontext - 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 packagerUnsupportedOperationException - if unsupported operationPackageException - if package errorIOException - if IO errorSQLException - if database errorAuthorizeException - if authorization errorCrosswalkException - if crosswalk errorpublic void disseminate(Context context, DSpaceObject dso, PackageParameters params, File pkgFile) throws PackageValidationException, CrosswalkException, AuthorizeException, SQLException, IOException
disseminate in interface PackageDisseminatordso - DSpaceObjectcontext - DSpace context.params - Properties-style list of options specific to this packagerpkgFile - File where export package should be writtenCrosswalkException - 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.public List<File> disseminateAll(Context context, DSpaceObject dso, PackageParameters params, File pkgFile) throws PackageException, CrosswalkException, AuthorizeException, SQLException, IOException
disseminateAll in interface PackageDisseminatorcontext - 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.PackageException - if package errorCrosswalkException - if crosswalk errorAuthorizeException - if authorization errorSQLException - if database errorIOException - if IO errorpublic String getMIMEType(PackageParameters params)
getMIMEType in interface PackageDisseminatorparams - package paramspublic String getParameterHelp()
-o or
--option flags with the Packager script.getParameterHelp in interface PackageDisseminatorgetParameterHelp in interface PackageIngesterCopyright © 2022 LYRASIS. All rights reserved.