Tom,

If you are only concerned with the values in the currently-running NiFi 
instance, you shouldn't need to directly interact with the file system. Just 
use NiFIPropertiesLoader#get(). Use the static loaders if you want to get an 
instance from a specific (non-default) file location. 

Andy LoPresto
alopre...@apache.org
alopresto.apa...@gmail.com
PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4  BACE 3C6E F65B 2F7D EF69

> On Sep 23, 2016, at 23:09, Tom Gullo <tomgu...@gmail.com> wrote:
> 
> Andy, I wasn't sure if I would need to read the file in myself but it looks 
> like I do.  Those unit tests help a lot. Thanks
> 
> -Tom
> 
>> On Fri, Sep 23, 2016 at 10:47 PM, Andy LoPresto <alopre...@apache.org> wrote:
>> Meant to add that there are Groovy unit tests for those classes so you may 
>> be able to copy the code directly from [1] and [2]. 
>> 
>> [1] 
>> https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-properties-loader/src/test/groovy/org/apache/nifi/properties/ProtectedNiFiPropertiesGroovyTest.groovy
>> [2] 
>> https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-properties-loader/src/test/groovy/org/apache/nifi/properties/NiFiPropertiesLoaderGroovyTest.groovy
>> 
>> Andy LoPresto
>> alopre...@apache.org
>> alopresto.apa...@gmail.com
>> PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4  BACE 3C6E F65B 2F7D EF69
>> 
>>> On Sep 23, 2016, at 7:45 PM, Andy LoPresto <alopre...@apache.org> wrote:
>>> 
>>> Tom,
>>> 
>>> You’ll want to take a look at ProtectedNiFiProperties [1] and 
>>> NiFiPropertiesLoader [2]. ProtectedNiFiProperties provides a decorator on a 
>>> normal NiFiProperties class which allows access to various values via key 
>>> access or through named getters. It “unprotects” the values and can return 
>>> a regular NiFiProperties instance with direct access to the plain values. 
>>> The NiFiPropertiesLoader can be instantiated with the decryption key 
>>> (currently the only supported protection scheme is AES/GCM encryption) and 
>>> can load multiple instances of the NiFiProperties directly from any 
>>> nifi.properties file simultaneously. 
>>> 
>>> If you wanted to do this with a non-native file (i.e. a source that NiFi 
>>> does not have an internal mechanism for reading), you’d probably use a 
>>> GetFile -> ExtractText -> EncryptContent processor chain, or the 
>>> ExecuteScript processor (Groovy and other scripting languages have 
>>> extensive tooling provided to easily read from files, parse text, etc.). 
>>> 
>>> [1] 
>>> https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-properties-loader/src/main/java/org/apache/nifi/properties/ProtectedNiFiProperties.java
>>> [2] 
>>> https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-properties-loader/src/main/java/org/apache/nifi/properties/NiFiPropertiesLoader.java
>>> 
>>>  
>>> Andy LoPresto
>>> alopre...@apache.org
>>> alopresto.apa...@gmail.com
>>> PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4  BACE 3C6E F65B 2F7D EF69
>>> 
>>>> On Sep 23, 2016, at 3:28 PM, Tom Gullo <tomgu...@gmail.com> wrote:
>>>> 
>>>> I'm using v1.0.  I want to access some values that are in the 
>>>> nifi.properties file.  And I would like to just use the nifi.properties 
>>>> file because I'll be encrypting some of these values and I want to use the 
>>>> built in encryption feature.
>>>> 
>>>> Thanks
>>>> 
>>>>> On Fri, Sep 23, 2016 at 6:05 PM, Andrew Grande <apere...@gmail.com> wrote:
>>>>> Which NiFi version? With 1.0 there are some bits for variable registry 
>>>>> available, basically one can reference values from external config files 
>>>>> via regular EL expressions.
>>>>> 
>>>>> Andrew
>>>>> 
>>>>> 
>>>>>> On Fri, Sep 23, 2016, 6:00 PM Tom Gullo <tomgu...@gmail.com> wrote:
>>>>>> I want to read in values from nifi.properties in a Groovy ExecuteScript 
>>>>>> processor.  What's the best way to do that?
>>>>>> 
>>>>>> Thanks
>>>>>> -Tom
>>>> 
>>> 
>> 
> 

Reply via email to