Enforcing private item to avoid issue #26391

This commit is contained in:
Luca Frosini 2024-01-18 12:27:36 +01:00
parent 703b284b92
commit 7915074947
1 changed files with 11 additions and 8 deletions

View File

@ -360,12 +360,12 @@ public class CKANPackage extends CKAN implements Moderated {
boolean privatePackage = objectNode.get(PRIVATE_KEY).asBoolean(); boolean privatePackage = objectNode.get(PRIVATE_KEY).asBoolean();
if(privatePackage) { if(privatePackage) {
/* /*
* This version is not properly managed by CKAN. * objectNode.put(SEARCHABLE_KEY, true);
* This code is not properly managed by the CKAN.
* It is converted to: * It is converted to:
* searchable: "true" * searchable: "true"
* which is incidentally considered as true value even is not correct. * which is considered true but only incidentally.
* We need to provide a string with T as capitol letters to make it working * We need to provide a string with T as capitol letters to be sure it properly works
* objectNode.put(SEARCHABLE_KEY, true);
*/ */
objectNode.put(SEARCHABLE_KEY, "True"); objectNode.put(SEARCHABLE_KEY, "True");
} }
@ -1387,13 +1387,16 @@ public class CKANPackage extends CKAN implements Moderated {
protected void setToRejected(JsonNode jsonNode) { protected void setToRejected(JsonNode jsonNode) {
addExtraField(jsonNode, Moderated.SYSTEM_CM_ITEM_STATUS, CMItemStatus.REJECTED.getValue()); addExtraField(jsonNode, Moderated.SYSTEM_CM_ITEM_STATUS, CMItemStatus.REJECTED.getValue());
// Enforcing private again
((ObjectNode) jsonNode).put(PRIVATE_KEY, true);
/* /*
* This version is not properly managed by CKAN. * ((ObjectNode) jsonNode).put(SEARCHABLE_KEY, false);
* This code is not properly managed by CKAN.
* It is converted to: * It is converted to:
* searchable: "false" * searchable: "false"
* which is considered as true value. * which is considered as true value.
* We need to provide a string with F as capitol letters to make it working * We need to provide a string with F as capitol letters to make it working
* ((ObjectNode) jsonNode).put(SEARCHABLE_KEY, false);
*/ */
((ObjectNode) jsonNode).put(SEARCHABLE_KEY, "False"); ((ObjectNode) jsonNode).put(SEARCHABLE_KEY, "False");
} }
@ -1416,12 +1419,12 @@ public class CKANPackage extends CKAN implements Moderated {
((ObjectNode) jsonNode).put(PRIVATE_KEY, true); ((ObjectNode) jsonNode).put(PRIVATE_KEY, true);
/* /*
* ((ObjectNode) jsonNode).put(SEARCHABLE_KEY, false);
* This version is not properly managed by CKAN. * This version is not properly managed by CKAN.
* It is converted to: * It is converted to:
* searchable: "false" * searchable: "false"
* which is considered as true value. * which is considered as true value.
* We need to provide a string with F as capitol letters to make it working * We need to provide a string with F as capitol letters to make it working
* ((ObjectNode) jsonNode).put(SEARCHABLE_KEY, false);
*/ */
((ObjectNode) jsonNode).put(SEARCHABLE_KEY, "False"); ((ObjectNode) jsonNode).put(SEARCHABLE_KEY, "False");
} }
@ -1454,7 +1457,7 @@ public class CKANPackage extends CKAN implements Moderated {
} }
boolean privateItem = cmItemVisibility == CMItemVisibility.RESTRICTED ? true :false; boolean privateItem = cmItemVisibility == CMItemVisibility.RESTRICTED ? true : false;
((ObjectNode) jsonNode).put(PRIVATE_KEY, privateItem); ((ObjectNode) jsonNode).put(PRIVATE_KEY, privateItem);
if(privateItem) { if(privateItem) {
((ObjectNode) jsonNode).put(SEARCHABLE_KEY, "True"); ((ObjectNode) jsonNode).put(SEARCHABLE_KEY, "True");