code: private boolean datastreamExists(FedoraClient fedora, String vitalPid,
              String dsPid) {
          try {
              // Some options:
              // * getAPIA().listDatastreams... seems best
              // * getAPIM().getDatastream... causes Exceptions against new IDs
              // * getAPIM().getDatastreams... is limited to a single state
              DatastreamDef[] streams = fedora.getAPIA().listDatastreams(
                      vitalPid, null);
              for (DatastreamDef stream : streams) {
                  if (stream.getID().equals(dsPid)) {
                      return true;
                  }
              }
          } catch (Exception ex) {
              log.error("API Query error: ", ex);
          }
          return false;
      }
docs: Test for the existence of a given datastream in VITAL.
  
  @param fedora An instantiated fedora client
  @param vitalPid The VITAL PID to use
  @param dsPid The datastream ID on the object
  @returns boolean True is found, False if not found or there are errors