org.dspace.content.packager
Class AbstractMETSIngester

java.lang.Object
  extended by org.dspace.content.packager.AbstractMETSIngester
All Implemented Interfaces:
PackageIngester
Direct Known Subclasses:
DSpaceMETSIngester

public abstract class AbstractMETSIngester
extends Object
implements PackageIngester

Base class for package ingester of METS (Metadata Encoding & Transmission Standard) Package.
See http://www.loc.gov/standards/mets/

This is a generic packager framework intended to be subclassed to create ingesters for more specific METS "profiles". METS is an abstract and flexible framework that can encompass many different kinds of metadata and inner package structures.

Configuration: If the property mets.submission.preserveManifest is true, the METS manifest itself is preserved in a bitstream named mets.xml in the METADATA bundle. If it is false (the default), the manifest is discarded after ingestion.

Version:
$Revision: 4930 $
Author:
Larry Stone
See Also:
METSManifest

Nested Class Summary
protected  class AbstractMETSIngester.MdrefManager
          An instance of MdrefManager holds the state needed to retrieve the contents (or bitstream corresponding to) an external metadata stream referenced by an mdRef element in the METS manifest.
 
Field Summary
static String MANIFEST_FILE
          Filename of manifest, relative to package toplevel.
 
Constructor Summary
AbstractMETSIngester()
           
 
Method Summary
abstract  void addLicense(Context context, Collection collection, Item item, METSManifest manifest, AbstractMETSIngester.MdrefManager callback, String license)
          Add license(s) to Item based on contents of METS and other policies.
abstract  void checkPackageFiles(Set packageFiles, Set missingFiles, METSManifest manifest)
          Hook for subclass to modify the test of the package's integrity, and add other tests.
abstract  void chooseItemDmd(Context context, Item item, METSManifest manifest, AbstractMETSIngester.MdrefManager callback, org.jdom.Element[] dmds, PackageParameters params)
          Select the dmdSec element(s) to apply to the Item.
abstract  void finishItem(Context context, Item item)
          Hook for final "finishing" operations on the new Item.
 WorkspaceItem ingest(Context context, Collection collection, InputStream pkg, PackageParameters params, String license)
          Create a new DSpace item out of a METS content package.
 Item replace(Context ctx, Item item, InputStream pckage, PackageParameters params)
          XXX FIXME Replace is not implemented yet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MANIFEST_FILE

public static final String MANIFEST_FILE
Filename of manifest, relative to package toplevel.

See Also:
Constant Field Values
Constructor Detail

AbstractMETSIngester

public AbstractMETSIngester()
Method Detail

ingest

public WorkspaceItem ingest(Context context,
                            Collection collection,
                            InputStream pkg,
                            PackageParameters params,
                            String license)
                     throws PackageValidationException,
                            CrosswalkException,
                            AuthorizeException,
                            SQLException,
                            IOException
Create a new DSpace item out of a METS content package. All contents are dictated by the METS manifest. Package is a ZIP archive, all files relative to top level and the manifest (as per spec) in mets.xml.

Specified by:
ingest in interface PackageIngester
Parameters:
context - - DSpace context.
collection - - collection under which to create new item.
pkg - - input stream containing package to ingest.
license - - may be null, which takes default license.
params - Properties-style list of options (interpreted by each packager).
Returns:
workspace item created by ingest.
Throws:
PackageValidationException - if package is unacceptable or there is a fatal error turning it into an Item.
CrosswalkException
AuthorizeException
SQLException
IOException

replace

public Item replace(Context ctx,
                    Item item,
                    InputStream pckage,
                    PackageParameters params)
             throws PackageException,
                    UnsupportedOperationException,
                    CrosswalkException,
                    AuthorizeException,
                    SQLException,
                    IOException
XXX FIXME Replace is not implemented yet.

Specified by:
replace in interface PackageIngester
Parameters:
ctx - DSpace context.
item - existing item to be replaced
pckage - input stream containing package to ingest.
params - Properties-style list of options specific to this packager
Returns:
item re-created by ingest.
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

checkPackageFiles

public abstract void checkPackageFiles(Set packageFiles,
                                       Set missingFiles,
                                       METSManifest manifest)
                                throws PackageValidationException,
                                       CrosswalkException
Hook for subclass to modify the test of the package's integrity, and add other tests. E.g. evaluate a PGP signature of the manifest in a separate file.

The packageFiles contains "extra" files that were in the package but were not referenced by the METS manifest (either as content or metadata (mdRefs)). The implementation of this method should look for any "extra" files uses (e.g. a checksum or cryptographic signature for the manifest itself) and remove them from the Set.

The missingFiles set is for any files referenced by the manifest but not found in the package. The implementation can check it for "false positives", or add other missing files it knows of.

If either of the Sets missingFiles or packageFiles is not empty, the ingest will fail.

Parameters:
packageFiles - files in package but not referenced by METS
missingFiles - files referenced by manifest but not in package
Throws:
PackageValidationException
CrosswalkException

chooseItemDmd

public abstract void chooseItemDmd(Context context,
                                   Item item,
                                   METSManifest manifest,
                                   AbstractMETSIngester.MdrefManager callback,
                                   org.jdom.Element[] dmds,
                                   PackageParameters params)
                            throws CrosswalkException,
                                   AuthorizeException,
                                   SQLException,
                                   IOException
Select the dmdSec element(s) to apply to the Item. The implementation is responsible for choosing which (if any) of the metadata sections to crosswalk to get the descriptive metadata for the item being ingested. It is responsible for calling the crosswalk, using the manifest's helper i.e. manifest.crosswalkItem(context,item,dmdElement,callback); (The callback argument is a reference to itself since the class also implements the METSManifest.MdRef interface to fetch package files referenced by mdRef elements.)

Note that item and manifest are available as protected fields from the superclass.

Parameters:
context - the DSpace context
item - the DSpace item
manifest - the METSManifest
callback - the MdrefManager (manages all external metadata files referenced by METS mdref elements)
dmds - array of Elements, each a METS dmdSec that applies to the Item as a whole.
params - any user parameters passed to the Packager script
Throws:
CrosswalkException
AuthorizeException
SQLException
IOException

addLicense

public abstract void addLicense(Context context,
                                Collection collection,
                                Item item,
                                METSManifest manifest,
                                AbstractMETSIngester.MdrefManager callback,
                                String license)
                         throws PackageValidationException,
                                CrosswalkException,
                                AuthorizeException,
                                SQLException,
                                IOException
Add license(s) to Item based on contents of METS and other policies. The implementation of this method controls exactly what licenses are added to the new item, including the DSpace deposit license. It is given the collection (which is the source of a default deposit license), an optional user-supplied deposit license (in the form of a String), and the METS manifest. It should invoke manifest.getItemRightsMD() to get an array of rightsMd elements which might contain other license information of interest, e.g. a Creative Commons license.

This framework does not add any licenses by default.

Parameters:
context - the DSpace context
collection - DSpace Collection to which the item is being submitted.
license - optional user-supplied Deposit License text (may be null)
Throws:
PackageValidationException
CrosswalkException
AuthorizeException
SQLException
IOException

finishItem

public abstract void finishItem(Context context,
                                Item item)
                         throws PackageValidationException,
                                CrosswalkException,
                                AuthorizeException,
                                SQLException,
                                IOException
Hook for final "finishing" operations on the new Item. This method is called when the new Item is otherwise complete and ready to be returned. The implementation should use this opportunity to make whatever final checks and modifications are necessary.

Parameters:
context - the DSpace context
Throws:
PackageValidationException
CrosswalkException
AuthorizeException
SQLException
IOException


Copyright © 2010 DuraSpace. All Rights Reserved.