Improved system metadata checks
This commit is contained in:
parent
120e807625
commit
f10bc09af1
|
@ -995,13 +995,20 @@ public class CKANPackage extends CKAN implements Moderated {
|
|||
String readSystemType = getSystemTypeMetadata(readJson);
|
||||
String gotSystemType = getSystemTypeMetadata(json);
|
||||
if(readSystemType.compareTo(gotSystemType)!=0) {
|
||||
throw new BadRequestException("You cannot chenge the system type. Expected '" + readSystemType + "'.Got '" + gotSystemType + "'");
|
||||
throw new BadRequestException("You cannot change the system type. Expected '" + readSystemType + "'. Got '" + gotSystemType + "'");
|
||||
}
|
||||
|
||||
Map<String, String> readSystemMetadata = CKANPackage.getModerationSystemMetadata(readJson);
|
||||
Map<String, String> gotSystemMetadata = CKANPackage.getModerationSystemMetadata(json);
|
||||
if(gotSystemMetadata.size()!=0 && !readSystemMetadata.equals(gotSystemMetadata)) {
|
||||
throw new BadRequestException("You cannot manage the system metadata. Expected " + readSystemMetadata.toString() + ".Got " + gotSystemMetadata.toString());
|
||||
Map<String, String> readModerationSystemMetadata = CKANPackage.getModerationSystemMetadata(readJson);
|
||||
Map<String, String> gotModerationSystemMetadata = CKANPackage.getModerationSystemMetadata(json);
|
||||
if(gotModerationSystemMetadata.size()!=0 && !readModerationSystemMetadata.equals(gotModerationSystemMetadata)) {
|
||||
throw new BadRequestException("You cannot manage the system metadata. Expected " + readModerationSystemMetadata.toString() + ". Got " + gotModerationSystemMetadata.toString());
|
||||
}
|
||||
|
||||
Map<String, String> readSystemMetadata = CKANPackage.getSystemMetadata(readJson);
|
||||
Map<String, String> gotSystemMetadata = CKANPackage.getSystemMetadata(json);
|
||||
if( gotSystemMetadata.size() != readSystemMetadata.size() &&
|
||||
gotSystemMetadata.size() != ( readSystemMetadata.size()-readModerationSystemMetadata.size() ) ) {
|
||||
throw new BadRequestException("You cannot manage the system metadata. Expected " + readSystemMetadata.toString() + ". Got " + gotSystemMetadata.toString());
|
||||
}
|
||||
|
||||
JsonNode jsonNode = validateJson(json);
|
||||
|
|
Loading…
Reference in New Issue