[exo-jcr-commits] exo-jcr SVN: r5012 - jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Oct 4 02:15:56 EDT 2011


Author: nzamosenchuk
Date: 2011-10-04 02:15:55 -0400 (Tue, 04 Oct 2011)
New Revision: 5012

Modified:
   jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingRepositorySameConfigRestore.java
   jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobRepositoryRestore.java
Log:
EXOJCR-1563 : don't call retain if same configuration used.

Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingRepositorySameConfigRestore.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingRepositorySameConfigRestore.java	2011-09-30 07:40:14 UTC (rev 5011)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingRepositorySameConfigRestore.java	2011-10-04 06:15:55 UTC (rev 5012)
@@ -116,20 +116,20 @@
 
             File fullBackupDir =
                JCRRestore.getFullBackupFile(workspacesMapping.get(wEntry.getName()).getBackupConfig().getBackupDir());
-            
+
             DataRestoreContext context;
 
             if (jdbcConn != null)
             {
-               context = new DataRestoreContext(
-                        new String[] {DataRestoreContext.STORAGE_DIR, DataRestoreContext.DB_CONNECTION}, 
-                        new Object[] {fullBackupDir, jdbcConn});
+               context =
+                  new DataRestoreContext(
+                     new String[]{DataRestoreContext.STORAGE_DIR, DataRestoreContext.DB_CONNECTION}, new Object[]{
+                        fullBackupDir, jdbcConn});
             }
             else
             {
-               context = new DataRestoreContext(
-                        new String[] {DataRestoreContext.STORAGE_DIR}, 
-                        new Object[] {fullBackupDir});
+               context =
+                  new DataRestoreContext(new String[]{DataRestoreContext.STORAGE_DIR}, new Object[]{fullBackupDir});
             }
 
             for (Backupable component : backupable)
@@ -226,4 +226,13 @@
          }
       }
    }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public boolean isSameConfiguration()
+   {
+      return true;
+   }
 }

Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobRepositoryRestore.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobRepositoryRestore.java	2011-09-30 07:40:14 UTC (rev 5011)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobRepositoryRestore.java	2011-10-04 06:15:55 UTC (rev 5012)
@@ -16,8 +16,6 @@
  */
 package org.exoplatform.services.jcr.ext.backup.impl;
 
-
-
 import org.exoplatform.services.jcr.RepositoryService;
 import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
 import org.exoplatform.services.jcr.config.RepositoryEntry;
@@ -162,7 +160,7 @@
     *           will be generated the Throwable
     */
    protected void restoreRepository() throws RepositoryRestoreExeption, BackupOperationException,
-            ClassNotFoundException
+      ClassNotFoundException
    {
       List<WorkspaceEntry> originalWorkspaceEntrys = repositoryEntry.getWorkspaceEntries();
 
@@ -182,7 +180,7 @@
 
       //getting backup chail log to system workspace.
       BackupChainLog systemBackupChainLog = workspacesMapping.get(systemWorkspaceEntry.getName());
-      
+
       WorkspaceInitializerEntry wiEntry = getWorkspaceInitializerEntry(systemBackupChainLog);
 
       // set initializer
@@ -206,8 +204,15 @@
          WorkspaceEntry createdWorkspaceEntry = (WorkspaceEntry)wcf.getComponent(WorkspaceEntry.class);
          createdWorkspaceEntry.setInitializer(wieOriginal);
 
-         // save configuration to persistence (file or persister)
-         repositoryService.getConfig().retain();
+         // if same configuration is used, then no need to retain configuration. There is
+         // a common usecase, when no configuration persister is used, so configuration can't 
+         // be rewritten, but backup-restore cycles are always performed. This usecase is 
+         // correct if same configuration used. Otherwise exception will be thrown on retain.  
+         if (!isSameConfiguration())
+         {
+            // save configuration to persistence (file or persister)
+            repositoryService.getConfig().retain();
+         }
 
          for (WorkspaceEntry wsEntry : originalWorkspaceEntrys)
          {
@@ -270,8 +275,7 @@
     * @throws RepositoryConfigurationException 
     */
    protected void removeRepository(RepositoryService repositoryService, String repositoryName)
-      throws RepositoryException,
-      RepositoryConfigurationException
+      throws RepositoryException, RepositoryConfigurationException
    {
       ManageableRepository mr = null;
 
@@ -293,7 +297,7 @@
    }
 
    private WorkspaceInitializerEntry getWorkspaceInitializerEntry(BackupChainLog systemBackupChainLog)
-            throws BackupOperationException, ClassNotFoundException
+      throws BackupOperationException, ClassNotFoundException
    {
       String fullBackupPath = systemBackupChainLog.getJobEntryInfos().get(0).getURL().getPath();
 
@@ -305,20 +309,20 @@
             fullbackupType = systemBackupChainLog.getFullBackupType();
          }
          else if ((Class.forName(systemBackupChainLog.getFullBackupType())
-                  .equals(org.exoplatform.services.jcr.ext.backup.impl.rdbms.FullBackupJob.class)))
+            .equals(org.exoplatform.services.jcr.ext.backup.impl.rdbms.FullBackupJob.class)))
          {
             fullbackupType = systemBackupChainLog.getFullBackupType();
          }
          else
          {
             throw new BackupOperationException("Class  \"" + systemBackupChainLog.getFullBackupType()
-                     + "\" is not support as full backup.");
+               + "\" is not support as full backup.");
          }
       }
       catch (ClassNotFoundException e)
       {
          throw new BackupOperationException("Class \"" + systemBackupChainLog.getFullBackupType() + "\" is not found.",
-                  e);
+            e);
       }
 
       WorkspaceInitializerEntry wiEntry = new WorkspaceInitializerEntry();
@@ -329,19 +333,19 @@
 
          List<SimpleParameterEntry> wieParams = new ArrayList<SimpleParameterEntry>();
          wieParams.add(new SimpleParameterEntry(BackupWorkspaceInitializer.RESTORE_PATH_PARAMETER, (new File(
-                  fullBackupPath).getParent())));
+            fullBackupPath).getParent())));
 
          wiEntry.setParameters(wieParams);
       }
       else if ((Class.forName(fullbackupType)
-               .equals(org.exoplatform.services.jcr.ext.backup.impl.rdbms.FullBackupJob.class)))
+         .equals(org.exoplatform.services.jcr.ext.backup.impl.rdbms.FullBackupJob.class)))
       {
          // set the initializer RdbmsBackupWorkspaceInitializer
          wiEntry.setType(RdbmsBackupWorkspaceInitializer.class.getCanonicalName());
 
          List<SimpleParameterEntry> wieParams = new ArrayList<SimpleParameterEntry>();
          wieParams.add(new SimpleParameterEntry(RdbmsBackupWorkspaceInitializer.RESTORE_PATH_PARAMETER, (new File(
-                  fullBackupPath).getParent())));
+            fullBackupPath).getParent())));
 
          wiEntry.setParameters(wieParams);
       }
@@ -395,6 +399,14 @@
    }
 
    /**
+    * @return true, if configuration the same
+    */
+   public boolean isSameConfiguration()
+   {
+      return false;
+   }
+
+   /**
     * getRestoreException.
     * 
     * @return Throwable return the exception of repository restore.



More information about the exo-jcr-commits mailing list