Added more condition to check authorship

This commit is contained in:
Luca Frosini 2022-10-18 16:06:32 +02:00
parent 25bce13814
commit 129251d232
1 changed files with 2 additions and 2 deletions

View File

@ -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 {