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 ; }
Test for the existence of a given datastream in VITAL .