From 37be067783f8184c33bdfba88aa17fa64d95be31 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 28 Nov 2016 08:31:40 +0000
Subject: [PATCH] code cleanups
---
opendj-core/src/main/java/com/forgerock/reactive/Completable.java | 5 +-
opendj-core/src/main/java/com/forgerock/reactive/RxJavaStreams.java | 3 -
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPPasswordModify.java | 55 +++++++++++----------------
opendj-core/src/main/java/com/forgerock/reactive/Single.java | 7 ++-
4 files changed, 30 insertions(+), 40 deletions(-)
diff --git a/opendj-core/src/main/java/com/forgerock/reactive/Completable.java b/opendj-core/src/main/java/com/forgerock/reactive/Completable.java
index 638faba..04aa6ad 100644
--- a/opendj-core/src/main/java/com/forgerock/reactive/Completable.java
+++ b/opendj-core/src/main/java/com/forgerock/reactive/Completable.java
@@ -24,9 +24,8 @@
* decouple ourself from reactive framework (RxJava/Reactor).
*/
public interface Completable extends Publisher<Void> {
-
/** Subscriber is notified when the operation has been completed, successfully or not. */
- public interface Subscriber {
+ interface Subscriber {
/** Called once this {@link Completable} is completed. */
void onComplete();
@@ -40,7 +39,7 @@
}
/** Adapts the streaming api to a callback one. */
- public interface Emitter {
+ interface Emitter {
/**
* Called when the streaming api has been subscribed.
*
diff --git a/opendj-core/src/main/java/com/forgerock/reactive/RxJavaStreams.java b/opendj-core/src/main/java/com/forgerock/reactive/RxJavaStreams.java
index b3370c3..2ef0205 100644
--- a/opendj-core/src/main/java/com/forgerock/reactive/RxJavaStreams.java
+++ b/opendj-core/src/main/java/com/forgerock/reactive/RxJavaStreams.java
@@ -17,7 +17,6 @@
import org.forgerock.util.Function;
import org.reactivestreams.Publisher;
-import org.reactivestreams.Subscription;
import io.reactivex.CompletableEmitter;
import io.reactivex.CompletableOnSubscribe;
@@ -88,7 +87,7 @@
/**
* Create a new {@link Single} from the given {@link Publisher}. If the {@link Publisher} produce more than one
- * result, they'll be dropped and the inner {@link Subscription} cancelled.
+ * result, they'll be dropped and the inner {@link org.reactivestreams.Subscription Subscription} cancelled.
*
* @param <V>
* Type of the datum emitted
diff --git a/opendj-core/src/main/java/com/forgerock/reactive/Single.java b/opendj-core/src/main/java/com/forgerock/reactive/Single.java
index 2d8c678..e0cdb93 100644
--- a/opendj-core/src/main/java/com/forgerock/reactive/Single.java
+++ b/opendj-core/src/main/java/com/forgerock/reactive/Single.java
@@ -29,7 +29,7 @@
public interface Single<V> extends Publisher<V> {
/** Subscriber is notified when the operation has been completed, successfully or not. */
- public interface Subscriber<V> {
+ interface Subscriber<V> {
/**
* Called once this {@link Single} is completed.
*
@@ -48,12 +48,13 @@
}
/** Adapts the streaming api to a callback one. */
- public interface Emitter<V> {
+ interface Emitter<V> {
/**
* Called for each SingleObserver that subscribes.
*
* @param s
- * The {@link Subscriber} to use to communicate the completeness of this {@link Single}
+ * The {@link com.forgerock.reactive.Single.Subscriber Subscriber} to use to communicate
+ * the completeness of this {@link Single}
* @throws Exception
* on error
*/
diff --git a/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPPasswordModify.java b/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPPasswordModify.java
index 3abb282..16a433b 100644
--- a/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPPasswordModify.java
+++ b/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPPasswordModify.java
@@ -38,13 +38,13 @@
import org.forgerock.opendj.ldap.requests.PasswordModifyExtendedRequest;
import org.forgerock.opendj.ldap.requests.Requests;
import org.forgerock.opendj.ldap.responses.PasswordModifyExtendedResult;
+import org.forgerock.util.annotations.VisibleForTesting;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.BooleanArgument;
import com.forgerock.opendj.cli.ConnectionFactoryProvider;
import com.forgerock.opendj.cli.FileBasedArgument;
import com.forgerock.opendj.cli.StringArgument;
-import org.forgerock.util.annotations.VisibleForTesting;
/**
* A tool that can be used to issue LDAP password modify extended requests to
@@ -196,43 +196,34 @@
throw newToolParamException(e, e.getMessageObject());
}
- Connection connection;
- try {
- connection = argParser.getConnectionFactory().getConnection();
- } catch (final LdapException ere) {
- return printErrorMessage(this, ere, ERR_LDAPPWMOD_FAILED);
- }
+ try (Connection connection = argParser.getConnectionFactory().getConnection()) {
+ if (proxyAuthzID.isPresent()) {
+ request.setUserIdentity(proxyAuthzID.getValue());
+ }
- if (proxyAuthzID.isPresent()) {
- request.setUserIdentity(proxyAuthzID.getValue());
- }
+ if (currentPW.isPresent()) {
+ request.setOldPassword(currentPW.getValue().toCharArray());
+ } else if (currentPWFile.isPresent()) {
+ request.setOldPassword(currentPWFile.getValue().toCharArray());
+ }
- if (currentPW.isPresent()) {
- request.setOldPassword(currentPW.getValue().toCharArray());
- } else if (currentPWFile.isPresent()) {
- request.setOldPassword(currentPWFile.getValue().toCharArray());
- }
+ if (newPW.isPresent()) {
+ request.setNewPassword(newPW.getValue().toCharArray());
+ } else if (newPWFile.isPresent()) {
+ request.setNewPassword(newPWFile.getValue().toCharArray());
+ }
- if (newPW.isPresent()) {
- request.setNewPassword(newPW.getValue().toCharArray());
- } else if (newPWFile.isPresent()) {
- request.setNewPassword(newPWFile.getValue().toCharArray());
- }
+ PasswordModifyExtendedResult result = connection.extendedRequest(request);
+ println(INFO_LDAPPWMOD_SUCCESSFUL.get());
+ Utils.printlnTextMsg(this, INFO_LDAPPWMOD_ADDITIONAL_INFO, result.getDiagnosticMessage());
+ if (result.getGeneratedPassword() != null) {
+ println(INFO_LDAPPWMOD_GENERATED_PASSWORD.get(
+ ByteString.valueOfBytes(result.getGeneratedPassword()).toString()));
+ }
- PasswordModifyExtendedResult result;
- try {
- result = connection.extendedRequest(request);
+ return ResultCode.SUCCESS.intValue();
} catch (final LdapException e) {
return printErrorMessage(this, e, ERR_LDAPPWMOD_FAILED);
}
-
- println(INFO_LDAPPWMOD_SUCCESSFUL.get());
- Utils.printlnTextMsg(this, INFO_LDAPPWMOD_ADDITIONAL_INFO, result.getDiagnosticMessage());
- if (result.getGeneratedPassword() != null) {
- println(INFO_LDAPPWMOD_GENERATED_PASSWORD.get(
- ByteString.valueOfBytes(result.getGeneratedPassword()).toString()));
- }
-
- return ResultCode.SUCCESS.intValue();
}
}
--
Gitblit v1.10.0