org.dspace.content.packager
Class IMSCPManifest

java.lang.Object
  extended by org.dspace.content.packager.IMSCPManifest
Direct Known Subclasses:
OCWIMSCPManifest

public abstract class IMSCPManifest
extends Object

Models the IMSCP Manifest document. The expected lifecycle of this object: create a new instance for each manifest, call parse() to read it, and then make queries about its contents.

For more information about IMSCP, see IMS Global Learning Consortium, http://www.imsglobal.org/content/packaging/

Note that this is an abstract class. The IMSCP manifest is a pretty abstract concept; in use it will be tightly profiled so the interpretation belongs in a subclass customized for that profile.

Version:
$Revision$
Author:
Larry Stone

Field Summary
protected  org.jdom.Namespace imscp_ns
          IMSCP namespace of root, which can vary.
protected  org.jdom.Element manifest
          root element of parsed manifest.
static String MANIFEST_FILE
          Filename of manifest, relative to package toplevel.
 
Constructor Summary
IMSCPManifest()
           
 
Method Summary
 void checkManifest()
          Sanity-check a newly-parsed manifest; separate operation so subclasses can override it.
 String getBase()
          Return value of manifest's xml:base attribute, or "" if there is none so caller can use "+" to assemble pathnames.
 Set getContentFiles()
          Get local (package) files referenced by manifest as containing content.
abstract  BitstreamFormat getManifestBitstreamFormat(Context context)
          Return the special bitstream format used to identify this particular (sub)class of IMSCP manifest.
 org.jdom.Element getMetadata()
          Get the "metadata" element of the manifest, throw exception if it is not available.
 Set getMetadataFiles()
          Get local (package) files referenced by manifest as containing metadata.
 void parse(InputStream docStream, boolean validate)
          Parse the manifest, store the results for later queries.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MANIFEST_FILE

public static final String MANIFEST_FILE
Filename of manifest, relative to package toplevel.

See Also:
Constant Field Values

manifest

protected org.jdom.Element manifest
root element of parsed manifest.


imscp_ns

protected org.jdom.Namespace imscp_ns
IMSCP namespace of root, which can vary.

Constructor Detail

IMSCPManifest

public IMSCPManifest()
Method Detail

parse

public void parse(InputStream docStream,
                  boolean validate)
           throws MetadataValidationException,
                  IOException
Parse the manifest, store the results for later queries.

Parameters:
docStream - input stream with XML document on it.
validate - true to do XML Schema validation.
Throws:
MetadataValidationException
IOException

getBase

public String getBase()
Return value of manifest's xml:base attribute, or "" if there is none so caller can use "+" to assemble pathnames.

Returns:
base URI, if any, or empty string.

getMetadata

public org.jdom.Element getMetadata()
                             throws MetadataValidationException
Get the "metadata" element of the manifest, throw exception if it is not available.

Returns:
metadata element, never null.
Throws:
MetadataValidationException

checkManifest

public void checkManifest()
                   throws MetadataValidationException
Sanity-check a newly-parsed manifest; separate operation so subclasses can override it. Subclass should call super.checkManifest(); first. Return nothing, throw on any failures.

Throws:
MetadataValidationException

getContentFiles

public Set getContentFiles()
                    throws PackageValidationException
Get local (package) files referenced by manifest as containing content. Includes all files that must be expected to be in package.

Collect set of files named in "resources" element. They are either (a) resource@href or (b) resource/file@href NOTE: since paths are stored in a Set, it doesn't hurt to make duplicate entries, so just grab all possible paths.

If a subclass overrides this method it should call the "super" version to combine that list of files with the extra files defined by its profile.

Returns:
Set of String pathnames (never null).
Throws:
PackageValidationException

getMetadataFiles

public Set getMetadataFiles()
                     throws MetadataValidationException
Get local (package) files referenced by manifest as containing metadata. E.g. LOM for specific learning objects. Subclasses should override this method since the default is to return an empty set.

Returns:
Set of String pathnames (never null).
Throws:
MetadataValidationException

getManifestBitstreamFormat

public abstract BitstreamFormat getManifestBitstreamFormat(Context context)
                                                    throws SQLException,
                                                           AuthorizeException,
                                                           IOException
Return the special bitstream format used to identify this particular (sub)class of IMSCP manifest.

Returns:
special bitstream format marking manifest (never null).
Throws:
SQLException
AuthorizeException
IOException


Copyright © 2010 The DSpace Foundation. All Rights Reserved.