コード例 #1
0
  @Override
  final void execute(final CommandLine commandLine) throws Exception {
    ensureProxyExists(commandLine);
    final ConfProxyProperties conf = loadConf(commandLine);

    ConfigurationAnchor sourceAnchor = null;
    try {
      sourceAnchor = new ConfigurationAnchor(conf.getProxyAnchorPath());
    } catch (Exception ex) {
      fail("Could not load source anchor: ", ex);
    }
    String instance = sourceAnchor.getInstanceIdentifier();

    if (conf.getConfigurationProxyURL().equals("0.0.0.0")) {
      fail("configuration-proxy.address has not been" + " configured in 'local.ini'!", null);
    }

    if (conf.getKeyList().isEmpty()) {
      fail("No signing keys configured!", null);
    }

    if (commandLine.hasOption("filename")) {
      String filename = commandLine.getOptionValue("f");

      try {
        AtomicSave.execute(filename, "tmpanchor", out -> generateAnchorXml(conf, instance, out));
      } catch (AccessDeniedException ex) {
        fail("Cannot write anchor to '" + filename + "', permission denied. ", ex);
      }
      System.out.println("Generated anchor xml to '" + filename + "'");
    } else {
      printHelp();
    }
  }