@Override public SchemaDetails<S> getLatestSchemaByTopic(String topicName) { File topicDir = getTopicPath(topicName); if (topicDir.exists()) { for (File file : topicDir.listFiles()) { if (file.getName().endsWith(".latest")) { String id = file.getName().replace(".schema.latest", ""); return new SchemaDetails<S>(topicName, id, serde.fromBytes(readBytes(file))); } } } throw new SchemaNotFoundException("Unable to find a latest schema for topic " + topicName + "."); }
@Override public SchemaDetails<S> getLatestSchemaByTopic(String topicName) { File topicDir = getTopicPath(topicName); if (topicDir.exists()) { for (File file : topicDir.listFiles()) { if (file.getName().endsWith(".latest")) { String id = file.getName().replace(".schema.latest", ""); return new SchemaDetails<S>(topicName, id, serde.fromBytes(readBytes(file))); } } } throw new SchemaNotFoundException("Unable to find a latest schema for topic " + topicName + "."); }
@Override public S getSchemaByID(String topic, String id) { File file = getSchemaPath(topic, id, false); if (!file.exists()) { file = getSchemaPath(topic, id, true); } if (!file.exists()) { throw new SchemaNotFoundException("No matching schema found for topic " + topic + " and id " + id + "."); } return serde.fromBytes(readBytes(file)); }
@Override public S getSchemaByID(String topic, String id) { File file = getSchemaPath(topic, id, false); if (!file.exists()) { file = getSchemaPath(topic, id, true); } if (!file.exists()) { throw new SchemaNotFoundException("No matching schema found for topic " + topic + " and id " + id + "."); } return serde.fromBytes(readBytes(file)); }