From 129251d232d492f493ceb06c080aa217276b00b5 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Tue, 18 Oct 2022 16:06:32 +0200 Subject: [PATCH] Added more condition to check authorship --- .../java/org/gcube/gcat/persistence/ckan/CKANPackage.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 b45bfdb..78e78df 100644 --- a/src/main/java/org/gcube/gcat/persistence/ckan/CKANPackage.java +++ b/src/main/java/org/gcube/gcat/persistence/ckan/CKANPackage.java @@ -279,11 +279,11 @@ public class CKANPackage extends CKAN implements Moderated { }else { // this prevent to change the original author in case of update Role role = ckanUser.getRole(); if(role.ordinal() < Role.ADMIN.ordinal()) { - if(objectNode.get(AUTHOR_KEY).asText().compareTo(authorName)!=0) { + if(objectNode.has(AUTHOR_KEY) && objectNode.get(AUTHOR_KEY).asText().compareTo(authorName)!=0) { throw new BadRequestException("Only Catalogue-Admins or above can change the authorship (i.e. " + AUTHOR_KEY + " field) of an item."); } - if(objectNode.get(AUTHOR_EMAIL_KEY).asText().compareTo(authorEmail)!=0) { + if(objectNode.has(AUTHOR_EMAIL_KEY) && objectNode.get(AUTHOR_EMAIL_KEY).asText().compareTo(authorEmail)!=0) { throw new BadRequestException("Only Catalogue-Admins or above can change the authorship (i.e. " + AUTHOR_EMAIL_KEY + " field) of an item."); } }else {