From 199c057e5c62d836fae0265a5923711b106490cd Mon Sep 17 00:00:00 2001 From: "yongsung1.kim" Date: Fri, 13 Sep 2013 17:40:47 +0900 Subject: [PATCH] [Title] Add more log codes for version problem. [Issue] Redmine #10528 Change-Id: I4ef05df075e7db8ec90b09c14dff17039d08b4a6 --- .../tizen/installmanager/pkg/model/Version.java | 40 +++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/InstallManager_java/src/org/tizen/installmanager/pkg/model/Version.java b/InstallManager_java/src/org/tizen/installmanager/pkg/model/Version.java index 9b9e644..90e1743 100644 --- a/InstallManager_java/src/org/tizen/installmanager/pkg/model/Version.java +++ b/InstallManager_java/src/org/tizen/installmanager/pkg/model/Version.java @@ -96,13 +96,37 @@ public class Version { int v2Length = v2.length; int repeat = 0; String[] fixedVersion = null; + versionLogging(v1, "Version 1 : "); if (v1Length != v2Length) {// Just in case, both version1's frame and version2's frame are different. + Log.log("Version lengths are different."); + versionLogging(v1, "Version 1 : "); + versionLogging(v2, "Version 2 : "); + if (v1Length > v2Length) { fixedVersion = setVersionFrame(v2, v1Length); repeat = v1Length; for (int i = 0; i < repeat; i++) { - result = compareVersionComponent(Integer.parseInt(v1[i]), Integer.parseInt(fixedVersion[i])); + int v1ToInt = -1; + int fixedVersionToInt = -1; + try { + v1ToInt = Integer.parseInt(v1[i]); + } catch (NumberFormatException e) { + versionLogging(v1, "Cannot convert to integer(Version 1) : "); + Log.ExceptionLog(e); + } + + try { + fixedVersionToInt = Integer.parseInt(fixedVersion[i]); + } catch (NumberFormatException e) { + versionLogging(v1, "Cannot convert to integer(fixedVersion) : "); + Log.ExceptionLog(e); + } + + result = compareVersionComponent(v1ToInt, fixedVersionToInt); + +// result = compareVersionComponent(Integer.parseInt(v1[i]), Integer.parseInt(fixedVersion[i])); + if (result != Version.EQ) { break; } @@ -130,6 +154,20 @@ public class Version { return result; } + private static void versionLogging(String[] version, String comment) { + String tmp = ""; + int length = version.length; + for (int i = 0; i < length; i++) { + if (i == length - 1) { + tmp += version[i]; + } else { + tmp += version[i] + "."; + } + } + + Log.log(comment + tmp); + } + /** * When versions' frame are different, each frames must be same. * @param version -- 2.7.4