Author: areshetnyak
Date: 2011-01-20 06:20:33 -0500 (Thu, 20 Jan 2011)
New Revision: 3821
Added:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JcrRestoreWiFilter.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestJcrRestoreWiFilter.java
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SysViewWorkspaceInitializer.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java
Log:
EXOJCR-1165 : The problem with "temporary jcrrestorewi*.tmp files not deleted"
was fixed.
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SysViewWorkspaceInitializer.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SysViewWorkspaceInitializer.java 2011-01-20
10:12:08 UTC (rev 3820)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SysViewWorkspaceInitializer.java 2011-01-20
11:20:33 UTC (rev 3821)
@@ -222,7 +222,7 @@
@Override
void close() throws IOException
{
- this.decoder.flush();
+ this.decoder.close();
}
@Override
@@ -297,7 +297,9 @@
super.flush();
if (buff != null)
+ {
buff.close();
+ }
}
File getFile() throws IOException
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java
===================================================================
---
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java 2011-01-20
10:12:08 UTC (rev 3820)
+++
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java 2011-01-20
11:20:33 UTC (rev 3821)
@@ -805,6 +805,13 @@
*/
public void start()
{
+ //remove if exists all old jcrrestorewi*.tmp files.
+ File[] files = PrivilegedFileHelper.listFiles(tempDir, new JcrRestoreWiFilter());
+ for (int i = 0; i < files.length; i++)
+ {
+ PrivilegedFileHelper.delete(files[i]);
+ }
+
// start all scheduled before tasks
if (registryService != null &&
!registryService.getForceXMLConfigurationValue(initParams))
Added:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JcrRestoreWiFilter.java
===================================================================
---
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JcrRestoreWiFilter.java
(rev 0)
+++
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JcrRestoreWiFilter.java 2011-01-20
11:20:33 UTC (rev 3821)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2003-2011 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.FilenameFilter;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 2011
+ *
+ * @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex
Reshetnyak</a>
+ * @version $Id: JcrRestoreWiFilter.java 111 2011-11-11 11:11:11Z rainf0x $
+ */
+public class JcrRestoreWiFilter
+ implements FilenameFilter
+{
+
+ public boolean accept(File dir, String name)
+ {
+ return name.endsWith(".tmp") &&
name.startsWith("jcrrestorewi");
+ }
+
+}
Added:
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestJcrRestoreWiFilter.java
===================================================================
---
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestJcrRestoreWiFilter.java
(rev 0)
+++
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestJcrRestoreWiFilter.java 2011-01-20
11:20:33 UTC (rev 3821)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2003-2011 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;
+
+import junit.framework.TestCase;
+
+import org.exoplatform.commons.utils.PrivilegedFileHelper;
+import org.exoplatform.commons.utils.PrivilegedSystemHelper;
+import org.exoplatform.services.jcr.ext.backup.impl.JcrRestoreWiFilter;
+
+import java.io.File;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 2011
+ *
+ * @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex
Reshetnyak</a>
+ * @version $Id: TestJcrREstoreWiFilter.java 111 2011-11-11 11:11:11Z rainf0x $
+ */
+public class TestJcrRestoreWiFilter
+ extends TestCase
+{
+
+ public void testListFiles() throws Exception
+ {
+ File tempDir = new
File(PrivilegedSystemHelper.getProperty("java.io.tmpdir") + File.separator +
Math.random());
+ PrivilegedFileHelper.mkdirs(tempDir);
+ PrivilegedFileHelper.deleteOnExit(tempDir);
+
+ for (int i = 0; i < 7; i++)
+ {
+ File f = PrivilegedFileHelper.createTempFile("jcrrestorewi",
".tmp", tempDir);
+ PrivilegedFileHelper.deleteOnExit(f);
+ }
+
+ File[] files = PrivilegedFileHelper.listFiles(tempDir, new JcrRestoreWiFilter());
+
+ assertEquals(7, files.length);
+ }
+}