private void processDatastreams ( FedoraClient fedora , DigitalObject object , String vitalPid ) throws Exception { int sent = 0 ; // Each payload we care about needs to be sent for ( String ourPid : pids . keySet ( ) ) { // Fascinator packages have unpredictable names, // so we just use the extension // eg. 'e6e174fe-3508-4c8a-8530-1d6bb644d10a.tfpackage' String realPid = ourPid ; if ( ourPid . equals ( ".tfpackage" ) ) { realPid = getPackagePid ( object ) ; if ( realPid == null ) { String message = partialUploadErrorMessage ( ourPid , sent , pids . size ( ) , vitalPid ) ; throw new Exception ( message + "\n\nPackage not found." ) ; } } log . info ( "Processing PID to send to VITAL: '{}'" , ourPid ) ; // Get our configuration JsonSimple thisPid = pids . get ( ourPid ) ; String dsId = thisPid . getString ( realPid , "dsID" ) ; String label = thisPid . getString ( dsId , "label" ) ; String status = thisPid . getString ( "A" , "status" ) ; String controlGroup = thisPid . getString ( "X" , "controlGroup" ) ; boolean versionable = thisPid . getBoolean ( true , "versionable" ) ; boolean retainIds = thisPid . getBoolean ( true , "retainIds" ) ; String [ ] altIds = { } ; if ( retainIds && datastreamExists ( fedora , vitalPid , dsId ) ) { altIds = getAltIds ( fedora , vitalPid , dsId ) ; for ( String altId : altIds ) { log . debug ( "Retaining alt ID: '{}' => {}'" , dsId , altId ) ; } } // MIME Type Payload payload = null ; String mimeType = null ; try { payload = object . getPayload ( realPid ) ; } catch ( StorageException ex ) { String message = partialUploadErrorMessage ( realPid , sent , pids . size ( ) , vitalPid ) ; throw new Exception ( message + "\n\nError accessing payload '" + realPid + "' : " , ex ) ; } mimeType = payload . getContentType ( ) ; // Default to binary data if ( mimeType == null ) { mimeType = "application/octet-stream" ; } try { sendToVital ( fedora , object , realPid , vitalPid , dsId , altIds , label , mimeType , controlGroup , status , versionable ) ; } catch ( Exception ex ) { String message = partialUploadErrorMessage ( realPid , sent , pids . size ( ) , vitalPid ) ; throw new Exception ( message , ex ) ; } // Increase our counter sent ++ ; } // End for loop // Datastreams are taken care of, now handle attachments try { processAttachments ( fedora , object , vitalPid ) ; } catch ( Exception ex ) { throw new Exception ( "Error processing attachments: " , ex ) ; } }
Method responsible for arranging submissions to VITAL to store our datastreams .