private void performRevertLogic ( String revision , UUID expectedContextHeadRevision , boolean expectedHeadCheck ) { String contextId = "" ; try { EDBCommit commit = edbService . getCommitByRevision ( revision ) ; contextId = commit . getContextId ( ) ; lockContext ( contextId ) ; if ( expectedHeadCheck ) { checkForContextHeadRevision ( contextId , expectedContextHeadRevision ) ; } EDBCommit newCommit = edbService . createEDBCommit ( new ArrayList < EDBObject > ( ) , new ArrayList < EDBObject > ( ) , new ArrayList < EDBObject > ( ) ) ; for ( EDBObject reverted : commit . getObjects ( ) ) { // need to be done in order to avoid problems with conflict detection reverted . remove ( EDBConstants . MODEL_VERSION ) ; newCommit . update ( reverted ) ; } for ( String delete : commit . getDeletions ( ) ) { newCommit . delete ( delete ) ; } newCommit . setComment ( String . format ( "revert [%s] %s" , commit . getRevisionNumber ( ) . toString ( ) , commit . getComment ( ) != null ? commit . getComment ( ) : "" ) ) ; edbService . commit ( newCommit ) ; } catch ( EDBException e ) { throw new EKBException ( "Unable to revert to the given revision " + revision , e ) ; } finally { releaseContext ( contextId ) ; } }
Performs the actual revert logic including the context locking and the context head revision check if desired .