pvillard31 commented on a change in pull request #4759:
URL: https://github.com/apache/nifi/pull/4759#discussion_r558227942
##########
File path:
nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-client-service-api/src/main/java/org/apache/nifi/mongodb/MongoDBClientService.java
##########
@@ -44,6 +44,22 @@
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.addValidator(StandardValidators.URI_VALIDATOR)
.build();
+ PropertyDescriptor DB_USER = new PropertyDescriptor.Builder()
+ .name("Database User")
+ .description("Database user name")
+ .defaultValue(null)
+ .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
+ .build();
+ PropertyDescriptor DB_PASSWORD = new PropertyDescriptor.Builder()
+ .name("Password")
+ .description("The password for the database user")
+ .defaultValue(null)
Review comment:
Same comment
##########
File path:
nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-client-service-api/src/main/java/org/apache/nifi/mongodb/MongoDBClientService.java
##########
@@ -44,6 +44,22 @@
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.addValidator(StandardValidators.URI_VALIDATOR)
.build();
+ PropertyDescriptor DB_USER = new PropertyDescriptor.Builder()
+ .name("Database User")
Review comment:
Please use both ``.name()`` and ``.displayName()``
##########
File path:
nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-services/src/main/java/org/apache/nifi/mongodb/MongoDBControllerService.java
##########
@@ -105,7 +110,18 @@ public final void closeClient() {
}
protected String getURI(final ConfigurationContext context) {
- return
context.getProperty(URI).evaluateAttributeExpressions().getValue();
+ final String _uri =
context.getProperty(URI).evaluateAttributeExpressions().getValue();
Review comment:
Stylish comment: not sure the use of an underscore is very common in the
NiFi codebase, I'd just go for ``uri``.
##########
File path:
nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-client-service-api/src/main/java/org/apache/nifi/mongodb/MongoDBClientService.java
##########
@@ -44,6 +44,22 @@
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.addValidator(StandardValidators.URI_VALIDATOR)
.build();
+ PropertyDescriptor DB_USER = new PropertyDescriptor.Builder()
+ .name("Database User")
+ .description("Database user name")
+ .defaultValue(null)
+ .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
+ .build();
+ PropertyDescriptor DB_PASSWORD = new PropertyDescriptor.Builder()
+ .name("Password")
Review comment:
Same comment
##########
File path:
nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-services/src/main/java/org/apache/nifi/mongodb/MongoDBControllerService.java
##########
@@ -105,7 +110,18 @@ public final void closeClient() {
}
protected String getURI(final ConfigurationContext context) {
- return
context.getProperty(URI).evaluateAttributeExpressions().getValue();
+ final String _uri =
context.getProperty(URI).evaluateAttributeExpressions().getValue();
+ final String user =
context.getProperty(DB_USER).evaluateAttributeExpressions().getValue();
+ final String passw =
context.getProperty(DB_PASSWORD).evaluateAttributeExpressions().getValue();
+ if (!_uri.contains("@") && user != null && passw != null) {
+ try {
+ return _uri.replaceFirst("://", "://" +
URLEncoder.encode(user, StandardCharsets.UTF_8.toString()) + ":" +
URLEncoder.encode(passw, StandardCharsets.UTF_8.toString()) + "@");
+ } catch (final UnsupportedEncodingException e) {
Review comment:
Probably worth logging the exception here, no? At least at debug level,
but maybe warning level makes sense.
##########
File path:
nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-client-service-api/src/main/java/org/apache/nifi/mongodb/MongoDBClientService.java
##########
@@ -44,6 +44,22 @@
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.addValidator(StandardValidators.URI_VALIDATOR)
.build();
+ PropertyDescriptor DB_USER = new PropertyDescriptor.Builder()
+ .name("Database User")
+ .description("Database user name")
+ .defaultValue(null)
Review comment:
No need for this line, this will default to ``null`` if not specified.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]