Class RoleDisseminator

  • All Implemented Interfaces:
    PackageDisseminator

    public class RoleDisseminator
    extends Object
    implements PackageDisseminator
    Plugin to export all Group and EPerson objects in XML, perhaps for reloading.
    Author:
    Mark Wood
    • Constructor Detail

      • RoleDisseminator

        public RoleDisseminator()
    • Method Detail

      • disseminate

        public void disseminate​(Context context,
                                DSpaceObject object,
                                PackageParameters params,
                                File pkgFile)
                         throws PackageException,
                                CrosswalkException,
                                AuthorizeException,
                                SQLException,
                                IOException
        Description copied from interface: PackageDisseminator
        Export the object (Item, Collection, or Community) as a "package" on the indicated OutputStream. Package is any serialized representation of the item, at the discretion of the implementing class. It does not have to include content bitstreams.

        Use the params parameter list to adjust the way the package is made, e.g. including a "metadataOnly" parameter might make the package a bare manifest in XML instead of a Zip file including manifest and contents.

        Throws an exception of the chosen object is not acceptable or there is a failure creating the package.

        Specified by:
        disseminate in interface PackageDisseminator
        Parameters:
        context - DSpace context.
        object - DSpace object (item, collection, etc)
        params - Properties-style list of options specific to this packager
        pkgFile - File where export package should be written
        Throws:
        PackageValidationException - if package cannot be created or there is a fatal error in creating it.
        CrosswalkException - if crosswalk error
        AuthorizeException - if authorization error
        SQLException - if database error
        IOException - if IO error
        PackageException
      • writeToStream

        protected void writeToStream​(Context context,
                                     DSpaceObject object,
                                     OutputStream stream,
                                     boolean emitPasswords)
                              throws PackageException
        Serialize users and groups to a stream.
        Parameters:
        context - current Context
        object - DSpaceObject
        stream - receives the output. Is not closed by this method.
        emitPasswords - true if password hashes should be included.
        Throws:
        PackageException - if error
      • disseminateAll

        public List<File> disseminateAll​(Context context,
                                         DSpaceObject dso,
                                         PackageParameters params,
                                         File pkgFile)
                                  throws PackageException,
                                         CrosswalkException,
                                         AuthorizeException,
                                         SQLException,
                                         IOException
        Description copied from interface: PackageDisseminator
        Recursively export one or more DSpace Objects as a series of packages. This method will export the given DSpace Object as well as all referenced DSpaceObjects (e.g. child objects) into a series of packages. The initial object is exported to the location specified by the pkgFile. All other generated packages are recursively exported to the same directory.

        Package is any serialized representation of the item, at the discretion of the implementing class. It does not have to include content bitstreams.

        Use the params parameter list to adjust the way the package is made, e.g. including a "metadataOnly" parameter might make the package a bare manifest in XML instead of a Zip file including manifest and contents.

        Throws an exception of the initial object is not acceptable or there is a failure creating the packages.

        A packager may choose not to implement disseminateAll, or simply forward the call to disseminate if it is unable to support recursive dissemination.

        Specified by:
        disseminateAll in interface PackageDisseminator
        Parameters:
        context - DSpace context.
        dso - initial DSpace object
        params - Properties-style list of options specific to this packager
        pkgFile - File where initial package should be written. All other packages will be written to the same directory as this File.
        Returns:
        List of all package Files which were successfully disseminated
        Throws:
        PackageValidationException - if package cannot be created or there is a fatal error in creating it.
        CrosswalkException - if crosswalk error
        AuthorizeException - if authorization error
        SQLException - if database error
        IOException - if IO error
        PackageException
      • getMIMEType

        public String getMIMEType​(PackageParameters params)
        Description copied from interface: PackageDisseminator
        Identifies the MIME-type of this package, e.g. "application/zip". Required when sending the package via HTTP, to provide the Content-Type header.
        Specified by:
        getMIMEType in interface PackageDisseminator
        Parameters:
        params - Package Parameters
        Returns:
        the MIME type (content-type header) of the package to be returned
      • getGroupType

        protected String getGroupType​(Context context,
                                      DSpaceObject dso,
                                      Group group)
        Return a Group Type string (see RoleDisseminator.GROUP_TYPE_* constants) which describes the type of group and its relation to the given object.

        As a basic example, if the Group is a Collection Administration group, the Group Type string returned should be "ADMIN"

        If type string cannot be determined, null is returned.

        Parameters:
        dso - the related DSpaceObject
        group - the group
        Returns:
        a group type string or null
      • writeEPerson

        protected void writeEPerson​(EPerson eperson,
                                    XMLStreamWriter writer,
                                    boolean emitPassword)
                             throws XMLStreamException
        Emit XML describing a single EPerson.
        Parameters:
        eperson - the EPerson to describe
        writer - the description to this stream
        emitPassword - do not export the password hash unless true
        Throws:
        XMLStreamException - if XML error
      • findAssociatedGroups

        protected List<Group> findAssociatedGroups​(Context context,
                                                   DSpaceObject object)
                                            throws SQLException
        Find all Groups associated with this DSpace Object.

        If object is SITE, all groups are returned.

        If object is COMMUNITY or COLLECTION, only groups associated with those objects are returned (if any).

        For all other objects, null is returned.

        Parameters:
        context - The DSpace context
        object - the DSpace object
        Returns:
        array of all associated groups
        Throws:
        SQLException - if database error
      • findAssociatedPeople

        protected List<EPerson> findAssociatedPeople​(Context context,
                                                     DSpaceObject object)
                                              throws SQLException
        Find all EPeople associated with this DSpace Object.

        If object is SITE, all people are returned.

        For all other objects, null is returned.

        Parameters:
        context - The DSpace context
        object - the DSpace object
        Returns:
        array of all associated EPerson objects
        Throws:
        SQLException - if database error
      • getParameterHelp

        public String getParameterHelp()
        Returns a user help string which should describe the additional valid command-line options that this packager implementation will accept when using the -o or --option flags with the Packager script.
        Specified by:
        getParameterHelp in interface PackageDisseminator
        Returns:
        a string describing additional command-line options available with this packager