org.dspace.content.packager
Class METSManifest

java.lang.Object
  extended by org.dspace.content.packager.METSManifest

public class METSManifest
extends Object

Manage the METS manifest document for METS importer classes, such as the package importer org.dspace.content.packager.MetsSubmission and the federated importer org.dspace.app.mets.FederatedMETSImport

It can parse the METS document, build an internal model, and give the importers access to that model. It also crosswalks all of the descriptive and administrative metadata in the METS manifest into the target DSpace Item, under control of the importer.

It reads the following DSpace Configuration entries:

Author:
Robert Tansley, WeiHua Huang, Rita Lee, Larry Stone
See Also:
MetsSubmission, FederatedMETSImport

Nested Class Summary
static interface METSManifest.Mdref
          Callback interface to retrieve data streams in mdRef elements.
 
Field Summary
static String MANIFEST_FILE
          Canonical filename of METS manifest within a package or as a bitstream.
static org.jdom.Namespace metsNS
          METS namespace -- includes "mets" prefix for use in XPaths
 
Method Summary
static METSManifest create(InputStream is, boolean validate)
          Create a new manifest object from a serialized METS XML document.
 void crosswalkBitstream(Context context, Bitstream bitstream, String fileId, METSManifest.Mdref callback)
          Crosswalk the metadata associated with a particular file element into the bitstream it corresponds to.
 void crosswalkItem(Context context, Item item, org.jdom.Element dmd, METSManifest.Mdref callback)
          Invokes appropriate crosswalks on Item-wide descriptive metadata.
static String getBundleName(org.jdom.Element file)
          Get the DSpace bundle name corresponding to the USE attribute of the file group enclosing this file element.
 List getContentFiles()
          Gets all file elements which make up the item's content.
static String getFileName(org.jdom.Element file)
          Get the "local" file name of this file or mdRef element.
 String getHandle()
          Find Handle (if any) identifier labelling this manifest.
 org.jdom.Element[] getItemDmds()
          Gets all dmdSec elements containing metadata for the DSpace Item.
 org.jdom.Element[] getItemRightsMD()
          Return rights metadata section(s) relevant to item as a whole.
 InputStream getMdContentAsStream(org.jdom.Element mdSec, METSManifest.Mdref callback)
          Return contents of *md element as stream.
 List getMdContentAsXml(org.jdom.Element mdSec, METSManifest.Mdref callback)
          Return contents of *md element as List of XML Element objects.
 String getMdContentMimeType(org.jdom.Element mdSec)
          Returns MIME type of metadata content, if available.
 List getMdFiles()
          Gets list of all mdRef elements in the METS document.
 String getMdType(org.jdom.Element mdSec)
          Get the metadata type from within a *mdSec element.
 org.jdom.Element getOriginalFile(org.jdom.Element file)
          Get the "original" file element for a derived file.
 org.jdom.Element getPrimaryBitstream()
          Returns file element corresponding to primary bitstream.
 String getProfile()
          Gets name of the profile to which this METS document conforms.
 
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
Canonical filename of METS manifest within a package or as a bitstream.

See Also:
Constant Field Values

metsNS

public static org.jdom.Namespace metsNS
METS namespace -- includes "mets" prefix for use in XPaths

Method Detail

create

public static METSManifest create(InputStream is,
                                  boolean validate)
                           throws IOException,
                                  MetadataValidationException
Create a new manifest object from a serialized METS XML document. Parse document read from the input stream, optionally validating.

Parameters:
is - input stream containing serialized XML
validate - if true, enable XML validation using schemas in document. Also validates any sub-documents.
Returns:
new METSManifest object.
Throws:
MetadataValidationException - if there is any error parsing or validating the METS.
IOException

getProfile

public String getProfile()
Gets name of the profile to which this METS document conforms.

Returns:
value the PROFILE attribute of mets element, or null if none.

getContentFiles

public List getContentFiles()
                     throws MetadataValidationException
Gets all file elements which make up the item's content.

Returns:
a List of Elements.
Throws:
MetadataValidationException

getMdFiles

public List getMdFiles()
                throws MetadataValidationException
Gets list of all mdRef elements in the METS document. Used by ingester to e.g. check that all required files are present.

Returns:
a List of Elements.
Throws:
MetadataValidationException

getOriginalFile

public org.jdom.Element getOriginalFile(org.jdom.Element file)
Get the "original" file element for a derived file. Finds the original from which this was derived by matching the GROUPID attribute that binds it to its original. For instance, the file for a thumbnail image would have the same GROUPID as its full-size version.

NOTE: This pattern of relating derived files through the GROUPID attribute is peculiar to the DSpace METS SIP profile, and may not be generally useful with other sorts of METS documents.

Parameters:
file - METS file element of derived file
Returns:
file Element of original or null if none found.

getBundleName

public static String getBundleName(org.jdom.Element file)
                            throws MetadataValidationException
Get the DSpace bundle name corresponding to the USE attribute of the file group enclosing this file element.

Returns:
DSpace bundle name
Throws:
MetadataValidationException - when there is no USE attribute on the enclosing fileGrp.

getFileName

public static String getFileName(org.jdom.Element file)
                          throws MetadataValidationException
Get the "local" file name of this file or mdRef element. By "local" we mean the reference to the actual resource containing the data for this file, e.g. a relative path within a Zip or tar archive if the METS is serving as a manifest for that sort of package.

Returns:
"local" file name (i.e. relative to package or content directory) corresponding to this file or mdRef element.
Throws:
MetadataValidationException - when there is not enough information to find a resource identifier.

getPrimaryBitstream

public org.jdom.Element getPrimaryBitstream()
                                     throws MetadataValidationException
Returns file element corresponding to primary bitstream. There is ONLY a primary bitstream if the first div under first structMap has an fptr.

Returns:
file element of Item's primary bitstream, or null if there is none.
Throws:
MetadataValidationException

getMdType

public String getMdType(org.jdom.Element mdSec)
                 throws MetadataValidationException
Get the metadata type from within a *mdSec element.

Returns:
metadata type name.
Throws:
MetadataValidationException

getMdContentMimeType

public String getMdContentMimeType(org.jdom.Element mdSec)
                            throws MetadataValidationException
Returns MIME type of metadata content, if available.

Returns:
MIMEtype word, or null if none is available.
Throws:
MetadataValidationException

getMdContentAsXml

public List getMdContentAsXml(org.jdom.Element mdSec,
                              METSManifest.Mdref callback)
                       throws MetadataValidationException,
                              IOException,
                              SQLException,
                              AuthorizeException
Return contents of *md element as List of XML Element objects. Gets content, dereferecing mdRef if necessary, or decoding and parsing a binData that contains XML.

Returns:
contents of metadata section, or empty list if no XML content is available.
Throws:
MetadataValidationException - if METS is invalid, or there is an error parsing the XML.
IOException
SQLException
AuthorizeException

getMdContentAsStream

public InputStream getMdContentAsStream(org.jdom.Element mdSec,
                                        METSManifest.Mdref callback)
                                 throws MetadataValidationException,
                                        IOException,
                                        SQLException,
                                        AuthorizeException
Return contents of *md element as stream. Gets content, dereferecing mdRef if necessary, or decoding a binData element if necessary.

Returns:
Stream containing contents of metadata section. Never returns null.
Throws:
MetadataValidationException - if METS format does not contain any metadata.
IOException
SQLException
AuthorizeException

getItemDmds

public org.jdom.Element[] getItemDmds()
                               throws MetadataValidationException
Gets all dmdSec elements containing metadata for the DSpace Item.

Returns:
array of Elements, each a dmdSec. May be empty but NOT null.
Throws:
MetadataValidationException - if the METS is missing a reference to item-wide DMDs in the correct place.

getItemRightsMD

public org.jdom.Element[] getItemRightsMD()
                                   throws MetadataValidationException
Return rights metadata section(s) relevant to item as a whole.

Returns:
array of rightsMd elements, possibly empty but never null.
Throws:
MetadataValidationException - if METS is invalid, e.g. referenced amdSec is missing.

crosswalkItem

public void crosswalkItem(Context context,
                          Item item,
                          org.jdom.Element dmd,
                          METSManifest.Mdref callback)
                   throws MetadataValidationException,
                          CrosswalkException,
                          IOException,
                          SQLException,
                          AuthorizeException
Invokes appropriate crosswalks on Item-wide descriptive metadata.

Throws:
MetadataValidationException
CrosswalkException
IOException
SQLException
AuthorizeException

crosswalkBitstream

public void crosswalkBitstream(Context context,
                               Bitstream bitstream,
                               String fileId,
                               METSManifest.Mdref callback)
                        throws MetadataValidationException,
                               CrosswalkException,
                               IOException,
                               SQLException,
                               AuthorizeException
Crosswalk the metadata associated with a particular file element into the bitstream it corresponds to.

Parameters:
context - a dspace context.
bs - bitstream target of the crosswalk
fileId - value of ID attribute in the file element responsible for the contents of that bitstream.
Throws:
MetadataValidationException
CrosswalkException
IOException
SQLException
AuthorizeException

getHandle

public String getHandle()
                 throws MetadataValidationException
Find Handle (if any) identifier labelling this manifest.

Returns:
handle (never null)
Throws:
MetadataValidationException - if no handle available.


Copyright © 2010 DuraSpace. All Rights Reserved.