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:
mets.xsd.identifier = namespace xsd-URL
mets.xsd.dc = http://purl.org/dc/elements/1.1/ dc.xsd
MDTYPE (or OTHERMDTYPE)
By default, the crosswalk mechanism will look for a plugin with the
same name as the metadata type (e.g. "MODS",
"DC"). This example line invokes the QDC
plugin when MDTYPE="DC"
mets.submission.crosswalk.DC = QDC
mets.submission.crosswalk.mdType = pluginName
| Modifier and Type | Class and Description |
|---|---|
static interface |
METSManifest.Mdref
Callback interface to retrieve data streams in mdRef elements.
|
| Modifier and Type | Field and Description |
|---|---|
protected List<org.jdom.Element> |
bundleFiles |
static String |
CONFIG_METS_PREFIX
Prefix of DSpace configuration lines that map METS metadata type to
crosswalk plugin names.
|
protected static String |
CONFIG_XSD_PREFIX
prefix of config lines identifying local XML Schema (XSD) files
|
protected String |
configName
name of packager who created this manifest object, for looking up configuration entries.
|
protected List<org.jdom.Element> |
contentFiles
<file> elements in "original" file group (bundle) |
protected static org.jdom.Namespace |
dcNS
Dublin core element namespace
|
protected static org.jdom.Namespace |
dcTermNS
Dublin core term namespace (for qualified DC)
|
protected static String |
localSchemas |
static String |
MANIFEST_FILE
Canonical filename of METS manifest within a package or as a bitstream.
|
protected List |
mdFiles
all mdRef elements in the manifest
|
protected org.jdom.Element |
mets
root element of the current METS manifest.
|
static org.jdom.Namespace |
metsNS
METS namespace -- includes "mets" prefix for use in XPaths
|
protected org.jdom.input.SAXBuilder |
parser
builder to use for mdRef streams, inherited from create()
|
static org.jdom.Namespace |
xlinkNS
XLink namespace -- includes "xlink" prefix prefix for use in XPaths
|
| Modifier | Constructor and Description |
|---|---|
protected |
METSManifest(org.jdom.input.SAXBuilder builder,
org.jdom.Element mets,
String configName)
Default constructor, only called internally.
|
| Modifier and Type | Method and Description |
|---|---|
static METSManifest |
create(InputStream is,
boolean validate,
String configName)
Create a new manifest object from a serialized METS XML document.
|
void |
crosswalkBitstream(Context context,
PackageParameters params,
Bitstream bitstream,
String fileId,
METSManifest.Mdref callback)
Crosswalk the metadata associated with a particular
file
element into the bitstream it corresponds to. |
void |
crosswalkBundle(Context context,
PackageParameters params,
Bundle bundle,
String fileId,
METSManifest.Mdref callback) |
void |
crosswalkItemDmd(Context context,
PackageParameters params,
DSpaceObject dso,
org.jdom.Element dmdSec,
METSManifest.Mdref callback)
Invokes appropriate crosswalks on Item-wide descriptive metadata.
|
void |
crosswalkObjectOtherAdminMD(Context context,
PackageParameters params,
DSpaceObject dso,
METSManifest.Mdref callback)
Crosswalk all technical and source metadata sections that belong
to the whole object.
|
boolean |
crosswalkObjectSourceMD(Context context,
PackageParameters params,
DSpaceObject dso,
METSManifest.Mdref callback)
Just crosswalk the sourceMD sections; used to set the handle and parent of AIP.
|
protected void |
crosswalkXmd(Context context,
PackageParameters params,
DSpaceObject dso,
org.jdom.Element xmd,
METSManifest.Mdref callback,
boolean createMissingMetadataFields) |
protected String[] |
getAmdIDs()
Get an array of all AMDID values for this object
|
List<org.jdom.Element> |
getBundleFiles()
Gets all
file elements which make up
the item's content. |
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. |
static String |
getBundleName(org.jdom.Element file,
boolean getParent)
Get the DSpace bundle name corresponding to the
USE
attribute of the file group enclosing this file element. |
String[] |
getChildMetsFilePaths()
Retrieve the file paths for the children objects' METS Manifest files.
|
List |
getChildObjDivs()
Get an array of child object
<div>s from the METS Manifest <structMap>. |
List<org.jdom.Element> |
getContentFiles() |
protected Object |
getCrosswalk(String type,
Class clazz) |
org.jdom.Element[] |
getDmdElements(String dmdList)
Gets all dmdSec elements from a space separated list
|
protected org.jdom.Element |
getElementByXPath(String path,
boolean nullOk) |
static String |
getFileName(org.jdom.Element file)
Get the "local" file name of this
file or mdRef element. |
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<org.jdom.Element> |
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 |
getMets() |
InputStream |
getMetsAsStream()
Return entire METS document as an inputStream
|
String |
getObjID()
Return the OBJID attribute of the METS manifest.
|
org.jdom.Element |
getObjStructDiv()
Return the
<div> which describes this DSpace Object (and its contents)
from the <structMap>. |
String |
getOriginalFilePath(org.jdom.Element file)
Get the "original" file element for a derived file.
|
String |
getParentOwnerLink()
Return the reference to the Parent Object from the "Parent"
<structMap>. |
org.jdom.Element |
getPrimaryOrLogoBitstream()
Returns file element corresponding to primary bitstream.
|
String |
getProfile()
Gets name of the profile to which this METS document conforms.
|
protected static String |
normalizeBundleName(String in) |
public static final String MANIFEST_FILE
public static final String CONFIG_METS_PREFIX
protected static final String CONFIG_XSD_PREFIX
protected static final org.jdom.Namespace dcNS
protected static final org.jdom.Namespace dcTermNS
public static final org.jdom.Namespace metsNS
public static final org.jdom.Namespace xlinkNS
protected org.jdom.Element mets
protected List mdFiles
protected List<org.jdom.Element> contentFiles
<file> elements in "original" file group (bundle)protected List<org.jdom.Element> bundleFiles
protected org.jdom.input.SAXBuilder parser
protected String configName
protected static String localSchemas
protected METSManifest(org.jdom.input.SAXBuilder builder,
org.jdom.Element mets,
String configName)
builder - XML parser (for parsing mdRef'd files and binData)mets - parsed METS documentconfigName - config namepublic static METSManifest create(InputStream is, boolean validate, String configName) throws IOException, MetadataValidationException
is - input stream containing serialized XMLvalidate - if true, enable XML validation using schemas
in document. Also validates any sub-documents.configName - config nameIOException - if IO errorMetadataValidationException - if there is any error parsing
or validating the METS.public String getProfile()
public String getObjID()
public List<org.jdom.Element> getBundleFiles() throws MetadataValidationException
file elements which make up
the item's content.Elements.MetadataValidationException - if validation errorpublic List<org.jdom.Element> getContentFiles() throws MetadataValidationException
MetadataValidationExceptionpublic List getMdFiles() throws MetadataValidationException
mdRef elements in the METS
document. Used by ingester to e.g. check that all
required files are present.Elements.MetadataValidationException - if validation errorpublic String getOriginalFilePath(org.jdom.Element file)
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.
file - METS file element of derived filepublic static String getBundleName(org.jdom.Element file) throws MetadataValidationException
USE
attribute of the file group enclosing this file element.file - file elementMetadataValidationException - when there is no USE attribute on the enclosing fileGrp.public static String getBundleName(org.jdom.Element file, boolean getParent) throws MetadataValidationException
USE
attribute of the file group enclosing this file element.file - file elementgetParent - parent flagMetadataValidationException - when there is no USE attribute on the enclosing fileGrp.public static String getFileName(org.jdom.Element file) throws MetadataValidationException
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.file - file elementfile or mdRef element.MetadataValidationException - when there is not enough information to find a resource identifier.public org.jdom.Element getPrimaryOrLogoBitstream()
throws MetadataValidationException
div under
first structMap has an fptr.MetadataValidationException - if validation errorpublic String getMdType(org.jdom.Element mdSec) throws MetadataValidationException
mdSec - mdSec elementMetadataValidationException - if validation errorpublic String getMdContentMimeType(org.jdom.Element mdSec) throws MetadataValidationException
mdSec - mdSec elementMetadataValidationException - if validation errorpublic List<org.jdom.Element> getMdContentAsXml(org.jdom.Element mdSec, METSManifest.Mdref callback) throws MetadataValidationException, PackageValidationException, IOException, SQLException, AuthorizeException
mdSec - mdSec elementcallback - mdref callbackMetadataValidationException - if METS is invalid, or there is an error parsing the XML.PackageValidationException - if invalid packageIOException - if IO errorSQLException - if database errorAuthorizeException - if authorization errorpublic InputStream getMdContentAsStream(org.jdom.Element mdSec, METSManifest.Mdref callback) throws MetadataValidationException, PackageValidationException, IOException, SQLException, AuthorizeException
mdSec - mdSec elementcallback - mdref callbackMetadataValidationException - if METS format does not contain any metadata.PackageValidationException - if invalid packageIOException - if IO errorSQLException - if database errorAuthorizeException - if authorization errorpublic org.jdom.Element getObjStructDiv()
throws MetadataValidationException
<div> which describes this DSpace Object (and its contents)
from the <structMap>. In all cases, this is the first <div>
in the first <structMap>.<div>MetadataValidationException - if metadata validation errorpublic List getChildObjDivs() throws MetadataValidationException
<div>s from the METS Manifest <structMap>.
These <div>s reference the location of any child objects METS manifests.Elements, each a <div>. May be empty but NOT null.MetadataValidationException - if metadata validation errorpublic String[] getChildMetsFilePaths() throws MetadataValidationException
<mptr> where @LOCTYPE=URLMetadataValidationException - if metadata validation errorpublic String getParentOwnerLink() throws MetadataValidationException
<structMap>.
This parent object is the owner of current object.MetadataValidationException - if metadata validation errorprotected org.jdom.Element getElementByXPath(String path, boolean nullOk) throws MetadataValidationException
MetadataValidationExceptionpublic org.jdom.Element[] getItemDmds()
throws MetadataValidationException
MetadataValidationException - if the METS is missing a reference to item-wide
DMDs in the correct place.public org.jdom.Element[] getDmdElements(String dmdList) throws MetadataValidationException
dmdList - space-separated list of DMDIDsMetadataValidationException - if the METS is missing a reference to item-wide
DMDs in the correct place.public org.jdom.Element[] getItemRightsMD()
throws MetadataValidationException
MetadataValidationException - if METS is invalid, e.g. referenced amdSec is missing.public void crosswalkItemDmd(Context context, PackageParameters params, DSpaceObject dso, org.jdom.Element dmdSec, METSManifest.Mdref callback) throws MetadataValidationException, PackageValidationException, CrosswalkException, IOException, SQLException, AuthorizeException
context - contextcallback - mdref callbackdso - DSpaceObjectparams - package paramsdmdSec - dmdSec elementMetadataValidationException - if METS errorCrosswalkException - if crosswalk errorPackageValidationException - if invalid packageIOException - if IO errorSQLException - if database errorAuthorizeException - if authorization errorpublic void crosswalkObjectOtherAdminMD(Context context, PackageParameters params, DSpaceObject dso, METSManifest.Mdref callback) throws MetadataValidationException, PackageValidationException, CrosswalkException, IOException, SQLException, AuthorizeException
context - contextcallback - mdref callbackparams - package paramsdso - DSpaceObjectMetadataValidationException - if METS is invalid, e.g. referenced amdSec is missing.PackageValidationException - if invalid packageIOException - if IO errorSQLException - if database errorAuthorizeException - if authorization errorCrosswalkExceptionpublic boolean crosswalkObjectSourceMD(Context context, PackageParameters params, DSpaceObject dso, METSManifest.Mdref callback) throws MetadataValidationException, PackageValidationException, CrosswalkException, IOException, SQLException, AuthorizeException
context - contextcallback - mdref callbackparams - package paramsdso - DSpaceObjectMetadataValidationException - if METS is invalid, e.g. referenced amdSec is missing.PackageValidationException - if invalid packageIOException - if IO errorSQLException - if database errorAuthorizeException - if authorization errorCrosswalkException - if crosswalk errorprotected String[] getAmdIDs() throws MetadataValidationException
MetadataValidationException - if metadata validation errorprotected void crosswalkXmd(Context context, PackageParameters params, DSpaceObject dso, org.jdom.Element xmd, METSManifest.Mdref callback, boolean createMissingMetadataFields) throws MetadataValidationException, PackageValidationException, CrosswalkException, IOException, SQLException, AuthorizeException
public void crosswalkBitstream(Context context, PackageParameters params, Bitstream bitstream, String fileId, METSManifest.Mdref callback) throws MetadataValidationException, PackageValidationException, CrosswalkException, IOException, SQLException, AuthorizeException
file
element into the bitstream it corresponds to.context - a dspace context.params - any PackageParameters which may affect how bitstreams are crosswalkedbitstream - bitstream target of the crosswalkfileId - value of ID attribute in the file element responsible
for the contents of that bitstream.callback - mdref callbackMetadataValidationException - if METS is invalid, e.g. referenced amdSec is missing.PackageValidationException - if invalid packageIOException - if IO errorSQLException - if database errorAuthorizeException - if authorization errorCrosswalkException - if crosswalk errorpublic void crosswalkBundle(Context context, PackageParameters params, Bundle bundle, String fileId, METSManifest.Mdref callback) throws MetadataValidationException, PackageValidationException, CrosswalkException, IOException, SQLException, AuthorizeException
public org.jdom.Element getMets()
public InputStream getMetsAsStream()
Copyright © 2022 LYRASIS. All rights reserved.