You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2020/11/17 21:07:10 UTC

[GitHub] [nifi] mattyb149 commented on a change in pull request #4577: NIFI-6752 Create ASN.1 RecordReader

mattyb149 commented on a change in pull request #4577:
URL: https://github.com/apache/nifi/pull/4577#discussion_r525408265



##########
File path: nifi-nar-bundles/nifi-asn1-bundle/nifi-asn1-services/checkstyle-suppressions.xml
##########
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<!DOCTYPE suppressions PUBLIC
+  "-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
+  "https://checkstyle.org/dtds/suppressions_1_2.dtd">
+
+<suppressions>
+  <suppress files="[/\\]target[/\\]" checks=".*" />

Review comment:
       Is this necessary? I thought our Checkstyle plugin always ignores `target`?

##########
File path: nifi-nar-bundles/nifi-asn1-bundle/nifi-asn1-services/src/main/java/org/apache/nifi/jasn1/JASN1Reader.java
##########
@@ -0,0 +1,315 @@
+/*
+ * 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.jasn1;
+
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.lifecycle.OnDisabled;
+import org.apache.nifi.annotation.lifecycle.OnEnabled;
+import org.apache.nifi.components.AbstractConfigurableComponent;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.components.PropertyValue;
+import org.apache.nifi.components.ValidationContext;
+import org.apache.nifi.components.ValidationResult;
+import org.apache.nifi.controller.ConfigurationContext;
+import org.apache.nifi.controller.ControllerServiceInitializationContext;
+import org.apache.nifi.expression.ExpressionLanguageScope;
+import org.apache.nifi.logging.ComponentLog;
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.processor.util.StandardValidators;
+import org.apache.nifi.reporting.InitializationException;
+import org.apache.nifi.schema.access.SchemaNotFoundException;
+import org.apache.nifi.serialization.MalformedRecordException;
+import org.apache.nifi.serialization.RecordReader;
+import org.apache.nifi.serialization.RecordReaderFactory;
+import org.apache.nifi.util.file.classloader.ClassLoaderUtils;
+
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@Tags({"asn", "ans1", "jasn.1", "jasn1", "record", "reader", "parser"})
+@CapabilityDescription("Reads ASN.1 content and creates NiFi records.")
+public class JASN1Reader extends AbstractConfigurableComponent implements RecordReaderFactory {
+
+    private static final PropertyDescriptor ROOT_MODEL_NAME = new PropertyDescriptor.Builder()
+        .name("root-model-name")
+        .displayName("Root Model Name")
+        .description("The model name in the form of 'MODULE-NAME.ModelType'. " +
+            "Mutually exclusive with and should be preferred to 'Root Model Class Name'. (See additional details for more information.)")
+        .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
+        .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+        .required(false)
+        .build();
+
+    private static final PropertyDescriptor ROOT_CLASS_NAME = new PropertyDescriptor.Builder()
+        .name("root-model-class-name")
+        .displayName("Root Model Class Name")
+        .description("A canonical class name that is generated by the ASN.1 compiler to encode the ASN.1 input data. Mutually exclusive with 'Root Model Name'." +
+            " Should be used when the former cannot be set properly. See additional details for more information.")
+        .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
+        .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+        .required(false)
+        .build();
+
+    /**
+     * Not included!
+     * To make this service as simple as possible, records are to be expected to correspond to a concrete ASN type.
+     * Not removing though, should it be required in the future.
+     */
+    private static final PropertyDescriptor RECORD_FIELD = new PropertyDescriptor.Builder()
+        .name("record-field")
+        .displayName("Record Field")
+        .description("Optional field name pointing an instance field containing record elements.")
+        .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
+        .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+        .required(false)
+        .build();
+
+
+    static final PropertyDescriptor ASN_FILES = new PropertyDescriptor.Builder()
+        .name("asn-files")
+        .displayName("ASN.1 Files")
+        .description("Comma-separated list of ASN.1 files.")
+        .required(false)
+        .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
+        .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+        .build();
+
+    /**
+     * Not included!
+     * To make this service as simple as possible, classpath modification is not supported currently as it's
+     * benefit would be questionable.
+     * Not removing though, should it be required in the future.
+     */
+    private static final PropertyDescriptor ITERATOR_PROVIDER_CLASS_NAME = new PropertyDescriptor.Builder()

Review comment:
       Same here about moving to a Jira

##########
File path: nifi-assembly/pom.xml
##########
@@ -760,6 +760,12 @@ language governing permissions and limitations under the License. -->
             <artifactId>javax.activation-api</artifactId>
             <version>1.2.0</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-asn1-nar</artifactId>

Review comment:
       This should be in a profile `include-asn1` in order to keep the assembly footprint the same

##########
File path: nifi-nar-bundles/nifi-asn1-bundle/nifi-asn1-services/src/main/java/org/apache/nifi/jasn1/JASN1Reader.java
##########
@@ -0,0 +1,315 @@
+/*
+ * 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.jasn1;
+
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.lifecycle.OnDisabled;
+import org.apache.nifi.annotation.lifecycle.OnEnabled;
+import org.apache.nifi.components.AbstractConfigurableComponent;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.components.PropertyValue;
+import org.apache.nifi.components.ValidationContext;
+import org.apache.nifi.components.ValidationResult;
+import org.apache.nifi.controller.ConfigurationContext;
+import org.apache.nifi.controller.ControllerServiceInitializationContext;
+import org.apache.nifi.expression.ExpressionLanguageScope;
+import org.apache.nifi.logging.ComponentLog;
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.processor.util.StandardValidators;
+import org.apache.nifi.reporting.InitializationException;
+import org.apache.nifi.schema.access.SchemaNotFoundException;
+import org.apache.nifi.serialization.MalformedRecordException;
+import org.apache.nifi.serialization.RecordReader;
+import org.apache.nifi.serialization.RecordReaderFactory;
+import org.apache.nifi.util.file.classloader.ClassLoaderUtils;
+
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@Tags({"asn", "ans1", "jasn.1", "jasn1", "record", "reader", "parser"})
+@CapabilityDescription("Reads ASN.1 content and creates NiFi records.")
+public class JASN1Reader extends AbstractConfigurableComponent implements RecordReaderFactory {
+
+    private static final PropertyDescriptor ROOT_MODEL_NAME = new PropertyDescriptor.Builder()
+        .name("root-model-name")
+        .displayName("Root Model Name")
+        .description("The model name in the form of 'MODULE-NAME.ModelType'. " +
+            "Mutually exclusive with and should be preferred to 'Root Model Class Name'. (See additional details for more information.)")
+        .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
+        .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+        .required(false)
+        .build();
+
+    private static final PropertyDescriptor ROOT_CLASS_NAME = new PropertyDescriptor.Builder()
+        .name("root-model-class-name")
+        .displayName("Root Model Class Name")
+        .description("A canonical class name that is generated by the ASN.1 compiler to encode the ASN.1 input data. Mutually exclusive with 'Root Model Name'." +
+            " Should be used when the former cannot be set properly. See additional details for more information.")
+        .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
+        .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+        .required(false)
+        .build();
+
+    /**
+     * Not included!
+     * To make this service as simple as possible, records are to be expected to correspond to a concrete ASN type.
+     * Not removing though, should it be required in the future.
+     */
+    private static final PropertyDescriptor RECORD_FIELD = new PropertyDescriptor.Builder()

Review comment:
       Rather than having unused code in a new module, maybe write a follow-on Jira of type `Wish` or something, and put this code there? That way we still have it to add later, if someone wants to do it.




----------------------------------------------------------------
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.

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