Class RoleDisseminator
- java.lang.Object
-
- org.dspace.content.packager.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classRoleDisseminator.SerializerEmbody a thread for serializing users and groups.
-
Field Summary
Fields Modifier and Type Field Description static StringCAN_LOGINstatic StringDSPACE_ROLESstatic org.jdom2.NamespaceDSROLES_NSDSpace Roles XML Namespace in JDOM form.static StringEMAILstatic StringEPERSONstatic StringEPERSONSprotected EPersonServiceePersonServicestatic StringFIRST_NAMEstatic StringGROUPstatic StringGROUP_TYPE_ADMINstatic StringGROUP_TYPE_SUBMITstatic StringGROUP_TYPE_WORKFLOW_STEP_1static StringGROUP_TYPE_WORKFLOW_STEP_2static StringGROUP_TYPE_WORKFLOW_STEP_3static StringGROUPSprotected GroupServicegroupServicestatic StringIDstatic StringLANGUAGEstatic StringLAST_NAMEstatic StringMEMBERstatic StringMEMBER_GROUPstatic StringMEMBER_GROUPSstatic StringMEMBERSstatic StringNAMEstatic StringNETIDstatic StringPASSWORD_DIGESTstatic StringPASSWORD_HASHstatic StringPASSWORD_SALTstatic StringREQUIRE_CERTIFICATEstatic StringSELF_REGISTEREDstatic StringTYPE
-
Constructor Summary
Constructors Constructor Description RoleDisseminator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddisseminate(Context context, DSpaceObject object, PackageParameters params, File pkgFile)Export the object (Item, Collection, or Community) as a "package" on the indicated OutputStream.List<File>disseminateAll(Context context, DSpaceObject dso, PackageParameters params, File pkgFile)Recursively export one or more DSpace Objects as a series of packages.protected List<Group>findAssociatedGroups(Context context, DSpaceObject object)Find all Groups associated with this DSpace Object.protected List<EPerson>findAssociatedPeople(Context context, DSpaceObject object)Find all EPeople associated with this DSpace Object.protected StringgetGroupType(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.StringgetMIMEType(PackageParameters params)Identifies the MIME-type of this package, e.g.StringgetParameterHelp()Returns a user help string which should describe the additional valid command-line options that this packager implementation will accept when using the-oor--optionflags with the Packager script.protected voidwriteEPerson(EPerson eperson, XMLStreamWriter writer, boolean emitPassword)Emit XML describing a single EPerson.protected voidwriteGroup(Context context, DSpaceObject relatedObject, Group group, XMLStreamWriter writer)Emit XML describing a single Group.protected voidwriteToStream(Context context, DSpaceObject object, OutputStream stream, boolean emitPasswords)Serialize users and groups to a stream.
-
-
-
Field Detail
-
DSROLES_NS
public static final org.jdom2.Namespace DSROLES_NS
DSpace Roles XML Namespace in JDOM form.
-
DSPACE_ROLES
public static final String DSPACE_ROLES
- See Also:
- Constant Field Values
-
ID
public static final String ID
- See Also:
- Constant Field Values
-
GROUPS
public static final String GROUPS
- See Also:
- Constant Field Values
-
GROUP
public static final String GROUP
- See Also:
- Constant Field Values
-
NAME
public static final String NAME
- See Also:
- Constant Field Values
-
TYPE
public static final String TYPE
- See Also:
- Constant Field Values
-
MEMBERS
public static final String MEMBERS
- See Also:
- Constant Field Values
-
MEMBER
public static final String MEMBER
- See Also:
- Constant Field Values
-
MEMBER_GROUPS
public static final String MEMBER_GROUPS
- See Also:
- Constant Field Values
-
MEMBER_GROUP
public static final String MEMBER_GROUP
- See Also:
- Constant Field Values
-
EPERSONS
public static final String EPERSONS
- See Also:
- Constant Field Values
-
EPERSON
public static final String EPERSON
- See Also:
- Constant Field Values
-
EMAIL
public static final String EMAIL
- See Also:
- Constant Field Values
-
NETID
public static final String NETID
- See Also:
- Constant Field Values
-
FIRST_NAME
public static final String FIRST_NAME
- See Also:
- Constant Field Values
-
LAST_NAME
public static final String LAST_NAME
- See Also:
- Constant Field Values
-
LANGUAGE
public static final String LANGUAGE
- See Also:
- Constant Field Values
-
PASSWORD_HASH
public static final String PASSWORD_HASH
- See Also:
- Constant Field Values
-
PASSWORD_DIGEST
public static final String PASSWORD_DIGEST
- See Also:
- Constant Field Values
-
PASSWORD_SALT
public static final String PASSWORD_SALT
- See Also:
- Constant Field Values
-
CAN_LOGIN
public static final String CAN_LOGIN
- See Also:
- Constant Field Values
-
REQUIRE_CERTIFICATE
public static final String REQUIRE_CERTIFICATE
- See Also:
- Constant Field Values
-
SELF_REGISTERED
public static final String SELF_REGISTERED
- See Also:
- Constant Field Values
-
GROUP_TYPE_ADMIN
public static final String GROUP_TYPE_ADMIN
- See Also:
- Constant Field Values
-
GROUP_TYPE_SUBMIT
public static final String GROUP_TYPE_SUBMIT
- See Also:
- Constant Field Values
-
GROUP_TYPE_WORKFLOW_STEP_1
public static final String GROUP_TYPE_WORKFLOW_STEP_1
- See Also:
- Constant Field Values
-
GROUP_TYPE_WORKFLOW_STEP_2
public static final String GROUP_TYPE_WORKFLOW_STEP_2
- See Also:
- Constant Field Values
-
GROUP_TYPE_WORKFLOW_STEP_3
public static final String GROUP_TYPE_WORKFLOW_STEP_3
- See Also:
- Constant Field Values
-
ePersonService
protected final EPersonService ePersonService
-
groupService
protected final GroupService groupService
-
-
Method Detail
-
disseminate
public void disseminate(Context context, DSpaceObject object, PackageParameters params, File pkgFile) throws PackageException, CrosswalkException, AuthorizeException, SQLException, IOException
Description copied from interface:PackageDisseminatorExport 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
paramsparameter 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:
disseminatein interfacePackageDisseminator- Parameters:
context- DSpace context.object- DSpace object (item, collection, etc)params- Properties-style list of options specific to this packagerpkgFile- 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 errorAuthorizeException- if authorization errorSQLException- if database errorIOException- if IO errorPackageException
-
writeToStream
protected void writeToStream(Context context, DSpaceObject object, OutputStream stream, boolean emitPasswords) throws PackageException
Serialize users and groups to a stream.- Parameters:
context- current Contextobject- DSpaceObjectstream- 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:PackageDisseminatorRecursively 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
paramsparameter 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 todisseminateif it is unable to support recursive dissemination.- Specified by:
disseminateAllin interfacePackageDisseminator- Parameters:
context- DSpace context.dso- initial DSpace objectparams- Properties-style list of options specific to this packagerpkgFile- 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 errorAuthorizeException- if authorization errorSQLException- if database errorIOException- if IO errorPackageException
-
getMIMEType
public String getMIMEType(PackageParameters params)
Description copied from interface:PackageDisseminatorIdentifies 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:
getMIMETypein interfacePackageDisseminator- Parameters:
params- Package Parameters- Returns:
- the MIME type (content-type header) of the package to be returned
-
writeGroup
protected void writeGroup(Context context, DSpaceObject relatedObject, Group group, XMLStreamWriter writer) throws XMLStreamException, PackageException
Emit XML describing a single Group.- Parameters:
context- the DSpace ContextrelatedObject- the DSpaceObject related to this group (if any)group- the Group to describewriter- the description to this stream- Throws:
XMLStreamException- if XML errorPackageException- if packaging error
-
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 DSpaceObjectgroup- 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 describewriter- the description to this streamemitPassword- 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 contextobject- 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 contextobject- 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-oor--optionflags with the Packager script.- Specified by:
getParameterHelpin interfacePackageDisseminator- Returns:
- a string describing additional command-line options available with this packager
-
-