[exo-jcr-commits] exo-jcr SVN: r2131 - in jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup: impl and 2 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Mar 25 10:29:10 EDT 2010


Author: areshetnyak
Date: 2010-03-25 10:29:09 -0400 (Thu, 25 Mar 2010)
New Revision: 2131

Modified:
   jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/BackupManager.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/server/HTTPBackupAgent.java
   jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/bean/response/DetailedInfo.java
Log:
EXOJCR-549 : The implementation backup/restore whole repository in HTTPBackupAgent.

Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/BackupManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/BackupManager.java	2010-03-25 14:27:01 UTC (rev 2130)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/BackupManager.java	2010-03-25 14:29:09 UTC (rev 2131)
@@ -349,5 +349,15 @@
     *           return the current backup to repository 
     */
    RepositoryBackupChain findRepositoryBackup(String repository);
+   
+   /**
+    * Finding current backup by id.
+    *
+    * @param reposytore
+    *          String, the repository name
+    * @return RepositoryBackupChain
+    *           return the current backup to repository 
+    */
+   RepositoryBackupChain findRepositoryBackupId(String id);
 
 }

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-03-25 14:27:01 UTC (rev 2130)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java	2010-03-25 14:29:09 UTC (rev 2131)
@@ -1498,8 +1498,26 @@
       return null;
    }
 
+   /**
+    * {@inheritDoc}
+    */
    public Set<RepositoryBackupChain> getCurrentRepositoryBackups()
    {
       return currentRepositoryBackups;
    }
+
+   /**
+    * {@inheritDoc}
+    */
+   public RepositoryBackupChain findRepositoryBackupId(String backupId)
+   {
+      Iterator<RepositoryBackupChain> it = currentRepositoryBackups.iterator();
+      while (it.hasNext())
+      {
+         RepositoryBackupChain chain = it.next();
+         if (backupId.equals(chain.getBackupId()))
+            return chain;
+      }
+      return null;
+   }
 }

Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java	2010-03-25 14:27:01 UTC (rev 2130)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java	2010-03-25 14:29:09 UTC (rev 2131)
@@ -825,14 +825,14 @@
    }
 
    /**
-    * Will be returned the list short info of current and completed backups .
+    * Will be returned the list short info of current and completed repository backups .
     * 
     * @return Response return the response
     */
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @RolesAllowed("administrators")
-   @Path("/info/backup/repository")
+   @Path("/info/backup-repository")
    public Response infoBackupRepository()
    {
       try
@@ -843,7 +843,7 @@
             list.add(new ShortInfo(ShortInfo.CURRENT, chain));
 
          for (RepositoryBackupChainLog chainLog : backupManager.getRepositoryBackupsLogs())
-            if (backupManager.findBackup(chainLog.getBackupId()) == null)
+            if (backupManager.findRepositoryBackupId(chainLog.getBackupId()) == null)
                list.add(new ShortInfo(ShortInfo.COMPLETED, chainLog));
 
          ShortInfoList shortInfoList = new ShortInfoList(list);
@@ -852,10 +852,10 @@
       }
       catch (Throwable e)
       {
-         log.error("Can not get information about current or completed backups", e);
+         log.error("Can not get information about current or completed reposioty backups", e);
 
          return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
-            "Can not get information about current or completed backups" + e.getMessage()).type(MediaType.TEXT_PLAIN)
+            "Can not get information about current or completed repository backups" + e.getMessage()).type(MediaType.TEXT_PLAIN)
             .cacheControl(noCache).build();
       }
    }
@@ -907,7 +907,55 @@
             MediaType.TEXT_PLAIN).cacheControl(noCache).build();
       }
    }
+   
+   /**
+    * Will be returned the detailed info of current or completed repository backup by 'id'.
+    * 
+    * @param id
+    *          String, the identifier to repository backup
+    * @return Response return the response
+    */
+   @GET
+   @Produces(MediaType.APPLICATION_JSON)
+   @RolesAllowed("administrators")
+   @Path("/info/backup-repository/{id}")
+   public Response infoBackupRepositoryId(@PathParam("id") String id)
+   {
+      try
+      {
+         RepositoryBackupChain current = backupManager.findRepositoryBackupId(id);
 
+         if (current != null)
+         {
+            DetailedInfo info = new DetailedInfo(DetailedInfo.CURRENT, current);
+            return Response.ok(info).cacheControl(noCache).build();
+         }
+
+         BackupChainLog completed = null;
+
+         for (BackupChainLog chainLog : backupManager.getBackupsLogs())
+            if (id.equals(chainLog.getBackupId()))
+               completed = chainLog;
+
+         if (completed != null)
+         {
+            DetailedInfo info = new DetailedInfo(DetailedInfo.COMPLETED, completed);
+            return Response.ok(info).cacheControl(noCache).build();
+         }
+
+         return Response.status(Response.Status.NOT_FOUND).entity("No current or completed backup with 'id' " + id)
+            .type(MediaType.TEXT_PLAIN).cacheControl(noCache).build();
+      }
+      catch (Throwable e)
+      {
+         log.error("Can not get information about current or completed backup with 'id' " + id, e);
+
+         return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
+            "Can not get information about current or completed backup with 'id' " + id + " : " + e.getMessage()).type(
+            MediaType.TEXT_PLAIN).cacheControl(noCache).build();
+      }
+   }
+
    /**
     * Will be returned the list short info of current backups .
     * 
@@ -939,7 +987,39 @@
             noCache).build();
       }
    }
+   
+   /**
+    * Will be returned the list short info of current backups .
+    * 
+    * @return Response return the response
+    */
+   @GET
+   @Produces(MediaType.APPLICATION_JSON)
+   @RolesAllowed("administrators")
+   @Path("/info/backup-repository/current")
+   public Response infoRepositoryBackupCurrent()
+   {
+      try
+      {
+         List<ShortInfo> list = new ArrayList<ShortInfo>();
 
+         for (RepositoryBackupChain chain : backupManager.getCurrentRepositoryBackups())
+            list.add(new ShortInfo(ShortInfo.CURRENT, chain));
+
+         ShortInfoList shortInfoList = new ShortInfoList(list);
+
+         return Response.ok(shortInfoList).cacheControl(noCache).build();
+      }
+      catch (Throwable e)
+      {
+         log.error("Can not get information about current repositorty backups", e);
+
+         return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
+            "Can not get information about current backups" + e.getMessage()).type(MediaType.TEXT_PLAIN).cacheControl(
+            noCache).build();
+      }
+   }
+
    /**
     * Will be returned the list short info of completed backups .
     * 

Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/bean/response/DetailedInfo.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/bean/response/DetailedInfo.java	2010-03-25 14:27:01 UTC (rev 2130)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/bean/response/DetailedInfo.java	2010-03-25 14:29:09 UTC (rev 2131)
@@ -20,6 +20,7 @@
 
 import org.exoplatform.services.jcr.ext.backup.BackupChain;
 import org.exoplatform.services.jcr.ext.backup.BackupChainLog;
+import org.exoplatform.services.jcr.ext.backup.RepositoryBackupChain;
 import org.exoplatform.services.jcr.ext.backup.RepositoryBackupChainLog;
 import org.exoplatform.services.jcr.ext.backup.server.bean.BackupConfigBean;
 
@@ -63,6 +64,20 @@
       super(type, chain);
       this.backupConfig = new BackupConfigBean(chain.getBackupConfig());
    }
+   
+   /**
+    * DetailedInfo constructor.
+    * 
+    * @param type
+    *          int, the type of detailed info (current or completed)
+    * @param chain
+    *          backupChain
+    */
+   public DetailedInfo(int type, RepositoryBackupChain chain)
+   {
+      super(type, chain);
+      this.backupConfig = new BackupConfigBean(chain.getBackupConfig());
+   }
 
    /**
     * DetailedInfo constructor.



More information about the exo-jcr-commits mailing list