[exo-jcr-commits] exo-jcr SVN: r3681 - in jcr/trunk/exo.jcr.component.ext/src: test/java/org/exoplatform/services/jcr/ext/backup and 1 other directory.
do-not-reply at jboss.org
do-not-reply at jboss.org
Mon Dec 20 05:25:56 EST 2010
Author: tolusha
Date: 2010-12-20 05:25:55 -0500 (Mon, 20 Dec 2010)
New Revision: 3681
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupTestCase.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupUseCasesTest.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/BaseRDBMSBackupTest.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestRDBMSBackupManager.java
Log:
EXOJCR-1078: don't support backup of single workspace in case of mulit-db configuration
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java 2010-12-20 09:24:58 UTC (rev 3680)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java 2010-12-20 10:25:55 UTC (rev 3681)
@@ -65,6 +65,7 @@
import org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager;
import org.exoplatform.services.jcr.impl.storage.JCRInvalidItemStateException;
import org.exoplatform.services.jcr.impl.storage.JCRItemExistsException;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
import org.exoplatform.services.jcr.impl.util.io.SpoolFile;
import org.exoplatform.services.jcr.observation.ExtendedEvent;
@@ -767,6 +768,41 @@
{
validateBackupConfig(config);
+ try
+ {
+ // check if it is RDBMS backup of single workspace in case of multi-db configuration
+ if ((Class.forName(fullBackupType)
+ .equals(org.exoplatform.services.jcr.ext.backup.impl.rdbms.FullBackupJob.class)))
+ {
+ WorkspaceEntry wEntry = null;
+ for (WorkspaceEntry entry : repoService.getRepository(config.getRepository()).getConfiguration()
+ .getWorkspaceEntries())
+ {
+ if (entry.getName().equals(config.getWorkspace()))
+ {
+ wEntry = entry;
+ break;
+ }
+ }
+
+ if (wEntry == null)
+ {
+ throw new WorkspaceRestoreException("Workspace " + config.getWorkspace()
+ + " did not found in current repository " + config.getRepository() + " configuration");
+ }
+
+ if (Boolean.parseBoolean(wEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.MULTIDB)))
+ {
+ throw new BackupOperationException(
+ "Backup of single workspace in case of multi-db configuration is not supported");
+ }
+ }
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new BackupOperationException("Class " + fullBackupType + " is not found.", e);
+ }
+
BackupChain bchain =
new BackupChainImpl(config, logsDirectory, repoService.getRepository(config.getRepository()),
fullBackupType, incrementalBackupType, IdGenerator.generate(), logsDirectory);
@@ -905,9 +941,8 @@
}
private void fullRestoreOverInitializer(String pathBackupFile, String repositoryName, WorkspaceEntry workspaceEntry,
- String fBackupType)
- throws FileNotFoundException, IOException, RepositoryException,
- RepositoryConfigurationException, ClassNotFoundException
+ String fBackupType) throws FileNotFoundException, IOException, RepositoryException,
+ RepositoryConfigurationException, ClassNotFoundException
{
WorkspaceInitializerEntry wieOriginal = workspaceEntry.getInitializer();
@@ -1966,5 +2001,5 @@
}
}
-
+
}
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupTestCase.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupTestCase.java 2010-12-20 09:24:58 UTC (rev 3680)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupTestCase.java 2010-12-20 10:25:55 UTC (rev 3681)
@@ -77,7 +77,7 @@
protected ExtendedBackupManager backup;
- protected String repositoryNameToBackup = "db8";
+ protected String repositoryNameToBackup = "db7";
protected String workspaceNameToBackup = "ws1";
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupUseCasesTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupUseCasesTest.java 2010-12-20 09:24:58 UTC (rev 3680)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupUseCasesTest.java 2010-12-20 10:25:55 UTC (rev 3681)
@@ -1265,8 +1265,10 @@
fail("There are no backup files in " + backDir.getAbsolutePath());
}
- public void _testExistedWorkspaceRestoreMultiDB() throws Exception
+ public void testExistedWorkspaceRestoreMultiDB() throws Exception
{
+ String repositoryNameToBackup = "db8";
+
// backup
File backDir = new File("target/backup/" + getUUIndex());
backDir.mkdirs();
@@ -1330,7 +1332,7 @@
fail("There are no backup files in " + backDir.getAbsolutePath());
}
- public void testExistedWorkspaceRestoreSingleDB() throws Exception
+ public void testExistedWorkspaceRestore() throws Exception
{
SessionImpl ws1Session = (SessionImpl)repositoryService.getRepository("db7").login(credentials, "ws1");
@@ -1411,9 +1413,6 @@
public void testExistedWorkspaceRestoreAsync() throws Exception
{
- SessionImpl ws1Session = (SessionImpl)repositoryService.getRepository("db7").login(credentials, "ws1");
- String repositoryNameToBackup = "db7";
-
// backup
File backDir = new File("target/backup/" + getUUIndex());
backDir.mkdirs();
@@ -1499,8 +1498,6 @@
public void testExistedWorkspaceRestoreAsync2() throws Exception
{
- SessionImpl ws1Session = (SessionImpl)repositoryService.getRepository("db7").login(credentials, "ws1");
- String repositoryNameToBackup = "db7";
// backup
File backDir = new File("target/backup/" + getUUIndex());
@@ -1980,10 +1977,6 @@
public void testExistedWorkspaceRestoreWithConfig() throws Exception
{
- RepositoryImpl repositoryDB7 = (RepositoryImpl)repositoryService.getRepository(repositoryNameToBackupSingleDB);
- String repositoryNameToBackup = "db7";
- SessionImpl sessionWS = (SessionImpl)repositoryDB7.login(credentials, workspaceNameToBackup);
-
// backup
File backDir = new File("target/backup/" + getUUIndex());
backDir.mkdirs();
@@ -2124,9 +2117,6 @@
public void testWorkspaceRestoreWithConfig() throws Exception
{
- RepositoryImpl repositoryDB7 = (RepositoryImpl)repositoryService.getRepository(repositoryNameToBackupSingleDB);
- String repositoryNameToBackup = "db7";
-
// backup
File backDir = new File("target/backup/" + getUUIndex());
backDir.mkdirs();
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/BaseRDBMSBackupTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/BaseRDBMSBackupTest.java 2010-12-20 09:24:58 UTC (rev 3680)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/BaseRDBMSBackupTest.java 2010-12-20 10:25:55 UTC (rev 3681)
@@ -31,6 +31,7 @@
public class BaseRDBMSBackupTest
extends AbstractBackupTestCase
{
+ @Override
protected ExtendedBackupManager getBackupManager()
{
InitParams initParams = new InitParams();
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestRDBMSBackupManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestRDBMSBackupManager.java 2010-12-20 09:24:58 UTC (rev 3680)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestRDBMSBackupManager.java 2010-12-20 10:25:55 UTC (rev 3681)
@@ -20,6 +20,7 @@
import org.exoplatform.container.xml.PropertiesParam;
import org.exoplatform.services.jcr.ext.backup.impl.BackupManagerImpl;
+import java.io.File;
/**
* Created by The eXo Platform SAS.
@@ -33,6 +34,7 @@
extends AbstractBackupUseCasesTest
{
+ @Override
protected ExtendedBackupManager getBackupManager()
{
InitParams initParams = new InitParams();
@@ -51,4 +53,30 @@
return backupManagerImpl;
}
+
+ @Override
+ public void testExistedWorkspaceRestoreMultiDB() throws Exception
+ {
+ String repositoryNameToBackup = "db8";
+
+ // backup
+ File backDir = new File("target/backup/" + System.currentTimeMillis());
+ backDir.mkdirs();
+
+ BackupConfig config = new BackupConfig();
+ config.setRepository(repositoryNameToBackup);
+ config.setWorkspace(workspaceNameToBackup);
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+
+ config.setBackupDir(backDir);
+
+ try
+ {
+ backup.startBackup(config);
+ fail("Exception should be thrown");
+ }
+ catch (BackupOperationException e)
+ {
+ }
+ }
}
More information about the exo-jcr-commits
mailing list