PackageOperation

PackageOperation

PackageOperation contains information describing a number of files to be packaged, what format they should be packed into, and where the final output should be stored.

Constructor

new PackageOperation(packageName, outputPath)

Creates a new PackageOperation.

Parameters:
Name Type Description
packageName string

The name of the package to create. Typically, this is the name of a bag, excluding any '.tar', '.zip' or other file format extension.

outputPath string

The absolute path to which the package should be written.

Source:

Members

_trimLeadingPaths :boolean

This indicates whether DART should trim common leading paths when packaging files. Use the method trimLeadingPaths instead of accessing this directory.

Let's assume you have the following in sourceFiles:

  • '/path/to/some/dir/photos'
  • '/path/to/some/dir/audios'
  • '/path/to/some/dir/videos'

These all have a common leading path of '/path/to/some/dir', which can be stripped off in the packaging process. So setting _trimLeadingPaths to true would lead to these files being bagged as:

  • 'data/photos'
  • 'data/audios'
  • 'data/videos'

If _trimLeadingPaths is false, these will be bagged as:

  • 'data/path/to/some/dir/photos'
  • 'data/path/to/some/dir/audios'
  • 'data/path/to/some/dir/videos'

Note that trimLeadingPaths is useless if the files in sourceFiles have no common leading path.

Source:

bagItSerialization :string

The serialization format of the bag to be produced. This applies only when creating bags. Some profiles include an acceptSerialization attribute describing what types of serialization are allowed. Types typically include 'application/tar', 'application/zip', etc.

Source:

errors :Object.<string, string>

Contains information describing validation errors. Key is the name of the invalid field. Value is a description of why the field is not valid.

Source:

outputPath :string

The absolute path to the file or directory in which to put the completed package. In other words the absolute path to the final .tar, .zip, or other file DART is creating. If DART is writing a bag to a directory, this path should point to that directory.

Source:

packageFormat :string

The format of the output package. E.g. '.tar', 'directory', etc.

DART allows a single plugin to write multiple formats, and several plugins may be able to write the same format. Therefore, packageFormat and packageWriter are specified separately.

PluginManager will return a list of plugins that write various formats. Just call:

PluginManager.getModuleCollection('FormatWriter')

See also {@see packageWriter}

Source:

packageName :string

The name of the package. Usually, this will be a bag name, and should not include a file extension.

Source:

payloadSize :OperationResult

The total size, in bytes, of the files to be packaged.

Source:

pluginId :string

The id (UUID) of the plugin that will write the output package.

DART allows a single plugin to write multiple formats, and several plugins may be able to write the same format. Therefore, packageFormat and packageWriter are specified separately.

PluginManager will return a list of plugins that write various formats. Just call:

PluginManager.getModuleCollection('FormatWriter')

See also {@see packageWriter}

Source:

result :OperationResult

This describes the result of DART's attempt to package the files.

Source:

skipFiles :Array.<string>

This is a list of patterns that DART should skip when creating this package. Any files matching these patterns will not be packaged.

See Constants.RE_DOT_FILES and Constants.RE_MAC_JUNK_FILES.

Source:

sourceFiles :Array.<string>

A list of files DART will be packaging. Each entry in this list should be an absolute path to a file or directory.

Source:

Methods

(static) inflateFrom(data) → {PackageOperation}

This converts the JSON representation of a PackageOperation to a full-fledged PackageOperation object with all of the expected methods.

Parameters:
Name Type Description
data Object

A JavaScript hash.

Source:

getWriter() → {Plugin}

This returns the class of the plugin that will write the package. Note that each time you call this, you'll get a new writer.

If this PackageOperation has no pluginId, or an ID that does not match any known plugin, this returns null.

Source:

pruneSourceFilesUnlessJobCompleted()

This removes items from the sourceFiles array if they no longer exist on disk. We need to do that to prevent errors when the job runs, as well as rendering errors in the UI. It logs items that it removes.

This won't prune the list if the PackageOperation has already been completed, because in that case, we want a record of what the operation actually did package. It's also expected that some source files will be deleted after a job has run.

Warning: The sourceFiles list should contain absolute paths. Relative paths may be trimmed even if they do exist, because the may have been added from a different working directory. Use absolute paths only.

Source:

trimLeadingPaths()

Returns true or false to describe whether we should trim leading path names when packaging files. Currently, only the bagger respects this. This simply returns the value of _trimLeadingPaths, except in cases where DART thinks the user is rebagging a legacy bag that was first produced with DART 1.0 and then deposited into APTrust's production repo. For those bags (of which only about 30 exist), this always returns false.

Source:

validate() → {boolean}

validate returns true or false, indicating whether this object contains complete and valid data. If it returns false, check the errors property for specific errors.

Source: