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.backup.impl;
  
  import  org.picocontainer.Startable;
  
  import java.io.File;
  import java.util.HashSet;
  import java.util.List;
  import java.util.Map;
  import java.util.Set;
  
Created by The eXo Platform SAS .

Author(s):
Gennady Azarenkov
Version:
$Id: $
  
  
  public class BackupManagerImpl implements ExtendedBackupManager, Startable
 {
 
    protected static Log log = ExoLogger.getLogger("exo.jcr.component.ext.BackupManagerImpl");

   
Name of default incremental job period parameter in configuration.
 
    public final static String DEFAULT_INCREMENTAL_JOB_PERIOD = "default-incremental-job-period";

   
Name of backup properties parameter in configuration.
 
    public final static String BACKUP_PROPERTIES = "backup-properties";

   
Name of full backup type parameter in configuration.
 
    public final static String FULL_BACKUP_TYPE = "full-backup-type";

   
Name of incremental backup type parameter in configuration.
 
    public final static String INCREMENTAL_BACKUP_TYPE = "incremental-backup-type";

   
Default value of incremental job period parameter in configuration.
 
    public final static String DEFAULT_VALUE_INCREMENTAL_JOB_PERIOD = "3600";

   
Default value of incremental backup type parameter in configuration.
 
    public final static String DEFAULT_VALUE_INCREMENTAL_BACKUP_TYPE =
Default value of incremental backup type parameter in configuration.
 
    public final static String DEFAULT_VALUE_FULL_BACKUP_TYPE =
Name of backup dir parameter in configuration.
 
    public final static String BACKUP_DIR = "backup-dir";

   
Backup messages log max. size.
 
    private static final int MESSAGES_MAXSIZE = 5;
 
    private static final String SERVICE_NAME = "BackupManager";

   
The timeout to checking finish of backup.
 
    private static final long AUTO_STOPPER_TIMEOUT = 5000;

   
Value of default incremental job period.
 
    private long defaultIncrementalJobPeriod;

   
Value of default incremental period.
 
    private String defIncrPeriod;

   
Path to backup folder.
 
    private String backupDir;

   
Value of full backup type.
 
    private String fullBackupType;

   
Value of incremental backup type.
 
    private String incrementalBackupType;

   
Set of current workspace backups.
 
    private final Set<BackupChaincurrentBackups;

   
Set of current repository backups.
 
    private final Set<RepositoryBackupChaincurrentRepositoryBackups;

   
The list of workspace restore job.
 
    private List<JobWorkspaceRestorerestoreJobs;

   
The list of repository restore job.
 
Initialization parameters of service.
 
    private InitParams initParams;

   
Directory to log.
 
    private File logsDirectory;
 
    private final RepositoryService repoService;
 
    private final RegistryService registryService;
 
    private BackupScheduler scheduler;
 
    private final BackupMessagesLog messages;
 
    private final MessagesListener messagesListener;
 
 
Temporary directory;
 
    private final File tempDir;
 
    class MessagesListener implements BackupJobListener
    {
 
       public void onError(BackupJob jobString messageThrowable error)
       {
          .addError(makeJobInfo(joberror) + messageerror);
          .error(makeJobInfo(joberror) + messageerror);
       }
 
       public void onStateChanged(BackupJob job)
       {
          .addMessage(makeJobInfo(jobnull));
          if (.isDebugEnabled())
          {
             .debug(makeJobInfo(jobnull));
          }
       }
 
       private String makeJobInfo(BackupJob jobThrowable error)
       {
          StringBuilder jobInfo = new StringBuilder();
 
          if (job != null)
          {
 
             switch (job.getType())
             {
                case . : {
                   jobInfo.append("FULL BACKUP");
                   break;
                }
                case . : {
                   jobInfo.append("INCREMENTAL BACKUP");
                   break;
                }
             }
 
             jobInfo.append(" [");
             switch (job.getState())
             {
                case . : {
                   jobInfo.append("FINISHED");
                   break;
                }
                case . : {
                   jobInfo.append("STARTING");
                   break;
                }
                case . : {
                   jobInfo.append("WAITING");
                   break;
                }
                case . : {
                   jobInfo.append("WORKING");
                   break;
                }
             }
 
             jobInfo.append("]");
 
             if (error != null)
             {
                jobInfo.append(" Error: ").append(error.getMessage());
             }
 
             try
             {
                jobInfo.append(" log: ").append(job.getStorageURL().getPath());
             }
             catch (BackupOperationException e)
             {
                // skip URL
             }
             finally
             {
                jobInfo.append(" ");
             }
          }
 
          return jobInfo.toString();
       }
 
       public String printStackTrace(Throwable error)
       {
 
          ByteArrayOutputStream out = new ByteArrayOutputStream();
          PrintWriter writer = new PrintWriter(out);
          error.printStackTrace(writer);
 
          return new String(out.toByteArray());
       }
    }
 
    class TaskFilter implements FileFilter
    {
 
       public boolean accept(File pathname)
       {
          return pathname.getName().endsWith(".task");
       }
    }
 
    class WorkspaceBackupAutoStopper extends Thread
    {
 
       private boolean isToBeStopped = false;
 
       {
          super("WorkspaceBackupAutoStopper" + (ctx == null ? "" : " " + ctx.getName()));
       }

      
 
       @Override
       public void run()
       {
          while (!)
          {
             try
             {
                Thread.sleep();
 
                Iterator<BackupChainit = .iterator();
                List<BackupChainstopedList = new ArrayList<BackupChain>();
 
                while (it.hasNext())
                {
                   BackupChain chain = it.next();
                   boolean isFinished = (chain.getBackupJobs().get(0).getState() == .);
 
                   for (int i = 1; i < chain.getBackupJobs().size(); i++)
                   {
                      isFinished &= (chain.getBackupJobs().get(i).getState() == .);
                   }
 
                   if (isFinished)
                   {
                      stopedList.add(chain);
                   }
                }
 
                // STOP backups
                for (BackupChain chain : stopedList)
                {
                   stopBackup(chain);
                }
             }
             catch (InterruptedException e)
             {
                .error("The interapted this thread."e);
             }
             catch (Throwable e)
             {
                .error("The unknown error"e);
             }
          }
       }
 
       public void close()
       {
           = true;
       }
    }
 
    class RepositoryBackupAutoStopper extends Thread
    {
       boolean isToBeStopped = false;
 
       {
          super("RepositoryBackupAutoStopper" + (ctx == null ? "" : " " + ctx.getName()));
       }

      
 
       @Override
       public void run()
       {
          while (!)
          {
             try
             {
                Thread.sleep();
 
                Iterator<RepositoryBackupChainit = .iterator();
                List<RepositoryBackupChainstopedList = new ArrayList<RepositoryBackupChain>();
 
                while (it.hasNext())
                {
                   RepositoryBackupChain chain = it.next();
 
                   if (chain.isFinished())
                   {
                      stopedList.add(chain);
                   }
                }
 
                // STOP backups
                for (RepositoryBackupChain chain : stopedList)
                {
                   stopBackup(chain);
                }
             }
             catch (InterruptedException e)
             {
                .error("The interapted this thread."e);
             }
             catch (Throwable e)
             {
                .error("The unknown error"e);
             }
          }
       }
 
       public void close()
       {
           = true;
       }
    }

   
BackupManagerImpl constructor.

Parameters:
initParams InitParams, the init parameters
repoService RepositoryService, the repository service
 
    public BackupManagerImpl(InitParams initParamsRepositoryService repoService)
    {
       this(nullinitParamsrepoServicenull);
    }

   
BackupManagerImpl constructor.

Parameters:
initParams InitParams, the init parameters
repoService RepositoryService, the repository service
 
    public BackupManagerImpl(ExoContainerContext ctxInitParams initParamsRepositoryService repoService)
    {
       this(ctxinitParamsrepoServicenull);
    }

   
BackupManagerImpl constructor. InitParams, the init parameters

Parameters:
repoService RepositoryService, the repository service
registryService RegistryService, the registry service
 
    public BackupManagerImpl(InitParams initParamsRepositoryService repoServiceRegistryService registryService)
    {
       this(nullinitParamsrepoServiceregistryService);
    }

   
BackupManagerImpl constructor. InitParams, the init parameters

Parameters:
repoService RepositoryService, the repository service
registryService RegistryService, the registry service
 
    public BackupManagerImpl(ExoContainerContext ctxInitParams initParamsRepositoryService repoService,
       RegistryService registryService)
    {
       this. = new MessagesListener();
       this. = repoService;
       this. = registryService;
       this. = initParams;
       this. = new File(PrivilegedSystemHelper.getProperty("java.io.tmpdir"));
 
        = Collections.synchronizedSet(new HashSet<BackupChain>());
 
 
 
        = new BackupScheduler(this);
 
       this. = new ArrayList<JobWorkspaceRestore>();
 
       this. = new WorkspaceBackupAutoStopper(ctx);
       this..start();
 
       this..start();
    }

   
 
    {
       return ;
    }

   
 
    public BackupMessage[] getMessages()
    {
       return .getMessages();
    }

   
 
    public BackupChainLog[] getBackupsLogs()
    {
       File[] cfs = PrivilegedFileHelper.listFiles(new BackupLogsFilter());
       List<BackupChainLoglogs = new ArrayList<BackupChainLog>();
       for (int i = 0; i < cfs.lengthi++)
       {
          File cf = cfs[i];
 
          try
          {
             if (!isCurrentBackup(cf))
             {
                logs.add(new BackupChainLog(cf));
             }
          }
          catch (BackupOperationException e)
          {
             .warn("Log file " + PrivilegedFileHelper.getAbsolutePath(cf) + " is bussy or corrupted. Skipped. " + e,
                e);
          }
       }
       BackupChainLog[] ls = new BackupChainLog[logs.size()];
       logs.toArray(ls);
       return ls;
    }

   
 
    {
       File[] cfs = PrivilegedFileHelper.listFiles(new RepositoryBackupLogsFilter());
       for (int i = 0; i < cfs.lengthi++)
       {
          File cf = cfs[i];
 
          try
          {
             if (!isCurrentRepositoryBackup(cf))
             {
                logs.add(new RepositoryBackupChainLog(cf));
             }
          }
          catch (BackupOperationException e)
          {
             .warn("Log file " + PrivilegedFileHelper.getAbsolutePath(cf) + " is bussy or corrupted. Skipped. " + e,
                e);
          }
       }
       RepositoryBackupChainLog[] ls = new RepositoryBackupChainLog[logs.size()];
       logs.toArray(ls);
       return ls;
    }

   
isCurrentBackup.

Parameters:
log File, the log to backup
Returns:
boolean return the 'true' if this log is current backup.
 
    private boolean isCurrentBackup(File log)
    {
       for (BackupChain chain : )
       {
          if (log.getName().equals(new File(chain.getLogFilePath()).getName()))
          {
             return true;
          }
       }
 
       return false;
    }

   
isCurrentRepositoryBackup.

Parameters:
log File, the log to backup
Returns:
boolean return the 'true' if this log is current backup.
 
    private boolean isCurrentRepositoryBackup(File log)
    {
       for (RepositoryBackupChain chain : )
       {
          if (log.getName().equals(new File(chain.getLogFilePath()).getName()))
          {
             return true;
          }
       }
 
       return false;
    }

   
 
    @Deprecated
    public void restore(BackupChainLog logString repositoryNameWorkspaceEntry workspaceEntry)
    {
       List<JobEntryInfolist = log.getJobEntryInfos();
       BackupConfig config = log.getBackupConfig();
 
       String reposytoryName = (repositoryName == null ? config.getRepository() : repositoryName);
       String workspaceName = workspaceEntry.getName();
 
       // ws should be registered not created
       if (!workspaceAlreadyExist(reposytoryNameworkspaceName))
       {
 
          for (int i = 0; i < list.size(); i++)
          {
             if (i == 0)
             {
                try
                {
                   fullRestore(list.get(i).getURL().getPath(), reposytoryNameworkspaceNameworkspaceEntry);
                }
                catch (FileNotFoundException e)
                {
                   throw new BackupOperationException("Restore of full backup file error " + ee);
                }
                catch (IOException e)
                {
                   throw new BackupOperationException("Restore of full backup file I/O error " + ee);
                }
             }
             else
             {
                try
                {
                   incrementalRestore(list.get(i).getURL().getPath(), reposytoryNameworkspaceName);
                }
                catch (FileNotFoundException e)
                {
                   throw new BackupOperationException("Restore of incremental backup file error " + ee);
                }
                catch (IOException e)
                {
                   throw new BackupOperationException("Restore of incremental backup file I/O error " + ee);
                }
                catch (ClassNotFoundException e)
                {
                   throw new BackupOperationException("Restore of incremental backup error " + ee);
                }
             }
          }
       }
       else
       {
          throw new BackupConfigurationException("Workspace should exists " + workspaceName);
       }
    }
 
    protected void restoreOverInitializer(BackupChainLog logString repositoryNameWorkspaceEntry workspaceEntry)
    {
 
       List<JobEntryInfolist = log.getJobEntryInfos();
       BackupConfig config = log.getBackupConfig();
 
       String reposytoryName = (repositoryName == null ? config.getRepository() : repositoryName);
       String workspaceName = workspaceEntry.getName();
 
       String fullbackupType = null;
 
       try
       {
          if ((Class.forName(log.getFullBackupType()).equals(FullBackupJob.class)))
          {
             fullbackupType = log.getFullBackupType();
          }
          else if ((Class.forName(log.getFullBackupType())
             .equals(org.exoplatform.services.jcr.ext.backup.impl.rdbms.FullBackupJob.class)))
          {
             fullbackupType = log.getFullBackupType();
          }
          else
          {
             throw new BackupOperationException("Class  \"" + log.getFullBackupType()
                + "\" is not support as full backup.");
          }
       }
       catch (ClassNotFoundException e)
       {
          throw new BackupOperationException("Class \"" + log.getFullBackupType() + "\" is not found."e);
       }
 
       // ws should not exists.
       if (!workspaceAlreadyExist(reposytoryNameworkspaceName))
       {
 
          for (int i = 0; i < list.size(); i++)
          {
             if (i == 0)
             {
                try
                {
                   fullRestoreOverInitializer(list.get(i).getURL().getPath(), reposytoryNameworkspaceEntry,
                      fullbackupType);
                }
                catch (FileNotFoundException e)
                {
                   throw new BackupOperationException("Restore of full backup file error " + ee);
                }
                catch (IOException e)
                {
                   throw new BackupOperationException("Restore of full backup file I/O error " + ee);
                }
                catch (ClassNotFoundException e)
                {
                   throw new BackupOperationException("Restore of full backup class load error " + ee);
                }
 
                .getConfig().retain(); // save configuration to persistence (file or persister)
             }
             else
             {
                try
                {
                   incrementalRestore(list.get(i).getURL().getPath(), reposytoryNameworkspaceName);
                }
                catch (FileNotFoundException e)
                {
                   throw new BackupOperationException("Restore of incremental backup file error " + ee);
                }
                catch (IOException e)
                {
                   throw new BackupOperationException("Restore of incremental backup file I/O error " + ee);
                }
                catch (ClassNotFoundException e)
                {
                   throw new BackupOperationException("Restore of incremental backup error " + ee);
                }
             }
          }
       }
       else
       {
          throw new BackupConfigurationException("Workspace \"" + workspaceName + "\" should not exists.");
       }
    }
 
    private boolean workspaceAlreadyExist(String repositoryString workspacethrows RepositoryException,
    {
       String[] ws = .getRepository(repository).getWorkspaceNames();
 
       for (int i = 0; i < ws.lengthi++)
       {
          if (ws[i].equals(workspace))
          {
             return true;
          }
       }
       return false;
    }

   
 
    {
 
       return startBackup(confignull);
    }

   
Internally used for call with job listener from scheduler.

Parameters:
config
jobListener
Returns:
Throws:
BackupOperationException
BackupConfigurationException
RepositoryException
RepositoryConfigurationException
 
    {
       validateBackupConfig(config);
 
       Calendar startTime = Calendar.getInstance();
       File dir =
          FileNameProducer.generateBackupSetDir(config.getRepository(), config.getWorkspace(), config.getBackupDir()
             .getPath(), startTime);
       PrivilegedFileHelper.mkdirs(dir);
       config.setBackupDir(dir);
 
       BackupChain bchain =
          new BackupChainImpl(config, IdGenerator
             .generate(), startTime);
 
       bchain.addListener();
       bchain.addListener(jobListener);
 
       .add(bchain);
       bchain.startBackup();
 
       return bchain;
    }

   
Initialize backup chain to workspace backup.

Parameters:
config
Returns:
Throws:
BackupOperationException
BackupConfigurationException
RepositoryException
RepositoryConfigurationException
 
    {
       if (config.getIncrementalJobPeriod() < 0)
       {
          throw new BackupConfigurationException("The parameter 'incremental job period' can not be negative.");
       }
 
       if (config.getIncrementalJobNumber() < 0)
       {
          throw new BackupConfigurationException("The parameter 'incremental job number' can not be negative.");
       }
 
       if (config.getIncrementalJobPeriod() == 0 && config.getBackupType() == .)
       {
       }
    }

   
 
    public void stopBackup(BackupChain backup)
    {
       backup.stopBackup();
       .remove(backup);
    }

   
 
    public void start()
    {
       if (!PrivilegedFileHelper.exists())
       {
          throw new IllegalStateException("Directory " + .getAbsolutePath() + " not found. Please create it.");
       }
 
       //remove if exists all old jcrrestorewi*.tmp files.
       File[] files = PrivilegedFileHelper.listFiles(new JcrRestoreWiFilter());
       for (int i = 0; i < files.lengthi++)
       {
          PrivilegedFileHelper.delete(files[i]);
       }
 
       // start all scheduled before tasks
       {
          SessionProvider sessionProvider = SessionProvider.createSystemProvider();
          try
          {
             readParamsFromRegistryService(sessionProvider);
          }
          catch (Exception e)
          {
             readParamsFromFile();
             try
             {
                writeParamsToRegistryService(sessionProvider);
             }
             catch (Exception exc)
             {
                .error("Cannot write init configuration to RegistryService."exc);
             }
          }
          finally
          {
             sessionProvider.close();
          }
       }
       else
       {
          readParamsFromFile();
       }
 
       // scan for task files
       File[] tasks = PrivilegedFileHelper.listFiles(this.new TaskFilter());
       for (File task : tasks)
       {
          try
          {
             .restore(task);
          }
          catch (BackupSchedulerException e)
          {
             .error("Can't restore backup scheduler task from file " + PrivilegedFileHelper.getAbsolutePath(task), e);
          }
          catch (BackupOperationException e)
          {
             .error("Can't restore backup scheduler task from file " + PrivilegedFileHelper.getAbsolutePath(task), e);
          }
          catch (BackupConfigurationException e)
          {
             .error("Can't restore backup scheduler task from file " + PrivilegedFileHelper.getAbsolutePath(task), e);
          }
          catch (RepositoryException e)
          {
             .error("Can't restore backup scheduler task from file " + PrivilegedFileHelper.getAbsolutePath(task), e);
          }
          catch (RepositoryConfigurationException e)
          {
             .error("Can't restore backup scheduler task from file " + PrivilegedFileHelper.getAbsolutePath(task), e);
          }
       }
    }

   
 
    public void stop()
    {
       .cancelTimer();
 
       // 1. stop current backup chains
       // for (Iterator iterator = currentBackups.iterator(); iterator.hasNext();) {
       // BackupChain bc = (BackupChain) iterator.next();
       // stopBackup(bc);
       // }
       //    
       // // 2. stop all scheduled tasks
       // scheduler = null;
    }
 
    @Deprecated
    private void fullRestore(String pathBackupFileString repositoryNameString workspaceName,
       WorkspaceEntry workspaceEntrythrows FileNotFoundExceptionIOExceptionRepositoryException,
    {
 
       RepositoryImpl defRep = (RepositoryImpl).getRepository(repositoryName);
 
      defRep.importWorkspace(workspaceEntry.getName(), PrivilegedFileHelper.fileInputStream(pathBackupFile));
   }
   private void fullRestoreOverInitializer(String pathBackupFileString repositoryNameWorkspaceEntry workspaceEntry,
      String fBackupTypethrows FileNotFoundExceptionIOExceptionRepositoryException,
   {
      WorkspaceInitializerEntry wieOriginal = workspaceEntry.getInitializer();
      RepositoryImpl defRep = (RepositoryImpl).getRepository(repositoryName);
      if ((Class.forName(fBackupType).equals(FullBackupJob.class)))
      {
         // set the initializer SysViewWorkspaceInitializer
         wiEntry.setType(SysViewWorkspaceInitializer.class.getCanonicalName());
         List<SimpleParameterEntrywieParams = new ArrayList<SimpleParameterEntry>();
         wieParams.add(new SimpleParameterEntry(.pathBackupFile));
         wiEntry.setParameters(wieParams);
      }
      else if ((Class.forName(fBackupType)
      {
         // set the initializer RdbmsWorkspaceInitializer
         wiEntry.setType(RdbmsWorkspaceInitializer.class.getCanonicalName());
         List<SimpleParameterEntrywieParams = new ArrayList<SimpleParameterEntry>();
            pathBackupFile).getParent()));
         wiEntry.setParameters(wieParams);
      }
      workspaceEntry.setInitializer(wiEntry);
      //restore
      defRep.configWorkspace(workspaceEntry);
      defRep.createWorkspace(workspaceEntry.getName());
      //set original workspace initializer
      WorkspaceContainerFacade wcf = defRep.getWorkspaceContainer(workspaceEntry.getName());
      WorkspaceEntry createdWorkspaceEntry = (WorkspaceEntry)wcf.getComponent(WorkspaceEntry.class);
      createdWorkspaceEntry.setInitializer(wieOriginal);
   }
   private void incrementalRestore(String pathBackupFileString repositoryNameString workspaceName)
   {
      WorkspaceContainerFacade workspaceContainer =
         .getRepository(repositoryName).getWorkspaceContainer(workspaceName);
      WorkspacePersistentDataManager dataManager =
      FileCleaner fileCleaner =
         ((FileCleanerHolder)workspaceContainer.getComponent(FileCleanerHolder.class)).getFileCleaner();
      JCRRestore restorer = new JCRRestore(dataManagerfileCleaner);
      restorer.incrementalRestore(new File(pathBackupFile));
   }

   
Write parameters to RegistryService.

Parameters:
sessionProvider The SessionProvider
Throws:
ParserConfigurationException
SAXException
IOException
RepositoryException
   private void writeParamsToRegistryService(SessionProvider sessionProviderthrows IOExceptionSAXException,
   {
      {
         public Document run() throws Exception
         {
            return DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
         }
      });
      Element root = doc.createElement();
      doc.appendChild(root);
      Element element = doc.createElement();
      setAttributeSmart(element);
      root.appendChild(element);
      RegistryEntry serviceEntry = new RegistryEntry(doc);
      .createEntry(sessionProvider.serviceEntry);
   }

   
Read parameters from RegistryService.

Parameters:
sessionProvider The SessionProvider
Throws:
RepositoryException
PathNotFoundException
   private void readParamsFromRegistryService(SessionProvider sessionProviderthrows PathNotFoundException,
   {
      String entryPath = . + "/" +  + "/" + ;
      RegistryEntry registryEntry = .getEntry(sessionProviderentryPath);
      Document doc = registryEntry.getDocument();
      Element element = doc.getDocumentElement();
       = getAttributeSmart(element);
      .info("Backup dir from RegistryService: " + );
      .info("Default incremental job period from RegistryService: " + );
      .info("Full backup type from RegistryService: " + );
      .info("Incremental backup type from RegistryService: " + );
      checkParams();
   }

   
Get attribute value.

Parameters:
element The element to get attribute value
attr The attribute name
Returns:
Value of attribute if present and null in other case
   private String getAttributeSmart(Element elementString attr)
   {
      return element.hasAttribute(attr) ? element.getAttribute(attr) : null;
   }

   
Set attribute value. If value is null the attribute will be removed.

Parameters:
element The element to set attribute value
attr The attribute name
value The value of attribute
   private void setAttributeSmart(Element elementString attrString value)
   {
      if (value == null)
      {
         element.removeAttribute(attr);
      }
      else
      {
         element.setAttribute(attrvalue);
      }
   }

   
Get parameters which passed from the file.

Throws:
RepositoryConfigurationException
   private void readParamsFromFile()
   {
       = pps.getProperty();
      // full backup type can be not defined. Using default.
       =
      // incremental backup can be not configured. Using default values.
       =
            .getProperty();
      .info("Backup dir from configuration file: " + );
      .info("Full backup type from configuration file: " + );
      .info("(Experimental) Incremental backup type from configuration file: " + );
      .info("(Experimental) Default incremental job period from configuration file: " + );
      checkParams();
   }

   
Check read params and initialize.
   private void checkParams()
   {
      if ( == null)
      {
         throw new IllegalStateException( + " not specified");
      }
       = new File();
      if (!PrivilegedFileHelper.exists())
      {
         if (!PrivilegedFileHelper.mkdirs())
         {
            throw new IllegalStateException("Could not create the backup directory at "
               +