Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions src/main/java/edu/harvard/iq/dataverse/GlobalId.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class GlobalId implements java.io.Serializable {
public static final String HDL_PROTOCOL = "hdl";
public static final String HDL_RESOLVER_URL = "https://hdl.handle.net/";
public static final String DOI_RESOLVER_URL = "https://doi.org/";
public static final String DXDOI_RESOLVER_URL = "https://dx.doi.org/";

public static Optional<GlobalId> parse(String identifierString) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,10 @@ private String getOtherIdFromDTO(DatasetVersionDTO datasetVersionDTO) {
if (!otherIds.isEmpty()) {
// We prefer doi or hdl identifiers like "doi:10.7910/DVN/1HE30F"
for (String otherId : otherIds) {
if (otherId.startsWith(GlobalId.DOI_PROTOCOL) || otherId.startsWith(GlobalId.HDL_PROTOCOL) || otherId.startsWith(GlobalId.DOI_RESOLVER_URL) || otherId.startsWith(GlobalId.HDL_RESOLVER_URL)) {
if (otherId.startsWith(GlobalId.DOI_PROTOCOL) || otherId.startsWith(GlobalId.HDL_PROTOCOL) ||
otherId.startsWith(GlobalId.DOI_RESOLVER_URL) || otherId.startsWith(GlobalId.HDL_RESOLVER_URL) || otherId.startsWith(GlobalId.DXDOI_RESOLVER_URL) ||
otherId.startsWith(GlobalId.DOI_RESOLVER_URL.replace("https","http")) || otherId.startsWith(GlobalId.HDL_RESOLVER_URL.replace("https","http")) || otherId.startsWith(GlobalId.DXDOI_RESOLVER_URL.replace("https","http"))
) {
return otherId;
}
}
Expand Down Expand Up @@ -389,15 +392,32 @@ public String reassignIdentifierAsGlobalId(String identifierString, DatasetDTO d

// We also recognize global identifiers formatted as global resolver URLs:

if (identifierString.startsWith(GlobalId.HDL_RESOLVER_URL)) {
if (identifierString.startsWith(GlobalId.HDL_RESOLVER_URL) || identifierString.startsWith(GlobalId.HDL_RESOLVER_URL.replace("https", "http"))) {
logger.fine("Processing Handle identifier formatted as a resolver URL: "+identifierString);
protocol = GlobalId.HDL_PROTOCOL;
index1 = GlobalId.HDL_RESOLVER_URL.length() - 1;
if (!identifierString.startsWith("https")){
// http
index1--;
}
index2 = identifierString.indexOf("/", index1 + 1);
} else if (identifierString.startsWith(GlobalId.DOI_RESOLVER_URL)) {
} else if (identifierString.startsWith(GlobalId.DOI_RESOLVER_URL) || identifierString.startsWith(GlobalId.DOI_RESOLVER_URL.replace("https", "http"))) {
logger.fine("Processing DOI identifier formatted as a resolver URL: "+identifierString);
protocol = GlobalId.DOI_PROTOCOL;
index1 = GlobalId.DOI_RESOLVER_URL.length() - 1;
if (!identifierString.startsWith("https")){
// http
index1--;
}
index2 = identifierString.indexOf("/", index1 + 1);
} else if (identifierString.startsWith(GlobalId.DXDOI_RESOLVER_URL) || identifierString.startsWith(GlobalId.DXDOI_RESOLVER_URL.replace("https", "http"))) {
logger.fine("Processing DOI identifier formatted as a resolver URL: "+identifierString);
protocol = GlobalId.DOI_PROTOCOL;
index1 = GlobalId.DXDOI_RESOLVER_URL.length() - 1;
if (!identifierString.startsWith("https")){
// http
index1--;
}
index2 = identifierString.indexOf("/", index1 + 1);
} else {
logger.warning("HTTP Url in supplied as the identifier is neither a Handle nor DOI resolver: "+identifierString);
Expand Down