Author: tolusha
Date: 2010-09-30 07:43:34 -0400 (Thu, 30 Sep 2010)
New Revision: 3222
Added:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/IndexCleanHelper.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/ValueStorageCleanHelper.java
Removed:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/IndexCleanerService.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/ValueStorageCleanerService.java
Log:
EXOJCR-747: code cleanup
Added:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/IndexCleanHelper.java
===================================================================
---
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/IndexCleanHelper.java
(rev 0)
+++
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/IndexCleanHelper.java 2010-09-30
11:43:34 UTC (rev 3222)
@@ -0,0 +1,83 @@
+/*
+ * 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;
+
+import org.exoplatform.services.jcr.config.QueryHandlerParams;
+import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * IndexCleanerService deliver tools for clean index data of workspace or repository.
+ *
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 2010
+ *
+ * @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex
Reshetnyak</a>
+ * @version $Id: IndexCleanerService.java 3210 2010-09-28 12:01:50Z areshetnyak $
+ */
+public class IndexCleanHelper
+{
+ /**
+ * Remove all file of workspace index.
+ *
+ * @param wsConfig - workspace configuration.
+ * @param isSystem - 'true' to clean system workspace.
+ * @throws RepositoryConfigurationException - exception on parsing workspace
configuration
+ * @throws IOException - exception on remove index folder
+ */
+ public void removeWorkspaceIndex(WorkspaceEntry wsConfig, boolean isSystem) throws
RepositoryConfigurationException, IOException
+ {
+ String indexDir =
wsConfig.getQueryHandler().getParameterValue(QueryHandlerParams.PARAM_INDEX_DIR);
+
+ removeFolder(new File(indexDir));
+
+ if (isSystem)
+ {
+ removeFolder(new File(indexDir + "_system"));
+ }
+ }
+
+ /**
+ * Remove folder
+ */
+ private void removeFolder(File dir) throws IOException
+ {
+ if (dir.isDirectory())
+ {
+ for (File subFile : dir.listFiles())
+ {
+ removeFolder(subFile);
+ }
+
+ if (!dir.delete())
+ {
+ throw new IOException("Index folder was not deleted : " +
dir.getCanonicalPath());
+ }
+ }
+ else
+ {
+ if (!dir.delete())
+ {
+ throw new IOException("Index file was not deleted : " +
dir.getCanonicalPath());
+ }
+ }
+ }
+}
Deleted:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/IndexCleanerService.java
===================================================================
---
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/IndexCleanerService.java 2010-09-30
10:31:24 UTC (rev 3221)
+++
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/IndexCleanerService.java 2010-09-30
11:43:34 UTC (rev 3222)
@@ -1,87 +0,0 @@
-/*
- * 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;
-
-import java.io.File;
-import java.io.IOError;
-import java.io.IOException;
-
-import javax.jcr.RepositoryException;
-import javax.naming.NamingException;
-
-import org.exoplatform.services.jcr.config.QueryHandlerParams;
-import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
-import org.exoplatform.services.jcr.config.WorkspaceEntry;
-
-/**
- * IndexCleanerService deliver tools for clean index data of workspace or repository.
- *
- * Created by The eXo Platform SAS.
- *
- * <br/>Date: 2010
- *
- * @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex
Reshetnyak</a>
- * @version $Id$
- */
-public class IndexCleanerService
-{
- /**
- * Remove all file of workspace index.
- *
- * @param wsConfig - workspace configuration.
- * @param isSystem - 'true' to clean system workspace.
- * @throws RepositoryConfigurationException - exception on parsing workspace
configuration
- * @throws IOException - exception on remove index folder
- */
- public static void removeWorkspaceIndex(WorkspaceEntry wsConfig, boolean isSystem)
throws RepositoryConfigurationException, IOException
- {
- String indexDir =
wsConfig.getQueryHandler().getParameterValue(QueryHandlerParams.PARAM_INDEX_DIR);
-
- removeFolder(new File(indexDir));
-
- if (isSystem)
- {
- removeFolder(new File(indexDir + "_system"));
- }
- }
-
- /**
- * Remove folder
- */
- private static void removeFolder(File dir) throws IOException
- {
- if (dir.isDirectory())
- {
- for (File subFile : dir.listFiles())
- {
- removeFolder(subFile);
- }
-
- if (!dir.delete())
- {
- throw new IOException("Index folder was not deleted : " +
dir.getCanonicalPath());
- }
- }
- else
- {
- if (!dir.delete())
- {
- throw new IOException("Index file was not deleted : " +
dir.getCanonicalPath());
- }
- }
- }
-}
Added:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/ValueStorageCleanHelper.java
===================================================================
---
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/ValueStorageCleanHelper.java
(rev 0)
+++
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/ValueStorageCleanHelper.java 2010-09-30
11:43:34 UTC (rev 3222)
@@ -0,0 +1,88 @@
+/*
+ * 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;
+
+import org.exoplatform.services.jcr.config.ContainerEntry;
+import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.config.ValueStorageEntry;
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
+import org.exoplatform.services.jcr.impl.storage.value.fs.FileValueStorage;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 2010
+ *
+ * @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex
Reshetnyak</a>
+ * @version $Id: ValueStorageCleanerService.java 3219 2010-09-30 07:40:51Z areshetnyak $
+ */
+public class ValueStorageCleanHelper
+{
+
+ /**
+ * Clear workspace value storage.
+ *
+ * @param wEntry
+ * workspace configuration
+ * @throws RepositoryConfigurationException
+ * @throws IOException
+ */
+ public void removeWorkspaceValueStorage(WorkspaceEntry wEntry) throws
RepositoryConfigurationException, IOException
+ {
+ ContainerEntry containerEntry = wEntry.getContainer();
+
+ if (containerEntry.getValueStorages() != null)
+ {
+ for (ValueStorageEntry valueStorageEntry : containerEntry.getValueStorages())
+ {
+ String path = valueStorageEntry.getParameterValue(FileValueStorage.PATH);
+
+ removeFolder(new File(path));
+ }
+ }
+ }
+
+ /**
+ * Remove folder
+ */
+ private void removeFolder(File dir) throws IOException
+ {
+ if (dir.isDirectory())
+ {
+ for (File subFile : dir.listFiles())
+ {
+ removeFolder(subFile);
+ }
+
+ if (!dir.delete())
+ {
+ throw new IOException("Value storage folder was not deleted : " +
dir.getCanonicalPath());
+ }
+ }
+ else
+ {
+ if (!dir.delete())
+ {
+ throw new IOException("Value storage file was not deleted : " +
dir.getCanonicalPath());
+ }
+ }
+ }
+
+}
Deleted:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/ValueStorageCleanerService.java
===================================================================
---
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/ValueStorageCleanerService.java 2010-09-30
10:31:24 UTC (rev 3221)
+++
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/ValueStorageCleanerService.java 2010-09-30
11:43:34 UTC (rev 3222)
@@ -1,80 +0,0 @@
-/*
- * 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;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.exoplatform.services.jcr.config.ContainerEntry;
-import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
-import org.exoplatform.services.jcr.config.ValueStorageEntry;
-import org.exoplatform.services.jcr.config.WorkspaceEntry;
-import org.exoplatform.services.jcr.impl.storage.value.fs.FileValueStorage;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * <br/>Date: 2010
- *
- * @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex
Reshetnyak</a>
- * @version $Id$
- */
-public class ValueStorageCleanerService
-{
-
- public static void removeWorkspaceValueStorage(WorkspaceEntry wEntry) throws
RepositoryConfigurationException, IOException
- {
- ContainerEntry containerEntry = wEntry.getContainer();
-
- if (containerEntry.getValueStorages() != null)
- {
- for (ValueStorageEntry valueStorageEntry : containerEntry.getValueStorages())
- {
- String path = valueStorageEntry.getParameterValue(FileValueStorage.PATH);
-
- removeFolder(new File(path));
- }
- }
- }
-
- /**
- * Remove folder
- */
- private static void removeFolder(File dir) throws IOException
- {
- if (dir.isDirectory())
- {
- for (File subFile : dir.listFiles())
- {
- removeFolder(subFile);
- }
-
- if (!dir.delete())
- {
- throw new IOException("Value storage folder was not deleted : " +
dir.getCanonicalPath());
- }
- }
- else
- {
- if (!dir.delete())
- {
- throw new IOException("Value storage file was not deleted : " +
dir.getCanonicalPath());
- }
- }
- }
-
-}