edu.ucsb.nceas.metacat.download

## Class PackageDownloaderV2

- java.lang.Object
- - edu.ucsb.nceas.metacat.download.PackageDownloaderV2

-     public class PackageDownloaderV2
      extends java.lang.Object

  A class that handles downloading data packages under the V2 format. It contains a number of private members that hold information about the data package (lists of identifiers, metadata, file paths, etc). The public member functions are used as interfaces: identifiers, metadata, etc. are added to this class through them.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `org.dataone.speedbagit.SpeedBagIt` | `speedBag`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PackageDownloaderV2(org.dataone.service.types.v1.Identifier pid, org.dspace.foresite.ResourceMap resourceMap, org.dataone.service.types.v2.SystemMetadata resourceMapSystemMetadata)` Creates a PackageDownloader object

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addDataFile(org.dataone.service.types.v2.SystemMetadata systemMetadata, java.io.InputStream inputStream)` Adds a data file's stream to the bag
    `void` | `addResourceMap()` Adds the resource map to the bag.
    `void` | `addScienceMetadata(org.dataone.service.types.v2.SystemMetadata sysMeta, java.io.InputStream inputStream)` Adds a system metadata document and its InputStream to the class record
    `void` | `addScienceMetadatas()`
    `void` | `addScienceSystemMetadata(org.dataone.service.types.v1.Identifier scienceMetadataIdentifier)` Sets the science metadata
    `void` | `addSystemMetadata(org.dataone.service.types.v2.SystemMetadata systemMetadata)` Adds a system metadata object to the bag
    `java.io.InputStream` | `download()` Streams the completed bag to the caller.
    `java.util.List<org.dataone.service.types.v1.Identifier>` | `getCoreMetadataIdentifiers()` Returns the core metadata identifiers
    `java.util.List<org.dataone.service.types.v1.Identifier>` | `getScienceMetadataIdentifiers()` Gets all of the science metadata documents in the downloader
    `void` | `getScienceMetadataIds()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### speedBag

          public org.dataone.speedbagit.SpeedBagIt speedBag

  - ### Constructor Detail

    - #### PackageDownloaderV2

          public PackageDownloaderV2(org.dataone.service.types.v1.Identifier pid,
                                     org.dspace.foresite.ResourceMap resourceMap,
                                     org.dataone.service.types.v2.SystemMetadata resourceMapSystemMetadata)
                              throws org.dataone.service.exceptions.ServiceFailure

      Creates a PackageDownloader object
      Parameters:
        `pid:` - The PID of the resource map
        `resourceMap:` - The package's resource map
      Throws:
        `org.dataone.service.exceptions.ServiceFailure`

  - ### Method Detail

    - #### getCoreMetadataIdentifiers

          public java.util.List<org.dataone.service.types.v1.Identifier> getCoreMetadataIdentifiers()

      Returns the core metadata identifiers

    - #### addScienceSystemMetadata

          public void addScienceSystemMetadata(org.dataone.service.types.v1.Identifier scienceMetadataIdentifier)

      Sets the science metadata
      Parameters:
        `scienceMetadataIdentifier:` - The science metadata identifier

    - #### getScienceMetadataIdentifiers

          public java.util.List<org.dataone.service.types.v1.Identifier> getScienceMetadataIdentifiers()

      Gets all of the science metadata documents in the downloader
      Returns:

    - #### addScienceMetadata

          public void addScienceMetadata(org.dataone.service.types.v2.SystemMetadata sysMeta,
                                         java.io.InputStream inputStream)

      Adds a system metadata document and its InputStream to the class record
      Parameters:
        `sysMeta` - the system metadata being added
        `inputStream` - An InputStream to the science metadata

    - #### addDataFile

          public void addDataFile(org.dataone.service.types.v2.SystemMetadata systemMetadata,
                                  java.io.InputStream inputStream)
                           throws org.dataone.service.exceptions.ServiceFailure

      Adds a data file's stream to the bag
      Parameters:
        `systemMetadata` - The object's system metadata
        `inputStream` - An input stream to the data file
      Throws:
        `org.dataone.service.exceptions.ServiceFailure`

    - #### addScienceMetadatas

          public void addScienceMetadatas()
                                   throws java.security.NoSuchAlgorithmException,
                                          org.dataone.service.exceptions.ServiceFailure

      Throws:
        `java.security.NoSuchAlgorithmException`
        `org.dataone.service.exceptions.ServiceFailure`

    - #### addResourceMap

          public void addResourceMap()
                              throws java.security.NoSuchAlgorithmException,
                                     org.dataone.service.exceptions.ServiceFailure

      Adds the resource map to the bag.
      Throws:
        `java.security.NoSuchAlgorithmException`
        `org.dataone.service.exceptions.ServiceFailure`

    - #### addSystemMetadata

          public void addSystemMetadata(org.dataone.service.types.v2.SystemMetadata systemMetadata)
                                 throws java.security.NoSuchAlgorithmException

      Adds a system metadata object to the bag
      Parameters:
        `systemMetadata:` - The system metadata object being added to the bag
      Throws:
        `java.security.NoSuchAlgorithmException`

    - #### download

          public java.io.InputStream download()
                                       throws org.dataone.service.exceptions.ServiceFailure,
                                              org.dataone.service.exceptions.InvalidToken,
                                              org.dataone.service.exceptions.NotAuthorized,
                                              org.dataone.service.exceptions.NotFound,
                                              org.dataone.service.exceptions.NotImplemented

      Streams the completed bag to the caller.
      Returns:
        An InputStream consisting of the bag bytes
      Throws:
        `org.dataone.service.exceptions.ServiceFailure`
        `org.dataone.service.exceptions.InvalidToken`
        `org.dataone.service.exceptions.NotAuthorized`
        `org.dataone.service.exceptions.NotFound`
        `org.dataone.service.exceptions.NotImplemented`

    - #### getScienceMetadataIds

          public void getScienceMetadataIds()

Copyright © 2023 Regents of the University of California. All Rights Reserved.