OPENDJ-1343 Migrate dsconfig
- Removed CommunicationException from dsconfig package.
- Replaced ReturnCode.TODO by appropriate return code.
StatusCli
- Reorganized imports.
| | |
| | | import org.forgerock.opendj.config.conditions.ContainsCondition; |
| | | import org.forgerock.opendj.ldap.AuthorizationException; |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | | import org.opends.server.admin.client.CommunicationException; |
| | | |
| | | import com.forgerock.opendj.cli.Argument; |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | |
| | | } catch (ConcurrentModificationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_CREATE_CME.get(irelation |
| | | .getUserFriendlyName()); |
| | | throw new ClientException(ReturnCode.TODO, msg); |
| | | throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, msg); |
| | | } catch (ErrorResultException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_CREATE_CE.get(irelation |
| | | .getUserFriendlyName(), e.getMessage()); |
| | | throw new ClientException(ReturnCode.TODO, msg); |
| | | throw new ClientException(ReturnCode.APPLICATION_ERROR, msg); |
| | | } catch (DefinitionDecodingException e) { |
| | | // Do nothing. |
| | | } catch (ManagedObjectDecodingException e) { |
| | |
| | | LocalizableMessage pufn = path.getManagedObjectDefinition().getUserFriendlyName(); |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_GET_PARENT_MODE.get(pufn); |
| | | throw new ClientException(ReturnCode.OTHER, msg, e); |
| | | } catch (CommunicationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_CREATE_CE.get(ufn, e |
| | | .getMessage()); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, msg); |
| | | } catch (ConcurrentModificationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_CREATE_CME.get(ufn); |
| | | throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, msg); |
| | |
| | | import org.forgerock.opendj.config.client.OperationRejectedException; |
| | | import org.forgerock.opendj.ldap.AuthorizationException; |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | | import org.opends.server.admin.client.CommunicationException; |
| | | |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.BooleanArgument; |
| | |
| | | LocalizableMessage pufn = path.getManagedObjectDefinition().getUserFriendlyName(); |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_GET_PARENT_MODE.get(pufn); |
| | | throw new ClientException(ReturnCode.OTHER, msg, e); |
| | | } catch (CommunicationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_DELETE_CE.get(ufn, e.getMessage()); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, msg); |
| | | } catch (ConcurrentModificationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_DELETE_CME.get(ufn); |
| | | throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, msg); |
| | |
| | | } catch (ConcurrentModificationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_DELETE_CME.get(ufn); |
| | | throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, msg); |
| | | } catch (CommunicationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_DELETE_CE.get(ufn, e.getMessage()); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, msg); |
| | | } catch (ErrorResultException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_DELETE_CE.get(ufn, e.getMessage()); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, msg); |
| | |
| | | import org.forgerock.opendj.config.client.ManagedObjectDecodingException; |
| | | import org.forgerock.opendj.config.client.ManagementContext; |
| | | import org.forgerock.opendj.ldap.AuthorizationException; |
| | | import org.opends.server.admin.client.CommunicationException; |
| | | |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.ReturnCode; |
| | |
| | | } catch (ManagedObjectDecodingException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_GET_CHILD_MODE.get(ufn); |
| | | throw new ClientException(ReturnCode.OTHER, msg, e); |
| | | } catch (CommunicationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_GET_CHILD_CE.get(ufn, e.getMessage()); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, msg); |
| | | } catch (ConcurrentModificationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_GET_CHILD_CME.get(ufn); |
| | | throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, msg); |
| | |
| | | import org.forgerock.opendj.config.client.ManagementContext; |
| | | import org.forgerock.opendj.ldap.AuthorizationException; |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | | import org.opends.server.admin.client.CommunicationException; |
| | | |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | |
| | | ufn = path.getManagedObjectDefinition().getUserFriendlyName(); |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_GET_PARENT_MODE.get(ufn); |
| | | throw new ClientException(ReturnCode.OTHER, msg, e); |
| | | } catch (CommunicationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_LIST_CE.get(ufn, e.getMessage()); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, msg); |
| | | } catch (ConcurrentModificationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_LIST_CME.get(ufn); |
| | | throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, msg); |
| | |
| | | try { |
| | | values.addAll(Arrays.asList(context.listManagedObjects(path, rd))); |
| | | } catch (AuthorizationException e) { |
| | | this.e = new ClientException(ReturnCode.TODO, LocalizableMessage.raw(e.getMessage())); |
| | | this.e = new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, LocalizableMessage.raw(e.getMessage())); |
| | | return MenuResult.quit(); |
| | | } catch (ManagedObjectNotFoundException e) { |
| | | this.e = new ClientException(ReturnCode.TODO, e.getMessageObject()); |
| | | this.e = new ClientException(ReturnCode.NO_SUCH_OBJECT, e.getMessageObject()); |
| | | return MenuResult.cancel(); |
| | | } catch (ErrorResultException e) { |
| | | this.e = new ClientException(ReturnCode.TODO, LocalizableMessage.raw(e.getMessage())); |
| | | this.e = new ClientException(ReturnCode.APPLICATION_ERROR, LocalizableMessage.raw(e.getMessage())); |
| | | return MenuResult.quit(); |
| | | } |
| | | |
| | |
| | | try { |
| | | values.addAll(Arrays.asList(context.listManagedObjects(path, rd))); |
| | | } catch (AuthorizationException e) { |
| | | this.e = new ClientException(ReturnCode.TODO, LocalizableMessage.raw(e.getMessage())); |
| | | this.e = new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, LocalizableMessage.raw(e.getMessage())); |
| | | return MenuResult.quit(); |
| | | } catch (ManagedObjectNotFoundException e) { |
| | | this.e = new ClientException(ReturnCode.TODO, e.getMessageObject()); |
| | | this.e = new ClientException(ReturnCode.NO_SUCH_OBJECT, e.getMessageObject()); |
| | | return MenuResult.cancel(); |
| | | } catch (ErrorResultException e) { |
| | | this.e = new ClientException(ReturnCode.TODO, LocalizableMessage.raw(e.getMessage())); |
| | | this.e = new ClientException(ReturnCode.APPLICATION_ERROR, LocalizableMessage.raw(e.getMessage())); |
| | | return MenuResult.quit(); |
| | | } |
| | | |
| | |
| | | try { |
| | | values.addAll(Arrays.asList(context.listManagedObjects(path, rd))); |
| | | } catch (AuthorizationException e) { |
| | | this.e = new ClientException(ReturnCode.TODO, LocalizableMessage.raw(e.getMessage())); |
| | | this.e = new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, LocalizableMessage.raw(e.getMessage())); |
| | | return MenuResult.quit(); |
| | | } catch (ManagedObjectNotFoundException e) { |
| | | this.e = new ClientException(ReturnCode.TODO, e.getMessageObject()); |
| | | this.e = new ClientException(ReturnCode.NO_SUCH_OBJECT, e.getMessageObject()); |
| | | return MenuResult.cancel(); |
| | | } catch (ErrorResultException e) { |
| | | this.e = new ClientException(ReturnCode.TODO, LocalizableMessage.raw(e.getMessage())); |
| | | this.e = new ClientException(ReturnCode.APPLICATION_ERROR, LocalizableMessage.raw(e.getMessage())); |
| | | return MenuResult.quit(); |
| | | } |
| | | |
| | |
| | | import org.forgerock.opendj.config.conditions.ContainsCondition; |
| | | import org.forgerock.opendj.ldap.AuthorizationException; |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | | import org.opends.server.admin.client.CommunicationException; |
| | | |
| | | import com.forgerock.opendj.cli.Argument; |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | |
| | | // verbose) and apply the changes to the partial managed object. |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_GET_CHILD_MODE.get(ufn); |
| | | throw new ClientException(ReturnCode.OTHER, msg, e); |
| | | } catch (CommunicationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_MODIFY_CE.get(ufn, e.getMessage()); |
| | | throw new ClientException(ReturnCode.OTHER, msg); |
| | | } catch (ConcurrentModificationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_MODIFY_CME.get(ufn); |
| | | throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, msg); |
| | |
| | | import org.forgerock.opendj.config.client.ManagementContext; |
| | | import org.forgerock.opendj.ldap.AuthorizationException; |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | | import org.opends.server.admin.client.CommunicationException; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | import com.forgerock.opendj.cli.Argument; |
| | |
| | | |
| | | private AuthorizationException authze; |
| | | |
| | | private CommunicationException ce; |
| | | |
| | | private ErrorResultException ere; |
| | | |
| | | /** |
| | |
| | | } catch (ErrorResultException e) { |
| | | ere = e; |
| | | result = MenuResult.quit(); |
| | | } catch (CommunicationException e) { |
| | | ce = e; |
| | | result = MenuResult.quit(); |
| | | } |
| | | } |
| | | } |
| | |
| | | String typeUsage = getSubTypesUsage(d); |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_SUB_TYPE_UNRECOGNIZED.get( |
| | | name, r.getUserFriendlyName(), typeUsage); |
| | | clie = new ClientException(ReturnCode.TODO, msg); |
| | | clie = new ClientException(ReturnCode.APPLICATION_ERROR, msg); |
| | | result = MenuResult.quit(); |
| | | return; |
| | | } else { |
| | |
| | | } catch (ErrorResultException e) { |
| | | ere = e; |
| | | result = MenuResult.quit(); |
| | | } catch (CommunicationException e) { |
| | | ce = e; |
| | | result = MenuResult.quit(); |
| | | } |
| | | } |
| | | } |
| | |
| | | * If the server refuses to retrieve the managed object |
| | | * because the client does not have the correct |
| | | * privileges. |
| | | * @throws CommunicationException |
| | | * If the client cannot contact the server due to an |
| | | * underlying communication problem. |
| | | */ |
| | | public MenuResult<ManagedObject<?>> find(ConsoleApplication app, |
| | | ManagementContext context, ManagedObjectPath<?, ?> path, |
| | | List<String> args) throws ClientException, CommunicationException, |
| | | List<String> args) throws ClientException, |
| | | AuthorizationException, ConcurrentModificationException, |
| | | DefinitionDecodingException, ManagedObjectDecodingException, |
| | | ManagedObjectNotFoundException { |
| | |
| | | |
| | | this.clie = null; |
| | | this.authze = null; |
| | | this.ce = null; |
| | | this.cme = null; |
| | | this.dde = null; |
| | | this.mode = null; |
| | |
| | | throw clie; |
| | | } else if (authze != null) { |
| | | throw authze; |
| | | } else if (ce != null) { |
| | | throw ce; |
| | | } else if (cme != null) { |
| | | throw cme; |
| | | } else if (dde != null) { |
| | |
| | | * If the server refuses to retrieve the managed object |
| | | * because the client does not have the correct |
| | | * privileges. |
| | | * @throws CommunicationException |
| | | * If the client cannot contact the server due to an |
| | | * underlying communication problem. |
| | | * @throws ClientException |
| | | * If one of the naming arguments referenced a managed |
| | | * object of the wrong type. |
| | |
| | | ConsoleApplication app, ManagementContext context, |
| | | ManagedObjectPath<?, ?> path, List<String> args) throws ClientException, |
| | | AuthorizationException, DefinitionDecodingException, |
| | | ManagedObjectDecodingException, CommunicationException, |
| | | ConcurrentModificationException, ManagedObjectNotFoundException |
| | | ManagedObjectDecodingException, ConcurrentModificationException, |
| | | ManagedObjectNotFoundException |
| | | { |
| | | ManagedObjectFinder finder = new ManagedObjectFinder(); |
| | | return finder.find(app, context, path, args); |
| | |
| | | * {@link MenuResult#quit()}, or {@link MenuResult#cancel()}, |
| | | * if the sub-command was run interactive and the user chose |
| | | * to quit or cancel. |
| | | * @throws CommunicationException |
| | | * If the server cannot be contacted. |
| | | * @throws ConcurrentModificationException |
| | | * If the parent managed object has been deleted. |
| | | * @throws AuthorizationException |
| | |
| | | RelationDefinition<C, S> r, |
| | | AbstractManagedObjectDefinition<? extends C, ? extends S> d) |
| | | throws AuthorizationException, ConcurrentModificationException, |
| | | CommunicationException, ClientException { |
| | | ClientException |
| | | { |
| | | if (d == null) { |
| | | d = r.getChildDefinition(); |
| | | } |
| | |
| | | package org.opends.server.tools.status; |
| | | |
| | | import static com.forgerock.opendj.cli.ArgumentConstants.LIST_TABLE_SEPARATOR; |
| | | import static com.forgerock.opendj.cli.CliMessages.ERR_CANNOT_INITIALIZE_ARGS; |
| | | import static com.forgerock.opendj.cli.CliMessages.ERR_ERROR_PARSING_ARGS; |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static org.opends.messages.ToolMessages.ERR_ERROR_PARSING_ARGS; |
| | | import static com.forgerock.opendj.cli.CliMessages.*; |
| | | import static org.opends.quicksetup.util.Utils.getCommandLineMaxLineWidth; |
| | | import static org.opends.messages.QuickSetupMessages.INFO_ERROR_READING_SERVER_CONFIGURATION; |
| | | import static org.opends.messages.QuickSetupMessages.INFO_NOT_AVAILABLE_LABEL; |
| | | import static org.opends.messages.QuickSetupMessages. |
| | | INFO_ERROR_READING_SERVER_CONFIGURATION; |
| | | import static com.forgerock.opendj.cli.Utils.MAX_LINE_WIDTH; |
| | | |
| | | import java.io.File; |
| | | import java.io.InputStream; |
| | |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | import com.forgerock.opendj.cli.ConsoleApplication; |
| | | import com.forgerock.opendj.cli.ReturnCode; |
| | | import com.forgerock.opendj.cli.TableBuilder; |
| | | import com.forgerock.opendj.cli.TextTablePrinter; |
| | | import com.forgerock.opendj.cli.ReturnCode; |
| | | |
| | | /** |
| | | * The class used to provide some CLI interface to display status. |
| | |
| | | private LocalizableMessage centerTitle(LocalizableMessage text) |
| | | { |
| | | LocalizableMessage centered; |
| | | if (text.length() <= getCommandLineMaxLineWidth() - 8) |
| | | if (text.length() <= MAX_LINE_WIDTH - 8) |
| | | { |
| | | LocalizableMessageBuilder buf = new LocalizableMessageBuilder(); |
| | | int extra = Math.min(10, |
| | | (getCommandLineMaxLineWidth() - 8 - text.length()) / 2); |
| | | (MAX_LINE_WIDTH - 8 - text.length()) / 2); |
| | | for (int i=0; i<extra; i++) |
| | | { |
| | | buf.append(" "); |
| | |
| | | private LocalizableMessage wrapText(LocalizableMessage text) |
| | | { |
| | | return LocalizableMessage.raw( |
| | | StaticUtils.wrapText(text, getCommandLineMaxLineWidth())); |
| | | StaticUtils.wrapText(text, MAX_LINE_WIDTH)); |
| | | } |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | throw new ClientException(ReturnCode.TODO, LocalizableMessage.EMPTY); |
| | | throw new ClientException(ReturnCode.ERROR_UNEXPECTED, LocalizableMessage.EMPTY); |
| | | } |
| | | |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | throw new ClientException(ReturnCode.TODO, LocalizableMessage.EMPTY); |
| | | throw new ClientException(ReturnCode.ERROR_UNEXPECTED, LocalizableMessage.EMPTY); |
| | | } |
| | | } |
| | | |