From fe342b6eb32dc30ef488236f90cf7c42de885df8 Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Thu, 22 Jun 2017 15:06:36 +0530 Subject: [PATCH] Adding correction --- .../org.carbon.android.emulator/TryIt.java | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.emulator/src/main/java/org.carbon.android.emulator/TryIt.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.emulator/src/main/java/org.carbon.android.emulator/TryIt.java index d33f8d4a32..98fe694202 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.emulator/src/main/java/org.carbon.android.emulator/TryIt.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.emulator/src/main/java/org.carbon.android.emulator/TryIt.java @@ -31,8 +31,6 @@ import java.io.Writer; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; -import java.nio.channels.Channels; -import java.nio.channels.ReadableByteChannel; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; @@ -65,17 +63,19 @@ public class TryIt { * This method gets the system specific variables. */ private TryIt() { - osSuffix = System.getProperty(Constants.OS_NAME_PROPERTY).toLowerCase(); + osSuffix = System.getProperty(Constants.OS_NAME_PROPERTY); if (osSuffix == null) { - sysPropertyError("OS NAME"); + sysPropertyError(Constants.OS_NAME_PROPERTY, "OS Name"); + } else { + osSuffix = osSuffix.toLowerCase(); } userHome = System.getProperty(Constants.USER_HOME_PROPERTY); if (userHome == null) { - sysPropertyError("Home Directory"); + sysPropertyError(Constants.USER_HOME_PROPERTY, "Home Directory"); } workingDirectory = System.getProperty(Constants.USER_DIRECTORY_PROPERTY); if (workingDirectory == null) { - sysPropertyError("Current Working Directory"); + sysPropertyError(Constants.USER_DIRECTORY_PROPERTY, "Current Working Directory"); } if (osSuffix.contains(Constants.WINDOWS_OS)) { osSuffix = Constants.WINDOWS_OS; @@ -174,10 +174,11 @@ public class TryIt { /** * This method is called when then is an error in getting system properties * - * @param error - system property name + * @param property -property type + * @param hint - property name */ - private void sysPropertyError(String error) { - System.out.println("Unable to get the " + error + " of your system"); + private void sysPropertyError(String property, String hint) { + System.out.println("Unable to get the" + property + "property of your system (" + hint + ")"); System.exit(1); } @@ -445,7 +446,7 @@ public class TryIt { */ private void makeDirectoryError(String name, String location) { System.out.println("Unable to make folder named " + name + " in " + location); - System.exit(0); + System.exit(1); } /** @@ -815,8 +816,10 @@ public class TryIt { private void setExecutePermission(String fileName) { if (!new File(fileName).canExecute()) { if (!new File(fileName).setExecutable(true)) { - System.out.println("Set the Execute permission of : " + fileName + " to continue"); - System.exit(0); // if can't execute, unable to proceed + System.out.println("Unable to set the execute permission of : " + fileName); + System.out.println("Please set the executable permission for file " + + new File(fileName).getAbsolutePath() + " to continue"); + System.exit(1); // if can't execute, unable to proceed } } }