Fixed doi base url to be able to operate both in sandbox and production
This commit is contained in:
parent
aed7fa7065
commit
de9066a4f7
|
@ -50,7 +50,11 @@ public class ZenodoSoftwareVersionPublisher extends SoftwareVersionPublisher {
|
||||||
|
|
||||||
public static final String METADATA_FIELD_NAME = "metadata";
|
public static final String METADATA_FIELD_NAME = "metadata";
|
||||||
|
|
||||||
public static final String ZENODO_DOI_URL_BASE_PATH = "https://doi.org/10.5072/zenodo.";
|
private static final String SANDBOX_BASE_PATH = "https://sandbox.zenodo.org";
|
||||||
|
private static final String SANDBOX_DOI_URL_BASE_PATH = "https://doi.org/10.5072/zenodo.";
|
||||||
|
|
||||||
|
private static final String PRODUCTION_BASE_PATH = "https://zenodo.org";
|
||||||
|
private static final String PRODUCTION_DOI_URL_BASE_PATH = "https://doi.org/10.5281/zenodo.";
|
||||||
|
|
||||||
public static final String DEPOSITIONS_COLLECTION_PATH = "/api/deposit/depositions";
|
public static final String DEPOSITIONS_COLLECTION_PATH = "/api/deposit/depositions";
|
||||||
public static final String DEPOSITION_PATH = DEPOSITIONS_COLLECTION_PATH + "/:id";
|
public static final String DEPOSITION_PATH = DEPOSITIONS_COLLECTION_PATH + "/:id";
|
||||||
|
@ -68,13 +72,14 @@ public class ZenodoSoftwareVersionPublisher extends SoftwareVersionPublisher {
|
||||||
|
|
||||||
protected String zenodoID;
|
protected String zenodoID;
|
||||||
protected JsonNode response;
|
protected JsonNode response;
|
||||||
|
protected String doiBaseURL;
|
||||||
|
|
||||||
protected String getZenodoIDFromDOIURL(URL doiURL) {
|
protected String getZenodoIDFromDOIURL(URL doiURL) {
|
||||||
return getZenodoIDFromDOIURL(doiURL.toString());
|
return getZenodoIDFromDOIURL(doiURL.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getZenodoIDFromDOIURL(String doiURL) {
|
protected String getZenodoIDFromDOIURL(String doiURL) {
|
||||||
return doiURL.replace(ZENODO_DOI_URL_BASE_PATH, "");
|
return doiURL.replace(doiBaseURL, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Map<String, String> getAccessTokenQueryParamters() {
|
protected Map<String, String> getAccessTokenQueryParamters() {
|
||||||
|
@ -87,6 +92,16 @@ public class ZenodoSoftwareVersionPublisher extends SoftwareVersionPublisher {
|
||||||
try {
|
try {
|
||||||
this.zenodoBaseURL = new URL(Config.getProperties().getProperty("zenodo_base_url"));
|
this.zenodoBaseURL = new URL(Config.getProperties().getProperty("zenodo_base_url"));
|
||||||
this.accessToken = Config.getProperties().getProperty("zenodo_access_token");
|
this.accessToken = Config.getProperties().getProperty("zenodo_access_token");
|
||||||
|
this.doiBaseURL = Config.getProperties().getProperty("doi_base_url");
|
||||||
|
if(doiBaseURL==null) {
|
||||||
|
if(zenodoBaseURL.toString().compareTo(SANDBOX_BASE_PATH)==0) {
|
||||||
|
doiBaseURL = SANDBOX_DOI_URL_BASE_PATH;
|
||||||
|
}else if(zenodoBaseURL.toString().compareTo(PRODUCTION_BASE_PATH)==0) {
|
||||||
|
doiBaseURL = PRODUCTION_DOI_URL_BASE_PATH;
|
||||||
|
}else {
|
||||||
|
throw new RuntimeException("Please set 'doi_base_url' in your config file");
|
||||||
|
}
|
||||||
|
}
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@ -251,7 +266,7 @@ public class ZenodoSoftwareVersionPublisher extends SoftwareVersionPublisher {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected URL createZenodoDOIURLFromID(String id) throws MalformedURLException {
|
protected URL createZenodoDOIURLFromID(String id) throws MalformedURLException {
|
||||||
return new URL(ZENODO_DOI_URL_BASE_PATH + id);
|
return new URL(doiBaseURL + id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void create() throws Exception {
|
public void create() throws Exception {
|
||||||
|
@ -270,7 +285,7 @@ public class ZenodoSoftwareVersionPublisher extends SoftwareVersionPublisher {
|
||||||
|
|
||||||
URL conceptDOIURL = createZenodoDOIURLFromID(response.get("conceptrecid").asText());
|
URL conceptDOIURL = createZenodoDOIURLFromID(response.get("conceptrecid").asText());
|
||||||
softwareVersion.setDOIURL(conceptDOIURL);
|
softwareVersion.setDOIURL(conceptDOIURL);
|
||||||
URL doiURL = new URL(ZENODO_DOI_URL_BASE_PATH + response.get("id").asText());
|
URL doiURL = new URL(doiBaseURL + response.get("id").asText());
|
||||||
softwareVersion.setVersionDOIURL(doiURL);
|
softwareVersion.setVersionDOIURL(doiURL);
|
||||||
|
|
||||||
finalize();
|
finalize();
|
||||||
|
|
|
@ -12,6 +12,7 @@ public class SoftwareConceptAnalyserTest {
|
||||||
|
|
||||||
public static final String FILENAME = "gcat-test-sandbox.json";
|
public static final String FILENAME = "gcat-test-sandbox.json";
|
||||||
// public static final String FILENAME = "gcat-from-scratch.json";
|
// public static final String FILENAME = "gcat-from-scratch.json";
|
||||||
|
// public static final String FILENAME = "exported-gcat-from-scratch.json";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUsingTestFile() throws Exception {
|
public void testUsingTestFile() throws Exception {
|
||||||
|
|
|
@ -139,7 +139,7 @@
|
||||||
"url": "https://cordis.europa.eu/project/id/871042"
|
"url": "https://cordis.europa.eu/project/id/871042"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"publish": "ALL",
|
"publish": "NONE",
|
||||||
"export": "ALL"
|
"export": "ALL"
|
||||||
},
|
},
|
||||||
"versions":
|
"versions":
|
||||||
|
|
|
@ -129,7 +129,7 @@
|
||||||
"url": "https://cordis.europa.eu/project/id/871042"
|
"url": "https://cordis.europa.eu/project/id/871042"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"publish": "ALL",
|
"publish": "NONE",
|
||||||
"export": "ALL"
|
"export": "ALL"
|
||||||
},
|
},
|
||||||
"versions": [
|
"versions": [
|
||||||
|
|
Loading…
Reference in New Issue