From 7e7fda533d4949c604671661d2a7ece4457edae6 Mon Sep 17 00:00:00 2001 From: "donghyuk.yang" Date: Mon, 7 Jan 2013 22:31:27 +0900 Subject: [PATCH] [Title] Fixed violations of sonar --- .../org/tizen/nativeplatform/git/GitCommander.java | 3 +- .../nativeplatform/rootstrap/RootstrapManager.java | 36 +++++++++++++--------- .../tizen/nativeplatform/util/CommandLauncher.java | 1 - .../wizards/TizenDebianProjectWizard.java | 5 ++- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/GitCommander.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/GitCommander.java index 8ab4ac4..d41aacb 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/GitCommander.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/GitCommander.java @@ -202,7 +202,8 @@ public class GitCommander { } }); } catch (CoreException ce) { - throw new InvocationTargetException(ce); + //throw new InvocationTargetException(ce); + ce.printStackTrace(); } } }); diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/rootstrap/RootstrapManager.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/rootstrap/RootstrapManager.java index 88c1ff8..b3cb41b 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/rootstrap/RootstrapManager.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/rootstrap/RootstrapManager.java @@ -222,6 +222,7 @@ public class RootstrapManager { // extract "tar" archive if( !CommandLauncher.execute( String.format("tar xvf %s", importFilePath), tempDirPath, "Platform Internal", monitor ) ) { + cleanUpRootstrap(pluginPath, rootstrapPath); throw new InterruptedException("Extracting rootsrap failed!"); } @@ -240,6 +241,7 @@ public class RootstrapManager { } ); if ( xmlFiles.length == 0 ) { + cleanUpRootstrap(pluginPath, rootstrapPath); throw new InterruptedException("There is no SBI plugin file(*.xml)"); } String pluginFilePath = xmlFiles[0].getPath().toString(); @@ -248,6 +250,7 @@ public class RootstrapManager { // check already exist? if( RootstrapManager.getRootstrap(pluginId) != null ) { + cleanUpRootstrap(pluginPath, rootstrapPath); throw new InterruptedException("There already exists the rootrap with same id!"); } @@ -260,10 +263,12 @@ public class RootstrapManager { try { SBIModel.reinitialize(); } catch (SBIException e) { + cleanUpRootstrap(pluginPath, rootstrapPath); throw new InterruptedException("SBIModel initialization failed!"); } result = createRootstrapFromSBIPlugin( pluginId ); if ( result == null ) { + cleanUpRootstrap(pluginPath, rootstrapPath); throw new InterruptedException("Loading SBI plugin failed!"); } @@ -279,25 +284,11 @@ public class RootstrapManager { if ( !CommandLauncher.executeSudo( String.format("sudo -S tar xvf %s/rootstrap.tar.gz", tempDirPath), baseDirDir.getPath(), "Platform Internal", monitor ) ) { + cleanUpRootstrap(pluginPath, rootstrapPath); throw new InterruptedException("Extracting rootsrap failed!"); } return result; - } - catch (InterruptedException e) { - if ( pluginPath != null ) { - CommandLauncher.execute( String.format("rm -rf %s", pluginPath) ); - try { - SBIModel.reinitialize(); - } catch (SBIException e1) { - throw new InterruptedException(e1.getMessage()); - } - } - if ( rootstrapPath != null ) { - CommandLauncher.executeSudo( String.format("sudo -S rm -rf %s", rootstrapPath), null ); - } - - throw new InterruptedException(e.getMessage()); } finally { // remove temporary directory @@ -305,6 +296,21 @@ public class RootstrapManager { } } + private static void cleanUpRootstrap(String pluginPath, String rootstrapPath) + throws InterruptedException{ + if ( pluginPath != null ) { + CommandLauncher.execute( String.format("rm -rf %s", pluginPath) ); + try { + SBIModel.reinitialize(); + } catch (SBIException e1) { + throw new InterruptedException(e1.getMessage()); + } + } + if ( rootstrapPath != null ) { + CommandLauncher.executeSudo( String.format("sudo -S rm -rf %s", rootstrapPath), null ); + } + } + private static String makeTempDirectory() { final File temp; diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/CommandLauncher.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/CommandLauncher.java index 191ef0a..ba4d00c 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/CommandLauncher.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/CommandLauncher.java @@ -426,7 +426,6 @@ public class CommandLauncher { killProcess.waitFor(); sendSignal = true; } - process.exitValue(); break; } catch(InterruptedException e) { diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/wizards/TizenDebianProjectWizard.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/wizards/TizenDebianProjectWizard.java index 003cc39..581db32 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/wizards/TizenDebianProjectWizard.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/wizards/TizenDebianProjectWizard.java @@ -64,7 +64,10 @@ public class TizenDebianProjectWizard extends CDTCommonProjectWizard{ continueCreationMonitor.beginTask("Add C/C++ Project Nature", 1); CProjectNature.addCNature(prj, new SubProgressMonitor(continueCreationMonitor, 1)); CCProjectNature.addCCNature(prj, new SubProgressMonitor(continueCreationMonitor, 1)); - } catch (CoreException e) {} + } catch (CoreException e) { + // nothing to do + e.printStackTrace(); + } finally {continueCreationMonitor.done();} return prj; } -- 2.7.4