dan-s1 commented on code in PR #8005:
URL: https://github.com/apache/nifi/pull/8005#discussion_r1416188685


##########
nifi-nar-bundles/nifi-registry-bundle/nifi-registry-service/src/main/java/org/apache/nifi/schemaregistry/services/InMemoryJsonSchemaRegistry.java:
##########
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.schemaregistry.services;
+
+import com.networknt.schema.JsonSchemaFactory;
+import com.networknt.schema.SpecVersion;
+import org.apache.nifi.annotation.behavior.DynamicProperty;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.components.ValidationContext;
+import org.apache.nifi.components.ValidationResult;
+import org.apache.nifi.controller.AbstractControllerService;
+import org.apache.nifi.expression.ExpressionLanguageScope;
+import org.apache.nifi.processor.util.StandardValidators;
+import org.apache.nifi.schema.access.JsonSchema;
+import org.apache.nifi.schema.access.JsonSchemaRegistryComponent;
+import org.apache.nifi.schema.access.SchemaNotFoundException;
+import org.apache.nifi.schema.access.SchemaVersion;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+import static org.apache.commons.lang3.StringUtils.isBlank;
+import static org.apache.commons.lang3.StringUtils.isNotBlank;
+
+@Tags({"schema", "registry", "json"})
+@CapabilityDescription("Provides a service for registering and accessing 
schemas. One can register a schema "
+        + "as a dynamic property where 'name' represents the schema name and 
'value' represents the textual "
+        + "representation of the actual schema following the syntax and 
semantics of JSON's Schema format. "
+        + "Empty schemas and schemas only consisting of whitespace are not 
acceptable schemas."
+        + "The registry is heterogeneous registry as it can store schemas of 
multiple schema draft versions. "
+        + "By default the registry is configured to store schemas of Draft 
2020-12. When a schema is added, the version "
+        + "which is currently is set, is what the schema is saved as.")
+@DynamicProperty(name = "Schema name", value = "Schema Content",
+        description = "Adds a named schema using the JSON string 
representation of a JSON schema",
+        expressionLanguageScope = ExpressionLanguageScope.NONE)
+public class InMemoryJsonSchemaRegistry extends AbstractControllerService 
implements JsonSchemaRegistry, JsonSchemaRegistryComponent {

Review Comment:
   Is `PersistentJsonSchemaRegistry ` accurate? Would the contents persist 
after a NIFI shutdown? I thought this would be similar to `AvroSchemaRegistry` 
which I thought does not persist. Please correct me if am wrong.
   I like `PropertiesJsonSchemaRegistry` better although I am not sure if there 
is a consideration to align the naming convention with `AvroSchemaRegistry` or 
not. As an end user I would expect similar naming conventions in order to 
associate items with. Essentially the `InMemoryJsonSchemaRegistry` conceptually 
is the same as `AvroSchemaRegistry` so I would expect a similar name conveying 
the point that this stores JSON schemas in NIFI instead of Avro Schemas.
   Could we perhaps change the interface name to `JsonSchemaStore `and name 
this implementation `JsonSchemaRegistry ` so it aligns more with 
`AvroSchemaRegistry`? I know it does not align perfectly with the hierarchy for 
Avro schemas (as its interface is SchemaRegistry which I would have used for 
all type of schemas). Other implementations would use the suffix `Registry 
`instead of `Store`. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to