From 5360b07bd36e6b3479c1bb3f911bb34f8d661b1f Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Wed, 21 Sep 2016 15:15:44 +0000
Subject: [PATCH] OPENDJ-2413 Apply PR comments: remove builders in parameters classes, simplify configuration retrieval Include also other minor changes and renaming
---
opendj-server-legacy/src/main/java/org/opends/server/util/embedded/SetupParameters.java | 124 +++++++++++++++++++----------------------
1 files changed, 57 insertions(+), 67 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/util/embedded/SetupParameters.java b/opendj-server-legacy/src/main/java/org/opends/server/util/embedded/SetupParameters.java
index 0edd54e..7ceafa0 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/util/embedded/SetupParameters.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/util/embedded/SetupParameters.java
@@ -15,9 +15,11 @@
*/
package org.opends.server.util.embedded;
-/**
- * Parameters to setup a directory server.
- */
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/** Parameters to setup a directory server. */
public final class SetupParameters
{
private String baseDn;
@@ -26,7 +28,7 @@
private SetupParameters()
{
- // private constructor to force usage of the associated Builder
+ // prefer usage of static method for creation
}
/**
@@ -34,9 +36,9 @@
*
* @return a builder
*/
- public static Builder setupParams()
+ public static SetupParameters setupParams()
{
- return new Builder();
+ return new SetupParameters();
}
/**
@@ -46,14 +48,14 @@
*/
String[] toCommandLineArguments(ConnectionParameters connParams)
{
- return new String[] {
+ String[] baseArgs = new String[] {
"--cli",
"--noPropertiesFile",
"--no-prompt",
"--doNotStart",
"--skipPortCheck",
"--baseDN", baseDn,
- "--hostname", connParams.getHostname(),
+ "--hostname", connParams.getHostName(),
"--rootUserDN", connParams.getBindDn(),
"--rootUserPassword", connParams.getBindPassword(),
"--ldapPort", s(connParams.getLdapPort()),
@@ -61,6 +63,21 @@
"--jmxPort", s(jmxPort),
"--backendType", backendType
};
+ List<String> args = new ArrayList<>(Arrays.asList(baseArgs));
+ if (connParams.getLdapSecurePort() != null)
+ {
+ args.add("--ldapsPort");
+ args.add(s(connParams.getLdapSecurePort()));
+ }
+ if (connParams.isStartTLSEnabled())
+ {
+ args.add("--enableStartTLS");
+ }
+ if (connParams.getLdapSecurePort() != null || connParams.isStartTLSEnabled())
+ {
+ args.add("--generateSelfSignedCertificate");
+ }
+ return args.toArray(new String[args.size()]);
}
String getBaseDn()
@@ -80,68 +97,41 @@
}
/**
- * Builder for this class.
+ * Sets the base Dn for user information in the directory server.
+ *
+ * @param baseDn
+ * the base Dn
+ * @return this builder
*/
- public static final class Builder
+ public SetupParameters baseDn(String baseDn)
{
- private SetupParameters params;
+ this.baseDn = baseDn;
+ return this;
+ }
- private Builder()
- {
- params = new SetupParameters();
- }
+ /**
+ * Sets the port on which the directory server should listen for JMX communication.
+ *
+ * @param jmxPort
+ * the JMX port
+ * @return this builder
+ */
+ public SetupParameters jmxPort(int jmxPort)
+ {
+ this.jmxPort = jmxPort;
+ return this;
+ }
- /**
- * Generates the parameters from this builder.
- * <p>
- * After this call, the builder is reset and can be used to generate other parameters.
- *
- * @return the replication parameters
- */
- public SetupParameters toParams()
- {
- SetupParameters p = params;
- this.params = new SetupParameters();
- return p;
- }
-
- /**
- * Sets the base Dn for user information in the directory server.
- *
- * @param baseDn
- * the base Dn
- * @return this builder
- */
- public Builder baseDn(String baseDn)
- {
- params.baseDn = baseDn;
- return this;
- }
-
- /**
- * Sets the port on which the directory server should listen for JMX communication.
- *
- * @param jmxPort
- * the JMX port
- * @return this builder
- */
- public Builder jmxPort(int jmxPort)
- {
- params.jmxPort = jmxPort;
- return this;
- }
-
- /**
- * Sets the type of the backend containing user information.
- *
- * @param backendType
- * the backend type (e.g. je, pdb)
- * @return this builder
- */
- public Builder backendType(String backendType)
- {
- params.backendType = backendType;
- return this;
- }
+ /**
+ * Sets the type of the backend containing user information.
+ *
+ * @param backendType
+ * the backend type (e.g. je, pdb)
+ * @return this builder
+ */
+ public SetupParameters backendType(String backendType)
+ {
+ this.backendType = backendType;
+ return this;
}
}
\ No newline at end of file
--
Gitblit v1.10.0