mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noël Rouvignac
17.30.2016 37be067783f8184c33bdfba88aa17fa64d95be31
code cleanups
4 files modified
70 ■■■■■ changed files
opendj-core/src/main/java/com/forgerock/reactive/Completable.java 5 ●●●●● patch | view | raw | blame | history
opendj-core/src/main/java/com/forgerock/reactive/RxJavaStreams.java 3 ●●●● patch | view | raw | blame | history
opendj-core/src/main/java/com/forgerock/reactive/Single.java 7 ●●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPPasswordModify.java 55 ●●●●● patch | view | raw | blame | history
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.
         *
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
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
         */
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();
    }
}