edu.uiuc.ndiipp.hubandspoke.profile
Class HaSMETSProfile

java.lang.Object
  extended by edu.uiuc.ndiipp.hubandspoke.profile.METSProfile
      extended by edu.uiuc.ndiipp.hubandspoke.profile.HaSMETSProfile
Direct Known Subclasses:
HaSMETSWebProfile

public class HaSMETSProfile
extends METSProfile

This class represents a METS XML document that conforms to the UIUC Hub and Spoke METS profile. This is basically a wrapper around various XMLBeans class libraries for the different XML Schema used by the profile.

Author:
thabing

Nested Class Summary
 
Nested classes/interfaces inherited from class edu.uiuc.ndiipp.hubandspoke.profile.METSProfile
METSProfile.AMD_SECTION, METSProfile.DMDSecStatus, METSProfile.PackageType, METSProfile.PREMISAgentType, METSProfile.PREMISEventType, METSProfile.PREMISIdentifierType, METSProfile.PREMISLinkingAgentRole, METSProfile.PREMISObjectCategory, METSProfile.PREMISSwType, METSProfile.StructMapType, METSProfile.TechMDStatus
 
Field Summary
 
Fields inherited from class edu.uiuc.ndiipp.hubandspoke.profile.METSProfile
AMD_NS, JHOVE_NS, METS_NS, MIX_NS, MODS_NS, PREMIS_NS, TEXTMD_NS, VMD_NS, XLINK_NS
 
Method Summary
 gov.loc.mets.MetsMdSecType addAgentToEvent(gov.loc.premis.PremisEventDocument event, gov.loc.premis.PremisAgentDocument agent, METSProfile.PREMISLinkingAgentRole agentRole)
          Associate the given PremisAgentDocument with the given PremisEventDocument using the given HaSMETSProfile.PREMISLinkingAgentRole.
 gov.loc.mets.MetsMdSecType addAlternateDmdSec(gov.loc.mets.MetsMdSecType.MdRef.MDTYPE.Enum type, java.lang.String otherType, java.io.File file)
          Add a new alternate dmdSec to the document.
 gov.loc.mets.MetsMdSecType addAlternateDmdSec(gov.loc.mets.MetsMdSecType.MdWrap.MDTYPE.Enum type, java.lang.String otherType, org.w3c.dom.Node xmlAny)
          Add a new alternate dmdSec to the document.
 gov.loc.mets.MetsMdSecType addEventToXmlObject(org.apache.xmlbeans.XmlObject mdSec, gov.loc.premis.PremisEventDocument event)
          Add the given PREMIS event as a new amdSec/digiprovMD element, also associate the given agents to the event
 gov.loc.mets.MetsMdSecType addEventToXmlObject(org.apache.xmlbeans.XmlObject mdSec, gov.loc.premis.PremisEventDocument event, gov.loc.premis.PremisAgentDocument[] agents, METSProfile.PREMISLinkingAgentRole[] roles)
          Add the given PREMIS event as a new amdSec/digiprovMD element, also associate the given agents to the event
 gov.loc.mets.MetsFileType addFile(java.io.File file)
          Add a new file and associated technical metadata to the METS document
 void addNewChecksum(gov.loc.mets.MetsFileType file, gov.loc.mets.MetsFileType.CHECKSUMTYPE.Enum cType, java.lang.String cValue)
          Add a new checksum to the file.
 void addNewPREMISObjectTechMDToAllFile()
          Add Premis object techMD to each file in the METS document, unless it already has one
 gov.loc.mets.MetsMdSecType addNewPrimaryRepresentation(METSProfile.PREMISIdentifierType idType, java.lang.String id)
          Add a new PRIMARY_REPRESENTATION Premis Object techMD section to the document
 void addPremisObjectIdentifierToFile(gov.loc.mets.MetsFileType file, METSProfile.PREMISIdentifierType idType, java.lang.String idVal, java.lang.String xlTitle)
          Add an objectIdentifier to the files associated PREMIS object technical metadata
 gov.loc.mets.MetsMdSecType addTechMDXmlObjectToFile(gov.loc.mets.MetsFileType ft, org.apache.xmlbeans.XmlObject xobj)
          Add a techMD/mdWrap/xmlData/any section of the appropriate type and link it to the given file element via the file elements ADMID attribute.
 void associateAmdSecToXmlObject(gov.loc.mets.MetsMdSecType mdSec, org.apache.xmlbeans.XmlObject xobj)
          Associate the given MetsMdSecType with the given XmlObject via the ADMID attribute of the XmlObject
 gov.loc.mods.ModsModsDocument augmentAquiferModsDocument(gov.loc.mods.ModsModsDocument modsDoc)
          Augment the ModsModsDocument so that it conforms to the Aquifer profile.
 void compareFiles(HaSMETSProfile mets)
          Compares files with those from another METS documents, checking for differences in file name, size, and mime type.
 void convertPrimaryDmdSecToAquifer()
           
static gov.loc.mods.ModsModsDocument createBasicAquiferModsDocument(java.lang.String title, gov.loc.mods.ModsResourceType.Enum resourceType, gov.loc.mods.ModsPhysicalDescriptionType.DigitalOrigin.Enum digitalOrigin, java.lang.String mimeType, java.lang.String location)
          Return a ModsModsDocument which is minimally compliant to the Aquifer MODS profile
static gov.loc.premis.PremisEventDocument createBasicPremisEvent(METSProfile.PREMISEventType eventType, java.lang.String eventDetail)
          Returns a basic PremisEventDocument with the given params The eventIdentifierValue is just the current dateTime and the eventIdentifierType is 'LOCAL'
static gov.loc.premis.PremisEventDocument createBasicPremisEvent(java.lang.String id, METSProfile.PREMISEventType eventType, java.lang.String eventDetail)
          Returns a basic PremisEventDocument with the given params
 gov.loc.mets.MetsMdSecType[] getAllAmdSecMDs(org.apache.xmlbeans.XmlObject xobj)
          If the given xobj has an ADMID attribute return all the MetsMdSecType elements that are referenced by that ADMID
 gov.loc.mets.MetsFileType[] getAllFiles()
          Return an array of XMLBean FileType objects for all files
 gov.loc.mets.MetsMdSecType[] getAlternateDmdSecArray()
          Returns the alternate dmdSec elements which has a STATUS='ALTERNATE_DMDSEC' attribute
 gov.loc.mets.MetsMdSecType getAlternateDmdSecArray(int i)
          Returns a specific alternate dmdSec element which has a STATUS='ALTERNATE_DMDSEC' attribute
 java.net.URI getBaseURIMinusFile()
          Return the base URI of the current METS file, minus the filename
 gov.loc.premis.PremisAgentDocument getDefaultHumanAgent()
          Return the default PREMIS agent which represent the current human operator
 gov.loc.premis.PremisAgentDocument getDefaultSoftwareAgent()
          Return the default PREMIS agent which represent this software
 java.io.InputStream getFileInputStream(gov.loc.mets.MetsFileType file)
          Return an InputStream for the MetsFileType object, can accomodate either the FContent or FLocat sub-elements
 gov.loc.mets.MetsFileType[] getFiles(gov.loc.mets.MetsFileType.CHECKSUMTYPE.Enum algorithm, java.lang.String digest)
          Given the CHECKSUM of a file return the XMLBean FileType object(s) that reference that file
 gov.loc.mets.MetsFileType[] getFiles(java.lang.String ids)
          Return an array of XMLBean FileType objects with a given ID(s)
 gov.loc.mets.MetsFileType.FLocat[] getFLocat(java.lang.String url)
          Given the URL of a file return the MetsFileType.FLocat(s) that reference that file in the href
 org.apache.xmlbeans.XmlObject getMDSecXmlObject(gov.loc.mets.MetsMdSecType mdsec)
          Return the xml which is either referenced or wrapped in the given mdSecType section.
 org.apache.xmlbeans.XmlID getNewID(java.lang.String prefix, org.apache.xmlbeans.XmlObject xobj)
          Get the next unassigned ID value that can be used in the METS file and assign it to an XmlObject
 METSProfile.PackageType getPackageType()
          Return the OAIS package type represented by the current METS document
 gov.loc.mets.MetsMdSecType getPrimaryDmdSec()
          Returns the primary dmdSec element which has a STATUS='PRIMARY_DMDSEC' attribute
 gov.loc.mets.MetsMdSecType getPrimaryRepresentation()
          Returns the primary representation techMD element which has a STATUS='PRIMARY_REPRESENTATION' attribute
 gov.loc.mets.MetsStructMapType getPrimaryStructMap()
          Returns the primary structMap element which has a TYPE='PRIMARY_STRUCTMAP' attribute
 gov.loc.mets.MetsMdSecType[] getSpecificAmdSecXmlData(org.apache.xmlbeans.XmlObject xobj, METSProfile.AMD_SECTION amdSec, javax.xml.namespace.QName qn)
          Return the specific administrative metadata MetsMdSec which is referenced from the XmlObject and is of the appropriate type
 gov.loc.mets.MetsMdSecType[] getTechMDsForFile(gov.loc.mets.MetsFileType ft)
          Return all the techMD sections associated with the given File
 org.apache.xmlbeans.XmlObject getXmlObject(java.lang.String id)
          Return an XmlObject for a given ID attribute value; you should cast this to an XMLBean object of the appropriate type
 METSProfile.PackageType guessPackageType(HaSMETSAppender app)
          Determine if the package is an AIP, SIP, or DIP by trying to validate it as if it was each type.
 boolean hasSpecificAmdSecXmlData(org.apache.xmlbeans.XmlObject xobj, METSProfile.AMD_SECTION amdSec, javax.xml.namespace.QName qn)
          Test whether the given XmlObject references an administrative metadata section of the given type which wraps metadata of a given type
 java.net.URI resolveURIAgainstBaseURI(java.lang.String relativeURI)
          Return a new URI which is the given relative URI string resolved against base URI for the METS document
 java.net.URI resolveURIAgainstBaseURI(java.net.URI relativeURI)
          Return a new URI which is the given relative URI resolved against the base URI for the METS document
 void save(java.lang.String dest)
          Save the METS document to the given destination file
 void saveFile(gov.loc.mets.MetsFileType file, java.lang.String path)
          Save the MetsFileType file to the given location
 void setBaseURI(java.net.URI baseURI)
          Set the base URI of the current METS file.
 void setLabelFromPrimaryDmdSec()
          Extracts the value of the MODS title element and sets it as the LABEL of the HaSMETSProfile
 org.w3c.dom.Node setMDSecXmlObject(gov.loc.mets.MetsMdSecType mdsec, org.apache.xmlbeans.XmlObject xobj)
          Set the xmlData of the given MetsMdSecType element to the given XmlObject.
 void setNewPrimaryID(java.lang.String idValue, METSProfile.PREMISIdentifierType idType)
          Use the given values to give the METS document a new identifier
 void setPackageType(METSProfile.PackageType packageType)
          Set the OAI package type of the current METS document
 boolean validateProfile(METSProfile.PackageType pt)
          Validate the METS document against the requirements of the METS HaS Profile
 boolean validateProfile(METSProfile.PackageType pt, HaSMETSAppender app)
          Validate the METS document against the requirements of the METS HaS Profile
 
Methods inherited from class edu.uiuc.ndiipp.hubandspoke.profile.METSProfile
createBasicPremisObject, createPremisObjectFromFile, getBaseURI, getMetsDocument, newPREMISObjectTechMD, newPREMISObjectTechMD, newPREMISObjectTechMD
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createBasicAquiferModsDocument

public static gov.loc.mods.ModsModsDocument createBasicAquiferModsDocument(java.lang.String title,
                                                                           gov.loc.mods.ModsResourceType.Enum resourceType,
                                                                           gov.loc.mods.ModsPhysicalDescriptionType.DigitalOrigin.Enum digitalOrigin,
                                                                           java.lang.String mimeType,
                                                                           java.lang.String location)
Return a ModsModsDocument which is minimally compliant to the Aquifer MODS profile

Parameters:
title -
resourceType -
digitalOrigin -
mimeType -
location -
Returns:
ModsModsDocument

createBasicPremisEvent

public static gov.loc.premis.PremisEventDocument createBasicPremisEvent(METSProfile.PREMISEventType eventType,
                                                                        java.lang.String eventDetail)
Returns a basic PremisEventDocument with the given params The eventIdentifierValue is just the current dateTime and the eventIdentifierType is 'LOCAL'

Parameters:
eventType -
eventDetail -
Returns:
PremisEventDocument

createBasicPremisEvent

public static gov.loc.premis.PremisEventDocument createBasicPremisEvent(java.lang.String id,
                                                                        METSProfile.PREMISEventType eventType,
                                                                        java.lang.String eventDetail)
Returns a basic PremisEventDocument with the given params

Parameters:
id -
eventType -
eventDetail -
Returns:
PremisEventDocument

addAgentToEvent

public gov.loc.mets.MetsMdSecType addAgentToEvent(gov.loc.premis.PremisEventDocument event,
                                                  gov.loc.premis.PremisAgentDocument agent,
                                                  METSProfile.PREMISLinkingAgentRole agentRole)
Associate the given PremisAgentDocument with the given PremisEventDocument using the given HaSMETSProfile.PREMISLinkingAgentRole. If there is already a PREMIS agent with the same identifier as the given agent then use the pre-exisitng agent; otherwise, create a new digiprovMD conatining the new agent

Parameters:
event - PremisEventDocument
agent - PremisAgentDocument
agentRole - HaSMETSProfile.PREMISLinkingAgentRole
Returns:
the MetsMdSecType containing the agent

addAlternateDmdSec

public gov.loc.mets.MetsMdSecType addAlternateDmdSec(gov.loc.mets.MetsMdSecType.MdRef.MDTYPE.Enum type,
                                                     java.lang.String otherType,
                                                     java.io.File file)
Add a new alternate dmdSec to the document. The dmdSec will reference the given file (METS mdRef). A reference to the new dmdSec will be added to the root div element of any structMaps

Parameters:
type - the MetsMdSecType.MdRef.MDTYPE for newly added dmdSec
otherType - if type is OTHER then set this to the other type
file - java.io.File representing MD to be referenced from a mdRef element
Returns:
the newly added dmdSec

addAlternateDmdSec

public gov.loc.mets.MetsMdSecType addAlternateDmdSec(gov.loc.mets.MetsMdSecType.MdWrap.MDTYPE.Enum type,
                                                     java.lang.String otherType,
                                                     org.w3c.dom.Node xmlAny)
Add a new alternate dmdSec to the document. The dmdSec will wrap the given XML DOM Node (METS mdWrap). A reference to the new dmdSec will be added to the root div element of any structMaps

Parameters:
type - the MetsMdSecType.MdWrap.MDTYPE for newly added dmdSec
otherType - if type is OTHER then set this to the other type
xmlAny - a DOM Node containing the XML for the newly added dmdSec
Returns:
the newly added dmdSec

addEventToXmlObject

public gov.loc.mets.MetsMdSecType addEventToXmlObject(org.apache.xmlbeans.XmlObject mdSec,
                                                      gov.loc.premis.PremisEventDocument event)
Add the given PREMIS event as a new amdSec/digiprovMD element, also associate the given agents to the event

Parameters:
mdSec - the MetsMdSecType element to associate with the event
event - the PremisEventDocument to use
Returns:
the MetsMdSecType for the newly added digiprovMD

addEventToXmlObject

public gov.loc.mets.MetsMdSecType addEventToXmlObject(org.apache.xmlbeans.XmlObject mdSec,
                                                      gov.loc.premis.PremisEventDocument event,
                                                      gov.loc.premis.PremisAgentDocument[] agents,
                                                      METSProfile.PREMISLinkingAgentRole[] roles)
Add the given PREMIS event as a new amdSec/digiprovMD element, also associate the given agents to the event

Parameters:
mdSec - the MetsMdSecType element to associate with the event
event - the PremisEventDocument to use
agents - an array of PremisAgentDocument elements associated to the event
roles - an array of HaSMETSProfile.PREMISLinkingAgentRole which are associated with each agent
Returns:
the MetsMdSecType for the newly added digiprovMD

addFile

public gov.loc.mets.MetsFileType addFile(java.io.File file)
                                  throws HaSMETSProfileException
Add a new file and associated technical metadata to the METS document

Parameters:
file -
Returns:
MetsFileType
Throws:
HaSMETSProfileException

addNewChecksum

public void addNewChecksum(gov.loc.mets.MetsFileType file,
                           gov.loc.mets.MetsFileType.CHECKSUMTYPE.Enum cType,
                           java.lang.String cValue)
                    throws HaSMETSProfileException
Add a new checksum to the file. This checksum will replace any CHECKSUM attributes on the file element, and it will also be added to the PREMIS object techMD, if any

Parameters:
file - the file of interest
cType - the checksum type
cValue - the checksum value
Throws:
HaSMETSProfileException

addNewPREMISObjectTechMDToAllFile

public void addNewPREMISObjectTechMDToAllFile()
                                       throws HaSMETSProfileException
Add Premis object techMD to each file in the METS document, unless it already has one

Throws:
HaSMETSProfileException

addNewPrimaryRepresentation

public gov.loc.mets.MetsMdSecType addNewPrimaryRepresentation(METSProfile.PREMISIdentifierType idType,
                                                              java.lang.String id)
                                                       throws HaSMETSProfileException
Add a new PRIMARY_REPRESENTATION Premis Object techMD section to the document

Parameters:
idType - the type of id to use for the object
id - the id to use for the object
Returns:
the newly added MetsMdSecType techMD
Throws:
HaSMETSProfileException - if the document already has a PRIMARY_REPRESENTATION

addPremisObjectIdentifierToFile

public void addPremisObjectIdentifierToFile(gov.loc.mets.MetsFileType file,
                                            METSProfile.PREMISIdentifierType idType,
                                            java.lang.String idVal,
                                            java.lang.String xlTitle)
                                     throws HaSMETSProfileException
Add an objectIdentifier to the files associated PREMIS object technical metadata

Parameters:
file - the file of interest
idType - the type of the new identifier
idVal - the value of the new identifier
Throws:
HaSMETSProfileException - if the file does not have an associated premis techMD

addTechMDXmlObjectToFile

public gov.loc.mets.MetsMdSecType addTechMDXmlObjectToFile(gov.loc.mets.MetsFileType ft,
                                                           org.apache.xmlbeans.XmlObject xobj)
                                                    throws HaSMETSProfileException
Add a techMD/mdWrap/xmlData/any section of the appropriate type and link it to the given file element via the file elements ADMID attribute.

Parameters:
ft - the FileType element to attach the new techMD to
xobj - the XmlObject to add under the xmlData section
Returns:
the newly added techMD section
Throws:
HaSMETSProfileException - if an unexpected type of XmlObject is passed

associateAmdSecToXmlObject

public void associateAmdSecToXmlObject(gov.loc.mets.MetsMdSecType mdSec,
                                       org.apache.xmlbeans.XmlObject xobj)
Associate the given MetsMdSecType with the given XmlObject via the ADMID attribute of the XmlObject

Parameters:
mdSec -
xobj -

augmentAquiferModsDocument

public gov.loc.mods.ModsModsDocument augmentAquiferModsDocument(gov.loc.mods.ModsModsDocument modsDoc)
Augment the ModsModsDocument so that it conforms to the Aquifer profile. Missing values will be derived from existing data in the profile when possible. If not possible default or boilerplate values will be supplied. All changes will be logged using log4j.

Parameters:
modsDoc - the ModsModsDocument to augment
Returns:
the augmented ModsModsDocument

compareFiles

public void compareFiles(HaSMETSProfile mets)
                  throws HaSMETSProfileException
Compares files with those from another METS documents, checking for differences in file name, size, and mime type.

Parameters:
mets - an EchoDep METS file
Throws:
HaSMETSProfileException

convertPrimaryDmdSecToAquifer

public void convertPrimaryDmdSecToAquifer()
                                   throws HaSMETSProfileException
Throws:
HaSMETSProfileException

getAllAmdSecMDs

public gov.loc.mets.MetsMdSecType[] getAllAmdSecMDs(org.apache.xmlbeans.XmlObject xobj)
If the given xobj has an ADMID attribute return all the MetsMdSecType elements that are referenced by that ADMID

Parameters:
xobj - XmlObject
Returns:
an array of MetsMdSecType elements, may be empty

getAllFiles

public gov.loc.mets.MetsFileType[] getAllFiles()
Return an array of XMLBean FileType objects for all files

Returns:
an array of XMLBean FileType objects

getAlternateDmdSecArray

public gov.loc.mets.MetsMdSecType[] getAlternateDmdSecArray()
Returns the alternate dmdSec elements which has a STATUS='ALTERNATE_DMDSEC' attribute

Returns:
MetsMdSecType[] object representing all the alternate dmdSec elements

getAlternateDmdSecArray

public gov.loc.mets.MetsMdSecType getAlternateDmdSecArray(int i)
Returns a specific alternate dmdSec element which has a STATUS='ALTERNATE_DMDSEC' attribute

Parameters:
i - the ordinal of the alternate dmdSec element to return
Returns:
MetsMdSecType object representing the ith alternate dmdSec element, or null

getBaseURIMinusFile

public java.net.URI getBaseURIMinusFile()
Return the base URI of the current METS file, minus the filename

Returns:
the base URI of the current METS file

getDefaultHumanAgent

public gov.loc.premis.PremisAgentDocument getDefaultHumanAgent()
Return the default PREMIS agent which represent the current human operator

Returns:
the default human PremisAgentDocument

getDefaultSoftwareAgent

public gov.loc.premis.PremisAgentDocument getDefaultSoftwareAgent()
Return the default PREMIS agent which represent this software

Returns:
the default software PremisAgentDocument

getFileInputStream

public java.io.InputStream getFileInputStream(gov.loc.mets.MetsFileType file)
                                       throws HaSMETSProfileException
Return an InputStream for the MetsFileType object, can accomodate either the FContent or FLocat sub-elements

Parameters:
file - the MetsFileType object for the file of interest
Returns:
the InputStream
Throws:
HaSMETSProfileException - if the stream is not accessible

getFiles

public gov.loc.mets.MetsFileType[] getFiles(gov.loc.mets.MetsFileType.CHECKSUMTYPE.Enum algorithm,
                                            java.lang.String digest)
Given the CHECKSUM of a file return the XMLBean FileType object(s) that reference that file

Parameters:
algorithm - CHECKSUM type
digest - CHECKSUM digest
Returns:
the MetsFileType[] for that file or null

getFiles

public gov.loc.mets.MetsFileType[] getFiles(java.lang.String ids)
Return an array of XMLBean FileType objects with a given ID(s)

Parameters:
ids - one or more ID values separated by space
Returns:
an array of XMLBean FileType objects

getFLocat

public gov.loc.mets.MetsFileType.FLocat[] getFLocat(java.lang.String url)
Given the URL of a file return the MetsFileType.FLocat(s) that reference that file in the href

Parameters:
url - String for the URL, either relative or absolute
Returns:
the MetsFileType.FLocat[] for that file or null

getMDSecXmlObject

public org.apache.xmlbeans.XmlObject getMDSecXmlObject(gov.loc.mets.MetsMdSecType mdsec)
                                                throws HaSMETSProfileException
Return the xml which is either referenced or wrapped in the given mdSecType section. Since the HaS profile is assumed, this method assumes just one child which is either wrapped or referenced. The XmlObject which will be returned will be one of these XMLBeans types depending on the xml: If the xml is not one of the recognized types a generic XmlObject will be returned

NOTE: The returned object is a copy; therefore, if changes are made which must be reflected back in the METS document the setMDSecXmlObject method must be called.

Parameters:
mdsec - an MdSecType object representing the MetsMdSecType element
Returns:
a XmlObject which may be cast into one of the appropriate XMLBean types list above
Throws:
HaSMETSProfileException - if the xmlData cannot be parsed into a recognized type or if the xml is not accessible

getNewID

public org.apache.xmlbeans.XmlID getNewID(java.lang.String prefix,
                                          org.apache.xmlbeans.XmlObject xobj)
Get the next unassigned ID value that can be used in the METS file and assign it to an XmlObject

Overrides:
getNewID in class METSProfile
Parameters:
prefix - string that will be prepended to all ID values, if this is null or empty string then the value "ID" will be used
xobj - the XmlObject to which the ID will be assigned
Returns:
an XmlID object representing the new ID attribute

getPackageType

public METSProfile.PackageType getPackageType()
Return the OAIS package type represented by the current METS document

Returns:
HaSMETSProfile.PackageType: SIP, DIP, AIP

getPrimaryDmdSec

public gov.loc.mets.MetsMdSecType getPrimaryDmdSec()
                                            throws HaSMETSProfileException
Returns the primary dmdSec element which has a STATUS='PRIMARY_DMDSEC' attribute

Returns:
MetsMdSecType object represetning the primary dmdSec element
Throws:
HaSMETSProfileException - if there is not exactly one primary dmdSec element

getPrimaryRepresentation

public gov.loc.mets.MetsMdSecType getPrimaryRepresentation()
                                                    throws HaSMETSProfileException
Returns the primary representation techMD element which has a STATUS='PRIMARY_REPRESENTATION' attribute

Returns:
MetsMdSecType object representing the primary representation techMD element
Throws:
HaSMETSProfileException - if there is not exactly one primary representation techMD element

getPrimaryStructMap

public gov.loc.mets.MetsStructMapType getPrimaryStructMap()
                                                   throws HaSMETSProfileException
Returns the primary structMap element which has a TYPE='PRIMARY_STRUCTMAP' attribute

Returns:
MetsMdSecType object representing the primary representation techMD element
Throws:
HaSMETSProfileException - if there is not exactly one primary structMap techMD element

getSpecificAmdSecXmlData

public gov.loc.mets.MetsMdSecType[] getSpecificAmdSecXmlData(org.apache.xmlbeans.XmlObject xobj,
                                                             METSProfile.AMD_SECTION amdSec,
                                                             javax.xml.namespace.QName qn)
Return the specific administrative metadata MetsMdSec which is referenced from the XmlObject and is of the appropriate type

Parameters:
xobj - the XmlObject to test
amdSec - the type of AMD_SECTION being looked for
qn - the QName of the root element in the xmlData being looked for
Returns:
MetsMDSecType[], may be empty of nothing matches

getTechMDsForFile

public gov.loc.mets.MetsMdSecType[] getTechMDsForFile(gov.loc.mets.MetsFileType ft)
Return all the techMD sections associated with the given File

Parameters:
ft - the XMLBean FileType object for the file object
Returns:
an array of XMLBean MdSecType objects (these will all be techMD elements)

getXmlObject

public org.apache.xmlbeans.XmlObject getXmlObject(java.lang.String id)
Return an XmlObject for a given ID attribute value; you should cast this to an XMLBean object of the appropriate type

Parameters:
id - the id string
Returns:
an XmlObjector null if none is found for the given id

guessPackageType

public METSProfile.PackageType guessPackageType(HaSMETSAppender app)
Determine if the package is an AIP, SIP, or DIP by trying to validate it as if it was each type. Currently, an AIP and a DIP are equivalent and both are also a valid SIP, so if the package passes the AIP validation, AIP is returned. If the package passes the SIP validation, but not the AIP (or DIP) validation SIP is returned. If none of the validations are passes, UNKNOWN is returned. This method will not aattempt to open each file as part of the validation, so it might report a valid AIP or SIP, but there still might be problems with the sizes or checksums of the actual files

Parameters:
app - an HaSMETSAppender to which error messages will be added, may be null
Returns:
HaSMETSProfile.PackageType which may be UNKNOWN

hasSpecificAmdSecXmlData

public boolean hasSpecificAmdSecXmlData(org.apache.xmlbeans.XmlObject xobj,
                                        METSProfile.AMD_SECTION amdSec,
                                        javax.xml.namespace.QName qn)
Test whether the given XmlObject references an administrative metadata section of the given type which wraps metadata of a given type

Parameters:
xobj - the XmlObject to test
amdSec - the type of AMD_SECTION being looked for
qn - the QName of the root element in the xmlData being looked for
Returns:
true or false

resolveURIAgainstBaseURI

public java.net.URI resolveURIAgainstBaseURI(java.lang.String relativeURI)
Return a new URI which is the given relative URI string resolved against base URI for the METS document

Parameters:
relativeURI - the relative URI to be resolved
Returns:
the new URI
See Also:
resolve

resolveURIAgainstBaseURI

public java.net.URI resolveURIAgainstBaseURI(java.net.URI relativeURI)
Return a new URI which is the given relative URI resolved against the base URI for the METS document

Parameters:
relativeURI - the relative URI to be resolved
Returns:
the new URI
See Also:
resolve

save

public void save(java.lang.String dest)
Save the METS document to the given destination file

Parameters:
dest -

saveFile

public void saveFile(gov.loc.mets.MetsFileType file,
                     java.lang.String path)
              throws HaSMETSProfileException
Save the MetsFileType file to the given location

Parameters:
file - the MetsFileType to save
path - the location to save
Throws:
HaSMETSProfileException

setBaseURI

public void setBaseURI(java.net.URI baseURI)
Set the base URI of the current METS file. Note this may invalidate any relative URLs contained in this file.

Parameters:
baseURI - the URI to set

setLabelFromPrimaryDmdSec

public void setLabelFromPrimaryDmdSec()
                               throws HaSMETSProfileException
Extracts the value of the MODS title element and sets it as the LABEL of the HaSMETSProfile

Throws:
HaSMETSProfileException

setMDSecXmlObject

public org.w3c.dom.Node setMDSecXmlObject(gov.loc.mets.MetsMdSecType mdsec,
                                          org.apache.xmlbeans.XmlObject xobj)
                                   throws HaSMETSProfileException
Set the xmlData of the given MetsMdSecType element to the given XmlObject. If the given mdsec already has xml metadata of the same type as that being set, either referenced or wrapped, it will be replaced. Referenced metadata of the same type will be replaced by wrapped metadata. If the existing metadata is of a different type that that being set an exception will be thrown.

Parameters:
mdsec - the MetsMdSecType object to which to add the XmlObject
xobj - the XmlObject to set
Returns:
the XML Node object representing the live DOM Node of the newly added XmlObject metadata
Throws:
HaSMETSProfileException - if the techMD//xmlData section contains multiple children or if the techMD//xmlData already contains an element which is of a different type than that being set

setNewPrimaryID

public void setNewPrimaryID(java.lang.String idValue,
                            METSProfile.PREMISIdentifierType idType)
                     throws HaSMETSProfileException
Use the given values to give the METS document a new identifier

Parameters:
idValue - String for the new id
idType - HaSMETSProfile.PREMISIdentifierType
Throws:
HaSMETSProfileException - if there is no Primary Representation

setPackageType

public void setPackageType(METSProfile.PackageType packageType)
Set the OAI package type of the current METS document

Parameters:
packageType - HaSMETSProfile.PackageType: SIP, DIP, AIP

validateProfile

public boolean validateProfile(METSProfile.PackageType pt)
Validate the METS document against the requirements of the METS HaS Profile

Parameters:
pt - the PackageType to assume for validation purposes

validateProfile

public boolean validateProfile(METSProfile.PackageType pt,
                               HaSMETSAppender app)
Validate the METS document against the requirements of the METS HaS Profile

Parameters:
pt - the PackageType to assume for validation purposes
app - HaSMETSAppender which will accumulate the log events, may be null


Copyright 2006, University of Illinois.