Author: tolusha
Date: 2012-02-07 07:12:58 -0500 (Tue, 07 Feb 2012)
New Revision: 5573
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/RepositoryServiceConfigurationImpl.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/DirectoryHelper.java
Log:
EXOJCR-1576: add special method with deleting destination file
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/RepositoryServiceConfigurationImpl.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/RepositoryServiceConfigurationImpl.java 2012-02-07
10:35:56 UTC (rev 5572)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/RepositoryServiceConfigurationImpl.java 2012-02-07
12:12:58 UTC (rev 5573)
@@ -18,9 +18,9 @@
*/
package org.exoplatform.services.jcr.impl.config;
+import org.exoplatform.commons.utils.ClassLoading;
import org.exoplatform.commons.utils.PrivilegedFileHelper;
import org.exoplatform.commons.utils.SecurityHelper;
-import org.exoplatform.commons.utils.ClassLoading;
import org.exoplatform.container.configuration.ConfigurationManager;
import org.exoplatform.container.xml.InitParams;
import org.exoplatform.container.xml.ValueParam;
@@ -184,7 +184,7 @@
{
public Void run() throws IOException
{
- DirectoryHelper.renameFile(sourceConfig, backUp);
+ DirectoryHelper.deleteDstAndRename(sourceConfig, backUp);
return null;
}
});
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/DirectoryHelper.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/DirectoryHelper.java 2012-02-07
10:35:56 UTC (rev 5572)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/DirectoryHelper.java 2012-02-07
12:12:58 UTC (rev 5573)
@@ -354,6 +354,31 @@
}
/**
+ * Rename file. Trying to remove destination first.
+ * If file can't be renamed in standard way the coping
+ * data will be used instead.
+ *
+ * @param srcFile
+ * source file
+ * @param dstFile
+ * destination file
+ * @throws IOException
+ * if any exception occurred
+ */
+ public static void deleteDstAndRename(File srcFile, File dstFile) throws IOException
+ {
+ if (dstFile.exists())
+ {
+ if (!dstFile.delete())
+ {
+ throw new IOException("Cannot delete " + dstFile);
+ }
+ }
+
+ renameFile(srcFile, dstFile);
+ }
+
+ /**
* Rename file. If file can't be renamed in standard way the coping
* data will be used instead.
*
Show replies by date