diff --git a/src/main/java/org/gcube/gcat/persistence/ckan/CKANPackage.java b/src/main/java/org/gcube/gcat/persistence/ckan/CKANPackage.java index 121cf0b..a2d972a 100644 --- a/src/main/java/org/gcube/gcat/persistence/ckan/CKANPackage.java +++ b/src/main/java/org/gcube/gcat/persistence/ckan/CKANPackage.java @@ -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);