tpalfy commented on a change in pull request #4577: URL: https://github.com/apache/nifi/pull/4577#discussion_r572140446
########## 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: The problem is that the code is already referencing these according to Koji's original idea. I removed it from the public interface because it was not needed so testing this would require time and effort that is not worth it really. I don't think it's possible to extract the relevant changes in a clean manner. On the other hand, completely eradicating them from the codebase feels risky and resource-intensive. (Testing all this is really hard.) Also, should we need these concepts later, we would need to implement them from scratch. All-in-all I would consider these as half-finished extension points. I know this is not ideal but I chose this approach because all things considered this seemed to be the best compromise. ########## 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 as above. ---------------------------------------------------------------- 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: us...@infra.apache.org