/**
* Reads those aspects of a record that are shared between top-level and nested records.
*/
protected Record readCommonRecordAspects(ValueHandle handle, ReadContext context, boolean topLevelRecord)
throws JsonFormatException, InterruptedException, RepositoryException {
LRepository repository = context.repository;
Namespaces namespaces = context.namespaces;
Record record = repository.getRecordFactory().newRecord();
JsonNode typeNode = handle.node.get("type");
if (typeNode != null) {
if (typeNode.isObject()) {
QName qname = QNameConverter.fromJson(JsonUtil.getString(typeNode, "name"), namespaces);
Long version = JsonUtil.getLong(typeNode, "version", null);
record.setRecordType(qname, version);
} else if (typeNode.isTextual()) {
record.setRecordType(QNameConverter.fromJson(typeNode.getTextValue(), namespaces));
}
}
ObjectNode fields = getObject(handle.node, "fields", null);
if (fields != null) {
Iterator<Map.Entry<String, JsonNode>> it = fields.getFields();
while (it.hasNext()) {
Map.Entry<String, JsonNode> entry = it.next();
QName qname = QNameConverter.fromJson(entry.getKey(), namespaces);
FieldType fieldType = repository.getTypeManager().getFieldTypeByName(qname);
ValueHandle subHandle = new ValueHandle(fields.get(entry.getKey()), "fields." + entry.getKey(),
fieldType.getValueType());
Object value = readValue(subHandle, context);
if (value != null) {
record.setField(qname, value);