summaryrefslogtreecommitdiff
path: root/qadevOOo/runner
diff options
context:
space:
mode:
authorsb <sb@openoffice.org>2010-04-28 11:08:02 +0200
committersb <sb@openoffice.org>2010-04-28 11:08:02 +0200
commit9501b9853084e65d9850fa81d8c5e46b9ed7d4e1 (patch)
tree57dab90cd325fcde077edf3b1ac081638935cafd /qadevOOo/runner
parent487c3b809916ca208251d2cead9b86cb151d1bc0 (diff)
sb120: do not swallow exceptions
Diffstat (limited to 'qadevOOo/runner')
-rw-r--r--qadevOOo/runner/util/utils.java52
1 files changed, 37 insertions, 15 deletions
diff --git a/qadevOOo/runner/util/utils.java b/qadevOOo/runner/util/utils.java
index 1091824480a6..3f882f10fafb 100644
--- a/qadevOOo/runner/util/utils.java
+++ b/qadevOOo/runner/util/utils.java
@@ -45,6 +45,7 @@ import com.sun.star.beans.XPropertySet;
import com.sun.star.beans.Property;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.uno.UnoRuntime;
+import com.sun.star.ucb.InteractiveAugmentedIOException;
import com.sun.star.ucb.XSimpleFileAccess;
import com.sun.star.lang.XServiceInfo;
@@ -542,16 +543,10 @@ public class utils {
return res;
}
- /**
- * Copies file to a new location using OpenOffice.org features. If the target
- * file already exists, the file is deleted.
- *
- * @returns <code>true</code> if the file was successfully copied,
- * <code>false</code> if some errors occured (e.g. file is locked, used
- * by another process).
- */
- public static boolean overwriteFile(XMultiServiceFactory xMsf, String oldF, String newF) {
- boolean res = false;
+ private static void overwriteFile_impl(
+ XMultiServiceFactory xMsf, String oldF, String newF)
+ throws InteractiveAugmentedIOException
+ {
try {
Object fileacc = xMsf.createInstance("com.sun.star.comp.ucb.SimpleFileAccess");
@@ -561,15 +556,42 @@ public class utils {
simpleAccess.kill(newF);
}
simpleAccess.copy(oldF, newF);
- res = true;
- } catch (com.sun.star.ucb.InteractiveAugmentedIOException e) {
- return false;
+ } catch (InteractiveAugmentedIOException e) {
+ throw e;
} catch (com.sun.star.uno.Exception e) {
- System.out.println("Couldn't copy " + oldF + " to " + newF + ".");
+ System.out.println("Couldn't copy " + oldF + " to " + newF + ":");
e.printStackTrace();
+ throw new RuntimeException(e);
}
+ }
- return res;
+ /**
+ * Copies file to a new location using OpenOffice.org features. If the target
+ * file already exists, the file is deleted.
+ *
+ * @returns <code>true</code> if the file was successfully copied,
+ * <code>false</code> if some errors occured (e.g. file is locked, used
+ * by another process).
+ */
+ public static boolean tryOverwriteFile(
+ XMultiServiceFactory xMsf, String oldF, String newF)
+ {
+ try {
+ overwriteFile_impl(xMsf, oldF, newF);
+ } catch (InteractiveAugmentedIOException e) {
+ return false;
+ }
+ return true;
+ }
+
+ public static void doOverwriteFile(
+ XMultiServiceFactory xMsf, String oldF, String newF)
+ {
+ try {
+ overwriteFile_impl(xMsf, oldF, newF);
+ } catch (InteractiveAugmentedIOException e) {
+ throw new RuntimeException(e);
+ }
}
public static boolean hasPropertyByName(XPropertySet props, String aName) {