Skip to content

Commit a88957b

Browse files
DmitryLitvintsevmksahakyan
authored andcommitted
dcache rest api: do not filter out fields with default and null values
when building json reply object. Enable get/set of OUTPUT quota Motivation: ----------- dCache rest api response filters out fields that have null or default (for that type) values. As the result, for instance, integer filed with 0 value is skipped (so is any filed with null value). This is not desirable Modification: ------------- Change custom Json ObjectMapper to retain fields with null and default values Result: ------- Request results returned by dCache rest api contain fields having null or default values Ticket: #7836 Patch: https://rb.dcache.org/r/14479/ Target: trunk Request: 11.0, 10.2, 10.1, 10.0, 9.2 Acked-by: Tigran Require-book: no Require-notes: yes
1 parent ba0cb38 commit a88957b

File tree

2 files changed

+6
-21
lines changed

2 files changed

+6
-21
lines changed

modules/dcache-frontend/src/main/java/org/dcache/restful/providers/ObjectMapperProvider.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ private static ObjectMapper createListObjectMapper() {
2424
return new ObjectMapper()
2525
.registerModule(PNFSID_SERIALIZER)
2626
.enable(DeserializationFeature.UNWRAP_ROOT_VALUE)
27-
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
28-
.setSerializationInclusion(JsonInclude.Include.NON_NULL)
29-
.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT);
27+
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
3028
}
3129

3230
private static ObjectMapper createDefaultMapper() {

modules/dcache-frontend/src/main/java/org/dcache/restful/resources/quota/QuotaResources.java

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -398,17 +398,8 @@ public Response removeGroupQuota(
398398
private List<QuotaInfo> getQuotas(PnfsManagerGetQuotaMessage message) {
399399
try {
400400
message = pnfsmanager.sendAndWait(message);
401-
402-
/*
403-
* REVISIT. Output is currently not used. This will be revisted with
404-
* further redesign of the QoS definitions. For now, we null
405-
* out those settings (just in case).
406-
*/
407-
return message.getQuotaInfos().stream().map(quotaInfo -> {
408-
quotaInfo.setOutput(null);
409-
quotaInfo.setOutputLimit(null);
410-
return quotaInfo;
411-
}).collect(Collectors.toList());
401+
return message.getQuotaInfos().stream()
402+
.collect(Collectors.toList());
412403
} catch (CacheException e) {
413404
switch (e.getRc()) {
414405
case SERVICE_UNAVAILABLE:
@@ -469,13 +460,9 @@ private static QuotaRequest toQuotaRequest(String requestPayload) {
469460
request.setReplicaLimit(jsonObject.getString("replicaLimit"));
470461
}
471462

472-
/*
473-
* REVISIT. Output is currently not used. This will be revisted with
474-
* further redesign of the QoS definitions.
475-
*/
476-
// if (jsonObject.has("outputLimit")) {
477-
// request.setOutputLimit(jsonObject.getString("outputLimit"));
478-
// }
463+
if (jsonObject.has("outputLimit")) {
464+
request.setOutputLimit(jsonObject.getString("outputLimit"));
465+
}
479466

480467
return request;
481468
}

0 commit comments

Comments
 (0)