/*
* search necessary restore
*/
List<JobWorkspaceRestore> restoreJobs = backupManager.getRestores();
JobWorkspaceRestore restore = null;
for (JobWorkspaceRestore curRestore : restoreJobs)
{
if (curRestore.getRepositoryName().equals(repository) && curRestore.getWorkspaceName().equals(workspace))
{
restore = curRestore;
break;
}
}
if (restore != null)
{
ShortInfo info =
new ShortInfo(ShortInfo.RESTORE, restore.getBackupChainLog(), restore.getStartTime(), restore
.getEndTime(), restore.getStateRestore(), restore.getRepositoryName(), restore
.getWorkspaceName());
return Response.ok(info).cacheControl(noCache).build();
}
return Response.ok().cacheControl(noCache).build();
}
catch (WorkspaceRestoreExeption e)
{
exception = e;
status = Response.Status.FORBIDDEN;
failMessage = e.getMessage();
}
catch (RepositoryException e)
{
exception = e;
status = Response.Status.NOT_FOUND;
failMessage = e.getMessage();
}
catch (RepositoryConfigurationException e)
{
exception = e;
status = Response.Status.NOT_FOUND;
failMessage = e.getMessage();
}
catch (BackupLogNotFoundException e)
{
exception = e;
status = Response.Status.NOT_FOUND;
failMessage = e.getMessage();
}
catch (Throwable e) //NOSONAR
{
exception = e;
status = Response.Status.INTERNAL_SERVER_ERROR;
failMessage = e.getMessage();
}
LOG.error("Can not start restore the workspace '" + "/" + repository + "/" + workspace
+ "' from backup set \"" + backupSetPath + "\"", exception);
return Response.status(status).entity(
"Can not start restore the workspace '" + "/" + repository + "/" + workspace + "' from backup set \""
+ backupSetPath + "\" : " + failMessage).type(MediaType.TEXT_PLAIN).cacheControl(noCache)
.build();
}
else
{
String repository = null;
try
{
RepositoryBackupChainLog backupChainLog = new RepositoryBackupChainLog(backuplog);
repository = backupChainLog.getBackupConfig().getRepository();
validateOneRepositoryRestoreInstants(repository);
if (removeExisting)
{
if (!isRepositoryExist(repository))
{
throw new RepositoryRestoreExeption("Repository " + repository + " is not exists!");
}
backupManager.restoreExistingRepository(backupSetDir, true);
}
else
{
if (isRepositoryExist(repository))
{
throw new RepositoryRestoreExeption("Repository " + repository + " already exists!");
}
backupManager.restoreRepository(backupSetDir, true);
}
// Sleeping. Restore should be initialized by job thread
Thread.sleep(100);
// search necessary restore
JobRepositoryRestore restore = backupManager.getLastRepositoryRestore(repository);
ShortInfo info =
new ShortInfo(ShortInfo.RESTORE, restore.getRepositoryBackupChainLog(), restore.getStartTime(),
restore.getEndTime(), restore.getStateRestore(), restore.getRepositoryName());
return Response.ok(info).cacheControl(noCache).build();
}
catch (RepositoryRestoreExeption e)
{