Class METSPacker

  • All Implemented Interfaces:
    Packer

    public class METSPacker
    extends Object
    implements Packer
    METSPacker packs and unpacks Item AIPs in METS compressed archives
    Author:
    richardrodgers
    • Constructor Summary

      Constructors 
      Constructor Description
      METSPacker​(org.dspace.core.Context context, String archFmt)  
      METSPacker​(org.dspace.core.Context context, org.dspace.content.DSpaceObject dso, String archFmt)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      List<String> getChildPackageRefs()
      Return list of referenced child packages (AIPs) which were located during the unpacking of an AIP (see unpack()).
      org.dspace.content.DSpaceObject getDSO()
      Get DSpaceObject we are working with
      File pack​(File packDir)
      Create a METS AIP Package, using the configured AIP PackageDisseminator (in dspace.cfg)
      void setContentFilter​(String filter)
      Sets a filter on this packer.
      void setContext​(org.dspace.core.Context context)
      Set application context
      void setDSO​(org.dspace.content.DSpaceObject dso)
      Set DSpaceObject we are working with
      void setReferenceFilter​(String filterSet)  
      long size​(String method)
      Estimate the size of the object as packed into a bag.
      void unpack​(File archive)
      Restore/Replace a DSpaceObject based on the contents of a METS AIP Package, using the configured AIP PackageIngester (in dspace.cfg)
      void unpack​(File archive, org.dspace.content.packager.PackageParameters pkgParams)
      Restore/Replace a *single* DSpaceObject based on the contents of a METS AIP Package, and the given PackageParameters.
    • Constructor Detail

      • METSPacker

        public METSPacker​(org.dspace.core.Context context,
                          String archFmt)
      • METSPacker

        public METSPacker​(org.dspace.core.Context context,
                          org.dspace.content.DSpaceObject dso,
                          String archFmt)
    • Method Detail

      • setContext

        public void setContext​(org.dspace.core.Context context)
        Set application context
        Parameters:
        context -
      • getDSO

        public org.dspace.content.DSpaceObject getDSO()
        Get DSpaceObject we are working with
        Returns:
        dso DSpaceObject
      • setDSO

        public void setDSO​(org.dspace.content.DSpaceObject dso)
        Set DSpaceObject we are working with
        Parameters:
        dso - DSpaceObject
      • pack

        public File pack​(File packDir)
                  throws org.dspace.authorize.AuthorizeException,
                         IOException,
                         SQLException
        Create a METS AIP Package, using the configured AIP PackageDisseminator (in dspace.cfg)
        Specified by:
        pack in interface Packer
        Parameters:
        packDir - the directory where this package should be created
        Returns:
        the created package file
        Throws:
        org.dspace.authorize.AuthorizeException - if authorize error
        IOException - if I/O error
        SQLException - if database error
      • unpack

        public void unpack​(File archive)
                    throws org.dspace.authorize.AuthorizeException,
                           IOException,
                           SQLException
        Restore/Replace a DSpaceObject based on the contents of a METS AIP Package, using the configured AIP PackageIngester (in dspace.cfg)
        Specified by:
        unpack in interface Packer
        Parameters:
        archive - the METS AIP package
        Throws:
        org.dspace.authorize.AuthorizeException - if authorize error
        IOException - if I/O error
        SQLException - if database error
      • unpack

        public void unpack​(File archive,
                           org.dspace.content.packager.PackageParameters pkgParams)
                    throws org.dspace.authorize.AuthorizeException,
                           IOException,
                           SQLException
        Restore/Replace a *single* DSpaceObject based on the contents of a METS AIP Package, and the given PackageParameters. This uses the configured AIP PackageIngester (in dspace.cfg).

        Please note that it is up to the calling Curation Task to perform any recursive restores/replaces of child objects. If recursiveMode is enabled, this method will attempt to save all referenced child packages for access via getChildPackageRefs().

        Parameters:
        archive - the METS AIP package
        pkgParams - the PackageParameters (if null, defaults to Recursive Replace settings)
        Throws:
        org.dspace.authorize.AuthorizeException - if authorize error
        IOException - if I/O error
        SQLException - if database error
      • size

        public long size​(String method)
                  throws SQLException
        Description copied from interface: Packer
        Estimate the size of the object as packed into a bag. This estimate uses any defined content filters.
        Specified by:
        size in interface Packer
        Parameters:
        method - how to estimate - not currently implemented
        Returns:
        the bagged object size in bytes
        Throws:
        SQLException - if database error
      • setContentFilter

        public void setContentFilter​(String filter)
        Description copied from interface: Packer
        Sets a filter on this packer. A filter will ignore (skip) object content when packing to a bag. Filter syntax: ["+"]{BundleName,}+ That is, a list of Item bundle names taken to be exclusions, unless preceeded by a '+", where the list is taken to be inclusive.
        Specified by:
        setContentFilter in interface Packer
        Parameters:
        filter - filter
      • getChildPackageRefs

        public List<String> getChildPackageRefs()
        Return list of referenced child packages (AIPs) which were located during the unpacking of an AIP (see unpack()).

        This may be used by tasks so that they can recursively unpack() additional referenced child packages as needed.

        Returns:
        List of references to child AIPs