Skip to content
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.identifier;

import java.util.HashSet;
import java.util.Set;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dspace.identifier.doi.ClarinDataCiteConnector;

/**
* DOI identifier provider for CLARIN communities.
* It uses the ClarinDataCiteConnector to connect to DataCite and requires the DOI prefix
* and the list of CLARIN community IDs to be configured.
*
* @author Milan Kuchtiak (kuchtiak@ufal.mff.cuni.cz)
*/
public class ClarinCommunityDOIIdentifierProvider extends VersionedDOIIdentifierProvider {
Comment thread
kuchtiak-ufal marked this conversation as resolved.
Outdated

private static final Logger log = LogManager.getLogger(ClarinCommunityDOIIdentifierProvider.class);

private String doiPrefix;

private String namespaceSeparator;

private Set<String> communities = new HashSet<>();

public void init() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushing username/password/prefix onto the connector at init() is safe with the example wiring only because each provider gets its own inner-bean connector. If someone later rewires the connector as a shared ref, all providers silently collapse onto the last-initialized credentials/prefix — DOIs minted against the wrong DataCite account, no error.

Since ClarinDataCiteConnector already has the setters, consider configuring username/password/prefix directly on each connector bean in Spring and dropping this push (and the identifier.doi.<prefix>.user/.password indirection) entirely. Smaller class, no hidden coupling.

if (!(this.connector instanceof ClarinDataCiteConnector)) {
throw new IllegalStateException("ClarinCommunityDOIIdentifierProvider requires ClarinDataCiteConnector");
}
if (doiPrefix == null) {
throw new IllegalStateException("No DOI prefix configured for ClarinCommunityDOIIdentifierProvider");
}
if (namespaceSeparator == null) {
namespaceSeparator = "";
}

ClarinDataCiteConnector dataCiteConnector = (ClarinDataCiteConnector) this.connector;

dataCiteConnector.setDoiPrefix(doiPrefix);

Comment thread
kuchtiak-ufal marked this conversation as resolved.
String username = this.configurationService.getProperty("identifier.doi." + doiPrefix + ".user");
if (username == null) {
log.error("No username configured for DOI prefix '{}'", doiPrefix);
throw new IllegalStateException("No username configured for DOI prefix '" + doiPrefix + "'");
}
dataCiteConnector.setUsername(username);

String password = this.configurationService.getProperty("identifier.doi." + doiPrefix + ".password");
if (password == null) {
log.error("No password configured for DOI prefix '{}'", doiPrefix);
throw new IllegalStateException("No password configured for DOI prefix '" + doiPrefix + "'");
}
dataCiteConnector.setPassword(password);
}

public void setDoiPrefix(String doiPrefix) {
this.doiPrefix = doiPrefix;
}

public void setNamespaceSeparator(String namespaceSeparator) {
this.namespaceSeparator = namespaceSeparator;
}

public void setCommunities(Set<String> communities) {
this.communities = communities;
}

@Override
protected String getPrefix() {
return this.doiPrefix;
}

@Override
protected String getNamespaceSeparator() {
return this.namespaceSeparator;
}

Set<String> getCommunities() {
return this.communities;
}

}
Loading
Loading