Skip to content

Commit

Permalink
NIFI-7355: PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
levilentz committed Sep 27, 2023
1 parent 44766e8 commit ae02fdc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
<version>2.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-graph-processors</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-ssl-context-service-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.apache.nifi.graph.gremlin.SimpleEntry;
import org.apache.nifi.processor.exception.ProcessException;
import org.apache.nifi.processor.util.StandardValidators;
import org.apache.nifi.processors.graph.ExecuteGraphQueryRecord;
import org.apache.nifi.reporting.InitializationException;
import org.apache.nifi.ssl.SSLContextService;
import org.apache.nifi.util.StringUtils;
Expand Down Expand Up @@ -73,8 +74,8 @@
"Script submission is the default, with the script command being sent to the gremlin server as text. This should only be used for simple interactions with a tinkerpop-compliant server " +
"such as counts or other operations that do not require the injection of custom classed. " +
"Bytecode submission allows much more flexibility. When providing a jar, custom serializers can be used and pre-compiled graph logic can be utilized by groovy scripts" +
"provided by processors such as the ExecuteGraphQueryRecordProcessor.")
@SeeAlso(classNames = {"ExecuteGraphQueryRecordProcessor"})
"provided by processors such as the ExecuteGraphQueryRecord.")
@SeeAlso({ExecuteGraphQueryRecord.class})
@RequiresInstanceClassLoading
public class TinkerpopClientService extends AbstractControllerService implements GraphClientService {
public static final String NOT_SUPPORTED = "NOT_SUPPORTED";
Expand All @@ -88,7 +89,7 @@ public class TinkerpopClientService extends AbstractControllerService implements
);

private static final AllowableValue YAML_SETTINGS = new AllowableValue("yaml-settings", "Yaml Settings",
"Connection to the gremlin server will be specified via a yaml file (very flexible)");
"Connection to the gremlin server will be specified via a YAML file (very flexible)");

private static final AllowableValue SERVICE_SETTINGS = new AllowableValue("service-settings", "Service-Defined Settings",
"Connection to the gremlin server will be specified via values on this controller (simpler). " +
Expand All @@ -106,7 +107,7 @@ public class TinkerpopClientService extends AbstractControllerService implements
public static final PropertyDescriptor CONNECTION_SETTINGS = new PropertyDescriptor.Builder()
.name("connection-settings")
.displayName("Settings Specification")
.description("Selecting \"Service-Defined Settings\" connects using the setting on this service. Selecting \"Yaml Settings\" uses the specified yaml file for connection settings. ")
.description("Selecting \"Service-Defined Settings\" connects using the setting on this service. Selecting \"Yaml Settings\" uses the specified YAML file for connection settings. ")
.allowableValues(SERVICE_SETTINGS, YAML_SETTINGS)
.defaultValue("service-settings")
.required(true)
Expand All @@ -115,7 +116,7 @@ public class TinkerpopClientService extends AbstractControllerService implements
public static final PropertyDescriptor CONTACT_POINTS = new PropertyDescriptor.Builder()
.name("tinkerpop-contact-points")
.displayName("Contact Points")
.description("A comma-separated list of hostnames or IP addresses where an OpenCypher-enabled server can be found.")
.description("A comma-separated list of hostnames or IP addresses where an Gremlin-enabled server can be found.")
.required(true)
.addValidator(StandardValidators.NON_EMPTY_EL_VALIDATOR)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
Expand Down Expand Up @@ -157,7 +158,7 @@ public class TinkerpopClientService extends AbstractControllerService implements
public static final PropertyDescriptor REMOTE_OBJECTS_FILE = new PropertyDescriptor.Builder()
.name("remote-objects-file")
.displayName("Remote Objects File")
.description("The remote-objects file yaml used for connecting to the gremlin server.")
.description("The remote-objects file YAML used for connecting to the gremlin server.")
.required(true)
.addValidator(StandardValidators.FILE_EXISTS_VALIDATOR)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
Expand All @@ -169,7 +170,7 @@ public class TinkerpopClientService extends AbstractControllerService implements
.displayName("Username")
.description("The username used to authenticate with the gremlin server." +
" Note: when using a remote.yaml file, this username value (if set) will overload any " +
"username set in the yaml file.")
"username set in the YAML file.")
.required(false)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.build();
Expand All @@ -179,7 +180,7 @@ public class TinkerpopClientService extends AbstractControllerService implements
.displayName("Password")
.description("The password used to authenticate with the gremlin server." +
" Note: when using a remote.yaml file, this password setting (if set) will override any " +
"password set in the yaml file")
"password set in the YAML file")
.required(false)
.sensitive(true)
.build();
Expand Down Expand Up @@ -322,22 +323,6 @@ public Collection<ValidationResult> customValidate(ValidationContext context) {
}
}

boolean standardConfigIsSet = context.getProperty(CONTACT_POINTS).isSet()
&& context.getProperty(PATH).isSet()
&& context.getProperty(PORT).isSet();
boolean fileIsSet = context.getProperty(REMOTE_OBJECTS_FILE).isSet();

if (standardConfigIsSet && fileIsSet) {
results.add(new ValidationResult.Builder()
.explanation("Cannot set the configuration file and connection details properties at the same time.")
.valid(false)
.build());
}
if (!standardConfigIsSet && !fileIsSet) {
results.add(new ValidationResult.Builder()
.explanation("Connection details properties or the configuration file must be set.").valid(false).build());
}

if (context.getProperty(USER_NAME).isSet() && !context.getProperty(PASSWORD).isSet()) {
results.add(new ValidationResult.Builder()
.explanation("When specifying a username, the password must also be set").valid(false).build()
Expand Down

0 comments on commit ae02fdc

Please sign in to comment.