private void iterateAndListCollections(ServiceDocument sd, AuthCredentials auth)
      throws Exception {
    if (sd == null) {
      System.out.println("--- Service Document was NULL --");
      return;
    }

    List<SWORDWorkspace> ws = sd.getWorkspaces();
    for (SWORDWorkspace w : ws) {
      List<SWORDCollection> collections = w.getCollections();
      for (SWORDCollection c : collections) {
        System.out.println("Collection: " + c.getTitle());
        IRI href = c.getHref();
        CollectionEntries ces = client.listCollection(href.toString(), auth);
        for (Entry entry : ces.getEntries()) {
          IRI id = entry.getId();
          System.out.println("\t\tID: " + id.toString());
        }
      }
    }
  }
  private void outputServiceDocument(ServiceDocument sd) throws Exception {
    if (sd == null) {
      System.out.println("--- Service Document was NULL --");
      return;
    }

    System.out.println("--- service document interpretation ---");
    System.out.println("Version: " + sd.getVersion());
    System.out.println("Max Upload Size: " + Long.toString(sd.getMaxUploadSize()));
    List<SWORDWorkspace> sws = sd.getWorkspaces();
    for (SWORDWorkspace ws : sws) {
      System.out.println("Workspace: " + ws.getTitle());
      List<SWORDCollection> cols = ws.getCollections();
      for (SWORDCollection c : cols) {
        System.out.println("\tCollection: " + c.getTitle());
        System.out.println("\t\tPolicy: " + c.getCollectionPolicy());
        System.out.println("\t\tTreatment: " + c.getTreatment());
        System.out.println("\t\tURI: " + c.getHref());
        System.out.println("\t\tURI (Resolved): " + c.getResolvedHref());
        System.out.println("\t\tMediation Allowed: " + c.allowsMediation());

        List<String> packaging = c.getAcceptPackaging();
        for (String pack : packaging) {
          System.out.println("\t\tAccepts Packaging: " + pack);
        }

        List<String> subservices = c.getSubServices();
        for (String ss : subservices) {
          System.out.println("\t\tSub Service: " + ss);
        }

        List<String> maccepts = c.getMultipartAccept();
        for (String acc : maccepts) {
          System.out.println("\t\tMultipart Accepts: " + acc);
        }

        List<String> accepts = c.getSinglepartAccept();
        for (String acc : accepts) {
          System.out.println("\t\tAccepts: " + acc);
        }

        System.out.println(
            "\t\tAccepts application/zip? " + c.singlepartAccepts("application/zip"));
        System.out.println(
            "\t\tMultipart Accepts application/zip? " + c.multipartAccepts("application/zip"));
        System.out.println("\t\tAccepts Entry? " + c.singlepartAcceptsEntry());
        System.out.println("\t\tMultipart Accepts Entry? " + c.multipartAcceptsEntry());
        System.out.println("\t\tAccepts Nothing? " + c.acceptsNothing());
      }
    }
  }