if (wEntry.getContainer().getParameterBoolean("multi-db") == false)
{
for (String wsName : repository.getWorkspaceNames())
{
WorkspaceContainerFacade wsContainer = repository.getWorkspaceContainer(wsName);
wsContainer.setState(ManageableRepository.SUSPENDED);
workspacesWaits4Resume.add(wsContainer);
}
}
else
{
WorkspaceContainerFacade wsContainer = repository.getWorkspaceContainer(wEntry.getName());
wsContainer.setState(ManageableRepository.SUSPENDED);
workspacesWaits4Resume.add(wsContainer);
}
// get all restorers
List<Backupable> backupable =
repository.getWorkspaceContainer(wEntry.getName())
.getComponentInstancesOfType(Backupable.class);
File storageDir = backupChainLog.getBackupConfig().getBackupDir();
File fullBackupDir = JCRRestore.getFullBackupFile(storageDir);
DataRestoreContext context = new DataRestoreContext(
new String[] {DataRestoreContext.STORAGE_DIR},
new Object[] {fullBackupDir});
for (Backupable component : backupable)
{
dataRestorer.add(component.getDataRestorer(context));
}
for (DataRestore restorer : dataRestorer)
{
restorer.clean();
}
for (DataRestore restorer : dataRestorer)
{
restorer.restore();
}
for (DataRestore restorer : dataRestorer)
{
restorer.commit();
}
for (WorkspaceContainerFacade wsContainer : workspacesWaits4Resume)
{
wsContainer.setState(ManageableRepository.ONLINE);
}
// incremental restore
DataManager dataManager =
(WorkspacePersistentDataManager) repository.getWorkspaceContainer(wEntry.getName()).getComponent(
WorkspacePersistentDataManager.class);
FileCleanerHolder fileCleanHolder =
(FileCleanerHolder) repository.getWorkspaceContainer(wEntry.getName())
.getComponent(FileCleanerHolder.class);
JCRRestore restorer = new JCRRestore(dataManager, fileCleanHolder.getFileCleaner());
for (File incrBackupFile : JCRRestore.getIncrementalFiles(storageDir))
{
restorer.incrementalRestore(incrBackupFile);
}
}
catch (Throwable t)
{
// rollback
for (DataRestore restorer : dataRestorer)
{
try
{
restorer.rollback();
}
catch (BackupException e)
{
LOG.error("Can't rollback changes", e);
}
}
throw new WorkspaceRestoreException("Workspace " + wEntry.getName() + " was not restored", t);
}
finally
{
// close
for (DataRestore restorer : dataRestorer)
{
try
{
restorer.close();
}
catch (BackupException e)
{
LOG.error("Can't close restorer", e);
}
}
try
{
for (WorkspaceContainerFacade wsContainer : workspacesWaits4Resume)
{
wsContainer.setState(ManageableRepository.ONLINE);
}
}
catch (RepositoryException e)
{
LOG.error("Can't resume component", e);