Пример #1
0
  public static Ds3Client createClient(final Arguments arguments) {
    final Ds3ClientBuilder builder =
        Ds3ClientBuilder.create(
                arguments.getEndpoint(),
                new Credentials(arguments.getAccessKey(), arguments.getSecretKey()))
            .withHttps(arguments.isHttps())
            .withCertificateVerification(arguments.isCertificateVerification())
            .withBufferSize(Integer.valueOf(arguments.getBufferSize()))
            .withRedirectRetries(arguments.getRetries());

    if (arguments.getProxy() != null) {
      builder.withProxy(arguments.getProxy());
    }
    return builder.build();
  }
Пример #2
0
  public static void main(final String[] args) {

    try {
      final Arguments arguments = new Arguments(args);

      // turn root log wide open, filters will be set to argument levels
      configureLogging(arguments.getConsoleLogLevel(), arguments.getFileLogLevel());

      LOG.info("Version: {}", arguments.getVersion());
      LOG.info("Command line args: {}", Joiner.on(", ").join(args));
      LOG.info("Console log level: {}", arguments.getConsoleLogLevel().toString());
      LOG.info("Log file log level: {}", arguments.getFileLogLevel().toString());
      LOG.info(CliCommand.getPlatformInformation());
      LOG.info(arguments.getArgumentLog());

      if (arguments.isHelp()) {
        // no need to connect to vend help
        final Ds3Cli runner = new Ds3Cli(null, arguments, null);
        final CommandResponse response = runner.getCommandHelp();
        System.out.println(response.getMessage());
        System.exit(response.getReturnCode());
      }

      final Ds3Client client = createClient(arguments);
      if (!Utils.isVersionSupported(client)) {
        System.out.println(
            String.format(
                "ERROR: Minimum Black Pearl supported is %s", Utils.MINIMUM_VERSION_SUPPORTED));
        System.exit(2);
      }

      final Ds3Provider provider = new Ds3ProviderImpl(client, Ds3ClientHelpers.wrap(client));
      final FileUtils fileUtils = new FileUtilsImpl();

      final Ds3Cli runner = new Ds3Cli(provider, arguments, fileUtils);
      final CommandResponse response = runner.call();
      System.out.println(response.getMessage());
      System.exit(response.getReturnCode());
    } catch (final FailedRequestException e) {
      System.out.println("ERROR: " + e.getMessage());
      LOG.info("Stack trace: ", e);
      LOG.info("Printing out the response from the server:");
      LOG.info(e.getResponseString());
      System.exit(2);
    } catch (final Exception e) {
      System.out.println("ERROR: " + e.getMessage());
      LOG.info("Stack trace: ", e);
      System.exit(2);
    }
  }