Reorganized code

This commit is contained in:
luca.frosini 2023-07-14 16:24:38 +02:00
parent 0cf6e58dd4
commit ded9f23deb
1 changed files with 25 additions and 20 deletions

View File

@ -300,6 +300,30 @@ public class CKANPackage extends CKAN implements Moderated {
}
protected ObjectNode checkAndFixAuthorAndMaintainer(ObjectNode objectNode) {
String authorName = ckanUser.getSurnameName();
if(authorName==null || authorName.compareTo("")==0) {
authorName = ckanUser.getName();
}
String authorEmail = ckanUser.getEMail();
objectNode = checkAuthor(objectNode, authorName, authorEmail);
if(!objectNode.has(MAINTAINER_KEY)) {
if(!objectNode.has(MAINTAINER_EMAIL_KEY)) {
objectNode.put(MAINTAINER_KEY, authorName);
objectNode.put(MAINTAINER_EMAIL_KEY, authorEmail);
}else {
// We could try to retrieve Surname and Name of the maintainer if
// he/she is present as user in the VRE or in the catalogue.
objectNode.put(MAINTAINER_KEY, objectNode.get(MAINTAINER_EMAIL_KEY).toString());
}
}
return objectNode;
}
/**
* @param json The json to check
* @param allowPartialInfo used for patch method which provide only partial information (i.e. the info to patch)
@ -374,26 +398,7 @@ public class CKANPackage extends CKAN implements Moderated {
objectNode.remove(CAPACITY_KEY);
}
String authorName = ckanUser.getSurnameName();
if(authorName==null || authorName.compareTo("")==0) {
authorName = ckanUser.getName();
}
String authorEmail = ckanUser.getEMail();
objectNode = checkAuthor(objectNode, authorName, authorEmail);
if(!objectNode.has(MAINTAINER_KEY)) {
if(!objectNode.has(MAINTAINER_EMAIL_KEY)) {
objectNode.put(MAINTAINER_KEY, authorName);
objectNode.put(MAINTAINER_EMAIL_KEY, authorEmail);
}else {
// We could try to retrieve Surname and Name of the maintainer if
// he/she is present as user in the VRE or in the catalogue.
objectNode.put(MAINTAINER_KEY, objectNode.get(MAINTAINER_EMAIL_KEY).toString());
}
}
objectNode = checkAndFixAuthorAndMaintainer(objectNode);
getPublishingOrganization(objectNode);