Author: tolusha
Date: 2010-09-30 06:31:24 -0400 (Thu, 30 Sep 2010)
New Revision: 3221
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/ExtendedBackupManager.java
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/JobExistedRepositoryRestore.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistedWorkspaceRestore.java
Log:
EXOJCR-747: code cleanup
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/ExtendedBackupManager.java
===================================================================
---
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/ExtendedBackupManager.java 2010-09-30
09:29:30 UTC (rev 3220)
+++
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/ExtendedBackupManager.java 2010-09-30
10:31:24 UTC (rev 3221)
@@ -30,78 +30,77 @@
public interface ExtendedBackupManager extends BackupManager
{
/**
- * Restoration over an existing repository.
- * Will be deleted old data.
- * Get status of repository restore was necessary use JobRepositoryRestore
BackupManager.getLastRestore(String repositoryName).
+ * Restore existed workspace. Previous data will be deleted.
+ * For getting status of workspace restore use can use
+ * BackupManager.getLastRestore(String repositoryName, String workspaceName) method
*
- * @param log
- * RepositoryBackupChainLog, the repository backup log
- * @param repositoryEntry
- * RepositoryEntry, the repository entry
+ * @param workspaceBackupIdentifier
+ * backup identifier
+ * @param workspaceEntry
+ * new workspace configuration
* @param asynchronous
- * boolean, in 'true' then asynchronous restore.
+ * if 'true' restore will be in asynchronous mode (i.e. in separated
thread)
* @throws BackupOperationException
- * will be generate the exception BackupOperationException
+ * if backup operation exception occurred
* @throws BackupConfigurationException
- * will be generate the exception BackupConfigurationException
+ * if configuration exception occurred
*/
- void restoreExistedRepository(RepositoryBackupChainLog log, RepositoryEntry
repositoryEntry, boolean asynchronous) throws BackupOperationException,
BackupConfigurationException;
-
+ void restoreExistedWorkspace(String workspaceBackupIdentifier, String repositoryName,
WorkspaceEntry workspaceEntry,
+ boolean asynchronous) throws BackupOperationException,
BackupConfigurationException;
+
/**
- * Restoration over an existing workspace.
- * Will be deleted old data.
- * Get status of workspace restore was necessary use JobWorkspaceRestore
BackupManager.getLastRestore(String repositoryName, String workspaceName).
+ * Restore existed workspace. Previous data will be deleted.
+ * For getting status of workspace restore use can use
+ * BackupManager.getLastRestore(String repositoryName, String workspaceName) method
*
* @param log
- * BackupChainLog, the backup log
- * @param repositoryName
- * String, repository name
+ * workspace backup log
* @param workspaceEntry
- * WorkspaceEntry, the workspace entry
+ * new workspace configuration
* @param asynchronous
- * boolean, in 'true' then asynchronous restore.
+ * if 'true' restore will be in asynchronous mode (i.e. in separated
thread)
* @throws BackupOperationException
- * will be generate the exception BackupOperationException
+ * if backup operation exception occurred
* @throws BackupConfigurationException
- * will be generate the exception BackupConfigurationException
+ * if configuration exception occurred
*/
void restoreExistedWorkspace(BackupChainLog log, String repositoryName, WorkspaceEntry
workspaceEntry, boolean asynchronous) throws BackupOperationException,
BackupConfigurationException;
-
+
/**
- * Restoration over an existing repository.
- * Will be deleted old data.
- * Get status of repository restore was necessary use JobRepositoryRestore
BackupManager.getLastRestore(String repositoryName).
+ * Restore existed repository. Previous data will be deleted.
+ * For getting status of repository restore use can use
+ * BackupManager.getLastRestore(String repositoryName) method
*
* @param repositoryBackupIdentifier
- * String, identifier of repository backup
+ * backup identifier
* @param repositoryEntry
- * RepositoryEntry, the repository entry
+ * new repository configuration
* @param asynchronous
- * boolean, in 'true' then asynchronous restore.
+ * if 'true' restore will be in asynchronous mode (i.e. in separated
thread)
* @throws BackupOperationException
- * will be generate the exception BackupOperationException
+ * if backup operation exception occurred
* @throws BackupConfigurationException
- * will be generate the exception BackupConfigurationException
+ * if configuration exception occurred
*/
void restoreExistedRepository(String repositoryBackupIdentifier, RepositoryEntry
repositoryEntry, boolean asynchronous) throws BackupOperationException,
BackupConfigurationException;
-
+
/**
- * Restoration over an existing workspace.
- * Will be deleted old data.
- * Get status of workspace restore was necessary use JobWorkspaceRestore
BackupManager.getLastRestore(String repositoryName, String workspaceName).
+ * Restore existed repository. Previous data will be deleted.
+ * For getting status of repository restore use can use
+ * BackupManager.getLastRestore(String repositoryName) method
*
- * @param workspaceBackupIdentifier
- * String, identifier of workspace backup
- * @param repositoryName
- * String, repository name
- * @param workspaceEntry
- * WorkspaceEntry, the workspace entry
+ * @param log
+ * repository backup log
+ * @param repositoryEntry
+ * new repository configuration
* @param asynchronous
- * boolean, in 'true' then asynchronous restore.
+ * if 'true' restore will be in asynchronous mode (i.e. in separated
thread)
* @throws BackupOperationException
- * will be generate the exception BackupOperationException
+ * if backup operation exception occurred
* @throws BackupConfigurationException
- * will be generate the exception BackupConfigurationException
+ * if configuration exception occurred
*/
- void restoreExistedWorkspace(String workspaceBackupIdentifier, String repositoryName,
WorkspaceEntry workspaceEntry, boolean asynchronous) throws BackupOperationException,
BackupConfigurationException;
+ void restoreExistedRepository(RepositoryBackupChainLog log, RepositoryEntry
repositoryEntry, boolean asynchronous)
+ throws BackupOperationException, BackupConfigurationException;
+
}
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-09-30
09:29:30 UTC (rev 3220)
+++
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java 2010-09-30
10:31:24 UTC (rev 3221)
@@ -18,29 +18,6 @@
*/
package org.exoplatform.services.jcr.ext.backup.impl;
-import java.io.ByteArrayOutputStream;
-import java.io.EOFException;
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.jcr.PathNotFoundException;
-import javax.jcr.RepositoryException;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
import org.apache.commons.collections.map.HashedMap;
import org.exoplatform.container.xml.InitParams;
import org.exoplatform.container.xml.PropertiesParam;
@@ -71,6 +48,7 @@
import org.exoplatform.services.jcr.ext.backup.RepositoryBackupChain;
import org.exoplatform.services.jcr.ext.backup.RepositoryBackupChainLog;
import org.exoplatform.services.jcr.ext.backup.RepositoryBackupConfig;
+import org.exoplatform.services.jcr.ext.backup.RepositoryRestoreExeption;
import org.exoplatform.services.jcr.ext.backup.WorkspaceRestoreException;
import org.exoplatform.services.jcr.ext.common.SessionProvider;
import org.exoplatform.services.jcr.ext.registry.RegistryEntry;
@@ -93,6 +71,29 @@
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
+import java.io.ByteArrayOutputStream;
+import java.io.EOFException;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
/**
* Created by The eXo Platform SAS .<br/>
*
@@ -1566,16 +1567,16 @@
{
try
{
- //repository should be existed
+ // repository should be existed
repoService.getRepository(repositoryEntry.getName());
}
catch (RepositoryException e)
{
- throw new WorkspaceRestoreException("Repository \"" +
repositoryEntry.getName() + "\" should be existed", e);
+ throw new RepositoryRestoreExeption("Repository \"" +
repositoryEntry.getName() + "\" should be existed", e);
}
catch (RepositoryConfigurationException e)
{
- throw new WorkspaceRestoreException("Repository \"" +
repositoryEntry.getName() + "\" should be existed", e);
+ throw new RepositoryRestoreExeption("Repository \"" +
repositoryEntry.getName() + "\" should be existed", e);
}
Map<String, BackupChainLog> workspacesMapping = new HashedMap();
@@ -1663,10 +1664,10 @@
{
try
{
- //repository should be existed
+ // repository should be existed
repoService.getRepository(repositoryName);
- //workspace should be existed
+ // workspace should be existed
if (!workspaceAlreadyExist(repositoryName, workspaceEntry.getName()))
{
throw new WorkspaceRestoreException("Workspace \"" +
workspaceEntry.getName() + "\" should be existed in repository \"" +
repositoryName + "\".");
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistedRepositoryRestore.java
===================================================================
---
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistedRepositoryRestore.java 2010-09-30
09:29:30 UTC (rev 3220)
+++
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistedRepositoryRestore.java 2010-09-30
10:31:24 UTC (rev 3221)
@@ -49,12 +49,28 @@
*/
private final DBCleanerService dbCleanerService;
+ /**
+ * Value storage cleaner.
+ */
+ private final ValueStorageCleanHelper valueStorageCleanHelper;
+
+ /**
+ * Index storage cleaner.
+ */
+ private final IndexCleanHelper indexCleanHelper;
+
+ /**
+ * JobExistedRepositoryRestore constructor.
+ */
public JobExistedRepositoryRestore(RepositoryService repoService, BackupManagerImpl
backupManagerImpl,
RepositoryEntry repositoryEntry, Map<String, BackupChainLog>
workspacesMapping,
RepositoryBackupChainLog backupChainLog)
{
super(repoService, backupManagerImpl, repositoryEntry, workspacesMapping,
backupChainLog);
+
this.dbCleanerService = new DBCleanerService();
+ this.valueStorageCleanHelper = new ValueStorageCleanHelper();
+ this.indexCleanHelper = new IndexCleanHelper();
}
@Override
@@ -65,13 +81,14 @@
{
try
{
+ // get current repository configuration
RepositoryEntry repositoryEntry =
repositoryService.getConfig().getRepositoryConfiguration(this.repositoryEntry.getName());
if (repositoryEntry == null)
{
- throw new RepositoryRestoreExeption("Repository " +
this.repositoryEntry.getName()
- + " did not found configuration");
+ throw new RepositoryRestoreExeption("Current repository configuration
" + this.repositoryEntry.getName()
+ + " did not found");
}
boolean isDefault =
@@ -99,14 +116,14 @@
//clean index
for (WorkspaceEntry wEntry : repositoryEntry.getWorkspaceEntries())
{
- IndexCleanerService.removeWorkspaceIndex(wEntry,
+ indexCleanHelper.removeWorkspaceIndex(wEntry,
repositoryEntry.getSystemWorkspaceName().equals(wEntry.getName()));
}
//clean value storage
for (WorkspaceEntry wEntry : repositoryEntry.getWorkspaceEntries())
{
- ValueStorageCleanerService.removeWorkspaceValueStorage(wEntry);
+ valueStorageCleanHelper.removeWorkspaceValueStorage(wEntry);
}
super.restoreRepository();
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistedWorkspaceRestore.java
===================================================================
---
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistedWorkspaceRestore.java 2010-09-30
09:29:30 UTC (rev 3220)
+++
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistedWorkspaceRestore.java 2010-09-30
10:31:24 UTC (rev 3221)
@@ -42,7 +42,7 @@
public class JobExistedWorkspaceRestore extends JobWorkspaceRestore
{
/**
- * The apache logger.
+ * The logger.
*/
private static Log log =
ExoLogger.getLogger("exo.jcr.component.ext.JobExistedWorkspaceRestore");
@@ -51,11 +51,27 @@
*/
private final DBCleanerService dbCleanerService;
+ /**
+ * Value storage cleaner.
+ */
+ private final ValueStorageCleanHelper valueStorageCleaner;
+
+ /**
+ * Index cleaner.
+ */
+ private final IndexCleanHelper indexCleanHelper;
+
+ /**
+ * JobExistedWorkspaceRestore constructor.
+ */
public JobExistedWorkspaceRestore(RepositoryService repositoryService, BackupManager
backupManager,
String repositoryName, BackupChainLog log, WorkspaceEntry wEntry)
{
super(repositoryService, backupManager, repositoryName, log, wEntry);
+
this.dbCleanerService = new DBCleanerService();
+ this.valueStorageCleaner = new ValueStorageCleanHelper();
+ this.indexCleanHelper = new IndexCleanHelper();
}
/**
@@ -66,6 +82,7 @@
{
try
{
+ // get current workspace configuration
WorkspaceEntry wEntry = null;;
for (WorkspaceEntry entry :
repositoryService.getRepository(repositoryName).getConfiguration()
.getWorkspaceEntries())
@@ -79,8 +96,8 @@
if (wEntry == null)
{
- throw new WorkspaceRestoreException("Workspace " +
this.wEntry.getName() + " did not found in repository "
- + repositoryName + " configuration");
+ throw new WorkspaceRestoreException("Workspace " +
this.wEntry.getName()
+ + " did not found in current repository " + repositoryName +
" configuration");
}
boolean isSystem =
@@ -96,10 +113,10 @@
dbCleanerService.cleanWorkspaceData(wEntry);
//clean index
- IndexCleanerService.removeWorkspaceIndex(wEntry, isSystem);
+ indexCleanHelper.removeWorkspaceIndex(wEntry, isSystem);
//clean value storage
- ValueStorageCleanerService.removeWorkspaceValueStorage(wEntry);
+ valueStorageCleaner.removeWorkspaceValueStorage(wEntry);
super.restore();
}