String fBackupType) throws FileNotFoundException, IOException, RepositoryException,
RepositoryConfigurationException, ClassNotFoundException
{
WorkspaceInitializerEntry wieOriginal = workspaceEntry.getInitializer();
RepositoryImpl defRep = (RepositoryImpl)repoService.getRepository(repositoryName);
WorkspaceInitializerEntry wiEntry = new WorkspaceInitializerEntry();
if ((Class.forName(fBackupType).equals(FullBackupJob.class)))
{
// set the initializer SysViewWorkspaceInitializer
wiEntry.setType(SysViewWorkspaceInitializer.class.getCanonicalName());
List<SimpleParameterEntry> wieParams = new ArrayList<SimpleParameterEntry>();
wieParams.add(new SimpleParameterEntry(SysViewWorkspaceInitializer.RESTORE_PATH_PARAMETER, pathBackupFile));
wiEntry.setParameters(wieParams);
}
else if ((Class.forName(fBackupType)
.equals(org.exoplatform.services.jcr.ext.backup.impl.rdbms.FullBackupJob.class)))
{
// set the initializer RdbmsWorkspaceInitializer
wiEntry.setType(RdbmsWorkspaceInitializer.class.getCanonicalName());
List<SimpleParameterEntry> wieParams = new ArrayList<SimpleParameterEntry>();
wieParams.add(new SimpleParameterEntry(RdbmsWorkspaceInitializer.RESTORE_PATH_PARAMETER, new File(
pathBackupFile).getParent()));
wiEntry.setParameters(wieParams);
}
workspaceEntry.setInitializer(wiEntry);
//restore
defRep.configWorkspace(workspaceEntry);
defRep.createWorkspace(workspaceEntry.getName());
//set original workspace initializer
WorkspaceContainerFacade wcf = defRep.getWorkspaceContainer(workspaceEntry.getName());
WorkspaceEntry createdWorkspaceEntry = (WorkspaceEntry)wcf.getComponent(WorkspaceEntry.class);
createdWorkspaceEntry.setInitializer(wieOriginal);
}