[exo-jcr-commits] exo-jcr SVN: r3305 - in jcr/branches/1.12.x: exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Oct 20 09:24:48 EDT 2010


Author: tolusha
Date: 2010-10-20 09:24:47 -0400 (Wed, 20 Oct 2010)
New Revision: 3305

Modified:
   jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupClient.java
   jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupClientImpl.java
   jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupConsole.java
   jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/ClientTransportImpl.java
   jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/RestRepositoryService.java
   jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/backup/backup-client.xml
Log:
JCR-1459: Whole Repository backup support in Backup Console tool

Modified: jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupClient.java
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupClient.java	2010-10-20 08:10:23 UTC (rev 3304)
+++ jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupClient.java	2010-10-20 13:24:47 UTC (rev 3305)
@@ -31,72 +31,108 @@
 {
 
    /**
-    * Start Backup.
+    * Start backup of repository or workspace.
+    * If workspaceName is 'null', then repository backup will be started. 
     * 
-    * @param repositoryName String, the repository name.
-    * @param workspaceName String, the workspace name.
-    * @param backupDir path to backup folder on remote server.
-    * @return String result.
-    * @throws IOException transport exception.
-    * @throws BackupExecuteException backup client internal exception.
+    * @param repositoryName 
+    *          String, the repository name.
+    * @param workspaceName 
+    *          String, the workspace name.
+    * @param backupDir 
+    *          path to backup folder on remote server
+    * @return String 
+    *       result
+    * @throws IOException 
+    *          transport exception.
+    * @throws BackupExecuteException 
+    *          backup client internal exception.
     */
    String startBackUp(String repositoryName, String workspaceName, String backupDir) throws IOException,
       BackupExecuteException;
 
    /**
-    * Start Incremental Backup.
+    * Start Incremental Backup of repository or workspace.
+    * If workspaceName is 'null', then repository backup will be started.
     * 
-    * @param repositoryName String, the repository name.
-    * @param workspaceName String, the workspace name.
-    * @param incr incemental job period.
-    * @param backupDir path to backup folder on remote server.
-    * @return String result.
-    * @throws IOException transport exception.
-    * @throws BackupExecuteException backup client internal exception.
+    * @param repositoryName 
+    *          String, the repository name
+    * @param workspaceName 
+    *          String, the workspace name
+    * @param incr 
+    *       incremental job period.
+    * @param backupDir 
+    *          path to backup folder on remote server
+    * @return String 
+    *       result
+    * @throws IOException 
+    *          transport exception
+    * @throws BackupExecuteException 
+    *          backup client internal exception
     */
    String startIncrementalBackUp(String repositoryName, String workspaceName, String backupDir, long incr)
       throws IOException, BackupExecuteException;
 
    /**
-    * Get Status.
+    * Get Status of backup.
     * 
-    * @param backupId the backup identifier.
-    * @return String result.
-    * @throws IOException transport exception.
-    * @throws BackupExecuteException backup client internal exception.
+    * @param backupId 
+    *          the backup identifier.
+    * @return String 
+    *          result.
+    * @throws IOException 
+    *          transport exception.
+    * @throws BackupExecuteException 
+    *          backup client internal exception.
     */
    String status(String backupId) throws IOException, BackupExecuteException;
 
    /**
     * Get information about backup service.
     * 
-    * @return String result.
-    * @throws IOException transport exception.
-    * @throws BackupExecuteException backup client internal exception.
+    * @return String 
+    *          result
+    * @throws IOException 
+    *          transport exception
+    * @throws BackupExecuteException 
+    *          backup client internal exception
     */
    String info() throws IOException, BackupExecuteException;
 
    /**
-    * Get information about current restores.
+    * Get information about current restores of repository or workspace.
+    * If workspaceName is 'null', then will be get status of repository backup.
     * 
-    * @param repositoryName String, the repository name.
-    * @param workspaceName String, the workspace name.
-    * @return String result.
-    * @throws IOException transport exception.
-    * @throws BackupExecuteException backup client internal exception.
+    * @param repositoryName 
+    *          String, the repository name
+    * @param workspaceName 
+    *          String, the workspace name
+    * @return String 
+    *          result
+    * @throws IOException 
+    *          transport exception
+    * @throws BackupExecuteException 
+    *          backup client internal exception
     */
    String restores(String repositoryName, String workspaceName) throws IOException, BackupExecuteException;
 
    /**
-    * Restore repository from backup file.
+    * Restore repository or workspace from backup file.
+    * If workspaceName is 'null', then will be run restore of repository.
     * 
-    * @param repositoryName String, the repository name.
-    * @param workspaceName String, the workspace name.
-    * @param backupId the backup identifier.
-    * @param config InputStream contains workspace configuration.
-    * @return String result.
-    * @throws IOException transport exception.
-    * @throws BackupExecuteException backup client internal exception.
+    * @param repositoryName 
+    *          String, the repository name
+    * @param workspaceName 
+    *          String, the workspace name
+    * @param backupId 
+    *          the backup identifier
+    * @param config 
+    *          InputStream contains workspace configuration
+    * @return String 
+    *          result
+    * @throws IOException 
+    *          transport exception
+    * @throws BackupExecuteException 
+    *          backup client internal exception
     */
    String restore(String repositoryName, String workspaceName, String backupId, InputStream config) throws IOException,
       BackupExecuteException;
@@ -104,22 +140,33 @@
    /**
     * Stop backup.
     * 
-    * @param backupId the backup identifier.
-    * @return String result.
-    * @throws IOException transport exception.
-    * @throws BackupExecuteException backup client internal exception.
+    * @param backupId 
+    *          the backup identifier
+    * @return String 
+    *          result
+    * @throws IOException 
+    *          transport exception
+    * @throws BackupExecuteException 
+    *          backup client internal exception
     */
    String stop(String backupId) throws IOException, BackupExecuteException;
 
    /**
-    * Drop backup.
+    * Drop workspace or repository.
+    * If workspaceName is 'null', then repository will be dropped.
     * 
-    * @param forceClose force sessions close on droped workspace.
-    * @param repositoryName String, the repository name.
-    * @param workspaceName String, the workspace name.
-    * @return String result.
-    * @throws IOException transport exception.
-    * @throws BackupExecuteException backup client internal exception.
+    * @param forceClose 
+    *       force sessions close on repository or workspace
+    * @param repositoryName 
+    *          String, the repository name
+    * @param workspaceName 
+    *          String, the workspace name
+    * @return String 
+    *          result
+    * @throws IOException 
+    *          transport exception
+    * @throws BackupExecuteException 
+    *          backup client internal exception
     */
    String drop(boolean forceClose, String repositoryName, String workspaceName) throws IOException,
       BackupExecuteException;
@@ -127,18 +174,24 @@
    /**
     * Get information about the current backups (in progress).
     *
-    * @return String result
-    * @throws IOException
-    * @throws BackupExecuteException
+    * @return String 
+    *          result
+    * @throws IOException 
+    *          transport exception
+    * @throws BackupExecuteException 
+    *          backup client internal exception
     */
    String list() throws IOException, BackupExecuteException;
 
    /**
     * Get information about the completed (ready to restore) backups.
     *
-    * @return String result
-    * @throws IOException
-    * @throws BackupExecuteException
+    * @return String 
+    *          result
+    * @throws IOException 
+    *          transport exception
+    * @throws BackupExecuteException 
+    *          backup client internal exception
     */
    String listCompleted() throws IOException, BackupExecuteException;
 

Modified: jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupClientImpl.java
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupClientImpl.java	2010-10-20 08:10:23 UTC (rev 3304)
+++ jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupClientImpl.java	2010-10-20 13:24:47 UTC (rev 3305)
@@ -18,12 +18,22 @@
  */
 package org.exoplatform.jcr.backupconsole;
 
+import java.io.ByteArrayInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
+import javax.ws.rs.core.Response;
+
 import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
 import org.exoplatform.services.jcr.config.RepositoryEntry;
 import org.exoplatform.services.jcr.config.RepositoryServiceConfiguration;
 import org.exoplatform.services.jcr.config.WorkspaceEntry;
 import org.exoplatform.services.jcr.ext.backup.BackupJob;
 import org.exoplatform.services.jcr.ext.backup.BackupManager;
+import org.exoplatform.services.jcr.ext.backup.RepositoryBackupChain;
+import org.exoplatform.services.jcr.ext.backup.impl.JobRepositoryRestore;
 import org.exoplatform.services.jcr.ext.backup.impl.JobWorkspaceRestore;
 import org.exoplatform.services.jcr.ext.backup.server.HTTPBackupAgent;
 import org.exoplatform.services.jcr.ext.backup.server.bean.BackupConfigBean;
@@ -31,6 +41,7 @@
 import org.exoplatform.services.jcr.ext.backup.server.bean.response.DetailedInfo;
 import org.exoplatform.services.jcr.ext.backup.server.bean.response.ShortInfo;
 import org.exoplatform.services.jcr.ext.backup.server.bean.response.ShortInfoList;
+import org.exoplatform.services.jcr.ext.repository.RestRepositoryService;
 import org.exoplatform.ws.frameworks.json.JsonHandler;
 import org.exoplatform.ws.frameworks.json.JsonParser;
 import org.exoplatform.ws.frameworks.json.impl.BeanBuilder;
@@ -44,550 +55,1080 @@
 import org.jibx.runtime.IUnmarshallingContext;
 import org.jibx.runtime.JiBXException;
 
-import java.io.ByteArrayInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-
-import javax.ws.rs.core.Response;
-
 /**
  * Created by The eXo Platform SAS. <br/>Date:
  * 
  * @author <a href="karpenko.sergiy at gmail.com">Karpenko Sergiy</a>
  * @version $Id: BackupClientImpl.java 111 2008-11-11 11:11:11Z serg $
  */
-public class BackupClientImpl implements BackupClient {
+public class BackupClientImpl
+   implements BackupClient
+{
 
-  /**
-   * Block size.
-   */
-  private static final int   BLOCK_SIZE = 1024;
+   /**
+    * Block size.
+    */
+   private static final int BLOCK_SIZE = 1024;
 
-  /**
-   * Client transport.
-   */
-  private ClientTransport transport;
-  
-  /**
-   * The URL path.
-   */
-  private final String path;
+   /**
+    * Client transport.
+    */
+   private ClientTransport transport;
 
-  /**
-   * User login.
-   */
-  private final String    userName;
+   /**
+    * The URL path.
+    */
+   private final String path;
 
-  /**
-   * User password.
-   */
-  private final String    pass;
-  
-  /**
-   * Constructor.
-   * 
-   * @param transport ClientTransport implementation.
-   * @param login user login.
-   * @param pass user password.
-   */
-  public BackupClientImpl(ClientTransport transport, String login, String pass, String urlPath) {
-    this.transport = transport;
-    this.userName = login;
-    this.pass = pass;
-    
-    if (urlPath == null)
-      path = "/rest";
-    else
-      path = urlPath;
-  }
-  
-  /**
-   * {@inheritDoc}
-   */
-  public String startBackUp(String repositoryName, String workspaceName, String backupDir) throws IOException, BackupExecuteException {
-    String sURL = path + HTTPBackupAgent.Constants.BASE_URL + 
-                  HTTPBackupAgent.Constants.OperationType.START_BACKUP +
-                  "/" + repositoryName +
-                  "/" + workspaceName;
+   /**
+    * User login.
+    */
+   private final String userName;
 
-    BackupConfigBean bean = new BackupConfigBean(BackupManager.FULL_BACKUP_ONLY,
-                                                 backupDir);
-    
-    JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
-    JsonValue json;
-    try {
-      json = generatorImpl.createJsonObject(bean);
-    } catch (JsonException e) {
-      throw new BackupExecuteException("Can not get json from  : " + bean.getClass().toString(), e);
-    }
-        
-    BackupAgentResponse response  = transport.executePOST(sURL, json.toString());
-    
-    if (response.getStatus() == Response.Status.OK.getStatusCode()) {
-      return "\nSuccessful : \n" +
-      		   "\tstatus code = " + response.getStatus() + "\n";
-    } else {
-      return failureProcessing(response);
-    } 
-  }
+   /**
+    * User password.
+    */
+   private final String pass;
 
-  /**
-   * {@inheritDoc}
-   */
-  public String startIncrementalBackUp(String repositoryName, String workspaceName, String backupDir, long incr) throws IOException,
-                                                                                 BackupExecuteException {
-    String sURL = path + HTTPBackupAgent.Constants.BASE_URL + 
-                  HTTPBackupAgent.Constants.OperationType.START_BACKUP +
-                  "/" + repositoryName +
-                  "/" + workspaceName;
+   /**
+    * Constructor.
+    * 
+    * @param transport ClientTransport implementation.
+    * @param login user login.
+    * @param pass user password.
+    */
+   public BackupClientImpl(ClientTransport transport, String login, String pass, String urlPath)
+   {
+      this.transport = transport;
+      this.userName = login;
+      this.pass = pass;
 
-    BackupConfigBean bean = new BackupConfigBean(BackupManager.FULL_AND_INCREMENTAL,
-                                                 backupDir,
-                                                 incr);
-    
-    JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
-    JsonValue json;
-    try {
-      json = generatorImpl.createJsonObject(bean);
-    } catch (JsonException e) {
-      throw new BackupExecuteException("Can not get json from  : " + bean.getClass().toString(), e);
-    }
-        
-    BackupAgentResponse response  = transport.executePOST(sURL, json.toString());
-    
-    if (response.getStatus() == Response.Status.OK.getStatusCode()) {
-      return "\nSuccessful : \n" +
-             "\tstatus code = " + response.getStatus() + "\n";
-    } else {
-      return failureProcessing(response);
-    } 
-  }
+      if (urlPath == null)
+         path = "/rest";
+      else
+         path = urlPath;
+   }
 
-  /**
-   * {@inheritDoc}
-   */
-  public String status(String backupId) throws IOException, BackupExecuteException {
-    String sURL = path + HTTPBackupAgent.Constants.BASE_URL + 
-                  HTTPBackupAgent.Constants.OperationType.CURRENT_OR_COMPLETED_BACKUP_INFO + 
-                  "/" + backupId;
+   /**
+    * {@inheritDoc}
+    */
+   public String startBackUp(String repositoryName, String workspaceName, String backupDir) throws IOException,
+            BackupExecuteException
+   {
+      if (workspaceName != null)
+      {
+         String sURL =
+                  path + HTTPBackupAgent.Constants.BASE_URL + HTTPBackupAgent.Constants.OperationType.START_BACKUP
+                           + "/" + repositoryName + "/" + workspaceName;
 
-    BackupAgentResponse response  = transport.executeGET(sURL);
-    
-    if (response.getStatus() == Response.Status.OK.getStatusCode()) {
-      DetailedInfo info;
-      try {
-        info = (DetailedInfo) getObject(DetailedInfo.class, response.getResponseData());
-      } catch (Exception e) {
-        throw new  RuntimeException("Can not get DetailedInfo from responce.", e);
+         BackupConfigBean bean = new BackupConfigBean(BackupManager.FULL_BACKUP_ONLY, backupDir);
+
+         JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
+         JsonValue json;
+         try
+         {
+            json = generatorImpl.createJsonObject(bean);
+         }
+         catch (JsonException e)
+         {
+            throw new BackupExecuteException("Can not get json from  : " + bean.getClass().toString(), e);
+         }
+
+         BackupAgentResponse response = transport.executePOST(sURL, json.toString());
+
+         if (response.getStatus() == Response.Status.OK.getStatusCode())
+         {
+            return "\nSuccessful : \n" + "\tstatus code = " + response.getStatus() + "\n";
+         }
+         else
+         {
+            return failureProcessing(response);
+         }
       }
-      
-      if (info.getType() == DetailedInfo.COMPLETED) {
-        String result = "\nThe completed (ready to restore) backup information : \n";
-      
-        BackupConfigBean configBean = info.getBackupConfig();
-        
-        result  += ("\t\tbackup id               : " + info.getBackupId() + "\n" 
-                  + "\t\tbackup folder           : " + configBean.getBackupDir() + "\n" 
-                  + "\t\trepository name         : " + info.getRepositoryName() + "\n"
-                  + "\t\tworkspace name          : " + info.getWorkspaceName() + "\n"
-                  + "\t\tbackup type             : " + (configBean.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremetal" : "full only") + "\n"
-                  + "\t\tstarted time            : " + info.getStartedTime() + "\n"
-                  + (info.getFinishedTime().equals("") ? "\n" : 
-                    "\t\tfinished time           : " + info.getFinishedTime() + "\n\n"));
-        
-        return result;
-      } else {
-        String result = "\nThe current backup information : \n";
-        
-        BackupConfigBean configBean = info.getBackupConfig();
-        
-        result  += ("\t\tbackup id                : " + info.getBackupId() + "\n" 
-                  + "\t\tbackup folder            : " + configBean.getBackupDir() + "\n" 
-                  + "\t\trepository name          : " + info.getRepositoryName() + "\n"
-                  + "\t\tworkspace name           : " + info.getWorkspaceName() + "\n"
-                  + "\t\tbackup type              : " + (configBean.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremetal" : "full only") + "\n"
-                  + "\t\tfull backup state        : " + getState(info.getState())) + "\n"
-                  + (info.getBackupType() == BackupManager.FULL_BACKUP_ONLY ? "" : 
-                    "\t\tincremental backup state : " +  "working" + "\n")
-                  + "\t\tstarted time             : " + info.getStartedTime() + "\n"
-                  + (info.getFinishedTime().equals("") ? "\n" : 
-                    "\t\tfinished time            : " + info.getFinishedTime() + "\n\n");
-        
-        return result;
+      else
+      {
+         String sURL =
+                  path + HTTPBackupAgent.Constants.BASE_URL
+                           + HTTPBackupAgent.Constants.OperationType.START_BACKUP_REPOSITORY + "/" + repositoryName;
+
+         BackupConfigBean bean = new BackupConfigBean(BackupManager.FULL_BACKUP_ONLY, backupDir);
+
+         JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
+         JsonValue json;
+         try
+         {
+            json = generatorImpl.createJsonObject(bean);
+         }
+         catch (JsonException e)
+         {
+            throw new BackupExecuteException("Can not get json from  : " + bean.getClass().toString(), e);
+         }
+
+         BackupAgentResponse response = transport.executePOST(sURL, json.toString());
+
+         if (response.getStatus() == Response.Status.OK.getStatusCode())
+         {
+            return "\nSuccessful : \n" + "\tstatus code = " + response.getStatus() + "\n";
+         }
+         else
+         {
+            return failureProcessing(response);
+         }
       }
-    } else {
-      return failureProcessing(response);
-    }
-  }
+   }
 
-  /**
-   * {@inheritDoc}
-   */
-  public String stop(String backupId) throws IOException, BackupExecuteException {
-    String sURL = path + HTTPBackupAgent.Constants.BASE_URL + 
-                  HTTPBackupAgent.Constants.OperationType.STOP_BACKUP + 
-                  "/" + backupId;
+   /**
+    * {@inheritDoc}
+    */
+   public String startIncrementalBackUp(String repositoryName, String workspaceName, String backupDir, long incr)
+            throws IOException, BackupExecuteException
+   {
+      if (workspaceName != null)
+      {
+         String sURL =
+                  path + HTTPBackupAgent.Constants.BASE_URL + HTTPBackupAgent.Constants.OperationType.START_BACKUP
+                           + "/" + repositoryName + "/" + workspaceName;
 
-    BackupAgentResponse response  = transport.executeGET(sURL);
-    
-    if (response.getStatus() == Response.Status.OK.getStatusCode()) {
-      return "\nSuccessful : \n" +
-             "\tstatus code = " + response.getStatus() + "\n";
-    } else {
-      return failureProcessing(response);
-    } 
-  }
+         BackupConfigBean bean = new BackupConfigBean(BackupManager.FULL_AND_INCREMENTAL, backupDir, incr);
 
-  /**
-   * {@inheritDoc}
-   */
-  public String restore(String repositoryName, String workspaceName, String backupId, InputStream config) throws IOException,
-                                                                                 BackupExecuteException {
-    String sURL = path + HTTPBackupAgent.Constants.BASE_URL + 
-                  HTTPBackupAgent.Constants.OperationType.RESTORE +
-                  "/" + repositoryName +
-                  "/" + backupId;
+         JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
+         JsonValue json;
+         try
+         {
+            json = generatorImpl.createJsonObject(bean);
+         }
+         catch (JsonException e)
+         {
+            throw new BackupExecuteException("Can not get json from  : " + bean.getClass().toString(), e);
+         }
 
-    
-    WorkspaceEntry wEntry = null;
-    try {
-      wEntry = getWorkspaceEntry(config, repositoryName, workspaceName);
-    } catch (Throwable e) {
-     throw new BackupExecuteException("Can not get WorkspaceEntry for workspace '" + workspaceName + "' from config.", e); 
-    }
-    
-    JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
-    JsonValue json;
-    
-    try {
-      json = generatorImpl.createJsonObject(wEntry);
-    } catch (JsonException e) {
-      throw new BackupExecuteException("Can not get json from  : " + wEntry.getClass().toString(), e);
-    }
-        
-    BackupAgentResponse response  = transport.executePOST(sURL, json.toString());
-    
-    if (response.getStatus() == Response.Status.OK.getStatusCode()) {
-      return "\nSuccessful : \n" +
-             "\tstatus code = " + response.getStatus() + "\n";
-    } else {
-      return failureProcessing(response);
-    }
-  }
+         BackupAgentResponse response = transport.executePOST(sURL, json.toString());
 
-  /**
-   * {@inheritDoc}
-   */
-  public String drop(boolean forceClose, String repositoryName, String workspaceName) throws IOException,
-                                                         BackupExecuteException {
-    String sURL = path + HTTPBackupAgent.Constants.BASE_URL + 
-                  HTTPBackupAgent.Constants.OperationType.DROP_WORKSPACE +
-                  "/" + repositoryName +
-                  "/" + workspaceName + 
-                  "/" + forceClose;
+         if (response.getStatus() == Response.Status.OK.getStatusCode())
+         {
+            return "\nSuccessful : \n" + "\tstatus code = " + response.getStatus() + "\n";
+         }
+         else
+         {
+            return failureProcessing(response);
+         }
+      }
+      else
+      {
+         String sURL =
+                  path + HTTPBackupAgent.Constants.BASE_URL
+                           + HTTPBackupAgent.Constants.OperationType.START_BACKUP_REPOSITORY + "/" + repositoryName;
 
-    BackupAgentResponse response  = transport.executeGET(sURL);
-    
-    if (response.getStatus() == Response.Status.OK.getStatusCode()) {
-      return "\nSuccessful : \n" +
-             "\tstatus code = " + response.getStatus() + "\n";
-    } else {
-      return failureProcessing(response);
-    } 
-  }
+         BackupConfigBean bean = new BackupConfigBean(BackupManager.FULL_AND_INCREMENTAL, backupDir, incr);
 
-  /**
-   * {@inheritDoc}
-   */
-  public String info() throws IOException, BackupExecuteException {
-    String sURL = path + HTTPBackupAgent.Constants.BASE_URL + HTTPBackupAgent.Constants.OperationType.BACKUP_SERVICE_INFO;
-    BackupAgentResponse response = transport.executeGET(sURL);
-    
-    if (response.getStatus() == Response.Status.OK.getStatusCode()) {
-      BackupServiceInfoBean info;
-      try {
-        info = (BackupServiceInfoBean) getObject(BackupServiceInfoBean.class, response.getResponseData());
-      } catch (Exception e) {
-        throw new  RuntimeException("Can not get BackupServiceInfoBean from responce.", e);
+         JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
+         JsonValue json;
+         try
+         {
+            json = generatorImpl.createJsonObject(bean);
+         }
+         catch (JsonException e)
+         {
+            throw new BackupExecuteException("Can not get json from  : " + bean.getClass().toString(), e);
+         }
+
+         BackupAgentResponse response = transport.executePOST(sURL, json.toString());
+
+         if (response.getStatus() == Response.Status.OK.getStatusCode())
+         {
+            return "\nSuccessful : \n" + "\tstatus code = " + response.getStatus() + "\n";
+         }
+         else
+         {
+            return failureProcessing(response);
+         }
       }
-      
-      String result = "\nThe backup service information : \n"
-                      + "\tfull backup type               : " + info.getFullBackupType() + "\n"
-                      + "\tincremetal backup type         : " + info.getIncrementalBackupType() + "\n"
-                      + "\tbackup log folder              : " + info.getBackupLogDir() + "\n"
-                      + "\tdefault incremental job period : " + info.getDefaultIncrementalJobPeriod() + "\n\n";
-      
-      return result;
-    } else {
-      return failureProcessing(response);
-    } 
-  }
 
-  /**
-   * {@inheritDoc}
-   */
-  public String list() throws IOException, BackupExecuteException {
-    String sURL = path + HTTPBackupAgent.Constants.BASE_URL + HTTPBackupAgent.Constants.OperationType.CURRENT_BACKUPS_INFO;
-    BackupAgentResponse response = transport.executeGET(sURL);
-    
-    if (response.getStatus() == Response.Status.OK.getStatusCode()) {
-      ShortInfoList infoList;
-      try {
-        infoList = (ShortInfoList) getObject(ShortInfoList.class, response.getResponseData());
-      } catch (Exception e) {
-        throw new  RuntimeException("Can not get ShortInfoList from responce.", e);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public String status(String backupId) throws IOException, BackupExecuteException
+   {
+
+      String sURL =
+               path + HTTPBackupAgent.Constants.BASE_URL
+                        + HTTPBackupAgent.Constants.OperationType.CURRENT_OR_COMPLETED_BACKUP_REPOSITORY_INFO + "/"
+                        + backupId;
+
+      BackupAgentResponse response = transport.executeGET(sURL);
+
+      if (response.getStatus() != Response.Status.OK.getStatusCode())
+      {
+
+         sURL =
+                  path + HTTPBackupAgent.Constants.BASE_URL
+                           + HTTPBackupAgent.Constants.OperationType.CURRENT_OR_COMPLETED_BACKUP_INFO + "/" + backupId;
+
+         response = transport.executeGET(sURL);
       }
-      
-      String result = "\nThe current backups information : \n";
-      
-      if (infoList.getBackups().size() == 0)
-        result += "\tNo active backups.\n\n";
-      
-      int count = 1;
-      for (ShortInfo shortInfo : infoList.getBackups()) {
-        result += "\t" + count + ") Backup with id " + shortInfo.getBackupId()  + " :\n";
-        
-        result  += ("\t\trepository name           : " + shortInfo.getRepositoryName() + "\n"
-                  + "\t\tworkspace name            : " + shortInfo.getWorkspaceName() + "\n"
-                  + "\t\tbackup type               : " + (shortInfo.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremetal" : "full only") + "\n"  
-                  + "\t\tfull backup state         : " + getState(shortInfo.getState())) + "\n"
-                  + (shortInfo.getBackupType() == BackupManager.FULL_BACKUP_ONLY ? "" : 
-                    "\t\tincremental backup state  : " +  "working" + "\n")
-                  + "\t\tstarted time              : " + shortInfo.getStartedTime() + "\n"
-                  + (shortInfo.getFinishedTime().equals("") ? "" : 
-                    "\t\tfinished time             : " + shortInfo.getFinishedTime() + "\n");
-        count++;
-      }   
-      
-      return result;
-    } else {
-      return failureProcessing(response);
-    }
-  }
 
-  /**
-   * {@inheritDoc}
-   */
-  public String listCompleted() throws IOException, BackupExecuteException {
-    String sURL = path + HTTPBackupAgent.Constants.BASE_URL + HTTPBackupAgent.Constants.OperationType.COMPLETED_BACKUPS_INFO;
-    BackupAgentResponse response = transport.executeGET(sURL);
-    
-    if (response.getStatus() == Response.Status.OK.getStatusCode()) {
-      ShortInfoList infoList;
-      try {
-        infoList = (ShortInfoList) getObject(ShortInfoList.class, response.getResponseData());
-        new String(response.getResponseData());
-      } catch (Exception e) {e.printStackTrace();
-        throw new  RuntimeException("Can not get ShortInfoList from responce.", e);
+      if (response.getStatus() == Response.Status.OK.getStatusCode())
+      {
+         DetailedInfo info;
+         try
+         {
+            info = (DetailedInfo) getObject(DetailedInfo.class, response.getResponseData());
+         }
+         catch (Exception e)
+         {
+            throw new RuntimeException("Can not get DetailedInfo from responce.", e);
+         }
+
+         if (info.getType() == DetailedInfo.COMPLETED)
+         {
+            String result = "\nThe completed (ready to restore) backup information : \n";
+
+            BackupConfigBean configBean = info.getBackupConfig();
+
+            result +=
+                     ("\t\tbackup id               : "
+                              + info.getBackupId()
+                              + "\n"
+                              + "\t\tbackup folder           : "
+                              + configBean.getBackupDir()
+                              + "\n"
+                              + "\t\trepository name         : "
+                              + info.getRepositoryName()
+                              + "\n"
+                              + (info.getWorkspaceName().equals("") ? "" : "\t\tworkspace name          : "
+                                       + info.getWorkspaceName() + "\n")
+                              + "\t\tbackup type             : "
+                              + (configBean.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremetal"
+                                       : "full only") + "\n" + "\t\tstarted time            : " + info.getStartedTime()
+                              + "\n" + (info.getFinishedTime().equals("") ? "\n" : "\t\tfinished time           : "
+                              + info.getFinishedTime() + "\n\n"));
+
+            return result;
+         }
+         else
+         {
+            String result = "\nThe current backup information : \n";
+
+            BackupConfigBean configBean = info.getBackupConfig();
+
+            result +=
+                     ("\t\tbackup id                : "
+                              + info.getBackupId()
+                              + "\n"
+                              + "\t\tbackup folder            : "
+                              + configBean.getBackupDir()
+                              + "\n"
+                              + "\t\trepository name          : "
+                              + info.getRepositoryName()
+                              + "\n"
+                              + (info.getWorkspaceName().equals("") ? "" : "\t\tworkspace name           : "
+                                       + info.getWorkspaceName() + "\n")
+                              + "\t\tbackup type              : "
+                              + (configBean.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremetal"
+                                       : "full only") + "\n" + "\t\tfull backup state        : " + getState(info
+                              .getState()))
+                              + "\n"
+                              + (info.getBackupType() == BackupManager.FULL_BACKUP_ONLY ? ""
+                                       : "\t\tincremental backup state : " + "working" + "\n")
+                              + "\t\tstarted time             : "
+                              + info.getStartedTime()
+                              + "\n"
+                              + (info.getFinishedTime().equals("") ? "\n" : "\t\tfinished time            : "
+                                       + info.getFinishedTime() + "\n\n");
+
+            return result;
+         }
       }
-      
-      String result = "\nThe completed (ready to restore) backups information : \n";
-      
-      if (infoList.getBackups().size() == 0)
-        result += "\tNo completed backups.\n\n";
-      
-      int count = 1;
-      for (ShortInfo shortInfo : infoList.getBackups()) {
-        result += "\t" + count + ") Backup with id " + shortInfo.getBackupId()  + " :\n";
-        
-        result  += ("\t\trepository name           : " + shortInfo.getRepositoryName() + "\n"
-                  + "\t\tworkspace name            : " + shortInfo.getWorkspaceName() + "\n"
-                  + "\t\tbackup type               : " + (shortInfo.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremetal" : "full only") + "\n"  
-                  + "\t\tstarted time              : " + shortInfo.getStartedTime() + "\n"
-                  + (shortInfo.getFinishedTime().equals("") ? "\n" : 
-                    "\t\tfinished time             : " + shortInfo.getFinishedTime() + "\n"));
-        count++;
-      }   
-      
-      return result;
-    } else {
-      return failureProcessing(response);
-    }
-  }
+      else
+      {
+         return failureProcessing(response);
+      }
+   }
 
-  /**
-   * {@inheritDoc}
-   */
-  public String restores(String repositoryName, String workspaceName) throws IOException, BackupExecuteException {
-    String sURL = path + HTTPBackupAgent.Constants.BASE_URL + 
-                  HTTPBackupAgent.Constants.OperationType.CURRENT_RESTORE_INFO_ON_WS +
-                  "/" + repositoryName +
-                  "/" + workspaceName;
-    BackupAgentResponse response = transport.executeGET(sURL);
-    
-    if (response.getStatus() == Response.Status.OK.getStatusCode()) {
-      DetailedInfo info;
-      try {
-        info = (DetailedInfo) getObject(DetailedInfo.class, response.getResponseData());
-      } catch (Exception e) {
-        throw new  RuntimeException("Can not get DetailedInfo from responce.", e);
+   /**
+    * {@inheritDoc}
+    */
+   public String stop(String backupId) throws IOException, BackupExecuteException
+   {
+      // first try to find current repository backup
+      String sURL =
+               path + HTTPBackupAgent.Constants.BASE_URL
+                        + HTTPBackupAgent.Constants.OperationType.CURRENT_BACKUPS_REPOSITORY_INFO;
+
+      BackupAgentResponse repositoryResponse = transport.executeGET(sURL);
+
+      if (repositoryResponse.getStatus() == Response.Status.OK.getStatusCode())
+      {
+         ShortInfoList repositoryInfoList;
+         try
+         {
+            repositoryInfoList = (ShortInfoList) getObject(ShortInfoList.class, repositoryResponse.getResponseData());
+         }
+         catch (Exception e)
+         {
+            throw new RuntimeException("Can not get ShortInfoList from responce.", e);
+         }
+
+         for (ShortInfo info : repositoryInfoList.getBackups())
+         {
+            if (info.getBackupId().equals(backupId))
+            {
+               // repository backup
+               sURL =
+                        path + HTTPBackupAgent.Constants.BASE_URL
+                                 + HTTPBackupAgent.Constants.OperationType.STOP_BACKUP_REPOSITORY + "/" + backupId;
+               BackupAgentResponse response = transport.executeGET(sURL);
+
+               if (response.getStatus() == Response.Status.OK.getStatusCode())
+               {
+                  return "\nSuccessful : \n" + "\tstatus code = " + response.getStatus() + "\n";
+               }
+               else
+               {
+                  return failureProcessing(response);
+               }
+            }
+         }
       }
-      
-      
-      String result = "\nThe current restores information : \n";
-      
-        result += "\tRestore with id " + info.getBackupId()  + ":\n";
-        
-        BackupConfigBean configBean = info.getBackupConfig();
-        
-        result  += ("\t\tbackup folder           : " + configBean.getBackupDir() + "\n" 
-                  + "\t\trepository name         : " + info.getRepositoryName() + "\n"
-                  + "\t\tworkspace name          : " + info.getWorkspaceName() + "\n"
-                  + "\t\tbackup type             : " + (configBean.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremetal" : "full only") + "\n"
-                  + "\t\trestore state           : " +  getRestoreState(info.getState()) + "\n"
-                  + "\t\tstarted time            : " + info.getStartedTime() + "\n"
-                  + (info.getFinishedTime().equals("") ? "\n" : 
-                    "\t\tfinished time           : " + info.getFinishedTime() + "\n\n"));
-        
-        return result;
-    } else {
-      return failureProcessing(response);
-    }
-  }
-  
-  
-  /**
-   * Will be created the Object from JSON binary data.
-   *
-   * @param cl 
-   *          Class
-   * @param data
-   *          binary data (JSON)
-   * @return Object
-   * @throws Exception
-   *           will be generated Exception
-   */
-  private Object getObject(Class cl, byte[] data) throws Exception { 
-    JsonHandler jsonHandler = new JsonDefaultHandler();
-    JsonParser jsonParser = new JsonParserImpl();
-    InputStream inputStream = new ByteArrayInputStream(data);
-    jsonParser.parse(inputStream, jsonHandler);
-    JsonValue jsonValue = jsonHandler.getJsonObject();
 
-    return new BeanBuilder().createObject(cl, jsonValue);
-  }
-  
-  
-  private String getRestoreState(int restoreState) {
-    String state = "unknown sate of restore";
-    
-    switch (restoreState) {
-    case JobWorkspaceRestore.RESTORE_INITIALIZED:
-       state = "initialized";
-      break;
-      
-    case JobWorkspaceRestore.RESTORE_STARTED:
-      state = "started";
-     break;
-     
-    case JobWorkspaceRestore.RESTORE_SUCCESSFUL:
-      state = "successful";
-     break;
-     
-    case JobWorkspaceRestore.RESTORE_FAIL:
-      state = "fail";
-     break;
+      // then try to find current workspace backup
+      sURL = path + HTTPBackupAgent.Constants.BASE_URL + HTTPBackupAgent.Constants.OperationType.CURRENT_BACKUPS_INFO;
 
-    default:
-      break;
-    }
-    
-    return state;
-  }
-  
-  /**
-   * getState.
-   * 
-   * @param state
-   *          value of state
-   * @return String sate
-   */
-  private String getState(int state) {
-    String st = "";
-    switch (state) {
+      BackupAgentResponse workspaceResponse = transport.executeGET(sURL);
+      if (workspaceResponse.getStatus() == Response.Status.OK.getStatusCode())
+      {
+         ShortInfoList workspaceInfoList;
+         try
+         {
+            workspaceInfoList = (ShortInfoList) getObject(ShortInfoList.class, workspaceResponse.getResponseData());
+         }
+         catch (Exception e)
+         {
+            throw new RuntimeException("Can not get ShortInfoList from responce.", e);
+         }
 
-    case BackupJob.FINISHED:
-      st = "finished";
-      break;
+         for (ShortInfo info : workspaceInfoList.getBackups())
+         {
+            if (info.getBackupId().equals(backupId))
+            {
+               // workspace backup
+               sURL =
+                        path + HTTPBackupAgent.Constants.BASE_URL + HTTPBackupAgent.Constants.OperationType.STOP_BACKUP
+                                 + "/" + backupId;
 
-    case BackupJob.WORKING:
-      st = "working";
-      break;
+               BackupAgentResponse response = transport.executeGET(sURL);
 
-    case BackupJob.WAITING:
-      st = "waiting";
-      break;
+               if (response.getStatus() == Response.Status.OK.getStatusCode())
+               {
+                  return "\nSuccessful : \n" + "\tstatus code = " + response.getStatus() + "\n";
+               }
+               else
+               {
+                  return failureProcessing(response);
+               }
+            }
+         }
+      }
 
-    case BackupJob.STARTING:
-      st = "starting";
-      break;
-    default:
-      break;
-    }
+      return "\nFailure :\n" + "\tmessage      : There are no active backup with id  " + backupId;
+   }
 
-    return st;
-  }
-  
-  /**
-   * failureProcessing.
-   *
-   * @param data
-   *          response data
-   * @return String
-   *           result
-   * @throws BackupExecuteException
-   *           will be generated BackupExecuteException  
-   */
-  private String failureProcessing(BackupAgentResponse response) throws BackupExecuteException {
-    try {
-      String result = "\nFailure :\n"
-                      + "\tsatatus code : " + response.getStatus() + "\n"
-                      + "\tmessage      : " + new String(response.getResponseData(), "UTF-8") + "\n\n";
-      
-      return result;
-    } catch (UnsupportedEncodingException e) {
-      throw new BackupExecuteException("Can not encoded the responce : " + e.getMessage(), e);
-    }
-  }
-    
-  /**
-   * getWorkspaceEntry.
-   *
-   * @param wEntryStream
-   *          InputStream, the workspace configuration
-   * @param workspaceName
-   *          String, the workspace name 
-   * @return WorkspaceEntry
-   *           return the workspace entry
-   * @throws FileNotFoundException
-   *           will be generated the FileNotFoundException 
-   * @throws JiBXException
-   *           will be generated the JiBXException 
-   * @throws RepositoryConfigurationException
-   *           will be generated the RepositoryConfigurationException 
-   */
-  private WorkspaceEntry getWorkspaceEntry(InputStream wEntryStream, String repositoryName, String workspaceName) throws FileNotFoundException,
-                                                                                          JiBXException,
-                                                                                          RepositoryConfigurationException {
-    WorkspaceEntry wsEntry = null;
+   /**
+    * {@inheritDoc}
+    */
+   public String restore(String repositoryName, String workspaceName, String backupId, InputStream config)
+            throws IOException, BackupExecuteException
+   {
+      if (workspaceName != null)
+      {
+         String sURL =
+                  path + HTTPBackupAgent.Constants.BASE_URL + HTTPBackupAgent.Constants.OperationType.RESTORE + "/"
+                           + repositoryName + "/" + backupId;
 
-    IBindingFactory factory = BindingDirectory.getFactory(RepositoryServiceConfiguration.class);
-    IUnmarshallingContext uctx = factory.createUnmarshallingContext();
-    RepositoryServiceConfiguration conf = (RepositoryServiceConfiguration) uctx.unmarshalDocument(wEntryStream,
-                                                                                                  null);
-    RepositoryEntry rEntry = conf.getRepositoryConfiguration(repositoryName);
-    
-    for (WorkspaceEntry wEntry : rEntry.getWorkspaceEntries())
-      if (wEntry.getName().equals(workspaceName))
-        wsEntry = wEntry;
-    
+         WorkspaceEntry wEntry = null;
+         try
+         {
+            wEntry = getWorkspaceEntry(config, repositoryName, workspaceName);
+         }
+         catch (Throwable e)
+         {
+            throw new BackupExecuteException("Can not get WorkspaceEntry for workspace '" + workspaceName
+                     + "' from config.", e);
+         }
 
-    if (wsEntry == null)
-      throw new RuntimeException("Can not find the workspace '" + workspaceName
-          + "' in configuration.");
+         JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
+         JsonValue json;
 
-    return wsEntry;
-  }
+         try
+         {
+            json = generatorImpl.createJsonObject(wEntry);
+         }
+         catch (JsonException e)
+         {
+            throw new BackupExecuteException("Can not get json from  : " + wEntry.getClass().toString(), e);
+         }
+
+         BackupAgentResponse response = transport.executePOST(sURL, json.toString());
+
+         if (response.getStatus() == Response.Status.OK.getStatusCode())
+         {
+            return "\nSuccessful : \n" + "\tstatus code = " + response.getStatus() + "\n";
+         }
+         else
+         {
+            return failureProcessing(response);
+         }
+      }
+      else
+      {
+         String sURL =
+                  path + HTTPBackupAgent.Constants.BASE_URL
+                           + HTTPBackupAgent.Constants.OperationType.RESTORE_REPOSITORY + "/" + backupId;
+
+         RepositoryEntry wEntry = null;
+         try
+         {
+            wEntry = getRepositoryEntry(config, repositoryName);
+         }
+         catch (Throwable e)
+         {
+            throw new BackupExecuteException("Can not get RepositoryEntry for repository '" + repositoryName
+                     + "' from config.", e);
+         }
+
+         JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
+         JsonValue json;
+
+         try
+         {
+            json = generatorImpl.createJsonObject(wEntry);
+         }
+         catch (JsonException e)
+         {
+            throw new BackupExecuteException("Can not get json from  : " + wEntry.getClass().toString(), e);
+         }
+
+         BackupAgentResponse response = transport.executePOST(sURL, json.toString());
+
+         if (response.getStatus() == Response.Status.OK.getStatusCode())
+         {
+            return "\nSuccessful : \n" + "\tstatus code = " + response.getStatus() + "\n";
+         }
+         else
+         {
+            return failureProcessing(response);
+         }
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public String drop(boolean forceClose, String repositoryName, String workspaceName) throws IOException,
+            BackupExecuteException
+   {
+      if (workspaceName != null)
+      {
+         String sURL =
+                  path + HTTPBackupAgent.Constants.BASE_URL + HTTPBackupAgent.Constants.OperationType.DROP_WORKSPACE
+                           + "/" + repositoryName + "/" + workspaceName + "/" + forceClose;
+
+         BackupAgentResponse response = transport.executeGET(sURL);
+
+         if (response.getStatus() == Response.Status.OK.getStatusCode())
+         {
+            return "\nSuccessful : \n" + "\tstatus code = " + response.getStatus() + "\n";
+         }
+         else
+         {
+            return failureProcessing(response);
+         }
+      }
+      else
+      {
+         String sURL =
+                  path + RestRepositoryService.Constants.BASE_URL
+                           + RestRepositoryService.Constants.OperationType.REMOVE_REPOSITORY + "/" + repositoryName
+                           + "/" + forceClose;
+
+         BackupAgentResponse response = transport.executeGET(sURL);
+
+         if (response.getStatus() == Response.Status.OK.getStatusCode())
+         {
+            return "\nSuccessful : \n" + "\tstatus code = " + response.getStatus() + "\n";
+         }
+         else
+         {
+            return failureProcessing(response);
+         }
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public String info() throws IOException, BackupExecuteException
+   {
+      String sURL =
+               path + HTTPBackupAgent.Constants.BASE_URL + HTTPBackupAgent.Constants.OperationType.BACKUP_SERVICE_INFO;
+      BackupAgentResponse response = transport.executeGET(sURL);
+
+      if (response.getStatus() == Response.Status.OK.getStatusCode())
+      {
+         BackupServiceInfoBean info;
+         try
+         {
+            info = (BackupServiceInfoBean) getObject(BackupServiceInfoBean.class, response.getResponseData());
+         }
+         catch (Exception e)
+         {
+            throw new RuntimeException("Can not get BackupServiceInfoBean from responce.", e);
+         }
+
+         String result =
+                  "\nThe backup service information : \n" + "\tfull backup type               : "
+                           + info.getFullBackupType() + "\n" + "\tincremetal backup type         : "
+                           + info.getIncrementalBackupType() + "\n" + "\tbackup log folder              : "
+                           + info.getBackupLogDir() + "\n" + "\tdefault incremental job period : "
+                           + info.getDefaultIncrementalJobPeriod() + "\n\n";
+
+         return result;
+      }
+      else
+      {
+         return failureProcessing(response);
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public String list() throws IOException, BackupExecuteException
+   {
+
+      String sURL =
+               path + HTTPBackupAgent.Constants.BASE_URL
+                        + HTTPBackupAgent.Constants.OperationType.CURRENT_BACKUPS_REPOSITORY_INFO;
+      BackupAgentResponse repositoryResponse = transport.executeGET(sURL);
+
+      sURL = path + HTTPBackupAgent.Constants.BASE_URL + HTTPBackupAgent.Constants.OperationType.CURRENT_BACKUPS_INFO;
+      BackupAgentResponse workspaceResponse = transport.executeGET(sURL);
+
+      if ((repositoryResponse.getStatus() == Response.Status.OK.getStatusCode())
+               && (workspaceResponse.getStatus() == Response.Status.OK.getStatusCode()))
+      {
+         ShortInfoList repositoryInfoList;
+         try
+         {
+            repositoryInfoList = (ShortInfoList) getObject(ShortInfoList.class, repositoryResponse.getResponseData());
+         }
+         catch (Exception e)
+         {
+            throw new RuntimeException("Can not get ShortInfoList from responce.", e);
+         }
+
+         ShortInfoList workspaceInfoList;
+         try
+         {
+            workspaceInfoList = (ShortInfoList) getObject(ShortInfoList.class, workspaceResponse.getResponseData());
+         }
+         catch (Exception e)
+         {
+            throw new RuntimeException("Can not get ShortInfoList from responce.", e);
+         }
+
+         String result = "\nThe current backups information : \n";
+
+         if ((repositoryInfoList.getBackups().size() == 0) && (workspaceInfoList.getBackups().size() == 0))
+         {
+            result += "\tNo active backups.\n\n";
+         }
+
+         int count = 1;
+         for (ShortInfo shortInfo : repositoryInfoList.getBackups())
+         {
+            result += "\t" + count + ") Repository backup with id " + shortInfo.getBackupId() + " :\n";
+
+            result +=
+                     ("\t\trepository name            : "
+                              + shortInfo.getRepositoryName()
+                              + "\n"
+                              + "\t\tbackup type                : "
+                              + (shortInfo.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremetal"
+                                       : "full only") + "\n" + "\t\tfull backups state         : " + getRepositoryBackupToFullState(shortInfo
+                              .getState()))
+                              + "\n"
+                              + (shortInfo.getBackupType() == BackupManager.FULL_BACKUP_ONLY ? ""
+                                       : "\t\tincremental backups state  : " + "working" + "\n")
+                              + "\t\tstarted time               : "
+                              + shortInfo.getStartedTime()
+                              + "\n"
+                              + (shortInfo.getFinishedTime().equals("") ? "" : "\t\tfinished time              : "
+                                       + shortInfo.getFinishedTime() + "\n");
+            count++;
+         }
+
+         for (ShortInfo shortInfo : workspaceInfoList.getBackups())
+         {
+            result += "\t" + count + ") Workspace backup with id " + shortInfo.getBackupId() + " :\n";
+
+            result +=
+                     ("\t\trepository name            : "
+                              + shortInfo.getRepositoryName()
+                              + "\n"
+                              + "\t\tworkspace name             : "
+                              + shortInfo.getWorkspaceName()
+                              + "\n"
+                              + "\t\tbackup type                : "
+                              + (shortInfo.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremetal"
+                                       : "full only") + "\n" + "\t\tfull backup state          : " + getState(shortInfo
+                              .getState()))
+                              + "\n"
+                              + (shortInfo.getBackupType() == BackupManager.FULL_BACKUP_ONLY ? ""
+                                       : "\t\tincremental backup state   : " + "working" + "\n")
+                              + "\t\tstarted time               : "
+                              + shortInfo.getStartedTime()
+                              + "\n"
+                              + (shortInfo.getFinishedTime().equals("") ? "" : "\t\tfinished time              : "
+                                       + shortInfo.getFinishedTime() + "\n");
+            count++;
+         }
+
+         return result;
+      }
+      else
+      {
+         return failureProcessing(workspaceResponse);
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public String listCompleted() throws IOException, BackupExecuteException
+   {
+      String sURL =
+               path + HTTPBackupAgent.Constants.BASE_URL
+                        + HTTPBackupAgent.Constants.OperationType.COMPLETED_BACKUPS_REPOSITORY_INFO;
+      BackupAgentResponse repositoryResponse = transport.executeGET(sURL);
+
+      sURL = path + HTTPBackupAgent.Constants.BASE_URL + HTTPBackupAgent.Constants.OperationType.COMPLETED_BACKUPS_INFO;
+      BackupAgentResponse workspaceResponse = transport.executeGET(sURL);
+
+      if ((workspaceResponse.getStatus() == Response.Status.OK.getStatusCode())
+               && (repositoryResponse.getStatus() == Response.Status.OK.getStatusCode()))
+      {
+
+         ShortInfoList repositoryInfoList;
+         try
+         {
+            repositoryInfoList = (ShortInfoList) getObject(ShortInfoList.class, repositoryResponse.getResponseData());
+         }
+         catch (Exception e)
+         {
+            throw new RuntimeException("Can not get ShortInfoList from responce.", e);
+         }
+
+         ShortInfoList workspaceInfoList;
+         try
+         {
+            workspaceInfoList = (ShortInfoList) getObject(ShortInfoList.class, workspaceResponse.getResponseData());
+         }
+         catch (Exception e)
+         {
+            throw new RuntimeException("Can not get ShortInfoList from responce.", e);
+         }
+
+         String result = "\nThe completed (ready to restore) backups information : \n";
+
+         if ((repositoryInfoList.getBackups().size() == 0) && (workspaceInfoList.getBackups().size() == 0))
+         {
+            result += "\tNo completed backups.\n\n";
+         }
+
+         int count = 1;
+         for (ShortInfo shortInfo : repositoryInfoList.getBackups())
+         {
+            result += "\t" + count + ") Repository backup with id " + shortInfo.getBackupId() + " :\n";
+
+            result +=
+                     ("\t\trepository name           : "
+                              + shortInfo.getRepositoryName()
+                              + "\n"
+                              + "\t\tbackup type               : "
+                              + (shortInfo.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremetal"
+                                       : "full only") + "\n" + "\t\tstarted time              : "
+                              + shortInfo.getStartedTime() + "\n" + (shortInfo.getFinishedTime().equals("") ? "\n"
+                              : "\t\tfinished time             : " + shortInfo.getFinishedTime() + "\n"));
+            count++;
+         }
+
+         for (ShortInfo shortInfo : workspaceInfoList.getBackups())
+         {
+            result += "\t" + count + ") Workspace backup with id " + shortInfo.getBackupId() + " :\n";
+
+            result +=
+                     ("\t\trepository name           : "
+                              + shortInfo.getRepositoryName()
+                              + "\n"
+                              + "\t\tworkspace name            : "
+                              + shortInfo.getWorkspaceName()
+                              + "\n"
+                              + "\t\tbackup type               : "
+                              + (shortInfo.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremetal"
+                                       : "full only") + "\n" + "\t\tstarted time              : "
+                              + shortInfo.getStartedTime() + "\n" + (shortInfo.getFinishedTime().equals("") ? "\n"
+                              : "\t\tfinished time             : " + shortInfo.getFinishedTime() + "\n"));
+            count++;
+         }
+
+         return result;
+      }
+      else
+      {
+         return failureProcessing(workspaceResponse);
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public String restores(String repositoryName, String workspaceName) throws IOException, BackupExecuteException
+   {
+      if (workspaceName != null)
+      {
+         String sURL =
+                  path + HTTPBackupAgent.Constants.BASE_URL
+                           + HTTPBackupAgent.Constants.OperationType.CURRENT_RESTORE_INFO_ON_WS + "/" + repositoryName
+                           + "/" + workspaceName;
+         BackupAgentResponse response = transport.executeGET(sURL);
+
+         if (response.getStatus() == Response.Status.OK.getStatusCode())
+         {
+            DetailedInfo info;
+            try
+            {
+               info = (DetailedInfo) getObject(DetailedInfo.class, response.getResponseData());
+            }
+            catch (Exception e)
+            {
+               throw new RuntimeException("Can not get DetailedInfo from responce.", e);
+            }
+
+            String result = "\nThe current restores information : \n";
+
+            result += "\tWorkspace restore with id " + info.getBackupId() + ":\n";
+
+            BackupConfigBean configBean = info.getBackupConfig();
+
+            result +=
+                     ("\t\tbackup folder           : "
+                              + configBean.getBackupDir()
+                              + "\n"
+                              + "\t\trepository name         : "
+                              + info.getRepositoryName()
+                              + "\n"
+                              + "\t\tworkspace name          : "
+                              + info.getWorkspaceName()
+                              + "\n"
+                              + "\t\tbackup type             : "
+                              + (configBean.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremetal"
+                                       : "full only") + "\n" + "\t\trestore state           : "
+                              + getRestoreState(info.getState()) + "\n" + "\t\tstarted time            : "
+                              + info.getStartedTime() + "\n" + (info.getFinishedTime().equals("") ? "\n"
+                              : "\t\tfinished time           : " + info.getFinishedTime() + "\n\n"));
+
+            return result;
+         }
+         else
+         {
+            return failureProcessing(response);
+         }
+      }
+      else
+      {
+         String sURL =
+                  path + HTTPBackupAgent.Constants.BASE_URL
+                           + HTTPBackupAgent.Constants.OperationType.CURRENT_RESTORE_INFO_ON_REPOSITORY + "/"
+                           + repositoryName;
+
+         BackupAgentResponse response = transport.executeGET(sURL);
+
+         if (response.getStatus() == Response.Status.OK.getStatusCode())
+         {
+            DetailedInfo info;
+            try
+            {
+               info = (DetailedInfo) getObject(DetailedInfo.class, response.getResponseData());
+            }
+            catch (Exception e)
+            {
+               throw new RuntimeException("Can not get DetailedInfo from responce.", e);
+            }
+
+            String result = "\nThe current restores information : \n";
+
+            result += "\tRepository restore with id " + info.getBackupId() + ":\n";
+
+            BackupConfigBean configBean = info.getBackupConfig();
+
+            result +=
+                     ("\t\tbackup folder           : "
+                              + configBean.getBackupDir()
+                              + "\n"
+                              + "\t\trepository name         : "
+                              + info.getRepositoryName()
+                              + "\n"
+                              + "\t\tbackup type             : "
+                              + (configBean.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremetal"
+                                       : "full only") + "\n" + "\t\trestore state           : "
+                              + getRepositoryRestoreState(info.getState()) + "\n" + "\t\tstarted time            : "
+                              + info.getStartedTime() + "\n" + (info.getFinishedTime().equals("") ? "\n"
+                              : "\t\tfinished time           : " + info.getFinishedTime() + "\n\n"));
+
+            return result;
+         }
+         else
+         {
+            return failureProcessing(response);
+         }
+      }
+   }
+
+   /**
+    * Will be created the Object from JSON binary data.
+    *
+    * @param cl 
+    *          Class
+    * @param data
+    *          binary data (JSON)
+    * @return Object
+    * @throws Exception
+    *           will be generated Exception
+    */
+   private Object getObject(Class cl, byte[] data) throws Exception
+   {
+      JsonHandler jsonHandler = new JsonDefaultHandler();
+      JsonParser jsonParser = new JsonParserImpl();
+      InputStream inputStream = new ByteArrayInputStream(data);
+      jsonParser.parse(inputStream, jsonHandler);
+      JsonValue jsonValue = jsonHandler.getJsonObject();
+
+      return new BeanBuilder().createObject(cl, jsonValue);
+   }
+
+   private String getRestoreState(int restoreState)
+   {
+      String state = "unknown sate of restore";
+
+      switch (restoreState)
+      {
+         case JobWorkspaceRestore.RESTORE_INITIALIZED :
+            state = "initialized";
+            break;
+
+         case JobWorkspaceRestore.RESTORE_STARTED :
+            state = "started";
+            break;
+
+         case JobWorkspaceRestore.RESTORE_SUCCESSFUL :
+            state = "successful";
+            break;
+
+         case JobWorkspaceRestore.RESTORE_FAIL :
+            state = "fail";
+            break;
+
+         default :
+            break;
+      }
+
+      return state;
+   }
+
+   private String getRepositoryRestoreState(int restoreState)
+   {
+      String state = "unknown sate of restore";
+
+      switch (restoreState)
+      {
+         case JobRepositoryRestore.REPOSITORY_RESTORE_INITIALIZED :
+            state = "initialized";
+            break;
+
+         case JobRepositoryRestore.REPOSITORY_RESTORE_STARTED :
+            state = "started";
+            break;
+
+         case JobRepositoryRestore.REPOSITORY_RESTORE_SUCCESSFUL :
+            state = "successful";
+            break;
+
+         case JobRepositoryRestore.REPOSITORY_RESTORE_FAIL :
+            state = "fail";
+            break;
+
+         default :
+            break;
+      }
+
+      return state;
+   }
+
+   /**
+    * getState.
+    * 
+    * @param state
+    *          value of state
+    * @return String sate
+    */
+   private String getState(int state)
+   {
+      String st = "";
+      switch (state)
+      {
+
+         case BackupJob.FINISHED :
+            st = "finished";
+            break;
+
+         case BackupJob.WORKING :
+            st = "working";
+            break;
+
+         case BackupJob.WAITING :
+            st = "waiting";
+            break;
+
+         case BackupJob.STARTING :
+            st = "starting";
+            break;
+         default :
+            break;
+      }
+
+      return st;
+   }
+
+   /**
+    * getState.
+    * 
+    * @param state
+    *          value of state
+    * @return String sate
+    */
+   private String getRepositoryBackupToFullState(int state)
+   {
+      String st = "";
+      switch (state)
+      {
+
+         case RepositoryBackupChain.FINISHED :
+            st = "finished";
+            break;
+
+         case RepositoryBackupChain.WORKING :
+            st = "working";
+            break;
+
+         case RepositoryBackupChain.INITIALIZED :
+            st = "initialized";
+            break;
+
+         case RepositoryBackupChain.FULL_BACKUP_FINISHED_INCREMENTAL_BACKUP_WORKING :
+            st = "finished";
+            break;
+         default :
+            break;
+      }
+
+      return st;
+   }
+
+   /**
+    * failureProcessing.
+    *
+    * @param data
+    *          response data
+    * @return String
+    *           result
+    * @throws BackupExecuteException
+    *           will be generated BackupExecuteException  
+    */
+   private String failureProcessing(BackupAgentResponse response) throws BackupExecuteException
+   {
+      try
+      {
+         String result =
+                  "\nFailure :\n" + "\tstatus code : " + response.getStatus() + "\n" + "\tmessage      : "
+                           + new String(response.getResponseData(), "UTF-8") + "\n\n";
+
+         return result;
+      }
+      catch (UnsupportedEncodingException e)
+      {
+         throw new BackupExecuteException("Can not encoded the responce : " + e.getMessage(), e);
+      }
+   }
+
+   /**
+    * getRepositoryEntry.
+    *
+    * @param wEntryStream
+    *          InputStream, the workspace configuration
+    * @return RepositoryEntry
+    *           return the workspace entry
+    * @throws FileNotFoundException
+    *           will be generated the FileNotFoundException 
+    * @throws JiBXException
+    *           will be generated the JiBXException 
+    * @throws RepositoryConfigurationException
+    *           will be generated the RepositoryConfigurationException 
+    */
+   private RepositoryEntry getRepositoryEntry(InputStream wEntryStream, String repositoryName)
+            throws FileNotFoundException, JiBXException, RepositoryConfigurationException
+   {
+      IBindingFactory factory = BindingDirectory.getFactory(RepositoryServiceConfiguration.class);
+      IUnmarshallingContext uctx = factory.createUnmarshallingContext();
+      RepositoryServiceConfiguration conf = (RepositoryServiceConfiguration) uctx.unmarshalDocument(wEntryStream, null);
+      RepositoryEntry rEntry = conf.getRepositoryConfiguration(repositoryName);
+
+      return rEntry;
+   }
+
+   /**
+    * getWorkspaceEntry.
+    *
+    * @param wEntryStream
+    *          InputStream, the workspace configuration
+    * @param workspaceName
+    *          String, the workspace name 
+    * @return WorkspaceEntry
+    *           return the workspace entry
+    * @throws FileNotFoundException
+    *           will be generated the FileNotFoundException 
+    * @throws JiBXException
+    *           will be generated the JiBXException 
+    * @throws RepositoryConfigurationException
+    *           will be generated the RepositoryConfigurationException 
+    */
+   private WorkspaceEntry getWorkspaceEntry(InputStream wEntryStream, String repositoryName, String workspaceName)
+            throws FileNotFoundException, JiBXException, RepositoryConfigurationException
+   {
+      RepositoryEntry rEntry = getRepositoryEntry(wEntryStream, repositoryName);
+
+      WorkspaceEntry wsEntry = null;
+
+      for (WorkspaceEntry wEntry : rEntry.getWorkspaceEntries())
+         if (wEntry.getName().equals(workspaceName))
+            wsEntry = wEntry;
+
+      if (wsEntry == null)
+         throw new RuntimeException("Can not find the workspace '" + workspaceName + "' in configuration.");
+
+      return wsEntry;
+   }
+
 }

Modified: jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupConsole.java
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupConsole.java	2010-10-20 08:10:23 UTC (rev 3304)
+++ jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupConsole.java	2010-10-20 13:24:47 UTC (rev 3305)
@@ -58,25 +58,33 @@
     */
    private static final String HELP_INFO =
       "Help info:\n" + " <url> <cmd> \n" + " <url>  :   http(s)//login:password at host:port/<context> \n"
-         + " <cmd>  :   start <repo/ws> <backup_dir> [<incr>] \n" + "            stop <backup_id> \n"
-         + "            status <backup_id> \n" + "            restores <repo/ws> \n"
-         + "            restore <repo/ws> <backup_id> <pathToConfigFile> \n" + "            list [completed] \n"
-         + "            info \n" + "            drop [force-close-session] <repo/ws>  \n" + "            help  \n\n"
+         + " <cmd>  :   start <repo[/ws]> <backup_dir> [<incr>] \n" 
+         + "            stop <backup_id> \n"
+         + "            status <backup_id> \n" 
+         + "            restores <repo[/ws]> \n"
+         + "            restore <repo[/ws]> <backup_id> <pathToConfigFile> \n" 
+         + "            list [completed] \n"
+         + "            info \n" 
+         + "            drop [force-close-session] <repo[/ws]>  \n" 
+         + "            help  \n\n"
 
-         + " start          - start backup \n" + " stop           - stop backup \n"
+         + " start          - start backup of repositpry or workspace \n" 
+         + " stop           - stop backup \n"
          + " status         - information about the current or completed backup by 'backup_id' \n"
-         + " restores       - information about the last restore on specific workspace \n"
-         + " restore        - restore the workspace from specific backup \n"
+         + " restores       - information about the last restore on specific repository or workspace \n"
+         + " restore        - restore the repository or workspace from specific backup \n"
          + " list           - information about the current backups (in progress) \n"
          + " list completed - information about the completed (ready to restore) backups \n"
-         + " info           - information about the service backup \n" + " drop           - delete the workspace \n"
+         + " info           - information about the service backup \n" 
+         + " drop           - delete the repository or workspace \n"
          + " help           - print help information about backup console \n\n"
 
-         + " <repo/ws>           - /<reponsitory-name>/<workspace-name>  the workspace \n"
+         + " <repo[/ws]>           - /<reponsitory-name>[/<workspace-name>]  the repository or workspace \n"
          + " <backup_dir>        - path to folder for backup on remote server \n"
-         + " <backup_id>         - the identifier for backup \n" + " <incr>              - incemental job period \n"
-         + " <pathToConfigFile>  - path (local) to workspace configuration \n"
-         + " force-close-session - close opened sessions on workspace. \n\n";
+         + " <backup_id>         - the identifier for backup \n" 
+         + " <incr>              - incemental job period \n"
+         + " <pathToConfigFile>  - path (local) to  repository or workspace configuration \n"
+         + " force-close-session - close opened sessions on repositpry or workspace. \n\n";
 
    /**
     * Main.
@@ -157,7 +165,7 @@
                return;
 
             String repositoryName = getRepositoryName(pathToWS);
-            String workspaceName = getWorkspaceName(pathToWS);
+            String workspaceName = (pathToWS.split("/").length == 3 ? getWorkspaceName(pathToWS) : null);
 
             if (curArg == args.length)
             {
@@ -233,7 +241,7 @@
                return;
 
             String repositoryName = getRepositoryName(pathToWS);
-            String workspaceName = getWorkspaceName(pathToWS);
+            String workspaceName = (pathToWS.split("/").length == 3 ? getWorkspaceName(pathToWS) : null);
 
             if (curArg < args.length)
             {
@@ -276,7 +284,7 @@
                return;
 
             String repositoryName = getRepositoryName(pathToWS);
-            String workspaceName = getWorkspaceName(pathToWS);
+            String workspaceName = (pathToWS.split("/").length == 3 ? getWorkspaceName(pathToWS) : null);;
 
             if (curArg < args.length)
             {
@@ -321,7 +329,7 @@
                return;
 
             String repositoryName = getRepositoryName(pathToWS);
-            String workspaceName = getWorkspaceName(pathToWS);
+            String workspaceName = (pathToWS.split("/").length == 3 ? getWorkspaceName(pathToWS) : null);
 
             // backup id
             if (curArg == args.length)
@@ -415,7 +423,7 @@
       String repWS = args[curArg];
       repWS = repWS.replaceAll("\\\\", "/");
 
-      if (!repWS.matches("[/][^/]+[/][^/]+"))
+      if ( !repWS.matches("[/][^/]+") && !repWS.matches("[/][^/]+[/][^/]+"))
       {
          System.out.println(INCORRECT_PARAM + "There is incorrect path to workspace parameter: " + repWS);
          return null;

Modified: jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/ClientTransportImpl.java
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/ClientTransportImpl.java	2010-10-20 08:10:23 UTC (rev 3304)
+++ jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/ClientTransportImpl.java	2010-10-20 13:24:47 UTC (rev 3305)
@@ -57,6 +57,16 @@
     * Flag is SSL.
     */
    private final String protocol;
+   
+   /**
+    * Is realm get.
+    */
+   private boolean isRealmGet = false;
+   
+   /**
+    * Realm to connection
+    */
+   private String realm;
 
    /**
     * Constructor.
@@ -124,7 +134,13 @@
          HTTPConnection connection = new HTTPConnection(url);
          connection.removeModule(CookieModule.class);
 
-         connection.addBasicAuthorization(getRealm(complURL), login, password);
+         if (!isRealmGet)
+         {
+            realm = getRealm(complURL);
+            isRealmGet = true;
+         }
+         
+         connection.addBasicAuthorization(realm, login, password);
 
          HTTPResponse resp;
          if (postData == null)
@@ -164,7 +180,13 @@
          HTTPConnection connection = new HTTPConnection(url);
          connection.removeModule(CookieModule.class);
 
-         connection.addBasicAuthorization(getRealm(complURL), login, password);
+         if (!isRealmGet)
+         {
+            realm = getRealm(complURL);
+            isRealmGet = true;
+         }
+         
+         connection.addBasicAuthorization(realm, login, password);
 
          HTTPResponse resp = connection.Get(url.getFile());
 

Modified: jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/RestRepositoryService.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/RestRepositoryService.java	2010-10-20 08:10:23 UTC (rev 3304)
+++ jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/RestRepositoryService.java	2010-10-20 13:24:47 UTC (rev 3305)
@@ -18,20 +18,6 @@
  */
 package org.exoplatform.services.jcr.ext.repository;
 
-import org.exoplatform.common.http.HTTPStatus;
-import org.exoplatform.services.jcr.RepositoryService;
-import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
-import org.exoplatform.services.jcr.config.RepositoryEntry;
-import org.exoplatform.services.jcr.config.RepositoryServiceConfiguration;
-import org.exoplatform.services.jcr.config.WorkspaceEntry;
-import org.exoplatform.services.jcr.core.ManageableRepository;
-import org.exoplatform.services.jcr.core.WorkspaceContainerFacade;
-import org.exoplatform.services.jcr.impl.core.RepositoryImpl;
-import org.exoplatform.services.jcr.impl.core.SessionRegistry;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-import org.exoplatform.services.rest.resource.ResourceContainer;
-
 import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.List;
@@ -51,6 +37,20 @@
 import javax.ws.rs.core.UriInfo;
 import javax.ws.rs.core.Response.Status;
 
+import org.exoplatform.services.jcr.RepositoryService;
+import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.config.RepositoryEntry;
+import org.exoplatform.services.jcr.config.RepositoryServiceConfiguration;
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
+import org.exoplatform.services.jcr.core.ManageableRepository;
+import org.exoplatform.services.jcr.core.WorkspaceContainerFacade;
+import org.exoplatform.services.jcr.impl.RepositoryServiceImpl;
+import org.exoplatform.services.jcr.impl.core.RepositoryImpl;
+import org.exoplatform.services.jcr.impl.core.SessionRegistry;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.services.rest.resource.ResourceContainer;
+
 /**
  * Created by The eXo Platform SAS.
  * 
@@ -370,7 +370,7 @@
     * @return Response
     *           return the Response
     */
-   @POST
+   @GET
    @RolesAllowed("administrators")
    @Path("/remove-repository/{repositoryName}/{forseSessionClose}")
    public Response removeRepository(@Context UriInfo uriInfo, @PathParam("repositoryName") String repositoryName,
@@ -390,14 +390,16 @@
             }
          }
 
-         if (repositoryService.canRemoveRepository(repositoryName))
+         if (repositoryService.getDefaultRepository().getConfiguration().getName().equals(repositoryName))
          {
+            ((RepositoryServiceImpl) repositoryService).removeDefaultRepository();
+         }
+         else
+         {
             repositoryService.removeRepository(repositoryName);
-            repositoryService.getConfig().retain(); // save configuration to persistence (file or persister)
-            return Response.noContent().build();
          }
-         return Response.status(HTTPStatus.CONFLICT).entity("Can't remove repository " + repositoryName).cacheControl(
-            NO_CACHE).build();
+         repositoryService.getConfig().retain(); // save configuration to persistence (file or persister) 
+         return Response.ok().build();
       }
       catch (RepositoryException e)
       {

Modified: jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/backup/backup-client.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/backup/backup-client.xml	2010-10-20 08:10:23 UTC (rev 3304)
+++ jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/backup/backup-client.xml	2010-10-20 13:24:47 UTC (rev 3305)
@@ -938,33 +938,33 @@
     <programlisting>Help info:
  &lt;url&gt; &lt;cmd&gt; 
  &lt;url&gt;  :   http(s)//login:password at host:port/&lt;context&gt; 
- &lt;cmd&gt;  :   start &lt;repo/ws&gt; &lt;backup_dir&gt; [&lt;incr&gt;] 
+ &lt;cmd&gt;  :   start &lt;repo[/ws]&gt; &lt;backup_dir&gt; [&lt;incr&gt;] 
             stop &lt;backup_id&gt; 
             status &lt;backup_id&gt; 
-            restores &lt;repo/ws&gt; 
-            restore &lt;repo/ws&gt; &lt;backup_id&gt; &lt;pathToConfigFile&gt; 
+            restores &lt;repo[/ws]&gt; 
+            restore &lt;repo[/ws]&gt; &lt;backup_id&gt; &lt;pathToConfigFile&gt;
             list [completed] 
             info 
-            drop [force-close-session] &lt;repo/ws&gt;  
+            drop [force-close-session] &lt;repo[/ws]&gt; 
             help  
 
- start          - start backup 
+ start          - start backup of repository or workspace
  stop           - stop backup 
  status         - information about the current or completed backup by 'backup_id' 
- restores       - information about the last restore on specific workspace 
- restore        - restore the workspace from specific backup 
+ restores       - information about the last restore on specific repository or workspace 
+ restore        - restore the repository or workspace from specific backup 
  list           - information about the current backups (in progress) 
  list completed - information about the completed (ready to restore) backups 
  info           - information about the service backup 
- drop           - delete the workspace 
+ drop           - delete the repository or workspace 
  help           - print help information about backup console 
 
- &lt;repo/ws&gt;           - /&lt;reponsitory-name&gt;/&lt;workspace-name&gt;  the workspace 
+ &lt;repo[/ws]&gt;         - /&lt;reponsitory-name&gt;[/&lt;workspace-name&gt;] the repository or workspace
  &lt;backup_dir&gt;        - path to folder for backup on remote server 
  &lt;backup_id&gt;         - the identifier for backup 
  &lt;incr&gt;              - incemental job period 
- &lt;pathToConfigFile&gt;  - path (local) to workspace configuration 
- force-close-session - close opened sessions on workspace.</programlisting>
+ &lt;pathToConfigFile&gt;  - path (local) to  repository or workspace configuration 
+ force-close-session - close opened sessions on repositpry or workspace</programlisting>
   </section>
 
   <section>
@@ -991,7 +991,8 @@
       </itemizedlist>
 
       <note>
-        <para><emphasis role="bold">${JCR-SRC-HOME}</emphasis> the path where eXo JCR sources located</para>
+        <para><emphasis role="bold">${JCR-SRC-HOME}</emphasis> the path where
+        eXo JCR sources located</para>
       </note>
     </section>
 
@@ -1323,4 +1324,244 @@
     finished time           : Fri, 17 Apr 2009 16:38:00 EEST</programlisting>
     </section>
   </section>
+
+  <section>
+    <title>Full example about creating backup and restoring it for repository
+    'repository'</title>
+
+    <section>
+      <title>Creating backup</title>
+
+      <programlisting>jcrbackup http://root:exo@127.0.0.1:8080 start /repository ../temp/backup 10000</programlisting>
+
+      <para>Return :</para>
+
+      <programlisting>Successful : 
+  status code = 200</programlisting>
+    </section>
+
+    <section>
+      <title>Getting information about current backups</title>
+
+      <programlisting>jcrbackup http://root:exo@127.0.0.1:8080 list</programlisting>
+
+      <para>Return :</para>
+
+      <programlisting>The current backups information : 
+  1) Repository backup with id 9a4d40fb7f0000012ec8f0a4ec70b3da :
+    repository name            : repository
+    backup type                : full + incremetal
+    full backups state         : finished
+    incremental backups state  : working
+    started time               : Mon, 11 Oct 2010 10:59:35 EEST</programlisting>
+    </section>
+
+    <section>
+      <title>Stopping backup by id</title>
+
+      <para>Stop backup with id 9a4d40fb7f0000012ec8f0a4ec70b3da :</para>
+
+      <programlisting>jcrbackup http://root:exo@127.0.0.1:8080 stop 9a4d40fb7f0000012ec8f0a4ec70b3da</programlisting>
+
+      <para>Return :</para>
+
+      <programlisting>Successful : 
+  status code = 200</programlisting>
+    </section>
+
+    <section>
+      <title>Deleting the repository "repository" and close all opened
+      sessions</title>
+
+      <programlisting>jcrbackup http://root:exo@127.0.0.1:8080 drop force-close-session /repository</programlisting>
+
+      <para>Return :</para>
+
+      <programlisting>Successful : 
+  status code = 200</programlisting>
+    </section>
+
+    <section>
+      <title>Restoring the workspace "backup"</title>
+
+      <itemizedlist>
+        <listitem>
+          <para>Delete/clean the database for workspace <emphasis
+          role="bold">"repository"</emphasis> : When we use "single-db", then
+          we will run the SQL queries for clean database :<programlisting>       drop table JCR_SREF;
+       drop table JCR_SVALUE;
+       drop table JCR_SITEM;</programlisting></para>
+        </listitem>
+
+        <listitem>
+          <para>Delete the value storage for repository <emphasis
+          role="bold">"repository"</emphasis>;</para>
+        </listitem>
+
+        <listitem>
+          <para>Delete the index data for repository <emphasis
+          role="bold">"repository"</emphasis>;</para>
+        </listitem>
+
+        <listitem>
+          <para>Restore:<programlisting>jcrbackup http://root:exo@127.0.0.1:8080 restore /repository/backup 9a6dba327f000001325dfb228a181b07 /home/rainf0x/exo-jcr-config_backup.xml</programlisting>Return
+          :<programlisting>Successful : 
+  status code = 200</programlisting>The
+          /home/rainf0x/exo-jcr-config_backup.xml content the configuration
+          for restored repository <emphasis
+          role="bold">"repository"</emphasis> :<programlisting>&lt;repository-service default-repository="repository"&gt;
+   &lt;repositories&gt;
+      &lt;repository name="repository" system-workspace="production" default-workspace="production"&gt;
+         &lt;security-domain&gt;exo-domain&lt;/security-domain&gt;
+         &lt;access-control&gt;optional&lt;/access-control&gt;
+         &lt;authentication-policy&gt;org.exoplatform.services.jcr.impl.core.access.JAASAuthenticator&lt;/authentication-policy&gt;
+         &lt;workspaces&gt;
+            &lt;workspace name="production"&gt;
+               &lt;!-- for system storage --&gt;
+               &lt;container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer"&gt;
+                  &lt;properties&gt;
+                     &lt;property name="source-name" value="jdbcjcr" /&gt;
+                     &lt;property name="multi-db" value="false" /&gt;
+                     &lt;property name="update-storage" value="false" /&gt;
+                     &lt;property name="max-buffer-size" value="200k" /&gt;
+                     &lt;property name="swap-directory" value="../temp/swap/production" /&gt;
+                  &lt;/properties&gt;
+                  &lt;value-storages&gt;
+                     &lt;value-storage id="system" class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage"&gt;
+                        &lt;properties&gt;
+                           &lt;property name="path" value="../temp/values/production" /&gt;
+                        &lt;/properties&gt;
+                        &lt;filters&gt;
+                           &lt;filter property-type="Binary" /&gt;
+                        &lt;/filters&gt;
+                     &lt;/value-storage&gt;
+                  &lt;/value-storages&gt;
+               &lt;/container&gt;
+               &lt;initializer class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer"&gt;
+                  &lt;properties&gt;
+                     &lt;property name="root-nodetype" value="nt:unstructured" /&gt;
+                  &lt;/properties&gt;
+               &lt;/initializer&gt;
+               &lt;cache enabled="true" class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl"&gt;
+                  &lt;properties&gt;
+                     &lt;property name="max-size" value="10k" /&gt;
+                     &lt;property name="live-time" value="1h" /&gt;
+                  &lt;/properties&gt;
+               &lt;/cache&gt;
+               &lt;query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex"&gt;
+                  &lt;properties&gt;
+                     &lt;property name="index-dir" value="../temp/jcrlucenedb/production" /&gt;
+                  &lt;/properties&gt;
+               &lt;/query-handler&gt;
+               &lt;lock-manager&gt;
+                  &lt;time-out&gt;15m&lt;/time-out&gt;
+                  &lt;persister class="org.exoplatform.services.jcr.impl.core.lock.FileSystemLockPersister"&gt;
+                     &lt;properties&gt;
+                        &lt;property name="path" value="../temp/lock/system" /&gt;
+                     &lt;/properties&gt;
+                  &lt;/persister&gt;
+               &lt;/lock-manager&gt;
+            &lt;/workspace&gt;
+
+            &lt;workspace name="backup"&gt;
+               &lt;container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer"&gt;
+                  &lt;properties&gt;
+                     &lt;property name="source-name" value="jdbcjcr" /&gt;
+                     &lt;property name="multi-db" value="false" /&gt;
+                     &lt;property name="update-storage" value="false" /&gt;
+                     &lt;property name="max-buffer-size" value="200k" /&gt;
+                     &lt;property name="swap-directory" value="../temp/swap/backup" /&gt;
+                  &lt;/properties&gt;
+                  &lt;value-storages&gt;
+                     &lt;value-storage id="draft" class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage"&gt;
+                        &lt;properties&gt;
+                           &lt;property name="path" value="../temp/values/backup" /&gt;
+                        &lt;/properties&gt;
+                        &lt;filters&gt;
+                           &lt;filter property-type="Binary" /&gt;
+                        &lt;/filters&gt;
+                     &lt;/value-storage&gt;
+                  &lt;/value-storages&gt;
+               &lt;/container&gt;
+               &lt;initializer class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer"&gt;
+                  &lt;properties&gt;
+                     &lt;property name="root-nodetype" value="nt:unstructured" /&gt;
+                  &lt;/properties&gt;
+               &lt;/initializer&gt;
+               &lt;cache enabled="true" class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl"&gt;
+                  &lt;properties&gt;
+                     &lt;property name="max-size" value="10k" /&gt;
+                     &lt;property name="live-time" value="1h" /&gt;
+                  &lt;/properties&gt;
+               &lt;/cache&gt;
+               &lt;query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex"&gt;
+                  &lt;properties&gt;
+                     &lt;property name="index-dir" value="../temp/jcrlucenedb/backup" /&gt;
+                  &lt;/properties&gt;
+               &lt;/query-handler&gt;
+            &lt;/workspace&gt;
+
+            &lt;workspace name="digital-assets"&gt;
+               &lt;container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer"&gt;
+                  &lt;properties&gt;
+                     &lt;property name="source-name" value="jdbcjcr" /&gt;
+                     &lt;property name="multi-db" value="false" /&gt;
+                     &lt;property name="update-storage" value="false" /&gt;
+                     &lt;property name="max-buffer-size" value="200k" /&gt;
+                     &lt;property name="swap-directory" value="../temp/swap/digital-assets" /&gt;
+                  &lt;/properties&gt;
+                  &lt;value-storages&gt;
+                     &lt;value-storage id="digital-assets" class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage"&gt;
+                        &lt;properties&gt;
+                           &lt;property name="path" value="../temp/values/digital-assets" /&gt;
+                        &lt;/properties&gt;
+                        &lt;filters&gt;
+                           &lt;filter property-type="Binary" /&gt;
+                        &lt;/filters&gt;
+                     &lt;/value-storage&gt;
+                  &lt;/value-storages&gt;
+               &lt;/container&gt;
+               &lt;initializer class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer"&gt;
+                  &lt;properties&gt;
+                     &lt;property name="root-nodetype" value="nt:folder" /&gt;
+                  &lt;/properties&gt;
+               &lt;/initializer&gt;
+               &lt;cache enabled="true" class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl"&gt;
+                  &lt;properties&gt;
+                     &lt;property name="max-size" value="5k" /&gt;
+                     &lt;property name="live-time" value="15m" /&gt;
+                  &lt;/properties&gt;
+               &lt;/cache&gt;
+               &lt;query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex"&gt;
+                  &lt;properties&gt;
+                     &lt;property name="index-dir" value="../temp/jcrlucenedb/digital-assets" /&gt;
+                  &lt;/properties&gt;
+               &lt;/query-handler&gt;
+            &lt;/workspace&gt;
+         &lt;/workspaces&gt;
+      &lt;/repository&gt;
+   &lt;/repositories&gt;
+&lt;/repository-service&gt;
+</programlisting></para>
+        </listitem>
+      </itemizedlist>
+    </section>
+
+    <section>
+      <title>Getting information about restore for repository
+      'repository'</title>
+
+      <programlisting>jcrbackup http://root:exo@127.0.0.1:8080 restores /repository</programlisting>
+
+      <para>Return:</para>
+
+      <programlisting>  Repository restore with id 9a6dba327f000001325dfb228a181b07:
+    backup folder           : /home/rainf0x/java/exo-working/JCR-1459/exo-tomcat/bin/../temp/backup/repository_repository_backup_1286786103858
+    repository name         : repository
+    backup type             : full + incremetal
+    restore state           : successful
+    started time            : Mon, 11 Oct 2010 11:51:15 EEST
+    finished time           : Mon, 11 Oct 2010 11:51:17 EEST</programlisting>
+    </section>
+  </section>
 </chapter>



More information about the exo-jcr-commits mailing list