Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

First, an Exception class to encapsulate other exceptions
encountered while ingesting or disseminating a package. Perhaps it
can be subclassed to give a finer-grained view of the type of
problem:

Panelcode

 /**
  *
 Failure when importing or exporting a package, e.g. unacceptable

  * package format or contents.


  */


 public class PackageException extends Exception

{
}

 \{
 \}

The ingester plugin has methods to create a new item out of a SIP
(ingest()), and
to overwrite an existing Item with a SIP (replace()).
Since the package is only
expected to describe the Item itself and its contents, other
necessary information must be passed as parameters – for example,
the Collection in which to create a new Item, or the Item to replace,
and the deposit license string to apply by default.
The packager implementation is free to override these parameters with
information from other sources, e.g. if the SIP contains the persistent
identifier of the Item it is replacing, the packager's replace()
method could ignore its parameter and use the data from the SIP.
Since most types of SIPs are completely
unrelated to DSpace and have no Collection or Item identifiers in them,
the packager needs to have them specified by an external source.

Panelcode

 /**

  * Plugin to ingest SIPs.


  */


 public interface SubmissionPackage extends SelfNamedPlugin

{

 \{
     /**
  • Create new Item out of the ingested package, in the indicated
  • collection. It creates a workspace item, so the application
  • can choose to enter it in workflow or just install it.
    *
  • @param context - DSpace context.
  • @param collection - collection under which to create new item.
  • @param in - input stream containing package to ingest.
  • @param params Properties-style list of options specific to this packager
  • @param license - may be null, which takes default license.
  • @return workspace item created by ingest.
  • @throws PackageException if package is unacceptable or there is
  • a fatal error turning it into an Item.
    */
    public WorkspaceItem ingest(Context context, Collection collection,
    InputStream in, PackageParameters params, String license)
    throws PackageException;
  • 
          * Create new Item out of the ingested package, in the indicated
          * collection.  It creates a workspace item, so the application
          * can choose to enter it in workflow or just install it.
          *
          * @param context - DSpace context.
          * @param collection - collection under which to create new item.
          * @param in - input stream containing package to ingest.
          * @param params Properties-style list of options specific to this packager
          * @param license - may be null, which takes default license.
          * @return workspace item created by ingest.
          * @throws PackageException if package is unacceptable or there is
          *  a fatal error turning it into an Item.
          */      
         public WorkspaceItem ingest(Context context, Collection collection,
                 InputStream in,  PackageParameters params, String license)
             throws PackageException;
    
    Code Block
    
         /**
          * Replace an existing Item with contents of the ingested package.
          * The packager MAY not implement replace; if it does, the exact
          * action is highly implementation-dependent.
          *
          * @param context - DSpace context.
          * @param item - existing item to be replaced
          * @param in - input stream containing package to ingest.
          * @param params Properties-style list of options specific to this packager
          * @return item re-created by ingest.
          * @throws PackageException if package is unacceptable or there is
          *  a fatal error turning it into an Item.
          * @throws UnsupportedOperationException if this packager does not
          *  implement 'replace'.
          */
         public Item replace(Context context, Item item, InputStream in, PackageParameters params)
             throws PackageException, UnsupportedOperationException;
     \}
    
    Panel

    /**

  • Replace an existing Item with contents of the ingested package.
  • The packager MAY not implement replace; if it does, the exact
  • action is highly implementation-dependent.
    *
  • @param context - DSpace context.
  • @param item - existing item to be replaced
  • @param in - input stream containing package to ingest.
  • @param params Properties-style list of options specific to this packager
  • @return item re-created by ingest.
  • @throws PackageException if package is unacceptable or there is
  • a fatal error turning it into an Item.
  • @throws UnsupportedOperationException if this packager does not
  • implement 'replace'.
    */
    public Item replace(Context context, Item item, InputStream in, PackageParameters params)
    throws PackageException, UnsupportedOperationException;
    }

    The disseminator plugin to create a DIP out of a DSpace Item.

    Panelcode
    
     /**
      *
     Plugin to export items as DIPs

    
      */

    
     public interface DisseminationPackage extends SelfNamedPlugin

    {
    /**Export the object
    
     \{
         /**
          * Export the object (Item, Collection, or Community) to
    a
  • package file on the indicated OutputStream.
  • Gets an exception of the object cannot be packaged or there is
  • a failure creating the package.
    *
  • @param context - DSpace context.
  • @param object - DSpace object (item, collection, etc)
  • @param params Properties-style list of options specific to this packager
  • @param out - output stream on which to write package
  • @throws PackageException if package cannot be created or there is
  • a fatal error in creating it.
    */
    public void disseminate(Context ctx, DSpaceObject obj,
    PackageParameters params, OutputStream out)
    throws PackageException;
  •  a
          * package file on the indicated OutputStream.
          * Gets an exception of the object cannot be packaged or there is
          * a failure creating the package.
          *
          * @param context - DSpace context.
          * @param object - DSpace object (item, collection, etc)
          * @param params Properties-style list of options specific to this packager
          * @param out - output stream on which to write package
          * @throws PackageException if package cannot be created or there is
          *  a fatal error in creating it.
          */
         public void disseminate(Context ctx, DSpaceObject obj,
                 PackageParameters params, OutputStream out)
             throws PackageException;
    
    Code Block
    
         /**
          * Identifies the MIME-type of this package, e.g. "application/zip"
          * equired when sending the package via e.g. WebDAV GET, to
          * provide the HTTP  Content-Type header.
          *
          * @return the MIME type (content-type header) of the package to be returned
          */
         String getMIMEType();
     \}
    
    Panel

    /**

  • Identifies the MIME-type of this package, e.g. "application/zip"
  • equired when sending the package via e.g. WebDAV GET, to
  • provide the HTTP Content-Type header.
    *
  • @return the MIME type (content-type header) of the package to be returned
    */
    String getMIMEType();
    }

    Packager Plugin Implementations

    ...

    The Packager application can be run from the command line to serve as a
    package-oriented batch import and export tool.

    Panelcode
    
     % dsrun org.dspace.app.packager.Packager -h

    
     usage: Packager
    options package-file
      options  package-file
     -c,--collection    destination collection(s) Handle (repeatable)

    
     -d,--disseminate   Disseminate package (output); default is to submit.

    
     -e,--eperson       email address of eperson doing
    importing
    h,-help help
    i,-item Handle of item to disseminate.
    o,-option Packager option to pass to plugin,
     importing
     -h,--help          help
     -i,--item          Handle of item to disseminate.
     -o,--option        Packager option to pass to plugin, "name=value"

    
     (repeatable)

    t,-type package type or MIMEtype
    w,-install disable workflow; install immediately without going
    through collection's workflow
    
     -t,--type          package type or MIMEtype
     -w,--install       disable workflow; install immediately without going
     through collection's workflow
    

    This command installs a SIP as a new item in
    the collection with handle 123.4/13

    Panelcode
    
     % dsrun org.dspace.app.packager.Packager -e lcs@mit.edu -c 123.4/13  -t pdf thesis.pdf
    

    This command gets a DIP of Item 123.4/34 in the METS format:

    Panelcode
    
     % dsrun org.dspace.app.packager.Packager -d -e lcs@mit.edu -i 123.4/34 -i -t METS
    

    Issues

    Should an importer save the exact original package file in a bitstream in the item it creates? A symmetric exporter*should be able to to recreate an exactly equivalent package. ANSWER: esolve this case-by-case, but generally do NOT save the package because it might be huge.

    ...