@Override public JsonElement serialize(LeaseDuration leaseDuration, Type typeOfSrc, JsonSerializationContext context) { JsonObject jsonObj = new JsonObject(); jsonObj.add("initial", context.serialize(leaseDuration.getInitial())); jsonObj.add("max", context.serialize(leaseDuration.getMax())); jsonObj.add("step", context.serialize(leaseDuration.getStep())); return jsonObj; } }
private <T extends AbstractTemplate> boolean validateTemplate(T template, HttpResponder responder) { long initial = template.getAdministration().getLeaseDuration().getInitial(); initial = initial == 0 ? Long.MAX_VALUE : initial; long max = template.getAdministration().getLeaseDuration().getMax(); max = max == 0 ? Long.MAX_VALUE : max; if (max < initial) { responder.sendString(HttpResponseStatus.BAD_REQUEST, "Initial lease duration cannot be more than max lease duration for template " + template.getName()); return false; } return true; } }
step = step == 0 ? Long.MAX_VALUE : step; long clusterMaxDuration = cluster.getClusterTemplate().getAdministration().getLeaseDuration().getMax(); if (clusterMaxDuration != 0 && expireTime - cluster.getExpireTime() > step) { throw new IllegalArgumentException("New expire time cannot be greater than allowed increment");