| | |
| | | import org.opends.admin.ads.ADSContextException; |
| | | import org.opends.admin.ads.ADSContext.ServerProperty; |
| | | import org.opends.admin.ads.ADSContextException.ErrorType; |
| | | import org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.ReturnCode; |
| | | import org.opends.server.tools.dsconfig.ArgumentExceptionFactory; |
| | | import org.opends.server.util.args.Argument; |
| | | import org.opends.server.util.args.ArgumentException; |
| | |
| | | import org.opends.server.util.table.TableBuilder; |
| | | import org.opends.server.util.table.TextTablePrinter; |
| | | |
| | | import static org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.*; |
| | | /** |
| | | * This class is handling server group CLI. |
| | | */ |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ReturnCode performSubCommand(SubCommand subCmd, |
| | | public DsFrameworkCliReturnCode performSubCommand(SubCommand subCmd, |
| | | OutputStream outStream, OutputStream errStream) |
| | | throws ADSContextException, ArgumentException |
| | | { |
| | | |
| | | ADSContext adsCtx = null; |
| | | InitialLdapContext ctx = null; |
| | | ReturnCode returnCode = ReturnCode.ERROR_UNEXPECTED; |
| | | DsFrameworkCliReturnCode returnCode = ERROR_UNEXPECTED; |
| | | |
| | | try |
| | | { |
| | |
| | | ctx = argParser.getContext(outStream, errStream); |
| | | if (ctx == null) |
| | | { |
| | | return ReturnCode.CANNOT_CONNECT_TO_ADS; |
| | | return CANNOT_CONNECT_TO_ADS; |
| | | } |
| | | adsCtx = new ADSContext(ctx); |
| | | adsCtx.registerServer(map); |
| | |
| | | // ----------------------- |
| | | if (subCmd.getName().equals(unregisterServerSubCmd.getName())) |
| | | { |
| | | returnCode = ReturnCode.SUCCESSFUL; |
| | | returnCode = SUCCESSFUL; |
| | | |
| | | Map<ServerProperty, Object> map = new HashMap<ServerProperty, Object>(); |
| | | String serverId = null; |
| | |
| | | ctx = argParser.getContext(outStream, errStream); |
| | | if (ctx == null) |
| | | { |
| | | return ReturnCode.CANNOT_CONNECT_TO_ADS; |
| | | return CANNOT_CONNECT_TO_ADS; |
| | | } |
| | | adsCtx = new ADSContext(ctx); |
| | | |
| | |
| | | ctx = argParser.getContext(outStream, errStream); |
| | | if (ctx == null) |
| | | { |
| | | return ReturnCode.CANNOT_CONNECT_TO_ADS; |
| | | return CANNOT_CONNECT_TO_ADS; |
| | | } |
| | | adsCtx = new ADSContext(ctx); |
| | | Set<Map<ServerProperty, Object>> serverList = adsCtx |
| | |
| | | out.println(ServerProperty.ID.getAttributeName() + ": " |
| | | + server.get(ServerProperty.ID)); |
| | | } |
| | | returnCode = ReturnCode.SUCCESSFUL; |
| | | returnCode = SUCCESSFUL; |
| | | } |
| | | else |
| | | // ----------------------- |
| | |
| | | ctx = argParser.getContext(outStream, errStream); |
| | | if (ctx == null) |
| | | { |
| | | return ReturnCode.CANNOT_CONNECT_TO_ADS; |
| | | return CANNOT_CONNECT_TO_ADS; |
| | | } |
| | | adsCtx = new ADSContext(ctx); |
| | | Set<Map<ServerProperty, Object>> adsServerList = adsCtx |
| | |
| | | } |
| | | out.println(); |
| | | } |
| | | returnCode = ReturnCode.SUCCESSFUL; |
| | | returnCode = SUCCESSFUL; |
| | | } |
| | | else |
| | | // ----------------------- |
| | |
| | | ctx = argParser.getContext(outStream, errStream); |
| | | if (ctx == null) |
| | | { |
| | | return ReturnCode.CANNOT_CONNECT_TO_ADS; |
| | | return CANNOT_CONNECT_TO_ADS; |
| | | } |
| | | adsCtx = new ADSContext(ctx); |
| | | adsCtx.updateServer(map, newServerId); |
| | | returnCode = ReturnCode.SUCCESSFUL; |
| | | returnCode = SUCCESSFUL; |
| | | } |
| | | else |
| | | // ----------------------- |
| | |
| | | } |
| | | TextTablePrinter printer = new TextTablePrinter(outStream); |
| | | table.print(printer); |
| | | returnCode = ReturnCode.SUCCESSFUL; |
| | | returnCode = SUCCESSFUL; |
| | | } |
| | | else |
| | | { |
| | | // Should never occurs: If we are here, it means that the code |
| | | // to |
| | | // handle to subcommand is not yet written. |
| | | returnCode = ReturnCode.ERROR_UNEXPECTED; |
| | | returnCode = ERROR_UNEXPECTED; |
| | | } |
| | | } |
| | | catch (ADSContextException e) |