Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Custom Nifi Controller properties do not appear

avatar
Contributor

Hello friends,

 

I wrote a custom processor and now wanted to add a custom controller. The problem is, that the properties I wrote for the controller do not appear when I create the service. I followed the structure of this controller: https://github.com/Automna/NiFi/blob/master/nifi-rel-nifi-1.1.2/nifi-nar-bundles/nifi-standard-servi...

 

Fredi_0-1680600586185.png

 

Here is what I did so far:

public class MyNewControllerService extends AbstractControllerService implements MyControllerService {

    public static final PropertyDescriptor USERNAME = new PropertyDescriptor.Builder()
            .name("Username")
            .expressionLanguageSupported(ExpressionLanguageScope.NONE)
            .displayName("Set username")
            .required(true)
            .defaultValue("User")
            .description("Username to login to graph service")
            .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
            .build();

    public static final PropertyDescriptor PASSWORD = new PropertyDescriptor.Builder().
            name("Password")
            .expressionLanguageSupported(ExpressionLanguageScope.NONE)
            .displayName("Set password")
            .required(true)
            .defaultValue("password")
            .description("Password to login to graph service")
            .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
            .build();

    public static final PropertyDescriptor URL = new PropertyDescriptor.Builder().
            name("ApiUrl")
            .expressionLanguageSupported(ExpressionLanguageScope.NONE)
            .displayName("Set url")
            .required(true)
            .defaultValue("url")
            .description("Full url to api")
            .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
            .build();

    private static final List<PropertyDescriptor> properties;
    static {
        final List<PropertyDescriptor> props = new ArrayList<>();
        props.add(USERNAME);
        props.add(PASSWORD);
        props.add(URL);

        properties = Collections.unmodifiableList(props);
    }

    OkHttpClient client = new OkHttpClient();
    private static ObjectMapper mapper = new ObjectMapper();

    @Override
    protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
        return properties;
    }

    @OnEnabled
    public void onConfigured(final ConfigurationContext context) throws InitializationException {
        final String user = context.getProperty(USERNAME).getValue();
        final String password = context.getProperty(PASSWORD).getValue();
        final String url = context.getProperty(URL).getValue();

What is missing that I only get a blank properties page?

1 ACCEPTED SOLUTION

avatar
Contributor

Just for everyones information; There was nothing wrong with the code. It was simply that the docker image I used to run Nifi did not build properly and therefore my modifications weren't taken into account.

View solution in original post

1 REPLY 1

avatar
Contributor

Just for everyones information; There was nothing wrong with the code. It was simply that the docker image I used to run Nifi did not build properly and therefore my modifications weren't taken into account.