Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (C) 2009 eXo Platform SAS.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
   * the License, or (at your option) any later version.
   *
   * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
 package org.exoplatform.services.jcr.ext.replication.recovery.backup;
 
 
 import java.io.File;
 
Created by The eXo Platform SAS.

Author(s):
Alex Reshetnyak
Version:
$Id: BackupCreator.java 34445 2009-07-24 07:51:18Z dkatayev $
 
 
 public class BackupCreator implements Runnable
 {
   
The apache logger.
 
    private static Log log = ExoLogger.getLogger("exo.jcr.component.ext.BackupCreator");

   
The thread to BackupCreator.
 
    private Thread backupCreatorThread;

   
The delay timeout.
 
    private long delayTime;

   
The workspace name.
 
    private String workspaceName;

   
The backup directory.
 
    private File backupDir;

   
The ManageableRepository will be needed to thread naming.
 
The FileNameFactory will be created file names.
 
    private FileNameFactory fileNameFactory;

   
BackupCreator constructor.

Parameters:
delayTime the delay timeout
workspaceName the workspace name
backupDir the backup directory
manageableRepository the ManageableReposirory
 
    public BackupCreator(long delayTimeString workspaceNameFile backupDirManageableRepository manageableRepository)
    {
       this. = delayTime;
       this. = workspaceName;
       this. = backupDir;
       this. = manageableRepository;
 
        = new FileNameFactory();
 
        =
         new Thread(this"BackupCreatorThread@" + manageableRepository.getConfiguration().getName() + ":"
            + workspaceName);
   }

   
   public void run()
   {
      try
      {
         Thread.yield();
         Thread.sleep();
         .info("The backup has been started : " + .getConfiguration().getName() + "@"
            + );
         Calendar backupTime = Calendar.getInstance();
         String fileName =
            .getConfiguration().getName() + "_" +  + "_"
               + .getStrDate(backupTime) + "_" + .getStrTime(backupTime) + ".xml";
         File backupFile = new File(PrivilegedFileHelper.getCanonicalPath() + . + fileName);
         if (PrivilegedFileHelper.createNewFile(backupFile))
         {
            session.exportWorkspaceSystemView(PrivilegedFileHelper.fileOutputStream(backupFile), falsefalse);
            .info("The backup has been finished : " + .getConfiguration().getName() + "@"
               + );
         }
         else
            throw new IOException("Can't create file : " + PrivilegedFileHelper.getCanonicalPath(backupFile));
      }
      catch (InterruptedException ie)
      {
         .error("The InterruptedExeption"ie);
      }
      catch (RepositoryException e)
      {
         .error("The RepositoryException"e);
      }
      catch (IOException e)
      {
         .error("The IOException"e);
      }
   }
New to GrepCode? Check out our FAQ X