recordType.addFieldTypeEntry(new SchemaIdImpl(fieldIdString), mandatory);
} else if (fieldName != null) {
QName fieldQName = QNameConverter.fromJson(fieldName, namespaces);
try {
SchemaId fieldId = typeManager.getFieldTypeByName(fieldQName).getId();
recordType.addFieldTypeEntry(fieldId, mandatory);
} catch (RepositoryException e) {
throw new JsonFormatException("Record type " + name + ": error looking up field type with name: " +
fieldQName, e);
}
} else {
throw new JsonFormatException("Record type " + name + ": field entry should specify an id or name");
}
}
}
if (node.get("supertypes") != null && node.get("mixins") != null) {
throw new JsonFormatException("Only one of 'supertypes' or 'mixins' can be specified " +
"(they are synonyms, and mixins is deprecated).");
}
if (node.get("supertypes") != null) {
ArrayNode supertypes = getArray(node, "supertypes", null);
for (int i = 0; i < supertypes.size(); i++) {
JsonNode supertype = supertypes.get(i);
String rtIdString = getString(supertype, "id", null);
String rtName = getString(supertype, "name", null);
Long rtVersion = getLong(supertype, "version", null);
if (rtIdString != null) {
recordType.addSupertype(new SchemaIdImpl(rtIdString), rtVersion);
} else if (rtName != null) {
QName rtQName = QNameConverter.fromJson(rtName, namespaces);
try {
SchemaId rtId = typeManager.getRecordTypeByName(rtQName, null).getId();
recordType.addSupertype(rtId, rtVersion);
} catch (RepositoryException e) {
throw new JsonFormatException("Record type " + name +
": error looking up supertype record type with name: " + rtQName, e);
}
} else {
throw new JsonFormatException("Record type " + name + ": supertype should specify an id or name");
}
}
} else if (node.get("mixins") != null) {
// This was deprecated in 2.2, and can be removed in 2.4
LogFactory.getLog("lily.deprecation").warn("The use of 'mixins' is deprecated, please use supertypes instead");
ArrayNode mixins = getArray(node, "mixins", null);
for (int i = 0; i < mixins.size(); i++) {
JsonNode mixin = mixins.get(i);
String rtIdString = getString(mixin, "id", null);
String rtName = getString(mixin, "name", null);
Long rtVersion = getLong(mixin, "version", null);
if (rtIdString != null) {
recordType.addMixin(new SchemaIdImpl(rtIdString), rtVersion);
} else if (rtName != null) {
QName rtQName = QNameConverter.fromJson(rtName, namespaces);
try {
SchemaId rtId = typeManager.getRecordTypeByName(rtQName, null).getId();
recordType.addMixin(rtId, rtVersion);
} catch (RepositoryException e) {
throw new JsonFormatException("Record type " + name + ": error looking up mixin record type with name: " +
rtQName, e);
}