[
https://issues.apache.org/jira/browse/MINIFI-41?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15357321#comment-15357321
]
ASF GitHub Bot commented on MINIFI-41:
--------------------------------------
Github user JPercivall commented on a diff in the pull request:
https://github.com/apache/nifi-minifi/pull/21#discussion_r69159093
--- Diff:
minifi-commons/minifi-commons-schema/src/main/java/org/apache/nifi/minifi/commons/schema/SchemaLoader.java
---
@@ -0,0 +1,52 @@
+/*
+ * 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.minifi.commons.schema;
+
+import
org.apache.nifi.minifi.commons.schema.exception.SchemaLoaderException;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.error.YAMLException;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+
+public class SchemaLoader {
+ public static Map<String, Object> loadYamlAsMap(InputStream
sourceStream) throws IOException, SchemaLoaderException {
+ try {
+ Yaml yaml = new Yaml();
+
+ // Parse the YAML file
+ final Object loadedObject = yaml.load(sourceStream);
+
+ // Verify the parsed object is a Map structure
+ if (loadedObject instanceof Map) {
+ return (Map<String, Object>) loadedObject;
+ } else {
+ throw new SchemaLoaderException("Provided YAML
configuration is not a Map");
+ }
+ } catch (YAMLException e ) {
+ throw new IOException(e);
+ } finally {
+ sourceStream.close();
+ }
+ }
+
+ public static ConfigSchema loadConfigSchema(InputStream sourceStream)
throws IOException, SchemaLoaderException {
--- End diff --
Since this is just a wrapper around loadYamlAsMap and has the requirement
that the input is Yaml, I'd prefer to have "Yaml" in somewhere in the method
name.
> Command Line Configuration Utility
> ----------------------------------
>
> Key: MINIFI-41
> URL: https://issues.apache.org/jira/browse/MINIFI-41
> Project: Apache NiFi MiNiFi
> Issue Type: New Feature
> Reporter: Bryan Rosander
>
> It would really increase usability if we had a way to transform template xmls
> into configuration YAML files for consumption by MiNiFi.
> The utility should:
> 1. Transform template xmls exported from NiFi into configuration YAML files.
> 2. Validate the contents of a given YAML file in the same way MiNiFi does at
> runtime.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)