@Test public void doesTransformOnMultipleProcessors() throws Exception { File inputFile = new File("./src/test/resources/config-multiple-processors.yml"); ConfigTransformer.transformConfigFile(new FileInputStream(inputFile), "./target/", null); File nifiPropertiesFile = new File("./target/nifi.properties"); assertTrue(nifiPropertiesFile.exists()); assertTrue(nifiPropertiesFile.canRead()); nifiPropertiesFile.deleteOnExit(); File flowXml = new File("./target/flow.xml.gz"); assertTrue(flowXml.exists()); assertTrue(flowXml.canRead()); flowXml.deleteOnExit(); }
public static void transformConfigFile(InputStream sourceStream, String destPath, Properties bootstrapProperties) throws Exception { ConvertableSchema<ConfigSchema> convertableSchema = throwIfInvalid(SchemaLoader.loadConvertableSchemaFromYaml(sourceStream)); ConfigSchema configSchema = throwIfInvalid(convertableSchema.convert()); SecurityPropertiesSchema securityProperties = BootstrapTransformer.buildSecurityPropertiesFromBootstrap(bootstrapProperties).orElse(null); ProvenanceReportingSchema provenanceReportingProperties = BootstrapTransformer.buildProvenanceReportingPropertiesFromBootstrap(bootstrapProperties).orElse(null); if (securityProperties != null) { configSchema.setSecurityProperties(securityProperties); logger.info("Bootstrap flow override: Replaced security properties"); } if (provenanceReportingProperties != null) { configSchema.setProvenanceReportingProperties(provenanceReportingProperties); logger.info("Bootstrap flow override: Replaced provenance reporting properties"); } if (BootstrapTransformer.processorSSLOverride(bootstrapProperties)) { for (ProcessorSchema processorConfig : configSchema.getProcessGroupSchema().getProcessors()) { processorConfig.getProperties().replace("SSL Context Service", processorConfig.getProperties().get("SSL Context Service"), "SSL-Context-Service"); logger.info("Bootstrap flow override: Replaced {} SSL Context Service with parent MiNiFi SSL", processorConfig.getName()); } } ByteArrayOutputStream nifiPropertiesOutputStream = new ByteArrayOutputStream(); writeNiFiProperties(configSchema, nifiPropertiesOutputStream); writeFlowXmlFile(configSchema, destPath); writeNiFiPropertiesFile(nifiPropertiesOutputStream, destPath); }
ConfigTransformer { public static void transformConfigFile(InputStream sourceStream, String destPath, Properties bootstrapProperties) throws Exception { ConvertableSchema<ConfigSchema> convertableSchema = throwIfInvalid(SchemaLoader.loadConvertableSchemaFromYaml(sourceStream)); ConfigSchema configSchema = throwIfInvalid(convertableSchema.convert()); SecurityPropertiesSchema securityProperties = BootstrapTransformer.buildSecurityPropertiesFromBootstrap(bootstrapProperties).orElse(null); ProvenanceReportingSchema provenanceReportingProperties = BootstrapTransformer.buildProvenanceReportingPropertiesFromBootstrap(bootstrapProperties).orElse(null); if (securityProperties != null) { configSchema.setSecurityProperties(securityProperties); logger.info("Bootstrap flow override: Replaced security properties"); } if (provenanceReportingProperties != null) { configSchema.setProvenanceReportingProperties(provenanceReportingProperties); logger.info("Bootstrap flow override: Replaced provenance reporting properties"); } if (BootstrapTransformer.processorSSLOverride(bootstrapProperties)) { for (ProcessorSchema processorConfig : configSchema.getProcessGroupSchema().getProcessors()) { processorConfig.getProperties().replace("SSL Context Service", processorConfig.getProperties().get("SSL Context Service"), "SSL-Context-Service"); logger.info("Bootstrap flow override: Replaced {} SSL Context Service with parent MiNiFi SSL", processorConfig.getName()); } } ByteArrayOutputStream nifiPropertiesOutputStream = new ByteArrayOutputStream(); writeNiFiProperties(configSchema, nifiPropertiesOutputStream); writeFlowXmlFile(configSchema, destPath); writeNiFiPropertiesFile(nifiPropertiesOutputStream, destPath); } }
ConfigTransformer { public static void transformConfigFile(InputStream sourceStream, String destPath, Properties bootstrapProperties) throws Exception { ConvertableSchema<ConfigSchema> convertableSchema = throwIfInvalid(SchemaLoader.loadConvertableSchemaFromYaml(sourceStream)); ConfigSchema configSchema = throwIfInvalid(convertableSchema.convert()); SecurityPropertiesSchema securityProperties = BootstrapTransformer.buildSecurityPropertiesFromBootstrap(bootstrapProperties).orElse(null); ProvenanceReportingSchema provenanceReportingProperties = BootstrapTransformer.buildProvenanceReportingPropertiesFromBootstrap(bootstrapProperties).orElse(null); if (securityProperties != null) { configSchema.setSecurityProperties(securityProperties); logger.info("Bootstrap flow override: Replaced security properties"); } if (provenanceReportingProperties != null) { configSchema.setProvenanceReportingProperties(provenanceReportingProperties); logger.info("Bootstrap flow override: Replaced provenance reporting properties"); } if (BootstrapTransformer.processorSSLOverride(bootstrapProperties)) { for (ProcessorSchema processorConfig : configSchema.getProcessGroupSchema().getProcessors()) { processorConfig.getProperties().replace("SSL Context Service", processorConfig.getProperties().get("SSL Context Service"), "SSL-Context-Service"); logger.info("Bootstrap flow override: Replaced {} SSL Context Service with parent MiNiFi SSL", processorConfig.getName()); } } ByteArrayOutputStream nifiPropertiesOutputStream = new ByteArrayOutputStream(); writeNiFiProperties(configSchema, nifiPropertiesOutputStream); writeFlowXmlFile(configSchema, destPath); writeNiFiPropertiesFile(nifiPropertiesOutputStream, destPath); } private  ConfigTransformer(); }
ConfigTransformer { public static void transformConfigFile(InputStream sourceStream, String destPath, Properties bootstrapProperties) throws Exception { ConvertableSchema<ConfigSchema> convertableSchema = throwIfInvalid(SchemaLoader.loadConvertableSchemaFromYaml(sourceStream)); ConfigSchema configSchema = throwIfInvalid(convertableSchema.convert()); SecurityPropertiesSchema securityProperties = BootstrapTransformer.buildSecurityPropertiesFromBootstrap(bootstrapProperties).orElse(null); ProvenanceReportingSchema provenanceReportingProperties = BootstrapTransformer.buildProvenanceReportingPropertiesFromBootstrap(bootstrapProperties).orElse(null); if (securityProperties != null) { configSchema.setSecurityProperties(securityProperties); logger.info("Bootstrap flow override: Replaced security properties"); } if (provenanceReportingProperties != null) { configSchema.setProvenanceReportingProperties(provenanceReportingProperties); logger.info("Bootstrap flow override: Replaced provenance reporting properties"); } if (BootstrapTransformer.processorSSLOverride(bootstrapProperties)) { for (ProcessorSchema processorConfig : configSchema.getProcessGroupSchema().getProcessors()) { processorConfig.getProperties().replace("SSL Context Service", processorConfig.getProperties().get("SSL Context Service"), "SSL-Context-Service"); logger.info("Bootstrap flow override: Replaced {} SSL Context Service with parent MiNiFi SSL", processorConfig.getName()); } } ByteArrayOutputStream nifiPropertiesOutputStream = new ByteArrayOutputStream(); writeNiFiProperties(configSchema, nifiPropertiesOutputStream); writeFlowXmlFile(configSchema, destPath); writeNiFiPropertiesFile(nifiPropertiesOutputStream, destPath); } private  ConfigTransformer(); static void transformConfigFile(InputStream sourceStream, String destPath, Properties bootstrapProperties); }
ConfigTransformer { public static void transformConfigFile(InputStream sourceStream, String destPath, Properties bootstrapProperties) throws Exception { ConvertableSchema<ConfigSchema> convertableSchema = throwIfInvalid(SchemaLoader.loadConvertableSchemaFromYaml(sourceStream)); ConfigSchema configSchema = throwIfInvalid(convertableSchema.convert()); SecurityPropertiesSchema securityProperties = BootstrapTransformer.buildSecurityPropertiesFromBootstrap(bootstrapProperties).orElse(null); ProvenanceReportingSchema provenanceReportingProperties = BootstrapTransformer.buildProvenanceReportingPropertiesFromBootstrap(bootstrapProperties).orElse(null); if (securityProperties != null) { configSchema.setSecurityProperties(securityProperties); logger.info("Bootstrap flow override: Replaced security properties"); } if (provenanceReportingProperties != null) { configSchema.setProvenanceReportingProperties(provenanceReportingProperties); logger.info("Bootstrap flow override: Replaced provenance reporting properties"); } if (BootstrapTransformer.processorSSLOverride(bootstrapProperties)) { for (ProcessorSchema processorConfig : configSchema.getProcessGroupSchema().getProcessors()) { processorConfig.getProperties().replace("SSL Context Service", processorConfig.getProperties().get("SSL Context Service"), "SSL-Context-Service"); logger.info("Bootstrap flow override: Replaced {} SSL Context Service with parent MiNiFi SSL", processorConfig.getName()); } } ByteArrayOutputStream nifiPropertiesOutputStream = new ByteArrayOutputStream(); writeNiFiProperties(configSchema, nifiPropertiesOutputStream); writeFlowXmlFile(configSchema, destPath); writeNiFiPropertiesFile(nifiPropertiesOutputStream, destPath); } private  ConfigTransformer(); static void transformConfigFile(InputStream sourceStream, String destPath, Properties bootstrapProperties); static final String NIFI_VERSION; static final String ROOT_GROUP; static final String NIFI_VERSION_KEY; static final Logger logger; static final String PROPERTIES_FILE_APACHE_2_0_LICENSE; }