@ Path ( "{snapshotId}/complete" ) @ POST @ Consumes ( MediaType . APPLICATION_JSON ) @ Produces ( MediaType . APPLICATION_JSON ) public Response complete ( @ PathParam ( "snapshotId" ) String snapshotId , CompleteSnapshotBridgeParameters params ) { try { Snapshot snapshot = this . snapshotRepo . findByName ( snapshotId ) ; // parse alternate IDs if provided List < String > alternateIds = params . getAlternateIds ( ) ; String altIds = "[]" ; if ( alternateIds != null && ! alternateIds . isEmpty ( ) ) { // add alternate IDs to snapshot snapshot = this . snapshotManager . addAlternateSnapshotIds ( snapshot , alternateIds ) ; // build alternate IDs for history StringBuilder history = new StringBuilder ( ) ; history . append ( "[" ) ; boolean first = true ; for ( String id : alternateIds ) { if ( ! first ) { history . append ( "," ) ; } history . append ( "'" + id + "'" ) ; first = false ; } history . append ( "]" ) ; altIds = history . toString ( ) ; } // Add history event String history = "[{'" + SNAPSHOT_ACTION_TITLE + "':'" + SNAPSHOT_ACTION_COMPLETED + "'}," + "{'" + SNAPSHOT_ID_TITLE + "':'" + snapshotId + "'}," + "{'" + SNAPSHOT_ALT_IDS_TITLE + "':" + altIds + "}]" ; snapshotManager . updateHistory ( snapshot , history ) ; snapshot = this . snapshotManager . transferToStorageComplete ( snapshotId ) ; log . info ( "successfully processed snapshot complete notification: {}" , snapshot ) ; return Response . ok ( null ) . entity ( new CompleteSnapshotBridgeResult ( snapshot . getStatus ( ) , snapshot . getStatusText ( ) ) ) . build ( ) ; } catch ( AlternateIdAlreadyExistsException ex ) { log . warn ( ex . getMessage ( ) ) ; return Response . status ( HttpStatus . SC_BAD_REQUEST ) . entity ( new ResponseDetails ( ex . getMessage ( ) ) ) . build ( ) ; } catch ( Exception ex ) { log . error ( ex . getMessage ( ) , ex ) ; return Response . serverError ( ) . entity ( new ResponseDetails ( ex . getMessage ( ) ) ) . build ( ) ; } }
Notifies the bridge that the snapshot transfer from the bridge storage to the preservation storage is complete . Also sets a snapshot s alternate id s if they are passed in .