Package org.dspace.identifier
Class DOIIdentifierProvider
- java.lang.Object
-
- org.dspace.identifier.IdentifierProvider
-
- org.dspace.identifier.FilteredIdentifierProvider
-
- org.dspace.identifier.DOIIdentifierProvider
-
- Direct Known Subclasses:
VersionedDOIIdentifierProvider
public class DOIIdentifierProvider extends FilteredIdentifierProvider
Provide service for DOIs using DataCite.This class handles reservation, registration and deletion of DOIs using the direct API from DataCite. Please pay attention that some members of DataCite offer special services and want their customers to use special APIs. If you are unsure ask your registration agency.
Any identifier a method of this class returns is a string in the following format: doi:10.123/456.
- Author:
- Pascal-Nicolas Becker
-
-
Field Summary
Fields Modifier and Type Field Description protected ContentServiceFactorycontentServiceFactorystatic IntegerDELETEDstatic StringDOI_ELEMENTstatic StringDOI_QUALIFIERprotected DOIServicedoiServiceprotected FilterfilterServicestatic IntegerIS_REGISTEREDstatic IntegerIS_RESERVEDprotected ItemServiceitemServicestatic StringMD_SCHEMAstatic IntegerTO_BE_DELETEDstatic IntegerTO_BE_REGISTEREDstatic IntegerTO_BE_RESERVEDstatic IntegerUPDATE_BEFORE_REGISTRATIONstatic IntegerUPDATE_REGISTEREDstatic IntegerUPDATE_RESERVED-
Fields inherited from class org.dspace.identifier.IdentifierProvider
configurationService, parentService
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedDOIIdentifierProvider()Empty / default constructor for Spring
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckMintable(Context context, DSpaceObject dso)Checks to see if an item can have a DOI minted, using the configured logical filtervoiddelete(Context context, DSpaceObject dso)Delete all DOIs for a DSpaceObjectvoiddelete(Context context, DSpaceObject dso, String identifier)Delete a specific DOI for a given DSpaceObjectvoiddeleteOnline(Context context, String identifier)Delete a specific DOI in the registration agency records via the DOI ConnectorStringgetDOIByObject(Context context, DSpaceObject dso)Search the database for a DOI, using the type and id of an DSpaceObject.StringgetDOIOutOfObject(DSpaceObject dso)Loads a DOI out of the metadata of an DSpaceObject.protected StringgetNamespaceSeparator()Get namespace separator from configurationDSpaceObjectgetObjectByDOI(Context context, String identifier)Returns a DSpaceObject depending on its DOI.protected StringgetPrefix()Get DOI prefix from configurationprotected DOIloadOrCreateDOI(Context context, DSpaceObject dso, String doiIdentifier)Load a DOI from the database or creates it if it does not exist.protected DOIloadOrCreateDOI(Context context, DSpaceObject dso, String doiIdentifier, boolean skipFilter)Load DOI from database, or create one if it doesn't yet exist.Stringlookup(Context context, DSpaceObject dso)Look up a DOI identifier for a given DSpaceObjectStringmint(Context context, DSpaceObject dso)Mint a new DOI in DSpace - this is usually the first step of registration Always apply filters if they are configuredStringmint(Context context, DSpaceObject dso, boolean skipFilter)Mint a new DOI in DSpace - this is usually the first step of registrationStringregister(Context context, DSpaceObject dso)Register a new identifier for a given DSpaceObject, never skipping or ignoring any configured filterStringregister(Context context, DSpaceObject dso, boolean skipFilter)Register a new DOI for a given DSpaceObjectvoidregister(Context context, DSpaceObject dso, String identifier)Register a specified DOI for a given DSpaceObject, never skipping or ignoring any configured filtervoidregister(Context context, DSpaceObject dso, String identifier, boolean skipFilter)Register a specified DOI for a given DSpaceObjectvoidregisterOnline(Context context, DSpaceObject dso, String identifier)Perform the actual online / API interaction required to register the DOI online always applying filters if they are configuredvoidregisterOnline(Context context, DSpaceObject dso, String identifier, boolean skipFilter)Perform the actual online / API interaction required to register the DOI onlineprotected voidremoveDOIFromObject(Context context, DSpaceObject dso, String doi)Removes a DOI out of the metadata of a DSpaceObject.voidreserve(Context context, DSpaceObject dso, String identifier)Set an object's identifier.voidreserve(Context context, DSpaceObject dso, String identifier, boolean skipFilter)Reserve a specified DOI for a given DSpaceObjectvoidreserveOnline(Context context, DSpaceObject dso, String identifier)Perform the actual online / API interaction required to reserve the DOI online always applying filters if they are configuredvoidreserveOnline(Context context, DSpaceObject dso, String identifier, boolean skipFilter)Perform the actual online / API interaction required to reserve the DOI onlineDSpaceObjectresolve(Context context, String identifier, String... attributes)Resolve an identifier to a DSpaceObject, if it is registeredprotected voidsaveDOIToObject(Context context, DSpaceObject dso, String doi)Adds a DOI to the metadata of an item.voidsetDOIConnector(DOIConnector connector)Set the DOI connector, which is the component that commuincates with the remote registration service (eg.voidsetFilterService(Filter filterService)Set the Filter to use when testing items to see if a DOI should be registered Spring will use this setter to set the filter from the configured property in identifier-services.xmlbooleansupports(Class<? extends Identifier> identifier)This identifier provider supports identifiers of typeDOI.booleansupports(String identifier)This identifier provider supports identifiers in the following format: doi:10.123/456 10.123/456 http://dx.doi.org/10.123/456voidupdateMetadata(Context context, DSpaceObject dso, String identifier)Update metadata for a registered object If the DOI for hte item already exists, *always* skip the filter since it should only be used for allowing / disallowing reservation and registration, not metadata updates or deletionsvoidupdateMetadataOnline(Context context, DSpaceObject dso, String identifier)Update metadata for a registered object in the DOI Connector to update the agency records If the DOI for hte item already exists, *always* skip the filter since it should only be used for allowing / disallowing reservation and registration, not metadata updates or deletions-
Methods inherited from class org.dspace.identifier.IdentifierProvider
setConfigurationService, setParentService
-
-
-
-
Field Detail
-
MD_SCHEMA
public static final String MD_SCHEMA
- See Also:
- Constant Field Values
-
DOI_ELEMENT
public static final String DOI_ELEMENT
- See Also:
- Constant Field Values
-
DOI_QUALIFIER
public static final String DOI_QUALIFIER
- See Also:
- Constant Field Values
-
TO_BE_REGISTERED
public static final Integer TO_BE_REGISTERED
-
TO_BE_RESERVED
public static final Integer TO_BE_RESERVED
-
IS_REGISTERED
public static final Integer IS_REGISTERED
-
IS_RESERVED
public static final Integer IS_RESERVED
-
UPDATE_RESERVED
public static final Integer UPDATE_RESERVED
-
UPDATE_REGISTERED
public static final Integer UPDATE_REGISTERED
-
UPDATE_BEFORE_REGISTRATION
public static final Integer UPDATE_BEFORE_REGISTRATION
-
TO_BE_DELETED
public static final Integer TO_BE_DELETED
-
DELETED
public static final Integer DELETED
-
doiService
@Autowired(required=true) protected DOIService doiService
-
contentServiceFactory
@Autowired(required=true) protected ContentServiceFactory contentServiceFactory
-
itemService
@Autowired(required=true) protected ItemService itemService
-
filterService
protected Filter filterService
-
-
Method Detail
-
getPrefix
protected String getPrefix()
Get DOI prefix from configuration- Returns:
- a String containing the DOI prefix
-
getNamespaceSeparator
protected String getNamespaceSeparator()
Get namespace separator from configuration- Returns:
- a String containing the namespace separator
-
setDOIConnector
@Autowired(required=true) public void setDOIConnector(DOIConnector connector)
Set the DOI connector, which is the component that commuincates with the remote registration service (eg. DataCite, EZID, Crossref) Spring will use this setter to set the DOI connector from the configured property in identifier-services.xml- Parameters:
connector- a DOIConnector
-
setFilterService
public void setFilterService(Filter filterService)
Set the Filter to use when testing items to see if a DOI should be registered Spring will use this setter to set the filter from the configured property in identifier-services.xml- Overrides:
setFilterServicein classFilteredIdentifierProvider- Parameters:
filterService- - an object implementing the org.dspace.content.logic.Filter interface
-
supports
public boolean supports(Class<? extends Identifier> identifier)
This identifier provider supports identifiers of typeDOI.- Specified by:
supportsin classIdentifierProvider- Parameters:
identifier- to check if it will be supported by this provider.- Returns:
- boolean
-
supports
public boolean supports(String identifier)
This identifier provider supports identifiers in the following format:- doi:10.123/456
- 10.123/456
- http://dx.doi.org/10.123/456
- Specified by:
supportsin classIdentifierProvider- Parameters:
identifier- to check if it is in a supported format.- Returns:
- boolean
-
register
public String register(Context context, DSpaceObject dso) throws IdentifierException
Register a new identifier for a given DSpaceObject, never skipping or ignoring any configured filter- Specified by:
registerin classIdentifierProvider- Parameters:
context- - DSpace contextdso- - DSpaceObject to use for identifier registration- Returns:
- identifier
- Throws:
IdentifierException
-
register
public void register(Context context, DSpaceObject dso, String identifier) throws IdentifierException
Register a specified DOI for a given DSpaceObject, never skipping or ignoring any configured filter- Specified by:
registerin classIdentifierProvider- Parameters:
context- - DSpace contextdso- - DSpaceObject identified by the new DOIidentifier- - String containing the identifier to register- Throws:
IdentifierException
-
register
public String register(Context context, DSpaceObject dso, boolean skipFilter) throws IdentifierException
Register a new DOI for a given DSpaceObject- Specified by:
registerin classFilteredIdentifierProvider- Parameters:
context- - DSpace contextdso- - DSpaceObject identified by the new DOIskipFilter- - boolean indicating whether to skip any filtering of items before performing registration- Returns:
- identifier
- Throws:
IdentifierException
-
register
public void register(Context context, DSpaceObject dso, String identifier, boolean skipFilter) throws IdentifierException
Register a specified DOI for a given DSpaceObject- Specified by:
registerin classFilteredIdentifierProvider- Parameters:
context- - DSpace contextdso- - DSpaceObject identified by the new DOIidentifier- - String containing the DOI to registerskipFilter- - boolean indicating whether to skip any filtering of items before performing registration- Throws:
IdentifierException
-
reserve
public void reserve(Context context, DSpaceObject dso, String identifier) throws IdentifierException, IllegalArgumentException
Description copied from class:IdentifierProviderSet an object's identifier.- Specified by:
reservein classIdentifierProvider- Parameters:
context- The relevant DSpace Context.dso- DSpaceObject the DOI should be reserved for. Some metadata of this object will be send to the registration agency.identifier- DOI to register in a format thatDOIService.formatIdentifier(String)accepts.- Throws:
IdentifierException- If the format ofidentifierwas unrecognized or if it was impossible to reserve the DOI (registration agency denied for some reason, see logs).IllegalArgumentException- Ifidentifieris a DOI already registered for another DSpaceObject thendso.- See Also:
IdentifierProvider.reserve(Context, DSpaceObject, String)
-
reserve
public void reserve(Context context, DSpaceObject dso, String identifier, boolean skipFilter) throws IdentifierException, IllegalArgumentException
Reserve a specified DOI for a given DSpaceObject- Specified by:
reservein classFilteredIdentifierProvider- Parameters:
context- - DSpace contextdso- - DSpaceObject identified by this DOIidentifier- - String containing the DOI to reserveskipFilter- - boolean indicating whether to skip any filtering of items before performing reservation- Throws:
IdentifierExceptionIllegalArgumentException
-
reserveOnline
public void reserveOnline(Context context, DSpaceObject dso, String identifier) throws IdentifierException, IllegalArgumentException, SQLException
Perform the actual online / API interaction required to reserve the DOI online always applying filters if they are configured- Parameters:
context- - DSpace contextdso- - DSpaceObject identified by this DOIidentifier- - String containing the DOI to reserve- Throws:
IdentifierExceptionIllegalArgumentExceptionSQLException
-
reserveOnline
public void reserveOnline(Context context, DSpaceObject dso, String identifier, boolean skipFilter) throws IdentifierException, IllegalArgumentException, SQLException
Perform the actual online / API interaction required to reserve the DOI online- Parameters:
context- - DSpace contextdso- - DSpaceObject identified by this DOIidentifier- - String containing the DOI to reserveskipFilter- - skip the filters forcheckMintable(org.dspace.core.Context,org.dspace.content.DSpaceObject)- Throws:
IdentifierExceptionIllegalArgumentExceptionSQLException
-
registerOnline
public void registerOnline(Context context, DSpaceObject dso, String identifier) throws IdentifierException, IllegalArgumentException, SQLException
Perform the actual online / API interaction required to register the DOI online always applying filters if they are configured- Parameters:
context- - DSpace contextdso- - DSpaceObject identified by this DOIidentifier- - String containing the DOI to register- Throws:
IdentifierExceptionIllegalArgumentExceptionSQLException
-
registerOnline
public void registerOnline(Context context, DSpaceObject dso, String identifier, boolean skipFilter) throws IdentifierException, IllegalArgumentException, SQLException
Perform the actual online / API interaction required to register the DOI online- Parameters:
context- - DSpace contextdso- - DSpaceObject identified by this DOIidentifier- - String containing the DOI to registerskipFilter- - skip filters forcheckMintable(org.dspace.core.Context,org.dspace.content.DSpaceObject)- Throws:
IdentifierExceptionIllegalArgumentExceptionSQLException
-
updateMetadata
public void updateMetadata(Context context, DSpaceObject dso, String identifier) throws IdentifierException, IllegalArgumentException, SQLException
Update metadata for a registered object If the DOI for hte item already exists, *always* skip the filter since it should only be used for allowing / disallowing reservation and registration, not metadata updates or deletions- Parameters:
context- - DSpace contextdso- - DSpaceObject identified by this DOIidentifier- - String containing the DOI to reserve- Throws:
IdentifierExceptionIllegalArgumentExceptionSQLException
-
updateMetadataOnline
public void updateMetadataOnline(Context context, DSpaceObject dso, String identifier) throws IdentifierException, SQLException
Update metadata for a registered object in the DOI Connector to update the agency records If the DOI for hte item already exists, *always* skip the filter since it should only be used for allowing / disallowing reservation and registration, not metadata updates or deletions- Parameters:
context- - DSpace contextdso- - DSpaceObject identified by this DOIidentifier- - String containing the DOI to reserve- Throws:
IdentifierExceptionIllegalArgumentExceptionSQLException
-
mint
public String mint(Context context, DSpaceObject dso) throws IdentifierException
Mint a new DOI in DSpace - this is usually the first step of registration Always apply filters if they are configured- Specified by:
mintin classIdentifierProvider- Parameters:
context- - DSpace contextdso- - DSpaceObject identified by the new identifier- Returns:
- a String containing the new identifier
- Throws:
IdentifierException
-
mint
public String mint(Context context, DSpaceObject dso, boolean skipFilter) throws IdentifierException
Mint a new DOI in DSpace - this is usually the first step of registration- Specified by:
mintin classFilteredIdentifierProvider- Parameters:
context- - DSpace contextdso- - DSpaceObject identified by the new identifierskipFilter- - boolean indicating whether to skip any filtering of items before minting.- Returns:
- a String containing the new identifier
- Throws:
IdentifierException
-
resolve
public DSpaceObject resolve(Context context, String identifier, String... attributes) throws IdentifierNotFoundException, IdentifierNotResolvableException
Resolve an identifier to a DSpaceObject, if it is registered- Specified by:
resolvein classIdentifierProvider- Parameters:
context- - DSpace contextidentifier- - to be resolved.attributes- - additional information for resolvingidentifier.- Returns:
- a DSpaceObject identified by the identifier string
- Throws:
IdentifierNotFoundExceptionIdentifierNotResolvableException
-
lookup
public String lookup(Context context, DSpaceObject dso) throws IdentifierNotFoundException, IdentifierNotResolvableException
Look up a DOI identifier for a given DSpaceObject- Specified by:
lookupin classIdentifierProvider- Parameters:
context- - DSpace contextdso- - DSpaceObject to look up- Returns:
- a String containing the DOI
- Throws:
IdentifierNotFoundExceptionIdentifierNotResolvableException
-
delete
public void delete(Context context, DSpaceObject dso) throws IdentifierException
Delete all DOIs for a DSpaceObject- Specified by:
deletein classIdentifierProvider- Parameters:
context- - DSpace contextdso- - DSpaceObject to have all its DOIs deleted- Throws:
IdentifierException
-
delete
public void delete(Context context, DSpaceObject dso, String identifier) throws IdentifierException
Delete a specific DOI for a given DSpaceObject- Specified by:
deletein classIdentifierProvider- Parameters:
context- - DSpace contextdso- - DSpaceObject to be de-identified.identifier- - String containing identifier to delete- Throws:
IdentifierException
-
deleteOnline
public void deleteOnline(Context context, String identifier) throws DOIIdentifierException
Delete a specific DOI in the registration agency records via the DOI Connector- Parameters:
context- - DSpace contextidentifier- - String containing identifier to delete- Throws:
DOIIdentifierException
-
getObjectByDOI
public DSpaceObject getObjectByDOI(Context context, String identifier) throws SQLException, DOIIdentifierException, IllegalArgumentException
Returns a DSpaceObject depending on its DOI.- Parameters:
context- the contextidentifier- The DOI in a format that is accepted byDOIService.formatIdentifier(String).- Returns:
- Null if the DOI couldn't be found or the associated DSpaceObject.
- Throws:
SQLException- if database errorDOIIdentifierException- Ifidentifieris null or an empty string.IllegalArgumentException- If the identifier couldn't be recognized as DOI.
-
getDOIByObject
public String getDOIByObject(Context context, DSpaceObject dso) throws SQLException
Search the database for a DOI, using the type and id of an DSpaceObject.- Parameters:
context- The relevant DSpace Context.dso- DSpaceObject to find doi for. DOIs with status TO_BE_DELETED will be ignored.- Returns:
- The DOI as String or null if DOI was not found.
- Throws:
SQLException- if database error
-
loadOrCreateDOI
protected DOI loadOrCreateDOI(Context context, DSpaceObject dso, String doiIdentifier) throws SQLException, DOIIdentifierException, IdentifierNotApplicableException
Load a DOI from the database or creates it if it does not exist. This method can be used to ensure that a DOI exists in the database and to load the appropriate TableRow. As protected method we don't check if the DOI is in a decent format, use DOI.formatIdentifier(String) if necessary.- Parameters:
context- The relevant DSpace Context.dso- The DSpaceObject the DOI should be loaded or created for.doiIdentifier- A DOI or null if a DOI should be generated. The generated DOI can be found in the appropriate column for the TableRow.- Returns:
- The database row of the object.
- Throws:
SQLException- In case of an error using the database.DOIIdentifierException- Ifdoiis not part of our prefix or DOI is registered for another object already.IdentifierNotApplicableException- passed through.
-
loadOrCreateDOI
protected DOI loadOrCreateDOI(Context context, DSpaceObject dso, String doiIdentifier, boolean skipFilter) throws SQLException, DOIIdentifierException, IdentifierNotApplicableException
Load DOI from database, or create one if it doesn't yet exist. We need to distinguish several cases.LoadOrCreate can be called with a specified identifier to load or create. It can also be used to create a new unspecified identifier. In the latter case doiIdentifier is set null. If doiIdentifier is set, we know which doi we should try to load or create, but even in such a situation we might be able to find it in the database or might have to create it.- Parameters:
context- - DSpace contextdso- - DSpaceObject to identifydoiIdentifier- - DOI to load or create (null to mint a new one)skipFilter- - Whether or not to skip the filters for the checkMintable() check- Returns:
- Throws:
SQLExceptionDOIIdentifierExceptionIdentifierNotApplicableException- passed through.
-
getDOIOutOfObject
public String getDOIOutOfObject(DSpaceObject dso) throws DOIIdentifierException
Loads a DOI out of the metadata of an DSpaceObject.- Parameters:
dso- DSpace object to get DOI metadata from- Returns:
- The DOI or null if no DOI was found.
- Throws:
DOIIdentifierException- if identifier error
-
saveDOIToObject
protected void saveDOIToObject(Context context, DSpaceObject dso, String doi) throws SQLException, AuthorizeException, IdentifierException
Adds a DOI to the metadata of an item.- Parameters:
context- The relevant DSpace Context.dso- DSpaceObject the DOI should be added to.doi- The DOI that should be added as metadata.- Throws:
SQLException- if database errorAuthorizeException- if authorization errorIdentifierException- if identifier error
-
removeDOIFromObject
protected void removeDOIFromObject(Context context, DSpaceObject dso, String doi) throws AuthorizeException, SQLException, IdentifierException
Removes a DOI out of the metadata of a DSpaceObject.- Parameters:
context- The relevant DSpace Context.dso- The DSpaceObject the DOI should be removed from.doi- The DOI to remove out of the metadata.- Throws:
AuthorizeException- if authorization errorSQLException- if database errorIdentifierException- if identifier error
-
checkMintable
public void checkMintable(Context context, DSpaceObject dso) throws DOIIdentifierNotApplicableException
Checks to see if an item can have a DOI minted, using the configured logical filter- Specified by:
checkMintablein classFilteredIdentifierProvider- Parameters:
context-dso- The item to be evaluated- Throws:
DOIIdentifierNotApplicableException
-
-