List<Backupable> backupable = new ArrayList<Backupable>();
try
{
// get current repository configuration
RepositoryEntry repositoryEntry =
repositoryService.getConfig().getRepositoryConfiguration(this.repositoryEntry.getName());
if (repositoryEntry == null)
{
throw new RepositoryRestoreExeption("Current repository configuration " + this.repositoryEntry.getName()
+ " did not found");
}
boolean isDefault =
repositoryService.getDefaultRepository().getConfiguration().getName().equals(repositoryEntry.getName());
String systemWsName =
repositoryService.getRepository(this.repositoryEntry.getName()).getConfiguration().getSystemWorkspaceName();
//Create local copy of WorkspaceEntry for all workspaces
ArrayList<WorkspaceEntry> workspaceList = new ArrayList<WorkspaceEntry>();
workspaceList.addAll(repositoryEntry.getWorkspaceEntries());
// get all backupable components
for (WorkspaceEntry wEntry : workspaceList)
{
backupable.addAll(repositoryService.getRepository(this.repositoryEntry.getName())
.getWorkspaceContainer(wEntry.getName()).getComponentInstancesOfType(Backupable.class));
}
//close all session
for (WorkspaceEntry wEntry : workspaceList)
{
forceCloseSession(repositoryEntry.getName(), wEntry.getName());
}
//remove repository
repositoryService.removeRepository(repositoryEntry.getName());
// clean
for (Backupable component : backupable)
{
component.clean();
}
super.restoreRepository();
}
catch (Throwable t)
{
throw new RepositoryRestoreExeption("Repository " + repositoryEntry.getName() + " was not restored", t);
}
}