Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright (C) 2003-2010 eXo Platform SAS.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Affero General Public License
  * as published by the Free Software Foundation; either version 3
  * of the License, or (at your option) any later version.
  *
  * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see<http://www.gnu.org/licenses/>.
 */
package org.exoplatform.services.jcr.ext.backup.impl;
IndexCleanerService deliver tools for clean index data of workspace or repository. Created by The eXo Platform SAS.
Date: 2010

Author(s):
Alex Reshetnyak
Version:
$Id: IndexCleanerService.java 3210 2010-09-28 12:01:50Z areshetnyak $
public class IndexCleanHelper
{
   
Remove all file of workspace index.

Parameters:
wsConfig - workspace configuration.
isSystem - 'true' to clean system workspace.
Throws:
org.exoplatform.services.jcr.config.RepositoryConfigurationException - exception on parsing workspace configuration
java.io.IOException - exception on remove index folder
   public void removeWorkspaceIndex(WorkspaceEntry wsConfigboolean isSystemthrows RepositoryConfigurationException,
            IOException
   {
      
      File indexDir = new File(indexDirName);
      if (PrivilegedFileHelper.exists(indexDir))
      {
         removeFolder(indexDir);
      }
      
      if (isSystem)
      {
         File systemIndexDir = new File(indexDirName + "_" + .);
         if (PrivilegedFileHelper.exists(systemIndexDir))
         {
            removeFolder(systemIndexDir);
         }
      }
   }
   
   
Remove folder
   private void removeFolder(File dirthrows IOException 
   {
      if (PrivilegedFileHelper.isDirectory(dir))
      {  
         for (File subFile : PrivilegedFileHelper.listFiles(dir))
         {
            removeFolder(subFile);
         }
         
         if (!PrivilegedFileHelper.delete(dir))
         {
            throw new IOException("Index folder was not deleted : " + PrivilegedFileHelper.getCanonicalPath(dir));
         }
      }
      else
      {
         if (!PrivilegedFileHelper.delete(dir))
         {
            throw new IOException("Index file was not deleted : " + PrivilegedFileHelper.getCanonicalPath(dir));
         }
      }
   }
New to GrepCode? Check out our FAQ X