{
return schema;
}
Schema avroSchema = Schema.parse(schema);
ObjectMapper mapper = new ObjectMapper();
JsonFactory factory = new JsonFactory();
StringWriter writer = new StringWriter();
JsonGenerator jgen = factory.createJsonGenerator(writer);
jgen.useDefaultPrettyPrinter();
@SuppressWarnings("checked")
HashMap<String,Object> schemaMap = new ObjectMapper().readValue(schema, HashMap.class);
@SuppressWarnings("checked")
ArrayList<HashMap<String,String>> list = (ArrayList<HashMap<String, String>>) schemaMap.get("fields");
int i=0;
while(i < list.size())
{
Schema.Field field = avroSchema.getField(list.get(i).get("name"));
String dbFieldName;
if(field.schema().getType() == Schema.Type.ARRAY)
{
throw new DatabusException("Field not supported for filtering");
//TODO fix this
/*
String innerSchema = field.getProp("items");
if(innerSchema == null)
throw new DatabusException("Unable to the inner schema type of the array");
Schema innerSchemaParsed = Schema.parse(innerSchema);
dbFieldName = SchemaHelper.getMetaField(innerSchemaParsed, "dbFieldName");
*/
}
else
dbFieldName = SchemaHelper.getMetaField(field, "dbFieldName");
if(dbFieldName == null)
throw new DatabusException("Unable to determine the dbFieldName from the meta information");
if(!_userFields.contains(dbFieldName.toUpperCase(Locale.ENGLISH)))
list.remove(i);
else
i++;
}
mapper.writeValue(jgen, schemaMap);
return writer.getBuffer().toString();
}