public abstract class AbstractMETSIngester extends AbstractPackageIngester
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.
Package Parameters:
validate -- true/false attempt to schema-validate the METS
manifest.manifestOnly -- package consists only of a manifest
document.ignoreHandle -- true/false, ignore AIP's idea of handle
when ingesting.ignoreParent -- true/false, ignore AIP's idea of parent
when ingesting.Configuration Properties:
mets.CONFIGNAME.ingest.preserveManifest - if 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.mets.CONFIGNAME.ingest.manifestBitstreamFormat - short name
of the bitstream format to apply to the manifest; MUST be specified when
preserveManifest is true.mets.default.ingest.crosswalk.MD_SEC_NAME = PLUGIN_NAME
Establishes a default crosswalk plugin for the given type of metadata in a
METS mdSec (e.g. "DC", "MODS"). The plugin may be either a stream or
XML-oriented ingestion crosswalk. Subclasses can override the default mapping
with their own, substituting their configurationName for "default" in the
configuration property key above.mets.CONFIGNAME.ingest.useCollectionTemplate - if
true, when an item is created, use the collection template. If it is
false (the default), any existing collection template is ignored.METSManifest,
AbstractPackageIngester,
PackageIngester| Modifier and Type | Class and Description |
|---|---|
protected static class |
AbstractMETSIngester.MdrefManager
An instance of ZipMdrefManager holds the state needed to retrieve the
contents of an external metadata stream referenced by an
mdRef element in a Zipped up METS manifest. |
| Modifier and Type | Field and Description |
|---|---|
protected BitstreamFormatService |
bitstreamFormatService |
protected BitstreamService |
bitstreamService |
protected BundleService |
bundleService |
protected CollectionService |
collectionService |
protected CommunityService |
communityService |
protected HandleService |
handleService |
protected ItemService |
itemService |
protected WorkspaceItemService |
workspaceItemService |
| Constructor and Description |
|---|
AbstractMETSIngester() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addBitstreams(Context context,
Item item,
METSManifest manifest,
File pkgFile,
PackageParameters params,
AbstractMETSIngester.MdrefManager mdRefCallback)
Add Bitstreams to an Item, based on the files listed in the METS Manifest
|
protected void |
addContainerLogo(Context context,
DSpaceObject dso,
METSManifest manifest,
File pkgFile,
PackageParameters params)
Add a Logo to a Community or Collection container object based on a METS
Manifest.
|
abstract void |
addLicense(Context context,
Item item,
String license,
Collection collection,
PackageParameters params)
Add license(s) to Item based on contents of METS and other policies.
|
protected void |
addManifestBitstream(Context context,
Item item,
METSManifest manifest)
Save/Preserve the METS Manifest as a Bitstream attached to the given
DSpace item.
|
protected void |
addTemplateItem(Context context,
DSpaceObject dso,
METSManifest manifest,
File pkgFile,
PackageParameters params,
AbstractMETSIngester.MdrefManager callback)
Add a Template Item to a Collection container object based on a METS
Manifest.
|
abstract void |
crosswalkObjectDmd(Context context,
DSpaceObject dso,
METSManifest manifest,
AbstractMETSIngester.MdrefManager callback,
org.jdom.Element[] dmds,
PackageParameters params)
Select the
dmdSec element(s) to apply to the Item. |
protected String |
decodeHandleURN(String value)
Parse the hdl: URI/URN format into a raw Handle.
|
abstract void |
finishBitstream(Context context,
Bitstream bs,
org.jdom.Element mfile,
METSManifest manifest,
PackageParameters params)
Subclass-dependent final processing on a Bitstream; could include fixing
up the name, bundle, other attributes.
|
abstract void |
finishObject(Context context,
DSpaceObject dso,
PackageParameters params)
Hook for final "finishing" operations on the new Object.
|
abstract String |
getConfigurationName()
Returns keyword that makes the configuration keys of this subclass
unique, e.g.
|
protected static InputStream |
getFileInputStream(File pkgFile,
PackageParameters params,
String path)
Retrieve the inputStream for a File referenced from a specific path
within a METS package.
|
protected String |
getManifestBitstreamFormat() |
String |
getObjectHandle(METSManifest manifest)
Determines the handle of the DSpace object represented in this METS doc.
|
abstract int |
getObjectType(METSManifest manifest)
Determines what type of DSpace object is represented in this METS doc.
|
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. |
DSpaceObject |
getParentObject(Context context,
METSManifest manifest)
Determines what parent DSpace object is referenced in this METS doc.
|
DSpaceObject |
ingest(Context context,
DSpaceObject parent,
File pkgFile,
PackageParameters params,
String license)
Create a new DSpace object out of a METS content package.
|
protected DSpaceObject |
ingestObject(Context context,
DSpaceObject parent,
METSManifest manifest,
File pkgFile,
PackageParameters params,
String license)
Ingest/import a single DSpace Object, based on the associated METS
Manifest and the parameters passed to the METSIngester
|
protected METSManifest |
parsePackage(Context context,
File pkgFile,
PackageParameters params)
Parse a given input package, ultimately returning the METS manifest out
of the package.
|
protected boolean |
preserveManifest() |
protected void |
removeObject(Context context,
DSpaceObject dso)
Remove an existing DSpace Object (called during a replace)
|
DSpaceObject |
replace(Context context,
DSpaceObject dsoToReplace,
File pkgFile,
PackageParameters params)
Replace an existing DSpace object with the contents of a METS-based
package.
|
protected DSpaceObject |
replaceObject(Context context,
DSpaceObject dso,
METSManifest manifest,
File pkgFile,
PackageParameters params,
String license)
Replace the contents of a single DSpace Object, based on the associated
METS Manifest and the parameters passed to the METSIngester.
|
protected boolean |
useCollectionTemplate() |
addPackageReference, addToIngestedMap, getIngestedList, getIngestedMap, getPackageReferences, ingestAll, replaceAllprotected final BitstreamService bitstreamService
protected final BitstreamFormatService bitstreamFormatService
protected final BundleService bundleService
protected final CommunityService communityService
protected final CollectionService collectionService
protected final ItemService itemService
protected final HandleService handleService
protected final WorkspaceItemService workspaceItemService
public DSpaceObject ingest(Context context, DSpaceObject parent, File pkgFile, PackageParameters params, String license) throws PackageValidationException, CrosswalkException, AuthorizeException, SQLException, IOException, WorkflowException
context - DSpace context.parent - parent under which to create new object (may be null -- in
which case ingester must determine parent from package or
throw an error).pkgFile - The package file to ingestparams - Properties-style list of options (interpreted by each
packager).license - may be null, which takes default license.PackageValidationException - if package validation error
if package is unacceptable or there is a fatal error turning
it into a DSpaceObject.CrosswalkException - if crosswalk errorAuthorizeException - if authorization errorSQLException - if database errorIOException - if IO errorWorkflowException - if workflow errorprotected METSManifest parsePackage(Context context, File pkgFile, PackageParameters params) throws IOException, SQLException, AuthorizeException, MetadataValidationException
context - DSpace ContextpkgFile - package to parseparams - Ingestion parametersIOException - if IO errorSQLException - if database errorAuthorizeException - if authorization errorMetadataValidationException - if metadata validation errorprotected DSpaceObject ingestObject(Context context, DSpaceObject parent, METSManifest manifest, File pkgFile, PackageParameters params, String license) throws IOException, SQLException, AuthorizeException, CrosswalkException, PackageValidationException, WorkflowException
context - DSpace Contextparent - Parent DSpace Objectmanifest - the parsed METS ManifestpkgFile - the full package file (which may include content files if a
zip)params - Parameters passed to METSIngesterlicense - DSpace license agreementIOException - if IO errorSQLException - if database errorAuthorizeException - if authorization errorCrosswalkException - if crosswalk errorMetadataValidationException - if metadata validation errorWorkflowException - if workflow errorPackageValidationException - if package validation errorprotected DSpaceObject replaceObject(Context context, DSpaceObject dso, METSManifest manifest, File pkgFile, PackageParameters params, String license) throws IOException, SQLException, AuthorizeException, CrosswalkException, MetadataValidationException, PackageValidationException
context - DSpace Contextdso - DSpace Object to replacemanifest - the parsed METS ManifestpkgFile - the full package file (which may include content files if a
zip)params - Parameters passed to METSIngesterlicense - DSpace license agreementIOException - if IO errorSQLException - if database errorAuthorizeException - if authorization errorCrosswalkException - if crosswalk errorMetadataValidationException - if metadata validation errorPackageValidationException - if package validation errorprotected void addBitstreams(Context context, Item item, METSManifest manifest, File pkgFile, PackageParameters params, AbstractMETSIngester.MdrefManager mdRefCallback) throws SQLException, IOException, AuthorizeException, MetadataValidationException, CrosswalkException, PackageValidationException
context - DSpace Contextitem - DSpace Itemmanifest - METS ManifestpkgFile - the full package file (which may include content files if a
zip)params - Ingestion ParametersmdRefCallback - MdrefManager storing info about mdRefs in manifestSQLException - if database errorIOException - if IO errorAuthorizeException - if authorization errorMetadataValidationException - if metadata validation errorCrosswalkException - if crosswalk errorPackageValidationException - if package validation errorprotected void addManifestBitstream(Context context, Item item, METSManifest manifest) throws IOException, SQLException, AuthorizeException, PackageValidationException
context - DSpace Contextitem - DSpace Itemmanifest - The METS ManifestIOException - if IO errorSQLException - if database errorAuthorizeException - if authorization errorPackageValidationException - if package validation errorprotected void addContainerLogo(Context context, DSpaceObject dso, METSManifest manifest, File pkgFile, PackageParameters params) throws SQLException, IOException, AuthorizeException, MetadataValidationException, PackageValidationException
context - DSpace Contextdso - DSpace Container Objectmanifest - METS ManifestpkgFile - the full package file (which may include content files if a
zip)params - Ingestion ParametersSQLException - if database errorIOException - if IO errorAuthorizeException - if authorization errorMetadataValidationException - if metadata validation errorPackageValidationException - if package validation errorprotected void addTemplateItem(Context context, DSpaceObject dso, METSManifest manifest, File pkgFile, PackageParameters params, AbstractMETSIngester.MdrefManager callback) throws SQLException, IOException, AuthorizeException, CrosswalkException, PackageValidationException
context - DSpace Contextdso - DSpace Container Objectmanifest - METS ManifestpkgFile - the full package file (which may include content files if a
zip)params - Ingestion Parameterscallback - the MdrefManager (manages all external metadata files
referenced by METS mdref elements)SQLException - if database errorIOException - if IO errorAuthorizeException - if authorization errorMetadataValidationException - if metadata validation errorPackageValidationException - if package validation errorCrosswalkExceptionpublic DSpaceObject replace(Context context, DSpaceObject dsoToReplace, File pkgFile, PackageParameters params) throws PackageValidationException, CrosswalkException, AuthorizeException, SQLException, IOException, WorkflowException
This method is similar to ingest(), except that if the object already exists in DSpace, it is emptied of files and metadata. The METS-based package is then used to ingest new values for these.
context - DSpace ContextdsoToReplace - DSpace Object to be replaced (may be null if it will be
specified in the METS manifest itself)pkgFile - The package file to ingestparams - Parameters passed from the packager scriptPackageValidationException - if package validation error
if package is unacceptable or there is a fatal error turning
it into a DSpace Object.IOException - if IO errorSQLException - if database errorAuthorizeException - if authorization errorCrosswalkException - if crosswalk errorWorkflowException - if workflow errorprotected boolean preserveManifest()
protected String getManifestBitstreamFormat()
protected boolean useCollectionTemplate()
protected String decodeHandleURN(String value)
value - handle URI stringprotected void removeObject(Context context, DSpaceObject dso) throws AuthorizeException, SQLException, IOException
context - contextdso - DSpace ObjectIOException - if IO errorSQLException - if database errorAuthorizeException - if authorization errorpublic DSpaceObject getParentObject(Context context, METSManifest manifest) throws PackageValidationException, MetadataValidationException, SQLException
This is a default implementation which assumes the parent will be specified in a <structMap LABEL="Parent">. You should override this method if your METS manifest specifies the parent object in another location.
context - DSpace Contextmanifest - METS manifestPackageValidationException - if package validation error
if parent reference cannot be found in manifestMetadataValidationException - if metadata validation errorSQLException - if database errorpublic String getObjectHandle(METSManifest manifest) throws PackageValidationException, MetadataValidationException, SQLException
This is a default implementation which assumes the handle of the DSpace Object can be found in the <mets> @OBJID attribute. You should override this method if your METS manifest specifies the handle in another location. If no handle was found then null is returned.
manifest - METS manifestPackageValidationException - if package validation error
if handle cannot be found in manifestMetadataValidationException - if validation errorSQLException - if database errorprotected static InputStream getFileInputStream(File pkgFile, PackageParameters params, String path) throws MetadataValidationException, IOException
If the packager is set to 'manifest-only' (i.e. pkgFile is just a manifest), we assume the file is available for download via a URL.
Otherwise, the pkgFile is a Zip, so the file should be retrieved from within that Zip package.
pkgFile - the full package file (which may include content files if a
zip)params - Parameters passed to METSIngesterpath - the File path (either path in Zip package or a URL)MetadataValidationException - if validation errorIOException - if IO errorpublic String getParameterHelp()
-o or
--option flags with the Packager script.public abstract void crosswalkObjectDmd(Context context, DSpaceObject dso, METSManifest manifest, AbstractMETSIngester.MdrefManager callback, org.jdom.Element[] dmds, PackageParameters params) throws CrosswalkException, PackageValidationException, AuthorizeException, SQLException, IOException
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.crosswalkItemDmd(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.
context - the DSpace contextdso - DSpace Objectmanifest - the METSManifestcallback - 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 - CrosswalkException - if crosswalk errorPackageValidationException - if package validation errorIOException - if IO errorSQLException - if database errorAuthorizeException - if authorization errorpublic abstract void addLicense(Context context, Item item, String license, Collection collection, PackageParameters params) throws PackageValidationException, AuthorizeException, SQLException, IOException
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.
Note that crosswalking rightsMD sections can also add a deposit or CC license to the object.
context - the DSpace contextitem - Itemcollection - DSpace Collection to which the item is being submitted.license - optional user-supplied Deposit License text (may be null)params - PackageValidationException - if package validation errorIOException - if IO errorSQLException - if database errorAuthorizeException - if authorization errorpublic abstract void finishObject(Context context, DSpaceObject dso, PackageParameters params) throws PackageValidationException, CrosswalkException, AuthorizeException, SQLException, IOException
context - the DSpace contextdso - the DSpace Objectparams - the Packager ParametersCrosswalkException - if crosswalk errorPackageValidationException - if package validation errorIOException - if IO errorSQLException - if database errorAuthorizeException - if authorization errorpublic abstract int getObjectType(METSManifest manifest) throws PackageValidationException
manifest - METS manifestPackageValidationException - if package validation errorpublic abstract void finishBitstream(Context context, Bitstream bs, org.jdom.Element mfile, METSManifest manifest, PackageParameters params) throws MetadataValidationException, SQLException, AuthorizeException, IOException
context - contextmanifest - METS manifestbs - bitstreammfile - elementparams - package paramsMetadataValidationException - if validation errorIOException - if IO errorSQLException - if database errorAuthorizeException - if authorization errorpublic abstract String getConfigurationName()
Copyright © 2022 LYRASIS. All rights reserved.