Created 04-04-2023 02:35 AM
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...
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?
Created 04-07-2023 12:32 AM
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.
Created 04-07-2023 12:32 AM
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.