Refactored code which check basic provided information

This commit is contained in:
Luca Frosini 2020-12-01 09:55:16 +01:00
parent 1733b66c05
commit b384c08972
1 changed files with 9 additions and 10 deletions

View File

@ -274,18 +274,17 @@ public class CKANPackage extends CKAN {
if(objectNode.has(LICENSE_KEY)) { if(objectNode.has(LICENSE_KEY)) {
licenseId = objectNode.get(LICENSE_KEY).asText(); licenseId = objectNode.get(LICENSE_KEY).asText();
} }
if(licenseId == null || licenseId.isEmpty() && !allowPartialInfo) {
if(licenseId!=null && !licenseId.isEmpty()) {
try {
CKANLicense.checkLicenseId(licenseId);
} catch(Exception e) {
throw new BadRequestException(
"You must specify an existing license identifier for the item. License list can be retrieved using licence collection");
}
}else if(!allowPartialInfo) {
throw new BadRequestException( throw new BadRequestException(
"You must specify a license identifier for the item. License list can be retrieved using licence collection"); "You must specify a license identifier for the item. License list can be retrieved using licence collection");
} else {
if(licenseId!=null) {
try {
CKANLicense.checkLicenseId(licenseId);
} catch(Exception e) {
throw new BadRequestException(
"You must specify an existing license identifier for the item. License list can be retrieved using licence collection");
}
}
} }
if(objectNode.has(CAPACITY_KEY)) { if(objectNode.has(CAPACITY_KEY)) {