Skip to content

Commit

Permalink
Fix support protocol http import OAI_DC
Browse files Browse the repository at this point in the history
  • Loading branch information
Esteban-Mtz committed Apr 29, 2022
1 parent 2bbe76f commit 275d16b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/main/java/edu/harvard/iq/dataverse/GlobalId.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ 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 HTTP_DOI_RESOLVER_URL = "http://doi.org/";
public static final String HTTP_HDL_RESOLVER_URL = "http://hdl.handle.net/";

public static Optional<GlobalId> parse(String identifierString) {
try {
return Optional.of(new GlobalId(identifierString));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ 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.HTTP_DOI_RESOLVER_URL) || otherId.startsWith(GlobalId.HTTP_HDL_RESOLVER_URL)) {
return otherId;
}
}
Expand Down Expand Up @@ -430,15 +430,15 @@ 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.HTTP_HDL_RESOLVER_URL)) {
logger.fine("Processing Handle identifier formatted as a resolver URL: "+identifierString);
protocol = GlobalId.HDL_PROTOCOL;
index1 = GlobalId.HDL_RESOLVER_URL.length() - 1;
index1 = (identifierString.startsWith(GlobalId.HDL_RESOLVER_URL)) ? GlobalId.HDL_RESOLVER_URL.length() - 1 : GlobalId.HTTP_HDL_RESOLVER_URL.length() - 1;
index2 = identifierString.indexOf("/", index1 + 1);
} else if (identifierString.startsWith(GlobalId.DOI_RESOLVER_URL)) {
} else if (identifierString.startsWith(GlobalId.DOI_RESOLVER_URL) || identifierString.startsWith(GlobalId.HTTP_DOI_RESOLVER_URL)) {
logger.fine("Processing DOI identifier formatted as a resolver URL: "+identifierString);
protocol = GlobalId.DOI_PROTOCOL;
index1 = GlobalId.DOI_RESOLVER_URL.length() - 1;
index1 = (identifierString.startsWith(GlobalId.DOI_RESOLVER_URL)) ? GlobalId.DOI_RESOLVER_URL.length() - 1 : GlobalId.HTTP_DOI_RESOLVER_URL.length() - 1;
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

0 comments on commit 275d16b

Please sign in to comment.