public class Packager extends Object
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.| Modifier and Type | Field and Description |
|---|---|
protected String |
packageType |
protected boolean |
submit |
protected boolean |
userInteractionEnabled |
| Constructor and Description |
|---|
Packager() |
| Modifier and Type | Method and Description |
|---|---|
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.
|
protected static void |
usageError(String msg) |
protected String packageType
protected boolean submit
protected boolean userInteractionEnabled
protected static void usageError(String msg)
protected void ingest(Context context, PackageIngester sip, PackageParameters pkgParams, String sourceFile, DSpaceObject[] parentObjs) throws IOException, SQLException, FileNotFoundException, AuthorizeException, CrosswalkException, PackageException
Please note that replace (-r -f) mode calls the replace() method instead.
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 toIOException - if IO errorSQLException - if database errorFileNotFoundException - if file doesn't existAuthorizeException - if authorization errorCrosswalkException - if crosswalk errorPackageException - if packaging errorprotected void disseminate(Context context, PackageDisseminator dip, DSpaceObject dso, PackageParameters pkgParams, String outputFile) throws IOException, SQLException, FileNotFoundException, AuthorizeException, CrosswalkException, PackageException
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 savedIOException - if IO errorSQLException - if database errorFileNotFoundException - if file doesn't existAuthorizeException - if authorization errorCrosswalkException - if crosswalk errorPackageException - if packaging errorprotected void replace(Context context, PackageIngester sip, PackageParameters pkgParams, String sourceFile, DSpaceObject objToReplace) throws IOException, SQLException, FileNotFoundException, AuthorizeException, CrosswalkException, PackageException
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)IOException - if IO errorSQLException - if database errorFileNotFoundException - if file doesn't existAuthorizeException - if authorization errorCrosswalkException - if crosswalk errorPackageException - if packaging errorCopyright © 2022 LYRASIS. All rights reserved.