| | |
| | | * |
| | | * Copyright 2007-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2016 ForgeRock AS. |
| | | * Portions Copyright 2026 3A Systems, LLC. |
| | | */ |
| | | package org.opends.server.tools.tasks; |
| | | |
| | |
| | | } |
| | | return 0; |
| | | } catch (LDAPConnectionException e) { |
| | | if (isWrongPortException(e, |
| | | Integer.valueOf(argParser.getArguments().getPort()))) |
| | | if (isWrongPortException(e, getPortNumber())) |
| | | { |
| | | printWrappedText(err, ERR_TASK_LDAP_FAILED_TO_CONNECT_WRONG_PORT.get( |
| | | argParser.getArguments().getHostName(), argParser.getArguments().getPort())); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the port this tool tried to connect to, or {@code -1} if the port argument does not |
| | | * hold a number, in which case the connection failure cannot be a wrong port one. |
| | | * @return the port this tool tried to connect to. |
| | | */ |
| | | private int getPortNumber() |
| | | { |
| | | try |
| | | { |
| | | return Integer.parseInt(argParser.getArguments().getPort()); |
| | | } |
| | | catch (NumberFormatException e) |
| | | { |
| | | return -1; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Returns {@code true} if the provided exception was caused by trying to |
| | | * connect to the wrong port and {@code false} otherwise. |
| | | * @param t the exception to be analyzed. |