Github user joewitt commented on a diff in the pull request:
https://github.com/apache/nifi/pull/1682#discussion_r112255200
--- Diff:
nifi-nar-bundles/nifi-registry-bundle/nifi-registry-service/src/main/java/org/apache/nifi/schemaregistry/services/AvroSchemaRegistry.java
---
@@ -54,39 +57,51 @@
private static final String LOGICAL_TYPE_TIMESTAMP_MILLIS =
"timestamp-millis";
private static final String LOGICAL_TYPE_TIMESTAMP_MICROS =
"timestamp-micros";
-
public AvroSchemaRegistry() {
this.schemaNameToSchemaMap = new HashMap<>();
}
- @OnEnabled
- public void enable(ConfigurationContext configuratiponContext) throws
InitializationException {
-
this.schemaNameToSchemaMap.putAll(configuratiponContext.getProperties().entrySet().stream()
- .filter(propEntry -> propEntry.getKey().isDynamic())
- .collect(Collectors.toMap(propEntry ->
propEntry.getKey().getName(), propEntry -> propEntry.getValue())));
+ @Override
+ public String retrieveSchemaText(final String schemaName) throws
SchemaNotFoundException {
+ final String schemaText = schemaNameToSchemaMap.get(schemaName);
+ if (schemaText == null) {
+ throw new SchemaNotFoundException("Unable to find schema with
name '" + schemaName + "'");
+ }
+
+ return schemaText;
}
@Override
- public String retrieveSchemaText(String schemaName) {
- if (!this.schemaNameToSchemaMap.containsKey(schemaName)) {
- throw new IllegalArgumentException("Failed to find schema;
Name: '" + schemaName + ".");
- } else {
- return this.schemaNameToSchemaMap.get(schemaName);
- }
+ public RecordSchema retrieveSchema(final String schemaName) throws
SchemaNotFoundException {
+ final String schemaText = retrieveSchemaText(schemaName);
+ final Schema schema = new Schema.Parser().parse(schemaText);
+ return createRecordSchema(schema, schemaText, schemaName);
}
@Override
- public String retrieveSchemaText(String schemaName, Map<String,
String> attributes) {
- throw new UnsupportedOperationException("This version of schema
registry does not "
- + "support this operation, since schemas are only identofied
by name.");
+ public RecordSchema retrieveSchema(long schemaId, int version) throws
IOException, SchemaNotFoundException {
+ throw new SchemaNotFoundException("This Schema Registry does not
support schema lookup by identifier and version - only by name.");
}
@Override
+ public String retrieveSchemaText(long schemaId, int version) throws
IOException, SchemaNotFoundException {
+ throw new SchemaNotFoundException("This Schema Registry does not
support schema lookup by identifier and version - only by name.");
+ }
+
@OnDisabled
public void close() throws Exception {
- this.schemaNameToSchemaMap.clear();
+ schemaNameToSchemaMap.clear();
}
+
+ @OnEnabled
+ public void enable(final ConfigurationContext configuratiponContext)
throws InitializationException {
--- End diff --
spelling mistake on the var name configuratiponContext
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---