private void encodeData(Object value, DataOutput dataOutput, IdentityRecordStack parentRecords)
throws RepositoryException, InterruptedException {
Record record = (Record)value;
if (parentRecords.contains(record)) {
throw new RecordException("A record may not be nested in itself: " + record.getId());
}
RecordType recordType;
QName recordRecordTypeName = record.getRecordTypeName();
if (recordRecordTypeName != null) {
if (valueTypeRecordTypeName != null) {
// Validate the same record type is being used
// 20130314: temporarily disabled this, see LILY-1279
// if (!valueTypeRecordTypeName.equals(recordRecordTypeName)) {
// throw new RecordException("The record's Record Type '" + recordRecordTypeName +
// "' does not match the record value type's record type '" + valueTypeRecordTypeName + "'");
// }
}
recordType = typeManager.getRecordTypeByName(recordRecordTypeName, null);
} else if (valueTypeRecordTypeName != null) {
recordType = typeManager.getRecordTypeByName(valueTypeRecordTypeName, null);
} else {
throw new RecordException("The record '" + record + "' should specify a record type");
}
// Get and sort the field type entries that should be in the record
List<FieldType> fieldTypes = getSortedFieldTypes(recordType);