From b384c0897268c17bfbfeb373712b70052865d7c3 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Tue, 1 Dec 2020 09:55:16 +0100 Subject: [PATCH] Refactored code which check basic provided information --- .../gcat/persistence/ckan/CKANPackage.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 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 9c2e376..6da21bc 100644 --- a/src/main/java/org/gcube/gcat/persistence/ckan/CKANPackage.java +++ b/src/main/java/org/gcube/gcat/persistence/ckan/CKANPackage.java @@ -274,18 +274,17 @@ public class CKANPackage extends CKAN { if(objectNode.has(LICENSE_KEY)) { 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( "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)) {