[Title] add boilerplate and add close function for sonar
authorjihye kim <jihye1128.kim@samsung.com>
Fri, 24 Aug 2012 05:29:37 +0000 (14:29 +0900)
committerjihye kim <jihye1128.kim@samsung.com>
Fri, 24 Aug 2012 06:00:56 +0000 (15:00 +0900)
[Type] work
[Module] emulator manager
[Priority] major
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

package/pkginfo.manifest
src/org/tizen/emulator/manager/image/BaseImage.java
src/org/tizen/emulator/manager/image/Skins.java
src/org/tizen/emulator/manager/tool/SelectSkin.java
src/org/tizen/emulator/manager/tool/SelectTemplate.java
src/org/tizen/emulator/manager/ui/detail/TableWidget.java
src/org/tizen/emulator/manager/ui/detail/TableWidgetChangeListener.java
src/org/tizen/emulator/manager/vms/VMsWorker.java

index ea4c7d9..3774e65 100644 (file)
@@ -1,5 +1,5 @@
 Source: emulator-manager
-Version: 1.3.25
+Version: 1.3.26
 Maintainer: Yeong-Kyoon Lee<yeongkyoon.lee@samsung.com>
 
 Package: emulator-manager
index 85de9f9..ced94b6 100644 (file)
@@ -31,8 +31,11 @@ package org.tizen.emulator.manager.image;
 
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.IOException;
 import java.util.Properties;
+import java.util.logging.Level;
 
+import org.tizen.emulator.manager.logging.EMLogger;
 import org.tizen.emulator.manager.tool.StringResource;
 
 public class BaseImage {
@@ -68,26 +71,35 @@ public class BaseImage {
        private void loadProperty(int id, File path) throws Exception {
                this.id = Integer.toString(id);
                File f = new File(path + File.separator + StringResource.IMAGE_INFO_FILENAME);
-               if (f.exists()) {
-                       FileInputStream inputStream = new FileInputStream(f);
-                       Properties prop = new Properties();
-                       prop.load(inputStream);
-                       platformName = prop.getProperty(StringResource.IMAGE_PLATFORM, platform.getVersion());
-                       type             = prop.getProperty(StringResource.IMAGE_TYPE, "default");
-                       name             = prop.getProperty(StringResource.IMAGE_NAME).toLowerCase();
-                       if (name == null) {
-                               throw new Exception();
+               FileInputStream inputStream = null;
+               try {
+                       if (f.exists()) {
+                               inputStream = new FileInputStream(f);
+                               Properties prop = new Properties();
+                               prop.load(inputStream);
+                               platformName = prop.getProperty(StringResource.IMAGE_PLATFORM, platform.getVersion());
+                               type             = prop.getProperty(StringResource.IMAGE_TYPE, "default");
+                               name             = prop.getProperty(StringResource.IMAGE_NAME).toLowerCase();
+                               if (name == null) {
+                                       throw new Exception();
+                               }
+                               version         = prop.getProperty(StringResource.IMAGE_VERSION, platform.getVersion());
+                               domain          = prop.getProperty(StringResource.PRODUCT_DOMAIN, "Phone");
+                               cpu                     = prop.getProperty(StringResource.TARGET_CPU, "x86");
+                               cpu = cpu.toLowerCase();
+                               release         = prop.getProperty(StringResource.RELEASE_VERSION, "Not identified");
+                       } else {
+                               throw new Exception("This file does not exist (" + path + ")");
                        }
-                       version         = prop.getProperty(StringResource.IMAGE_VERSION, platform.getVersion());
-                       domain          = prop.getProperty(StringResource.PRODUCT_DOMAIN, "Phone");
-                       cpu                     = prop.getProperty(StringResource.TARGET_CPU, "x86");
-                       cpu = cpu.toLowerCase();
-                       release         = prop.getProperty(StringResource.RELEASE_VERSION, "Not identified");
-
+               } finally {
                        // clear
-                       inputStream.close();
-               } else {
-                       throw new Exception("This file does not exist (" + path + ")");
+                       if (inputStream != null) {
+                               try {
+                                       inputStream.close();
+                               } catch (IOException e) {
+                                       EMLogger.getLogger().log(Level.WARNING, e.getMessage());
+                               }
+                       }
                }
        }
 
index 0acf052..7ba2700 100644 (file)
@@ -1,3 +1,32 @@
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * JiHye Kim <jihye1128.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
 package org.tizen.emulator.manager.image;
 
 import java.io.File;
index 694a570..a9dcbc4 100644 (file)
@@ -1,3 +1,32 @@
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * JiHye Kim <jihye1128.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
 package org.tizen.emulator.manager.tool;
 
 import java.io.File;
index e82d41f..1697dec 100644 (file)
@@ -1,3 +1,32 @@
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * JiHye Kim <jihye1128.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
 package org.tizen.emulator.manager.tool;
 
 import java.io.File;
index 06b6d14..ff7fefd 100644 (file)
@@ -1,3 +1,32 @@
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * JiHye Kim <jihye1128.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
 package org.tizen.emulator.manager.ui.detail;
 
 import java.io.File;
index f7212ab..d17e437 100644 (file)
@@ -1,3 +1,32 @@
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * JiHye Kim <jihye1128.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
 package org.tizen.emulator.manager.ui.detail;
 
 public interface TableWidgetChangeListener {
index 03533a2..a6bf17f 100644 (file)
@@ -32,6 +32,7 @@ package org.tizen.emulator.manager.vms;
 
 import java.io.BufferedReader;
 import java.io.File;
+import java.io.IOException;
 import java.io.InputStreamReader;
 import java.util.ArrayList;
 import java.util.List;
@@ -247,31 +248,35 @@ public class VMsWorker {
                int isLinux = System.getProperty("os.name").toLowerCase().indexOf("linux");
                int isWindows = System.getProperty("os.name").toLowerCase().indexOf("windows");
                int isMac = System.getProperty("os.name").toLowerCase().indexOf("mac");
-               try { 
-                       String line;
-                       List<String> cmd = new ArrayList<String>();
-                       if(isLinux > -1) {
-                               cmd.add("/bin/ps");
-                               cmd.add("-ef");
-                       }
-                       else if(isWindows > -1) {
-                               cmd.add("tasklist");
-                               cmd.add("/V");
-                               cmd.add("/FI");
-                               cmd.add("\"IMAGENAME eq java.exe\"");
-                               cmd.add("/FO");
-                               cmd.add("CSV");
-                       }
-                       else if (isMac > -1){
-                               cmd.add("/bin/ps");
-                               cmd.add("-ef");
-                       }
 
+               String line;
+               List<String> cmd = new ArrayList<String>();
+               if(isLinux > -1) {
+                       cmd.add("/bin/ps");
+                       cmd.add("-ef");
+               }
+               else if(isWindows > -1) {
+                       cmd.add("tasklist");
+                       cmd.add("/V");
+                       cmd.add("/FI");
+                       cmd.add("\"IMAGENAME eq java.exe\"");
+                       cmd.add("/FO");
+                       cmd.add("CSV");
+               }
+               else if (isMac > -1){
+                       cmd.add("/bin/ps");
+                       cmd.add("-ef");
+               }
 
-                       ProcessBuilder pb = new ProcessBuilder(cmd);
-                       Process p = pb.start();
-                       InputStreamReader inputReader = new InputStreamReader(p.getInputStream());
-                       BufferedReader stdOut = new BufferedReader(inputReader);
+               ProcessBuilder pb = null;
+               Process p = null;
+               InputStreamReader inputReader = null;
+               BufferedReader stdOut = null;
+               try {
+                       pb = new ProcessBuilder(cmd);
+                       p = pb.start();
+                       inputReader = new InputStreamReader(p.getInputStream());
+                       stdOut = new BufferedReader(inputReader);
                        if(isLinux > -1) {
                                while ((line = stdOut.readLine()) != null) {
                                        String imagePath = property.getConfiguration().getBaseInformation().getDiskImage().getCurrentDiskImage().getValue();
@@ -304,9 +309,6 @@ public class VMsWorker {
                 }
             }
 
-                       // clear;
-                       stdOut.close();
-                       inputReader.close();
                        if (!result) {
                                logger.log(Level.INFO, "The same name of VM not exist anywhere. You can continue your job.\n");
                        }
@@ -316,6 +318,22 @@ public class VMsWorker {
                        msg.openWarningDialog("Error occured while checking if the same VM .\n" +
                                                                                                                                                err.getMessage());
                        return false;
+               } finally {
+                       // clear;
+                       if (stdOut != null) {
+                               try {
+                                       stdOut.close();
+                               } catch (IOException e) {
+                                       logger.log(Level.WARNING, e.getMessage());
+                               }
+                       }
+                       if (inputReader != null) {
+                               try {
+                                       inputReader.close();
+                               } catch (IOException e) {
+                                       logger.log(Level.WARNING, e.getMessage());
+                               }
+                       }
                }
        }
 }