[exo-jcr-commits] exo-jcr SVN: r3707 - jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Dec 22 06:34:50 EST 2010


Author: areshetnyak
Date: 2010-12-22 06:34:50 -0500 (Wed, 22 Dec 2010)
New Revision: 3707

Modified:
   jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupClientImpl.java
Log:
JCR-1502 : Bug in BackupClientImpl was fixed.

Modified: jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupClientImpl.java
===================================================================
--- jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupClientImpl.java	2010-12-22 11:33:16 UTC (rev 3706)
+++ jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupClientImpl.java	2010-12-22 11:34:50 UTC (rev 3707)
@@ -466,10 +466,11 @@
             String backupSetPath, boolean removeExists)
             throws IOException, BackupExecuteException
    {
+      BackupAgentResponse response = null;
+      String sURL = null;
+
       if (workspaceName != null)
       {
-         String sURL = null;
-         BackupAgentResponse response = null;
          if (config != null)
          {
             if (backupId != null )
@@ -511,38 +512,9 @@
 
             response = transport.executePOST(sURL, json.toString());
          }
-         else
-         {
-            if (backupId != null)
-            {
-               sURL =
-                        path + HTTPBackupAgent.Constants.BASE_URL + HTTPBackupAgent.Constants.OperationType.RESTORE
-                                 + "/" + backupId + "/" + removeExists;
-            }
-            else if (backupSetPath != null)
-            {
-               sURL =
-                        path + HTTPBackupAgent.Constants.BASE_URL
-                                 + HTTPBackupAgent.Constants.OperationType.RESTORE_BACKUP_SET + "/" + repositoryName
-                                 + "/" + backupSetPath + "/" + removeExists;
-            }
-
-            response = transport.executeGET(sURL);
-         }
-
-         if (response.getStatus() == Response.Status.OK.getStatusCode())
-         {
-            return "\nSuccessful : \n" + "\tstatus code = " + response.getStatus() + "\n";
-         }
-         else
-         {
-            return failureProcessing(response);
-         }
       }
-      else
+      else if (repositoryName != null)
       {
-         String sURL = null;
-         BackupAgentResponse response = null;
          if (config != null)
          {
             if (backupId != null)
@@ -586,35 +558,76 @@
    
             response = transport.executePOST(sURL, json.toString());
          } 
-         else
+      }
+      else
+      {
+         if (backupId != null)
          {
-            if (backupId != null)
+
+            //check is repository or workspace backup
+            boolean isRepository = true;
+
+            String lsURL =
+                     path + HTTPBackupAgent.Constants.BASE_URL
+                              + HTTPBackupAgent.Constants.OperationType.CURRENT_OR_COMPLETED_BACKUP_REPOSITORY_INFO
+                              + "/" + backupId;
+
+            BackupAgentResponse lResponse = transport.executeGET(lsURL);
+
+            if (lResponse.getStatus() != Response.Status.OK.getStatusCode())
             {
+
                sURL =
                         path + HTTPBackupAgent.Constants.BASE_URL
+                                 + HTTPBackupAgent.Constants.OperationType.CURRENT_OR_COMPLETED_BACKUP_INFO + "/"
+                                 + backupId;
+
+               lResponse = transport.executeGET(sURL);
+
+               if (lResponse.getStatus() == Response.Status.OK.getStatusCode())
+               {
+                  isRepository = false;
+               }
+               else
+               {
+                  return failureProcessing(lResponse);
+               }
+            }
+
+            if (isRepository)
+            {
+               sURL =
+                        path + HTTPBackupAgent.Constants.BASE_URL
                                  + HTTPBackupAgent.Constants.OperationType.RESTORE_REPOSITORY + "/" + backupId + "/"
                                  + removeExists;
             }
-            else if (backupSetPath != null)
+            else
             {
                sURL =
-                        path + HTTPBackupAgent.Constants.BASE_URL
-                                 + HTTPBackupAgent.Constants.OperationType.RESTORE_BACKUP_SET
-                                 + "/" + backupSetPath + "/" + removeExists;
+                        path + HTTPBackupAgent.Constants.BASE_URL + HTTPBackupAgent.Constants.OperationType.RESTORE
+                                 + "/" + backupId + "/" + removeExists;
             }
 
-            response = transport.executeGET(sURL);
          }
-
-         if (response.getStatus() == Response.Status.OK.getStatusCode())
+         else if (backupSetPath != null)
          {
-            return "\nSuccessful : \n" + "\tstatus code = " + response.getStatus() + "\n";
+            sURL =
+                     path + HTTPBackupAgent.Constants.BASE_URL
+                              + HTTPBackupAgent.Constants.OperationType.RESTORE_BACKUP_SET + "/" + backupSetPath + "/"
+                              + removeExists;
          }
-         else
-         {
-            return failureProcessing(response);
-         }
+
+         response = transport.executeGET(sURL);
       }
+
+      if (response.getStatus() == Response.Status.OK.getStatusCode())
+      {
+         return "\nSuccessful : \n" + "\tstatus code = " + response.getStatus() + "\n";
+      }
+      else
+      {
+         return failureProcessing(response);
+      }
    }
 
    /**



More information about the exo-jcr-commits mailing list