public Response restoreRepository ( ServletContext context , HttpServletRequest request , String repositoryName , String backupName , RestoreOptions options ) throws RepositoryException { if ( StringUtil . isBlank ( backupName ) ) { throw new IllegalArgumentException ( "The name of the backup cannot be null" ) ; } File backup = resolveBackup ( context , backupName ) ; logger . debug ( "Restoring repository '{0}' from backup '{1}' using '{2}'" , repositoryName , backup , options ) ; Session session = getSession ( request , repositoryName , null ) ; RepositoryManager repositoryManager = ( ( org . modeshape . jcr . api . Workspace ) session . getWorkspace ( ) ) . getRepositoryManager ( ) ; final Problems problems = repositoryManager . restoreRepository ( backup , options ) ; if ( ! problems . hasProblems ( ) ) { return Response . ok ( ) . build ( ) ; } List < JSONAble > response = new ArrayList < JSONAble > ( problems . size ( ) ) ; for ( Problem problem : problems ) { RestException exception = problem . getThrowable ( ) != null ? new RestException ( problem . getMessage ( ) , problem . getThrowable ( ) ) : new RestException ( problem . getMessage ( ) ) ; response . add ( exception ) ; } return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . entity ( response ) . build ( ) ; }
Restores a repository using an existing backup .