Package org.dspace.identifier.doi
Class DataCiteConnector
- java.lang.Object
-
- org.dspace.identifier.doi.DataCiteConnector
-
- All Implemented Interfaces:
DOIConnector
public class DataCiteConnector extends Object implements DOIConnector
- Author:
- Pascal-Nicolas Becker
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classDataCiteConnector.DataCiteResponse
-
Field Summary
Fields Modifier and Type Field Description protected ConfigurationServiceconfigurationServiceprotected StringCROSSWALK_NAMEName of crosswalk to convert metadata into DataCite Metadata Scheme.protected StringDOI_PATHPath on the DataCite server used to generate DOIs.protected HandleServicehandleServiceprotected StringHOSTStores the hostname of the DataCite server.protected StringMETADATA_PATHPath on the DataCite server used to register metadata.protected StringPASSWORDprotected StringSCHEMEStores the scheme used to connect to the DataCite server.protected StringUSERNAMEprotected ParameterizedDisseminationCrosswalkxwalkDisseminationCrosswalk to map local metadata into DataCite metadata.
-
Constructor Summary
Constructors Constructor Description DataCiteConnector()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.jdom.ElementaddDOI(String doi, org.jdom.Element root)voiddeleteDOI(Context context, String doi)Sends the DELETE-Request to the DOI registry.protected StringextractAlternateIdentifier(Context context, String content)protected StringextractDOI(org.jdom.Element root)protected StringgetPassword()protected StringgetUsername()booleanisDOIRegistered(Context context, String doi)booleanisDOIReserved(Context context, String doi)protected voidprepareXwalk()voidregisterDOI(Context context, DSpaceObject dso, String doi)Sends a request to the DOI registry to register a DOI.voidreserveDOI(Context context, DSpaceObject dso, String doi)Sends a request to the DOI registry to reserve a DOI.protected DataCiteConnector.DataCiteResponsesendDOIGetRequest(String doi)protected DataCiteConnector.DataCiteResponsesendDOIPostRequest(String doi, String url)protected DataCiteConnector.DataCiteResponsesendGetRequest(String doi, String path)protected DataCiteConnector.DataCiteResponsesendHttpRequest(org.apache.http.client.methods.HttpUriRequest req, String doi)Internal method to send requests prepared by the caller to DataCite.protected DataCiteConnector.DataCiteResponsesendMetadataDeleteRequest(String doi)protected DataCiteConnector.DataCiteResponsesendMetadataGetRequest(String doi)protected DataCiteConnector.DataCiteResponsesendMetadataPostRequest(String doi, String metadata)protected DataCiteConnector.DataCiteResponsesendMetadataPostRequest(String doi, org.jdom.Element metadataRoot)voidsetConfigurationService(ConfigurationService configurationService)voidsetDATACITE_DOI_PATH(String DATACITE_DOI_PATH)Set the path on the DataCite server to register DOIs.voidsetDATACITE_HOST(String DATACITE_HOST)Set the hostname of the DataCite server.voidsetDATACITE_METADATA_PATH(String DATACITE_METADATA_PATH)Set the path to register metadata on DataCite server.voidsetDATACITE_SCHEME(String DATACITE_SCHEME)Used to set the scheme to connect the DataCite server.voidsetDisseminationCrosswalkName(String CROSSWALK_NAME)Set the name of the dissemination crosswalk used to convert the metadata into DataCite Metadata Schema.voidupdateMetadata(Context context, DSpaceObject dso, String doi)Sends a request to the DOI registry to update metadata for a DOI.
-
-
-
Field Detail
-
SCHEME
protected String SCHEME
Stores the scheme used to connect to the DataCite server. It will be set by spring dependency injection.
-
HOST
protected String HOST
Stores the hostname of the DataCite server. Set by spring dependency injection.
-
DOI_PATH
protected String DOI_PATH
Path on the DataCite server used to generate DOIs. Set by spring dependency injection.
-
METADATA_PATH
protected String METADATA_PATH
Path on the DataCite server used to register metadata. Set by spring dependency injection.
-
CROSSWALK_NAME
protected String CROSSWALK_NAME
Name of crosswalk to convert metadata into DataCite Metadata Scheme. Set by spring dependency injection.
-
xwalk
protected ParameterizedDisseminationCrosswalk xwalk
DisseminationCrosswalk to map local metadata into DataCite metadata. The name of the crosswalk is set by spring dependency injection usingsetDisseminationCrosswalkNamewhich instantiates the crosswalk.
-
configurationService
protected ConfigurationService configurationService
-
USERNAME
protected String USERNAME
-
PASSWORD
protected String PASSWORD
-
handleService
@Autowired protected HandleService handleService
-
-
Method Detail
-
setDATACITE_SCHEME
public void setDATACITE_SCHEME(String DATACITE_SCHEME)
Used to set the scheme to connect the DataCite server. Used by spring dependency injection.- Parameters:
DATACITE_SCHEME- Probably https or http.
-
setDATACITE_HOST
public void setDATACITE_HOST(String DATACITE_HOST)
Set the hostname of the DataCite server. Used by spring dependency injection.- Parameters:
DATACITE_HOST- Hostname to connect to register DOIs (f.e. test.datacite.org).
-
setDATACITE_DOI_PATH
public void setDATACITE_DOI_PATH(String DATACITE_DOI_PATH)
Set the path on the DataCite server to register DOIs. Used by spring dependency injection.- Parameters:
DATACITE_DOI_PATH- Path to register DOIs, f.e. /doi.
-
setDATACITE_METADATA_PATH
public void setDATACITE_METADATA_PATH(String DATACITE_METADATA_PATH)
Set the path to register metadata on DataCite server. Used by spring dependency injection.- Parameters:
DATACITE_METADATA_PATH- Path to register metadata, f.e. /mds.
-
setConfigurationService
@Autowired public void setConfigurationService(ConfigurationService configurationService)
-
setDisseminationCrosswalkName
public void setDisseminationCrosswalkName(String CROSSWALK_NAME)
Set the name of the dissemination crosswalk used to convert the metadata into DataCite Metadata Schema. Used by spring dependency injection.- Parameters:
CROSSWALK_NAME- The name of the dissemination crosswalk to use. This crosswalk must be configured in dspace.cfg.
-
prepareXwalk
protected void prepareXwalk()
-
getUsername
protected String getUsername()
-
getPassword
protected String getPassword()
-
isDOIReserved
public boolean isDOIReserved(Context context, String doi) throws DOIIdentifierException
- Specified by:
isDOIReservedin interfaceDOIConnector- Throws:
DOIIdentifierException
-
isDOIRegistered
public boolean isDOIRegistered(Context context, String doi) throws DOIIdentifierException
- Specified by:
isDOIRegisteredin interfaceDOIConnector- Throws:
DOIIdentifierException
-
deleteDOI
public void deleteDOI(Context context, String doi) throws DOIIdentifierException
Description copied from interface:DOIConnectorSends the DELETE-Request to the DOI registry.This method sends a request to "delete" a DOI. As DOIs are persistent identifiers they should never be deleted. For example, if you send a HTTP DELETE request to the DataCite Metadata API directly, it will set the DOI to inactive.
- Specified by:
deleteDOIin interfaceDOIConnector- Parameters:
context- The relevant DSpace Context.doi- DOI string to "delete"- Throws:
DOIIdentifierException- if DOI error
-
reserveDOI
public void reserveDOI(Context context, DSpaceObject dso, String doi) throws DOIIdentifierException
Description copied from interface:DOIConnectorSends a request to the DOI registry to reserve a DOI. The DOIConnector should check weather this DOI is reserved for another object already. In this case it should throw anDOIIdentifierException. DOIIdentifierException} and set the error code toDOIIdentifierException.DOI_ALREADY_EXISTS.- Specified by:
reserveDOIin interfaceDOIConnector- Parameters:
context- The relevant DSpace Context.dso- DSpace object to associate to the DOIdoi- DOI string to reserve- Throws:
DOIIdentifierException- if DOI error
-
registerDOI
public void registerDOI(Context context, DSpaceObject dso, String doi) throws DOIIdentifierException
Description copied from interface:DOIConnectorSends a request to the DOI registry to register a DOI. The DOIConnector ensures compliance with the workflow of the registration agency. For example, if a DOI has to be reserved before it can be registered the DOIConnector has to check if it is reserved. In this case you can throw anDOIIdentifierException. and set the error code toDOIIdentifierException.RESERVE_FIRST.- Specified by:
registerDOIin interfaceDOIConnector- Parameters:
context- The relevant DSpace Context.dso- DSpace object to associate to the DOIdoi- DOI string to register- Throws:
DOIIdentifierException- if DOI error
-
updateMetadata
public void updateMetadata(Context context, DSpaceObject dso, String doi) throws DOIIdentifierException
Description copied from interface:DOIConnectorSends a request to the DOI registry to update metadata for a DOI. The DOIConnector should check weather the DOI is reserved or registered for the specified DSpace Object before it sends the metadata update.- Specified by:
updateMetadatain interfaceDOIConnector- Parameters:
context- The relevant DSpace Context.dso- DSpace object associated to the DOIdoi- DOI string to update (metadata)- Throws:
DOIIdentifierException- if DOI error
-
sendDOIPostRequest
protected DataCiteConnector.DataCiteResponse sendDOIPostRequest(String doi, String url) throws DOIIdentifierException
- Throws:
DOIIdentifierException
-
sendMetadataDeleteRequest
protected DataCiteConnector.DataCiteResponse sendMetadataDeleteRequest(String doi) throws DOIIdentifierException
- Throws:
DOIIdentifierException
-
sendDOIGetRequest
protected DataCiteConnector.DataCiteResponse sendDOIGetRequest(String doi) throws DOIIdentifierException
- Throws:
DOIIdentifierException
-
sendMetadataGetRequest
protected DataCiteConnector.DataCiteResponse sendMetadataGetRequest(String doi) throws DOIIdentifierException
- Throws:
DOIIdentifierException
-
sendGetRequest
protected DataCiteConnector.DataCiteResponse sendGetRequest(String doi, String path) throws DOIIdentifierException
- Throws:
DOIIdentifierException
-
sendMetadataPostRequest
protected DataCiteConnector.DataCiteResponse sendMetadataPostRequest(String doi, org.jdom.Element metadataRoot) throws DOIIdentifierException
- Throws:
DOIIdentifierException
-
sendMetadataPostRequest
protected DataCiteConnector.DataCiteResponse sendMetadataPostRequest(String doi, String metadata) throws DOIIdentifierException
- Throws:
DOIIdentifierException
-
sendHttpRequest
protected DataCiteConnector.DataCiteResponse sendHttpRequest(org.apache.http.client.methods.HttpUriRequest req, String doi) throws DOIIdentifierException
Internal method to send requests prepared by the caller to DataCite.- Parameters:
req- Extended version of the HttpRequest interface that provides convenience methods to access request properties such as request URI and method type.doi- DOI string to operate on- Returns:
- response from DataCite
- Throws:
DOIIdentifierException- if DOI error
-
extractAlternateIdentifier
protected String extractAlternateIdentifier(Context context, String content) throws SQLException, DOIIdentifierException
- Throws:
SQLExceptionDOIIdentifierException
-
extractDOI
protected String extractDOI(org.jdom.Element root)
-
addDOI
protected org.jdom.Element addDOI(String doi, org.jdom.Element root)
-
-