@ Path ( "{snapshotId}/history" ) @ POST @ Consumes ( MediaType . APPLICATION_JSON ) @ Produces ( MediaType . APPLICATION_JSON ) public Response updateHistory ( @ PathParam ( "snapshotId" ) String snapshotId , UpdateSnapshotHistoryBridgeParameters params ) { try { if ( params . getAlternate ( ) == null ) { return Response . serverError ( ) . entity ( new ResponseDetails ( "Incorrect parameters submitted!" ) ) . build ( ) ; } Snapshot snapshot = ( params . getAlternate ( ) ? this . snapshotRepo . findBySnapshotAlternateIds ( snapshotId ) : this . snapshotRepo . findByName ( snapshotId ) ) ; // sanity check to make sure snapshot exists if ( snapshot != null ) { // sanity check input from history if ( params . getHistory ( ) != null && params . getHistory ( ) . length ( ) > 0 ) { // set history, and refresh our variable from the DB snapshot = this . snapshotManager . updateHistory ( snapshot , params . getHistory ( ) ) ; log . info ( "successfully processed snapshot " + "history update: {}" , snapshot ) ; } else { log . info ( "did not process empty or null snapshot " + "history update: {}" , snapshot ) ; } SnapshotSummary snapSummary = createSnapshotSummary ( snapshot ) ; List < SnapshotHistory > snapMeta = snapshot . getSnapshotHistory ( ) ; String history = // retrieve latest history update ( ( snapMeta != null && snapMeta . size ( ) > 0 ) ? snapMeta . get ( snapMeta . size ( ) - 1 ) . getHistory ( ) : "" ) ; UpdateSnapshotHistoryBridgeResult result = new UpdateSnapshotHistoryBridgeResult ( snapSummary , history ) ; log . debug ( "Returning results of update snapshot history: {}" , result ) ; return Response . ok ( null ) . entity ( result ) . build ( ) ; } else { String error = "Snapshot with " + ( params . getAlternate ( ) ? "alternate " : "" ) + "id [" + snapshotId + "] not found!" ; return Response . serverError ( ) . entity ( new ResponseDetails ( error ) ) . build ( ) ; } } catch ( Exception ex ) { log . error ( ex . getMessage ( ) , ex ) ; return Response . serverError ( ) . entity ( new ResponseDetails ( ex . getMessage ( ) ) ) . build ( ) ; } }
Updates a snapshot s history