Package org.dspace.app.packager
Class Packager
- java.lang.Object
-
- 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$
- Author:
- Larry Stone, Tim Donohue
-
-
Field Summary
Fields Modifier and Type Field Description protected StringpackageTypeprotected booleansubmitprotected booleanuserInteractionEnabled
-
Constructor Summary
Constructors Constructor Description Packager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddisseminate(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' scriptprotected voidingest(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 voidmain(String[] argv)protected voidreplace(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.protected static voidusageError(String msg)
-
-
-
Field Detail
-
packageType
protected String packageType
-
submit
protected boolean submit
-
userInteractionEnabled
protected boolean userInteractionEnabled
-
-
Method Detail
-
usageError
protected static void usageError(String msg)
-
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 Contextsip- PackageIngester which will actually ingest the packagepkgParams- Parameters to pass to individual packager instancessourceFile- location of the source package to ingestparentObjs- Parent DSpace object(s) to attach new object to- Throws:
IOException- if IO errorSQLException- if database errorFileNotFoundException- if file doesn't existAuthorizeException- if authorization errorCrosswalkException- if crosswalk errorPackageException- if packaging error
-
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 contextdip- PackageDisseminator which will actually create the packagedso- DSpace Object to disseminate as a packagepkgParams- Parameters to pass to individual packager instancesoutputFile- File where final package should be saved- Throws:
IOException- if IO errorSQLException- if database errorFileNotFoundException- if file doesn't existAuthorizeException- if authorization errorCrosswalkException- if crosswalk errorPackageException- if packaging error
-
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 Contextsip- PackageIngester which will actually replace the object with the packagepkgParams- Parameters to pass to individual packager instancessourceFile- location of the source package to ingest as the replacementobjToReplace- DSpace object to replace (may be null if it will be specified in the package itself)- Throws:
IOException- if IO errorSQLException- if database errorFileNotFoundException- if file doesn't existAuthorizeException- if authorization errorCrosswalkException- if crosswalk errorPackageException- if packaging error
-
-