Skip to main content
Fredi
Gold ⭐️
Apr 4, 2023 9:35 AM UTC
Solved

Custom Nifi Controller properties do not appear

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-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPConnectionPool.java

 

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?

Fredi
FrediAnswer
Gold ⭐️
Apr 7, 2023 7:32 AM UTC

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.

1 reply

Fredi
FrediAuthorAnswer
Gold ⭐️
Apr 7, 2023 7:32 AM UTC

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.

Translate