org.dspace.content.packager
Class PDFPackager

java.lang.Object
  extended by org.dspace.core.SelfNamedPlugin
      extended by 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: 5844 $
Author:
Larry Stone
See Also:
PackageIngester, PackageDisseminator

Constructor Summary
PDFPackager()
           
 
Method Summary
 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<DSpaceObject> 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<DSpaceObject> 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
 
Methods inherited from class org.dspace.core.SelfNamedPlugin
getPluginInstanceName, setPluginInstanceName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PDFPackager

public PDFPackager()
Method Detail

getPluginNames

public static String[] getPluginNames()

ingest

public DSpaceObject ingest(Context context,
                           DSpaceObject parent,
                           File pkgFile,
                           PackageParameters params,
                           String license)
                    throws PackageValidationException,
                           CrosswalkException,
                           AuthorizeException,
                           SQLException,
                           IOException
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:
ingest in interface PackageIngester
Parameters:
context - DSpace context.
parent - collection under which to create new item.
pkgFile - The package file to ingest
params - package parameters (none recognized)
license - may be null, which takes default license.
Returns:
workspace item created by ingest.
Throws:
PackageException - if package is unacceptable or there is a fatal error turning it into an Item.
PackageValidationException - if package is unacceptable or there is a fatal error turning it into a DSpaceObject.
CrosswalkException
AuthorizeException
SQLException
IOException

ingestAll

public List<DSpaceObject> 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:
ingestAll in interface PackageIngester
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 ingest
params - Properties-style list of options (interpreted by each packager).
license - may be null, which takes default license.
Returns:
List of DSpaceObjects created
Throws:
PackageValidationException - if initial package (or any referenced package) is unacceptable or there is a fatal error in creating a DSpaceObject
UnsupportedOperationException - if this packager does not implement ingestAll
PackageException
CrosswalkException
AuthorizeException
SQLException
IOException

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:
replace in interface PackageIngester
Parameters:
context - DSpace context.
dso - existing DSpace Object to be replaced, may be null if object to replace can be determined from package
pkgFile - The package file to ingest.
params - Properties-style list of options specific to this packager
Returns:
DSpaceObject with contents replaced
Throws:
PackageValidationException - if package is unacceptable or there is a fatal error turning it into an Item.
UnsupportedOperationException - if this packager does not implement replace.
PackageException
CrosswalkException
AuthorizeException
SQLException
IOException

replaceAll

public List<DSpaceObject> 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:
replaceAll in interface PackageIngester
Parameters:
context - DSpace context.
dso - initial existing DSpace Object to be replaced, may be null if object to replace can be determined from package
pkgFile - The package file to ingest.
params - Properties-style list of options specific to this packager
Returns:
List of DSpaceObjects replaced
Throws:
PackageValidationException - if initial package (or any referenced package) is unacceptable or there is a fatal error in creating a DSpaceObject
UnsupportedOperationException - if this packager does not implement replaceAll
PackageException
CrosswalkException
AuthorizeException
SQLException
IOException

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:
disseminate in interface PackageDisseminator
Parameters:
context - DSpace context.
dso - DSpace object (item, collection, etc)
params - Properties-style list of options specific to this packager
pkgFile - File where export package should be written
Throws:
PackageValidationException - if package cannot be created or there is a fatal error in creating it.
CrosswalkException
AuthorizeException
SQLException
IOException

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:
disseminateAll in interface PackageDisseminator
Parameters:
context - DSpace context.
dso - initial DSpace object
params - Properties-style list of options specific to this packager
pkgFile - 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:
PackageValidationException - if package cannot be created or there is a fatal error in creating it.
PackageException
CrosswalkException
AuthorizeException
SQLException
IOException

getMIMEType

public String getMIMEType(PackageParameters params)
Identifies the MIME-type of this package, i.e. "application/pdf".

Specified by:
getMIMEType in interface PackageDisseminator
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 -o or --option flags with the Packager script.

Specified by:
getParameterHelp in interface PackageDisseminator
Specified by:
getParameterHelp in interface PackageIngester
Returns:
a string describing additional command-line options available with this packager


Copyright © 2010 DuraSpace. All Rights Reserved.