diff options
author | sb <sb@openoffice.org> | 2010-04-28 11:08:02 +0200 |
---|---|---|
committer | sb <sb@openoffice.org> | 2010-04-28 11:08:02 +0200 |
commit | 9501b9853084e65d9850fa81d8c5e46b9ed7d4e1 (patch) | |
tree | 57dab90cd325fcde077edf3b1ac081638935cafd | |
parent | 487c3b809916ca208251d2cead9b86cb151d1bc0 (diff) |
sb120: do not swallow exceptions
-rw-r--r-- | qadevOOo/runner/util/utils.java | 52 | ||||
-rw-r--r-- | qadevOOo/tests/java/mod/_dbaccess/ORowSet.java | 2 | ||||
-rw-r--r-- | qadevOOo/tests/java/mod/_forms/ODatabaseForm.java | 2 | ||||
-rw-r--r-- | qadevOOo/tests/java/mod/_sfx/StandaloneDocumentInfo.java | 2 |
4 files changed, 40 insertions, 18 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) { diff --git a/qadevOOo/tests/java/mod/_dbaccess/ORowSet.java b/qadevOOo/tests/java/mod/_dbaccess/ORowSet.java index 37311b118d0e..c349d5dcdb28 100644 --- a/qadevOOo/tests/java/mod/_dbaccess/ORowSet.java +++ b/qadevOOo/tests/java/mod/_dbaccess/ORowSet.java @@ -293,7 +293,7 @@ public class ORowSet extends TestCase { oldF = utils.getFullURL(origDB); newF = tempFolder + tableName + ".dbf"; } - while ( !utils.overwriteFile( orb, oldF, newF ) ); + while ( !utils.tryOverwriteFile( orb, oldF, newF ) ); m_tableFile = newF; } diff --git a/qadevOOo/tests/java/mod/_forms/ODatabaseForm.java b/qadevOOo/tests/java/mod/_forms/ODatabaseForm.java index fe44c30e7c05..4b360e20fd10 100644 --- a/qadevOOo/tests/java/mod/_forms/ODatabaseForm.java +++ b/qadevOOo/tests/java/mod/_forms/ODatabaseForm.java @@ -311,7 +311,7 @@ public class ODatabaseForm extends TestCase { oldF = utils.getFullURL(origDB); newF = utils.getOfficeTemp((XMultiServiceFactory) tParam.getMSF()) + tableName + ".dbf"; - } while (!utils.overwriteFile(((XMultiServiceFactory) tParam.getMSF()), oldF, newF) && + } while (!utils.tryOverwriteFile(((XMultiServiceFactory) tParam.getMSF()), oldF, newF) && (uniqueSuffix++ < 50)); } } diff --git a/qadevOOo/tests/java/mod/_sfx/StandaloneDocumentInfo.java b/qadevOOo/tests/java/mod/_sfx/StandaloneDocumentInfo.java index 715fdc72d371..81e0d459c0a3 100644 --- a/qadevOOo/tests/java/mod/_sfx/StandaloneDocumentInfo.java +++ b/qadevOOo/tests/java/mod/_sfx/StandaloneDocumentInfo.java @@ -87,7 +87,7 @@ public class StandaloneDocumentInfo extends TestCase { destUrl = utils.getOfficeTemp((XMultiServiceFactory)tParam.getMSF()) + "SfxStandaloneDocInfoObject.sdw"; - utils.overwriteFile((XMultiServiceFactory)tParam.getMSF(), srcUrl, destUrl) ; + utils.doOverwriteFile((XMultiServiceFactory)tParam.getMSF(), srcUrl, destUrl) ; } /** |