Used sysadmin to approve/reject the item

This commit is contained in:
Luca Frosini 2022-04-11 16:10:49 +02:00
parent 8395cebf3c
commit 1ccec24890
1 changed files with 9 additions and 1 deletions

View File

@ -1342,6 +1342,10 @@ public class CKANPackage extends CKAN implements Moderated {
throw new MethodNotSupportedException("Only catalogue moderator can approve a pending item.");
}
setToApproved(result);
// Need to use sysadmin because the user could not have the right to modify the item
setApiKey(CKANUtility.getSysAdminAPI());
String ret = sendPostRequest(ITEM_UPDATE, getAsString(result));
result = mapper.readTree(ret);
@ -1389,6 +1393,10 @@ public class CKANPackage extends CKAN implements Moderated {
}
setToRejected(result);
// Need to use sysadmin because the user could not have the right to modify the item
setApiKey(CKANUtility.getSysAdminAPI());
String ret = sendPostRequest(ITEM_PATCH, getAsString(result));
result = mapper.readTree(ret);
parseResult();
@ -1457,7 +1465,7 @@ public class CKANPackage extends CKAN implements Moderated {
throw new BadRequestException("Allowed moderation operations are approve, reject and message");
}
}else {
if(message==null || message.compareTo("")==0) {
if(message==null || message.length()==0) {
throw new BadRequestException("Allowed moderation operations are approve, reject and message");
}
message(message);