Improving solution

This commit is contained in:
Luca Frosini 2023-01-30 17:42:31 +01:00
parent d75bbb53e8
commit 97b7b50bf1
2 changed files with 11 additions and 3 deletions

View File

@ -404,9 +404,8 @@ public class ZenodoSoftwareVersionExporter extends SoftwareVersionExporter {
gxHTTPStringRequest.header("Content-Type", "application/json");
gxHTTPStringRequest.header("Accept", "application/json");
String conceptDOI = softwareVersionConfig.getConceptDOIURL();
String conceptID = getZenodoIDFromDOIURL(softwareVersionConfig.getConceptDOIURL());
String conceptDOIURL = softwareVersionConfig.getConceptDOIURL();
String conceptID = getZenodoIDFromDOIURL(conceptDOIURL);
gxHTTPStringRequest.path(RECORD_PATH.replace(":id", conceptID));
HttpURLConnection httpURLConnection = gxHTTPStringRequest.get();
JsonNode jsonNode = getResponse(httpURLConnection);

View File

@ -22,6 +22,8 @@ import org.gcube.common.software.utils.Utils;
*/
public class SoftwareVersionConfig {
public static final String PREVIOUS_CONCEPT_DOI_VALUE = "PREVIOUS";
public static final String NAME_PROPERTY_NAME = "name";
public static final String VERSION_PROPERTY_NAME = "version";
public static final String TITLE_PROPERTY_NAME = "title";
@ -176,6 +178,13 @@ public class SoftwareVersionConfig {
}
public String getConceptDOIURL() {
if(conceptDOIURL!=null && conceptDOIURL.compareTo(PREVIOUS_CONCEPT_DOI_VALUE)==0) {
if(previous!=null) {
conceptDOIURL = previous.getConceptDOIURL();
}else {
throw new RuntimeException(CONCEPT_DOI_URL_PROPERTY_NAME + " is indicates as " + PREVIOUS_CONCEPT_DOI_VALUE + " but " + getTitle() + " has no previous. Please check you config.");
}
}
return conceptDOIURL;
}