public abstract class AbstractMETSDisseminator extends AbstractPackageDisseminator
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 is false.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.| Modifier and Type | Class and Description |
|---|---|
protected static class |
AbstractMETSDisseminator.MdStreamCache
Wrapper for a table of streams to add to the package, such as
mdRef'd metadata.
|
| Modifier and Type | Field and Description |
|---|---|
protected static java.lang.String |
TEMPLATE_TYPE_SUFFIX
Suffix for Template objects (e.g.
|
| Constructor and Description |
|---|
AbstractMETSDisseminator() |
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.String |
addAmdSec(Context context,
DSpaceObject dso,
PackageParameters params,
edu.harvard.hul.ois.mets.Mets mets,
AbstractMETSDisseminator.MdStreamCache extraStreams) |
protected void |
addBitstreamsToZip(Context context,
DSpaceObject dso,
PackageParameters params,
java.util.zip.ZipOutputStream zip)
Add Bitstreams associated with a given DSpace Object into an
existing ZipOutputStream
|
protected void |
addLogoBitstream(Bitstream logoBs,
edu.harvard.hul.ois.mets.FileSec fileSec,
edu.harvard.hul.ois.mets.Div div0,
PackageParameters params) |
abstract void |
addStructMap(Context context,
DSpaceObject dso,
PackageParameters params,
edu.harvard.hul.ois.mets.Mets mets)
Add any additional
structMap elements to the
METS document, as required by this subclass. |
protected void |
addToAmdSec(edu.harvard.hul.ois.mets.AmdSec fAmdSec,
java.lang.String[] mdTypes,
java.lang.Class mdSecClass,
Context context,
DSpaceObject dso,
PackageParameters params,
AbstractMETSDisseminator.MdStreamCache extraStreams) |
abstract java.lang.String |
bundleToFileGrp(java.lang.String bname)
Returns fileGrp's USE attribute value corresponding to a DSpace bundle name.
|
void |
disseminate(Context context,
DSpaceObject dso,
PackageParameters params,
java.io.File pkgFile)
Export the object (Item, Collection, or Community) as a
"package" on the indicated OutputStream.
|
protected static Bitstream |
findOriginalBitstream(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 java.lang.String |
gensym(java.lang.String prefix)
Make a new unique ID symbol with specified prefix.
|
abstract java.lang.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 java.lang.String[] |
getDmdTypes(Context context,
DSpaceObject dso,
PackageParameters params)
Get the types of Item-wide DMD to include in package.
|
protected java.lang.String |
getHandleURN(java.lang.String handle) |
java.lang.String |
getMIMEType(PackageParameters params)
Identifies the MIME-type of this package, e.g.
|
java.lang.String |
getObjectTypeString(DSpaceObject dso)
Build a string which will be used as the "Type" of this object in
the METS manifest.
|
java.lang.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. |
abstract java.lang.String |
getProfile()
Returns name of METS profile to which this package conforms, e.g.
|
abstract java.lang.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 java.lang.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 java.lang.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 boolean |
includeBundle(Bundle bundle) |
protected void |
linkLicenseRefsToBitstreams(Context context,
PackageParameters params,
DSpaceObject dso,
edu.harvard.hul.ois.mets.MdRef mdRef)
Cleanup our license file reference links, as Deposit Licenses & 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)
|
java.lang.String |
makeBitstreamURL(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.Div |
makeChildDiv(java.lang.String type,
DSpaceObject dso,
PackageParameters params)
Create a element with
|
protected edu.harvard.hul.ois.mets.Div |
makeFileDiv(java.lang.String fileID,
java.lang.String type) |
protected edu.harvard.hul.ois.mets.Mets |
makeManifest(Context context,
DSpaceObject dso,
PackageParameters params,
AbstractMETSDisseminator.MdStreamCache extraStreams)
Write out a METS manifest.
|
protected edu.harvard.hul.ois.mets.helper.MdSec |
makeMdSec(Context context,
DSpaceObject dso,
java.lang.Class mdSecClass,
java.lang.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.MetsHdr |
makeMetsHdr(Context context,
DSpaceObject dso,
PackageParameters params)
Create metsHdr element - separate so subclasses can override.
|
protected java.lang.String |
makePersistentID(DSpaceObject dso) |
protected void |
resetCounter()
Resets the unique ID counter used by gensym() method to
determine the @ID values of METS tags.
|
protected void |
setMdType(edu.harvard.hul.ois.mets.MdRef mdRef,
java.lang.String mdtype) |
protected void |
setMdType(edu.harvard.hul.ois.mets.MdWrap mdWrap,
java.lang.String mdtype) |
protected void |
writeZipPackage(Context context,
DSpaceObject dso,
PackageParameters params,
java.io.OutputStream pkg)
Make a Zipped up METS package for the given DSpace Object
|
addToPackageList, disseminateAll, getPackageListprotected static final java.lang.String TEMPLATE_TYPE_SUFFIX
protected java.lang.String gensym(java.lang.String prefix)
prefix - the prefix of the identifier, constrained to XML ID schemaprotected void resetCounter()
public java.lang.String getMIMEType(PackageParameters params)
PackageDisseminator"application/zip".
Required when sending the package via HTTP, to
provide the Content-Type header.public void disseminate(Context context, DSpaceObject dso, PackageParameters params, java.io.File pkgFile) throws PackageValidationException, CrosswalkException, AuthorizeException, java.sql.SQLException, java.io.IOException
Use the params parameter 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.
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 writtenPackageValidationException - if package cannot be created or there
is a fatal error in creating it.CrosswalkExceptionAuthorizeExceptionjava.sql.SQLExceptionjava.io.IOExceptionprotected void writeZipPackage(Context context, DSpaceObject dso, PackageParameters params, java.io.OutputStream pkg) throws PackageValidationException, CrosswalkException, edu.harvard.hul.ois.mets.helper.MetsException, AuthorizeException, java.sql.SQLException, java.io.IOException
context - DSpace Contextdso - The DSpace Objectparams - Parameters to the Packager scriptpkg - Package output streamPackageValidationExceptionAuthorizeExceptionjava.sql.SQLExceptionjava.io.IOExceptionCrosswalkExceptionedu.harvard.hul.ois.mets.helper.MetsExceptionprotected void addBitstreamsToZip(Context context, DSpaceObject dso, PackageParameters params, java.util.zip.ZipOutputStream zip) throws PackageValidationException, AuthorizeException, java.sql.SQLException, java.io.IOException
context - DSpace Contextdso - The DSpace Objectparams - Parameters to the Packager scriptzip - Zip outputPackageValidationExceptionAuthorizeExceptionjava.sql.SQLExceptionjava.io.IOExceptionprotected void setMdType(edu.harvard.hul.ois.mets.MdWrap mdWrap,
java.lang.String mdtype)
protected void setMdType(edu.harvard.hul.ois.mets.MdRef mdRef,
java.lang.String mdtype)
protected edu.harvard.hul.ois.mets.helper.MdSec makeMdSec(Context context, DSpaceObject dso, java.lang.Class mdSecClass, java.lang.String typeSpec, PackageParameters params, AbstractMETSDisseminator.MdStreamCache extraStreams) throws java.sql.SQLException, PackageValidationException, CrosswalkException, java.io.IOException, AuthorizeException
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 packagejava.sql.SQLExceptionPackageValidationExceptionCrosswalkExceptionjava.io.IOExceptionAuthorizeExceptionprotected void addToAmdSec(edu.harvard.hul.ois.mets.AmdSec fAmdSec,
java.lang.String[] mdTypes,
java.lang.Class mdSecClass,
Context context,
DSpaceObject dso,
PackageParameters params,
AbstractMETSDisseminator.MdStreamCache extraStreams)
throws java.sql.SQLException,
PackageValidationException,
CrosswalkException,
java.io.IOException,
AuthorizeException
java.sql.SQLExceptionPackageValidationExceptionCrosswalkExceptionjava.io.IOExceptionAuthorizeExceptionprotected java.lang.String addAmdSec(Context context, DSpaceObject dso, PackageParameters params, edu.harvard.hul.ois.mets.Mets mets, AbstractMETSDisseminator.MdStreamCache extraStreams) throws java.sql.SQLException, PackageValidationException, CrosswalkException, java.io.IOException, AuthorizeException
java.sql.SQLExceptionPackageValidationExceptionCrosswalkExceptionjava.io.IOExceptionAuthorizeExceptionprotected java.lang.String makePersistentID(DSpaceObject dso)
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, java.sql.SQLException, java.io.IOException
edu.harvard.hul.ois.mets.helper.MetsExceptionPackageValidationExceptionCrosswalkExceptionAuthorizeExceptionjava.sql.SQLExceptionjava.io.IOExceptionprotected void addLogoBitstream(Bitstream logoBs, edu.harvard.hul.ois.mets.FileSec fileSec, edu.harvard.hul.ois.mets.Div div0, PackageParameters params)
protected edu.harvard.hul.ois.mets.Div makeFileDiv(java.lang.String fileID,
java.lang.String type)
protected edu.harvard.hul.ois.mets.Div makeChildDiv(java.lang.String type,
DSpaceObject dso,
PackageParameters params)
type - - type attr value for the dso - - object for which to create the divparams - Div with dso as child.protected java.lang.String getHandleURN(java.lang.String handle)
protected static Bitstream findOriginalBitstream(Item item, Bitstream derived) throws java.sql.SQLException
item - the item we're dealing withderived - the derived bitstreamjava.sql.SQLExceptionprotected void linkLicenseRefsToBitstreams(Context context, PackageParameters params, DSpaceObject dso, edu.harvard.hul.ois.mets.MdRef mdRef) throws java.sql.SQLException, java.io.IOException, AuthorizeException
So, if they are being added by *both*, then we want to just link the rightsMD
context - current DSpace Contextparams - current Packager Parametersdso - current DSpace ObjectmdRef - the rightsMD java.sql.SQLExceptionjava.io.IOExceptionAuthorizeExceptionpublic java.lang.String getObjectTypeString(DSpaceObject dso)
Default format is "DSpace [Type-as-string]".
dso - DSpaceObject to create type-string forConstantspublic java.lang.String getParameterHelp()
-o or
--option flags with the Packager script.public java.lang.String makeBitstreamURL(Bitstream bitstream, PackageParameters params)
For a manifest-only METS, this is a reference to an HTTP URL where the bitstream should be able to be downloaded from.
bitstream - the Bitstreamparams - Packager Parameterspublic abstract edu.harvard.hul.ois.mets.MetsHdr makeMetsHdr(Context context, DSpaceObject dso, PackageParameters params)
public abstract java.lang.String getProfile()
public abstract java.lang.String bundleToFileGrp(java.lang.String bname)
bname - name of DSpace bundle.public abstract java.lang.String[] getDmdTypes(Context context, DSpaceObject dso, PackageParameters params) throws java.sql.SQLException, java.io.IOException, AuthorizeException
"DC:qualifiedDublinCore" tells it to
create a METS section with MDTYPE="DC" and use the plugin
named "qualifiedDublinCore" to obtain the data.params - the PackageParameters passed to the disseminator.java.sql.SQLExceptionjava.io.IOExceptionAuthorizeExceptionpublic abstract java.lang.String[] getTechMdTypes(Context context, DSpaceObject dso, PackageParameters params) throws java.sql.SQLException, java.io.IOException, AuthorizeException
getDmdTypes() above.params - the PackageParameters passed to the disseminator.java.sql.SQLExceptionjava.io.IOExceptionAuthorizeExceptionpublic abstract java.lang.String[] getSourceMdTypes(Context context, DSpaceObject dso, PackageParameters params) throws java.sql.SQLException, java.io.IOException, AuthorizeException
getDmdTypes() above.params - the PackageParameters passed to the disseminator.java.sql.SQLExceptionjava.io.IOExceptionAuthorizeExceptionpublic abstract java.lang.String[] getDigiprovMdTypes(Context context, DSpaceObject dso, PackageParameters params) throws java.sql.SQLException, java.io.IOException, AuthorizeException
getDmdTypes() above.params - the PackageParameters passed to the disseminator.java.sql.SQLExceptionjava.io.IOExceptionAuthorizeExceptionpublic abstract java.lang.String[] getRightsMdTypes(Context context, DSpaceObject dso, PackageParameters params) throws java.sql.SQLException, java.io.IOException, AuthorizeException
getDmdTypes() above.params - the PackageParameters passed to the disseminator.java.sql.SQLExceptionjava.io.IOExceptionAuthorizeExceptionpublic abstract void addStructMap(Context context, DSpaceObject dso, PackageParameters params, edu.harvard.hul.ois.mets.Mets mets) throws java.sql.SQLException, java.io.IOException, AuthorizeException, edu.harvard.hul.ois.mets.helper.MetsException
structMap elements 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.mets - the METS document to which to add structMapsjava.sql.SQLExceptionjava.io.IOExceptionAuthorizeExceptionedu.harvard.hul.ois.mets.helper.MetsExceptionpublic abstract boolean includeBundle(Bundle bundle)
Copyright © 2018 DuraSpace. All Rights Reserved.