public void updateChangeLog( final Principal user, final Verb verb, final PropertyKey key, final Object previousValue, final Object newValue) { if (changeLogEnabled && changeLog != null && key != null) { final String name = key.jsonName(); if (!hiddenPropertiesInAuditLog.contains(name) && !(key.isUnvalidated() || key.isReadOnly())) { final JsonObject obj = new JsonObject(); obj.add("time", toElement(System.currentTimeMillis())); obj.add("userId", toElement(user.getUuid())); obj.add("userName", toElement(user.getName())); obj.add("verb", toElement(verb)); obj.add("key", toElement(key.jsonName())); obj.add("prev", toElement(previousValue)); obj.add("val", toElement(newValue)); changeLog.append(obj.toString()); changeLog.append("\n"); } } }
@Override public JsonElement getContent() { JsonObject obj = new JsonObject(); JsonObject vals = new JsonObject(); for (Entry<PropertyKey, Object> entry : attributes.entrySet()) { PropertyKey key = entry.getKey(); Object value = entry.getValue(); if (value == null) { vals.add(key.jsonName(), new JsonNull()); } else { vals.add(key.jsonName(), new JsonPrimitive(value.toString())); } } obj.add(getErrorToken(), vals); return obj; }