Class AbstractMETSDisseminator
- java.lang.Object
-
- org.dspace.content.packager.AbstractPackageDisseminator
-
- org.dspace.content.packager.AbstractMETSDisseminator
-
- All Implemented Interfaces:
PackageDisseminator
- Direct Known Subclasses:
DSpaceAIPDisseminator,DSpaceMETSDisseminator
public abstract class AbstractMETSDisseminator extends AbstractPackageDisseminator
Base class for disseminator of METS (Metadata Encoding and Transmission Standard) Package.
See http://www.loc.gov/standards/mets/This is a generic packager framework intended to be subclassed to create packagers for more specific METS "profiles". METS is an abstract and flexible framework that can encompass many different kinds of metadata and inner package structures.
Package Parameters:
manifestOnly-- if true, generate a standalone XML document of the METS manifest instead of a complete package. Any other metadata (such as licenses) will be encoded inline. Default isfalse.unauthorized-- this determines what is done when the packager encounters a Bundle or Bitstream it is not authorized to read. By default, it just quits with an AuthorizeException. If this option is present, it must be one of the following values:skip-- simply exclude unreadable content from package.zero-- include unreadable bitstreams as 0-length files; unreadable Bundles will still cause authorize errors.
- Version:
- $Revision$
- Author:
- Larry Stone, Robert Tansley, Tim Donohue
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classAbstractMETSDisseminator.MdStreamCacheWrapper for a table of streams to add to the package, such as mdRef'd metadata.
-
Field Summary
Fields Modifier and Type Field Description protected AuthorizeServiceauthorizeServiceprotected BitstreamServicebitstreamServiceprotected ConfigurationServiceconfigurationServiceprotected CreativeCommonsServicecreativeCommonsServiceprotected static longDEFAULT_MODIFIED_DATEDefault date/time (in milliseconds since epoch) to set for Zip Entries for DSpace Objects which don't have a Last Modified date.protected intidCounterprotected static org.jdom.output.XMLOutputteroutputterprotected SiteServicesiteServiceprotected static StringTEMPLATE_TYPE_SUFFIXSuffix for Template objects (e.g.-
Fields inherited from class org.dspace.content.packager.AbstractPackageDisseminator
communityService, itemService
-
-
Constructor Summary
Constructors Constructor Description AbstractMETSDisseminator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected StringaddAmdSec(Context context, DSpaceObject dso, PackageParameters params, edu.harvard.hul.ois.mets.Mets mets, AbstractMETSDisseminator.MdStreamCache extraStreams)protected voidaddBitstreamsToZip(Context context, DSpaceObject dso, PackageParameters params, ZipOutputStream zip)Add Bitstreams associated with a given DSpace Object into an existing ZipOutputStreamprotected voidaddLogoBitstream(Context context, Bitstream logoBs, edu.harvard.hul.ois.mets.FileSec fileSec, edu.harvard.hul.ois.mets.Div div0, PackageParameters params)abstract voidaddStructMap(Context context, DSpaceObject dso, PackageParameters params, edu.harvard.hul.ois.mets.Mets mets)Add any additionalstructMapelements to the METS document, as required by this subclass.protected voidaddToAmdSec(edu.harvard.hul.ois.mets.AmdSec fAmdSec, String[] mdTypes, Class mdSecClass, Context context, DSpaceObject dso, PackageParameters params, AbstractMETSDisseminator.MdStreamCache extraStreams)abstract StringbundleToFileGrp(String bname)Returns fileGrp's USE attribute value corresponding to a DSpace bundle name.protected edu.harvard.hul.ois.mets.helper.MetsElementcrosswalkToMetsElement(Context context, DisseminationCrosswalk xwalk, DSpaceObject dso, edu.harvard.hul.ois.mets.helper.MetsElement me)voiddisseminate(Context context, DSpaceObject dso, PackageParameters params, File pkgFile)Export the object (Item, Collection, or Community) as a "package" on the indicated OutputStream.protected BitstreamfindOriginalBitstream(Item item, Bitstream derived)For a bitstream that's a thumbnail or extracted text, find the corresponding bitstream it was derived from, in the ORIGINAL bundle.protected Stringgensym(String prefix)Make a new unique ID symbol with specified prefix.abstract String[]getDigiprovMdTypes(Context context, DSpaceObject dso, PackageParameters params)Get the type string of the "digiprov" (digital provenance) metadata to create for each object and each Bitstream in an Item.abstract String[]getDmdTypes(Context context, DSpaceObject dso, PackageParameters params)Get the types of Item-wide DMD to include in package.protected StringgetHandleURN(String handle)StringgetMIMEType(PackageParameters params)Identifies the MIME-type of this package, e.g.StringgetObjectTypeString(DSpaceObject dso)Build a string which will be used as the "Type" of this object in the METS manifest.StringgetParameterHelp()Returns a user help string which should describe the additional valid command-line options that this packager implementation will accept when using the-oor--optionflags with the Packager script.abstract StringgetProfile()Returns name of METS profile to which this package conforms, e.g.abstract String[]getRightsMdTypes(Context context, DSpaceObject dso, PackageParameters params)Get the type string of the "rights" (permission and/or license) metadata to create for each object and each Bitstream in an Item.abstract String[]getSourceMdTypes(Context context, DSpaceObject dso, PackageParameters params)Get the type string of the source metadata to create for each object and each Bitstream in an Item.abstract String[]getTechMdTypes(Context context, DSpaceObject dso, PackageParameters params)Get the type string of the technical metadata to create for each object and each Bitstream in an Item.abstract booleanincludeBundle(Bundle bundle)protected voidlinkLicenseRefsToBitstreams(Context context, PackageParameters params, DSpaceObject dso, edu.harvard.hul.ois.mets.MdRef mdRef)Cleanup our license file reference links, as Deposit Licenses and CC Licenses can be added two ways (and we only want to add them to zip package *once*): (1) Added as a normal Bitstream (assuming LICENSE and CC_LICENSE bundles will be included in pkg) (2) Added via a 'rightsMD' crosswalk (as they are rights information/metadata on an Item)StringmakeBitstreamURL(Context context, Bitstream bitstream, PackageParameters params)Get the URL by which the METS manifest refers to a Bitstream member within the same package.protected edu.harvard.hul.ois.mets.DivmakeChildDiv(String type, DSpaceObject dso, PackageParameters params)Create a<div>element with<mptr>which references a child object via its handle (and via a local file name, when recursively disseminating all child objects).protected edu.harvard.hul.ois.mets.DivmakeFileDiv(String fileID, String type)protected edu.harvard.hul.ois.mets.MetsmakeManifest(Context context, DSpaceObject dso, PackageParameters params, AbstractMETSDisseminator.MdStreamCache extraStreams)Write out a METS manifest.protected edu.harvard.hul.ois.mets.helper.MdSecmakeMdSec(Context context, DSpaceObject dso, Class mdSecClass, String typeSpec, PackageParameters params, AbstractMETSDisseminator.MdStreamCache extraStreams)Create an element wrapped around a metadata reference (either mdWrap or mdRef); i.e.abstract edu.harvard.hul.ois.mets.MetsHdrmakeMetsHdr(Context context, DSpaceObject dso, PackageParameters params)Create metsHdr element - separate so subclasses can override.protected StringmakePersistentID(DSpaceObject dso)protected voidresetCounter()Resets the unique ID counter used by gensym() method to determine the @ID values of METS tags.protected voidsetMdType(edu.harvard.hul.ois.mets.MdRef mdRef, String mdtype)protected voidsetMdType(edu.harvard.hul.ois.mets.MdWrap mdWrap, String mdtype)protected voidwriteZipPackage(Context context, DSpaceObject dso, PackageParameters params, OutputStream pkg)Make a Zipped up METS package for the given DSpace Object-
Methods inherited from class org.dspace.content.packager.AbstractPackageDisseminator
addToPackageList, disseminateAll, getPackageList
-
-
-
-
Field Detail
-
outputter
protected static org.jdom.output.XMLOutputter outputter
-
authorizeService
protected final AuthorizeService authorizeService
-
bitstreamService
protected final BitstreamService bitstreamService
-
siteService
protected final SiteService siteService
-
creativeCommonsService
protected final CreativeCommonsService creativeCommonsService
-
configurationService
protected final ConfigurationService configurationService
-
idCounter
protected int idCounter
-
DEFAULT_MODIFIED_DATE
protected static final long DEFAULT_MODIFIED_DATE
Default date/time (in milliseconds since epoch) to set for Zip Entries for DSpace Objects which don't have a Last Modified date. If we don't set our own date/time, then it will default to current system date/time. This is less than ideal, as it causes the md5 checksum of Zip file to change whenever Zip is regenerated (even if compressed files are unchanged) 1036368000 seconds * 1000 = Nov 4, 2002 GMT (the date DSpace 1.0 was released)- See Also:
- Constant Field Values
-
TEMPLATE_TYPE_SUFFIX
protected static final String TEMPLATE_TYPE_SUFFIX
Suffix for Template objects (e.g. Item Templates)- See Also:
- Constant Field Values
-
-
Method Detail
-
gensym
protected String gensym(String prefix)
Make a new unique ID symbol with specified prefix.- Parameters:
prefix- the prefix of the identifier, constrained to XML ID schema- Returns:
- a new string identifier unique in this session (instance).
-
resetCounter
protected void resetCounter()
Resets the unique ID counter used by gensym() method to determine the @ID values of METS tags.
-
getMIMEType
public String getMIMEType(PackageParameters params)
Description copied from interface:PackageDisseminatorIdentifies the MIME-type of this package, e.g."application/zip". Required when sending the package via HTTP, to provide the Content-Type header.- Parameters:
params- Package Parameters- Returns:
- the MIME type (content-type header) of the package to be returned
-
disseminate
public void disseminate(Context context, DSpaceObject dso, PackageParameters params, File pkgFile) throws PackageValidationException, CrosswalkException, AuthorizeException, SQLException, IOException
Export the object (Item, Collection, or Community) as a "package" on the indicated OutputStream. Package is any serialized representation of the item, at the discretion of the implementing class. It does not have to include content bitstreams.Use the
paramsparameter list to adjust the way the package is made, e.g. including a "metadataOnly" parameter might make the package a bare manifest in XML instead of a Zip file including manifest and contents.Throws an exception of the chosen object is not acceptable or there is a failure creating the package.
- Parameters:
context- DSpace context.dso- DSpace object (item, collection, etc)params- Properties-style list of options specific to this packagerpkgFile- File where export package should be written- Throws:
PackageValidationException- if package cannot be created or there is a fatal error in creating it.CrosswalkException- if crosswalk errorAuthorizeException- if authorization errorSQLException- if database errorIOException- if IO error
-
writeZipPackage
protected void writeZipPackage(Context context, DSpaceObject dso, PackageParameters params, OutputStream pkg) throws PackageValidationException, CrosswalkException, edu.harvard.hul.ois.mets.helper.MetsException, AuthorizeException, SQLException, IOException
Make a Zipped up METS package for the given DSpace Object- Parameters:
context- DSpace Contextdso- The DSpace Objectparams- Parameters to the Packager scriptpkg- Package output stream- Throws:
PackageValidationException- if package validation errorCrosswalkException- if crosswalk errorAuthorizeException- if authorization erroredu.harvard.hul.ois.mets.helper.MetsException- if METS errorSQLException- if database errorIOException- if IO error
-
addBitstreamsToZip
protected void addBitstreamsToZip(Context context, DSpaceObject dso, PackageParameters params, ZipOutputStream zip) throws PackageValidationException, AuthorizeException, SQLException, IOException
Add Bitstreams associated with a given DSpace Object into an existing ZipOutputStream- Parameters:
context- DSpace Contextdso- The DSpace Objectparams- Parameters to the Packager scriptzip- Zip output- Throws:
PackageValidationException- if validation errorAuthorizeException- if authorization errorSQLException- if database errorIOException- if IO error
-
setMdType
protected void setMdType(edu.harvard.hul.ois.mets.MdWrap mdWrap, String mdtype)
-
setMdType
protected void setMdType(edu.harvard.hul.ois.mets.MdRef mdRef, String mdtype)
-
makeMdSec
protected edu.harvard.hul.ois.mets.helper.MdSec makeMdSec(Context context, DSpaceObject dso, Class mdSecClass, String typeSpec, PackageParameters params, AbstractMETSDisseminator.MdStreamCache extraStreams) throws SQLException, PackageValidationException, CrosswalkException, IOException, AuthorizeException
Create an element wrapped around a metadata reference (either mdWrap or mdRef); i.e. dmdSec, techMd, sourceMd, etc. Checks for XML-DOM oriented crosswalk first, then if not found looks for stream crosswalk of the same name.- Parameters:
context- DSpace Contextdso- DSpace Object we are generating METS manifest formdSecClass- class of mdSec (TechMD, RightsMD, DigiProvMD, etc)typeSpec- Type of metadata going into this mdSec (e.g. MODS, DC, PREMIS, etc)params- the PackageParametersextraStreams- list of extra files which need to be added to final dissemination package- Returns:
- mdSec element or null if xwalk returns empty results.
- Throws:
SQLException- if database errorPackageValidationException- if package validation errorCrosswalkException- if crosswalk errorIOException- if IO errorAuthorizeException- if authorization error
-
addToAmdSec
protected void addToAmdSec(edu.harvard.hul.ois.mets.AmdSec fAmdSec, String[] mdTypes, Class mdSecClass, Context context, DSpaceObject dso, PackageParameters params, AbstractMETSDisseminator.MdStreamCache extraStreams) throws SQLException, PackageValidationException, CrosswalkException, IOException, AuthorizeException
-
addAmdSec
protected String addAmdSec(Context context, DSpaceObject dso, PackageParameters params, edu.harvard.hul.ois.mets.Mets mets, AbstractMETSDisseminator.MdStreamCache extraStreams) throws SQLException, PackageValidationException, CrosswalkException, IOException, AuthorizeException
-
makePersistentID
protected String makePersistentID(DSpaceObject dso)
-
makeManifest
protected edu.harvard.hul.ois.mets.Mets makeManifest(Context context, DSpaceObject dso, PackageParameters params, AbstractMETSDisseminator.MdStreamCache extraStreams) throws edu.harvard.hul.ois.mets.helper.MetsException, PackageValidationException, CrosswalkException, AuthorizeException, SQLException, IOException
Write out a METS manifest. Mostly lifted from Rob Tansley's METS exporter.- Parameters:
context- contextdso- DSpaceObjectparams- packaging paramsextraStreams- streams- Returns:
- METS manifest
- Throws:
edu.harvard.hul.ois.mets.helper.MetsException- if mets errorPackageValidationException- if validation errorCrosswalkException- if crosswalk errorAuthorizeException- if authorization errorSQLException- if database errorIOException- if IO error
-
addLogoBitstream
protected void addLogoBitstream(Context context, Bitstream logoBs, edu.harvard.hul.ois.mets.FileSec fileSec, edu.harvard.hul.ois.mets.Div div0, PackageParameters params) throws SQLException
- Throws:
SQLException
-
makeChildDiv
protected edu.harvard.hul.ois.mets.Div makeChildDiv(String type, DSpaceObject dso, PackageParameters params)
Create a<div>element with<mptr>which references a child object via its handle (and via a local file name, when recursively disseminating all child objects).- Parameters:
type- - type attr value for the<div>dso- - object for which to create the divparams- package params- Returns:
- a new
Divwithdsoas child.
-
findOriginalBitstream
protected Bitstream findOriginalBitstream(Item item, Bitstream derived) throws SQLException
For a bitstream that's a thumbnail or extracted text, find the corresponding bitstream it was derived from, in the ORIGINAL bundle.- Parameters:
item- the item we're dealing withderived- the derived bitstream- Returns:
- the corresponding original bitstream (or null)
- Throws:
SQLException- if database error
-
crosswalkToMetsElement
protected edu.harvard.hul.ois.mets.helper.MetsElement crosswalkToMetsElement(Context context, DisseminationCrosswalk xwalk, DSpaceObject dso, edu.harvard.hul.ois.mets.helper.MetsElement me) throws CrosswalkException, IOException, SQLException, AuthorizeException
-
linkLicenseRefsToBitstreams
protected void linkLicenseRefsToBitstreams(Context context, PackageParameters params, DSpaceObject dso, edu.harvard.hul.ois.mets.MdRef mdRef) throws SQLException, IOException, AuthorizeException
Cleanup our license file reference links, as Deposit Licenses and CC Licenses can be added two ways (and we only want to add them to zip package *once*): (1) Added as a normal Bitstream (assuming LICENSE and CC_LICENSE bundles will be included in pkg) (2) Added via a 'rightsMD' crosswalk (as they are rights information/metadata on an Item)So, if they are being added by *both*, then we want to just link the rightsMD
<mdRef>entry so that it points to the Bitstream location. This implementation is a bit 'hackish', but it's the best we can do, as the Harvard METS API doesn't allow us to go back and crawl an entire METS file to look for these inconsistencies/duplications.- Parameters:
context- current DSpace Contextparams- current Packager Parametersdso- current DSpace ObjectmdRef- the rightsMD<mdRef>element- Throws:
SQLException- if database errorIOException- if IO errorAuthorizeException- if authorization error
-
getObjectTypeString
public String getObjectTypeString(DSpaceObject dso)
Build a string which will be used as the "Type" of this object in the METS manifest.Default format is "DSpace [Type-as-string]".
- Parameters:
dso- DSpaceObject to create type-string for- Returns:
- a string which will represent this object Type in METS
- See Also:
Constants
-
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-oor--optionflags with the Packager script.- Returns:
- a string describing additional command-line options available with this packager
-
makeBitstreamURL
public String makeBitstreamURL(Context context, Bitstream bitstream, PackageParameters params) throws SQLException
Get the URL by which the METS manifest refers to a Bitstream member within the same package. In other words, this is generally a relative path link to where the Bitstream file is within the Zipped up package.For a manifest-only METS, this is a reference to an HTTP URL where the bitstream should be able to be downloaded from.
- Parameters:
context- contextbitstream- the Bitstreamparams- Packager Parameters- Returns:
- String in URL format naming path to bitstream.
- Throws:
SQLException- if database error
-
makeMetsHdr
public abstract edu.harvard.hul.ois.mets.MetsHdr makeMetsHdr(Context context, DSpaceObject dso, PackageParameters params) throws SQLException
Create metsHdr element - separate so subclasses can override.- Parameters:
context- contextdso- DSpaceObjectparams- packaging params- Returns:
- Mets header
- Throws:
SQLException- if database error
-
getProfile
public abstract String getProfile()
Returns name of METS profile to which this package conforms, e.g. "DSpace METS DIP Profile 1.0"- Returns:
- string name of profile.
-
bundleToFileGrp
public abstract String bundleToFileGrp(String bname)
Returns fileGrp's USE attribute value corresponding to a DSpace bundle name.- Parameters:
bname- name of DSpace bundle.- Returns:
- string name of fileGrp
-
getDmdTypes
public abstract String[] getDmdTypes(Context context, DSpaceObject dso, PackageParameters params) throws SQLException, IOException, AuthorizeException
Get the types of Item-wide DMD to include in package. Each element of the returned array is a String, which MAY be just a simple name, naming both the Crosswalk Plugin and the METS "MDTYPE", or a colon-separated pair consisting of the METS name followed by a colon and the Crosswalk Plugin name. E.g. the type string"DC:qualifiedDublinCore"tells it to create a METS section withMDTYPE="DC"and use the plugin named "qualifiedDublinCore" to obtain the data.- Parameters:
context- contextdso- DSpaceObjectparams- the PackageParameters passed to the disseminator.- Returns:
- array of metadata type strings, never null.
- Throws:
IOException- if IO errorSQLException- if database errorAuthorizeException- if authorization error
-
getTechMdTypes
public abstract String[] getTechMdTypes(Context context, DSpaceObject dso, PackageParameters params) throws SQLException, IOException, AuthorizeException
Get the type string of the technical metadata to create for each object and each Bitstream in an Item. The type string may be a simple name or colon-separated compound as specified forgetDmdTypes()above.- Parameters:
context- contextdso- DSpaceObjectparams- the PackageParameters passed to the disseminator.- Returns:
- array of metadata type strings, never null.
- Throws:
IOException- if IO errorSQLException- if database errorAuthorizeException- if authorization error
-
getSourceMdTypes
public abstract String[] getSourceMdTypes(Context context, DSpaceObject dso, PackageParameters params) throws SQLException, IOException, AuthorizeException
Get the type string of the source metadata to create for each object and each Bitstream in an Item. The type string may be a simple name or colon-separated compound as specified forgetDmdTypes()above.- Parameters:
context- contextdso- DSpaceObjectparams- the PackageParameters passed to the disseminator.- Returns:
- array of metadata type strings, never null.
- Throws:
IOException- if IO errorSQLException- if database errorAuthorizeException- if authorization error
-
getDigiprovMdTypes
public abstract String[] getDigiprovMdTypes(Context context, DSpaceObject dso, PackageParameters params) throws SQLException, IOException, AuthorizeException
Get the type string of the "digiprov" (digital provenance) metadata to create for each object and each Bitstream in an Item. The type string may be a simple name or colon-separated compound as specified forgetDmdTypes()above.- Parameters:
context- contextdso- DSpaceObjectparams- the PackageParameters passed to the disseminator.- Returns:
- array of metadata type strings, never null.
- Throws:
IOException- if IO errorSQLException- if database errorAuthorizeException- if authorization error
-
getRightsMdTypes
public abstract String[] getRightsMdTypes(Context context, DSpaceObject dso, PackageParameters params) throws SQLException, IOException, AuthorizeException
Get the type string of the "rights" (permission and/or license) metadata to create for each object and each Bitstream in an Item. The type string may be a simple name or colon-separated compound as specified forgetDmdTypes()above.- Parameters:
context- contextdso- DSpaceObjectparams- the PackageParameters passed to the disseminator.- Returns:
- array of metadata type strings, never null.
- Throws:
IOException- if IO errorSQLException- if database errorAuthorizeException- if authorization error
-
addStructMap
public abstract void addStructMap(Context context, DSpaceObject dso, PackageParameters params, edu.harvard.hul.ois.mets.Mets mets) throws SQLException, IOException, AuthorizeException, edu.harvard.hul.ois.mets.helper.MetsException
Add any additionalstructMapelements to the METS document, as required by this subclass. A simple default structure map which fulfills the minimal DSpace METS DIP/SIP requirements is already present, so this does not need to do anything.- Parameters:
context- contextdso- DSpaceObjectmets- the METS document to which to add structMapsparams- the PackageParameters passed to the disseminator.- Throws:
IOException- if IO errorSQLException- if database errorAuthorizeException- if authorization erroredu.harvard.hul.ois.mets.helper.MetsException- if METS error
-
includeBundle
public abstract boolean includeBundle(Bundle bundle)
- Parameters:
bundle- bundle- Returns:
- true when this bundle should be included as "content" in the package.. e.g. DSpace SIP does not include metadata bundles.
-
-