org.dspace.app.packager
Class Packager

java.lang.Object
  extended by org.dspace.app.packager.Packager

public class Packager
extends Object

Command-line interface to the Packager plugin.

This class ONLY exists to provide a CLI for the packager plugins. It does not "manage" the plugins and it is not called from within DSpace, but the name follows a DSpace convention.

It can invoke one of the Submission (SIP) packagers to create a new DSpace Item out of a package, or a Dissemination (DIP) packager to write an Item out as a package.

Usage is as follows:
(Add the -h option to get the command to show its own help)

  1. To submit a SIP  (submissions tend to create a *new* object, with a new handle.  If you want to restore an object, see -r option below)
   dspace packager
       -e {ePerson}
       -t {PackagerType}
       -p {parent-handle} [ -p {parent2} ...]
       [-o {name}={value} [ -o {name}={value} ..]]
       [-a] --- also recursively ingest all child packages of the initial package
                (child pkgs must be referenced from parent pkg)
       [-w]   --- skip Workflow
       {package-filename}

   {PackagerType} must match one of the aliases of the chosen Packager
   plugin.

   The "-w" option circumvents Workflow, and is optional.  The "-o"
   option, which may be repeated, passes options to the packager
   (e.g. "metadataOnly" to a DIP packager).

  2. To restore an AIP  (similar to submit mode, but attempts to restore with the handles/parents specified in AIP):
   dspace packager
       -r     --- restores a object from a package info, including the specified handle (will throw an error if handle is already in use)
       -e {ePerson}
       -t {PackagerType}
       [-o {name}={value} [ -o {name}={value} ..]]
       [-a] --- also recursively restore all child packages of the initial package
                (child pkgs must be referenced from parent pkg)
       [-k]   --- Skip over errors where objects already exist and Keep Existing objects by default.
                  Use with -r to only restore objects which do not already exist.  By default, -r will throw an error
                  and rollback all changes when an object is found that already exists.
       [-f]   --- Force a restore (even if object already exists).
                  Use with -r to replace an existing object with one from a package (essentially a delete and restore).
                  By default, -r will throw an error and rollback all changes when an object is found that already exists.
       [-i {identifier-handle-of-object}] -- Optional when -f is specified.  When replacing an object, you can specify the
                  object to replace if it cannot be easily determined from the package itself.
       {package-filename}

   Restoring is very similar to submitting, except that you are recreating pre-existing objects.  So, in a restore, the object(s) are
   being recreated based on the details in the AIP.  This means that the object is recreated with the same handle and same parent/children
   objects.  Not all {PackagerTypes} may support a "restore".

  3. To write out a DIP:
   dspace packager
       -d
       -e {ePerson}
       -t {PackagerType}
       -i {identifier-handle-of-object}
       [-a] --- also recursively disseminate all child objects of this object
       [-o {name}={value} [ -o {name}={value} ..]]
       {package-filename}

   The "-d" switch chooses a Dissemination packager, and is required.
   The "-o" option, which may be repeated, passes options to the packager
   (e.g. "metadataOnly" to a DIP packager).
 
Note that {package-filename} may be "-" for standard input or standard output, respectively.

Version:
$Revision: 5844 $
Author:
Larry Stone, Tim Donohue

Constructor Summary
Packager()
           
 
Method Summary
protected  void disseminate(Context context, PackageDisseminator dip, DSpaceObject dso, PackageParameters pkgParams, String outputFile)
          Disseminate one or more DSpace objects into package(s) based on the options passed to the 'packager' script
protected  void ingest(Context context, PackageIngester sip, PackageParameters pkgParams, String sourceFile, DSpaceObject[] parentObjs)
          Ingest one or more DSpace objects from package(s) based on the options passed to the 'packager' script.
static void main(String[] argv)
           
protected  void replace(Context context, PackageIngester sip, PackageParameters pkgParams, String sourceFile, DSpaceObject objToReplace)
          Replace an one or more existing DSpace objects with the contents of specified package(s) based on the options passed to the 'packager' script.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Packager

public Packager()
Method Detail

main

public static void main(String[] argv)
                 throws Exception
Throws:
Exception

ingest

protected void ingest(Context context,
                      PackageIngester sip,
                      PackageParameters pkgParams,
                      String sourceFile,
                      DSpaceObject[] parentObjs)
               throws IOException,
                      SQLException,
                      FileNotFoundException,
                      AuthorizeException,
                      CrosswalkException,
                      PackageException
Ingest one or more DSpace objects from package(s) based on the options passed to the 'packager' script. This method is called for both 'submit' (-s) and 'restore' (-r) modes.

Please note that replace (-r -f) mode calls the replace() method instead.

Parameters:
context - DSpace Context
sip - PackageIngester which will actually ingest the package
pkgParams - Parameters to pass to individual packager instances
sourceFile - location of the source package to ingest
parentObjs - Parent DSpace object(s) to attach new object to
Throws:
IOException
SQLException
FileNotFoundException
AuthorizeException
CrosswalkException
PackageException

disseminate

protected void disseminate(Context context,
                           PackageDisseminator dip,
                           DSpaceObject dso,
                           PackageParameters pkgParams,
                           String outputFile)
                    throws IOException,
                           SQLException,
                           FileNotFoundException,
                           AuthorizeException,
                           CrosswalkException,
                           PackageException
Disseminate one or more DSpace objects into package(s) based on the options passed to the 'packager' script

Parameters:
context - DSpace context
dip - PackageDisseminator which will actually create the package
dso - DSpace Object to disseminate as a package
pkgParams - Parameters to pass to individual packager instances
outputFile - File where final package should be saved
identifier - identifier of main DSpace object to disseminate
Throws:
IOException
SQLException
FileNotFoundException
AuthorizeException
CrosswalkException
PackageException

replace

protected void replace(Context context,
                       PackageIngester sip,
                       PackageParameters pkgParams,
                       String sourceFile,
                       DSpaceObject objToReplace)
                throws IOException,
                       SQLException,
                       FileNotFoundException,
                       AuthorizeException,
                       CrosswalkException,
                       PackageException
Replace an one or more existing DSpace objects with the contents of specified package(s) based on the options passed to the 'packager' script. This method is only called for full replaces ('-r -f' options specified)

Parameters:
context - DSpace Context
sip - PackageIngester which will actually replace the object with the package
pkgParams - Parameters to pass to individual packager instances
sourceFile - location of the source package to ingest as the replacement
objToReplace - DSpace object to replace (may be null if it will be specified in the package itself)
Throws:
IOException
SQLException
FileNotFoundException
AuthorizeException
CrosswalkException
PackageException


Copyright © 2010 DuraSpace. All Rights Reserved.