Example #1
0
  @SuppressWarnings("deprecation")
  @Override
  public Bundle assemble(IssueSubmissionRequest request) throws IssueSubmissionException {
    OutputStream out = null;
    try {
      final ManagedBundle bundle = storageManager.createBundle("nexus.xml", "application/xml");
      final Configuration configuration =
          configHelper.maskPasswords(nexusConfig.getConfigurationModel());

      // No config ?
      if (configuration != null) {
        NexusConfigurationXpp3Writer writer = new NexusConfigurationXpp3Writer();
        out = bundle.getOutputStream();
        writer.write(out, configuration);
        out.close();
      } else {
        ByteStreams.write(
            "Got no configuration from config helper".getBytes("utf-8"),
            new OutputSupplier<OutputStream>() {
              @Override
              public OutputStream getOutput() throws IOException {
                return bundle.getOutputStream();
              }
            });
      }
      return bundle;
    } catch (IOException e) {
      IOUtil.close(out);
      throw new IssueSubmissionException("Could not assemble nexus.xml: " + e.getMessage(), e);
    }
  }