private JsonObject mergeConfig(JsonObject to, JsonObject from, Set<String> immutables, boolean isImmutable) throws TemplateImmutabilityException { //merge defaults config JsonObject finalConfig = new JsonObject(); for (Map.Entry<String, JsonElement> config : to.entrySet()) { finalConfig.add(config.getKey(), config.getValue()); } for (Map.Entry<String, JsonElement> fromConfigItem : from.entrySet()) { String name = fromConfigItem.getKey(); JsonElement value = fromConfigItem.getValue(); if (immutables.contains(name) && finalConfig.has(name)) { throw new TemplateImmutabilityException(name + " can't be overridden due immutability."); } finalConfig.add(name, value); if (isImmutable) { immutables.add(name); } } return finalConfig; }
responder.sendString(HttpResponseStatus.NOT_FOUND, e.getMessage()); } catch (TemplateImmutabilityException e) { responder.sendString(HttpResponseStatus.BAD_REQUEST, e.getMessage()); } catch (IOException e) { responder.sendString(HttpResponseStatus.INTERNAL_SERVER_ERROR, "Exception processing template.");