[Title]
authorshihyun.kim <shihyun.kim@samsung.com>
Mon, 28 Jan 2013 00:50:12 +0000 (09:50 +0900)
committershihyun.kim <shihyun.kim@samsung.com>
Mon, 28 Jan 2013 00:50:12 +0000 (09:50 +0900)
* Do not remove SDK packages when install extension packages.
* Show an error message when cannot find files in repository.

Change-Id: Iad1f2a08b2e3f293897b54bffc61e213b486596c

InstallManager_java/src/org/tizen/installmanager/core/InstallManager.java
InstallManager_java/src/org/tizen/installmanager/lib/Downloader.java
InstallManager_java/src/org/tizen/installmanager/lib/ErrorController.java
InstallManager_java/src/org/tizen/installmanager/lib/exception/IMNetworkException.java
InstallManager_java/src/org/tizen/installmanager/pkg/lib/PackageManager.java
InstallManager_java/src/org/tizen/installmanager/ui/page/InstallableListPage.java
InstallManager_java/src/org/tizen/installmanager/ui/page/UpdatableListPage.java
InstallManager_java/src/org/tizen/installmanager/ui/page/ViewController.java

index a633463..055d7a1 100644 (file)
@@ -498,8 +498,10 @@ public class InstallManager {
                }
                Log.log("start download package: " + packageToDownload);
                URL packageUrl = packageToDownload.getURL();
+               
                size = mDownloader.download(packageUrl, fileDownloadTargetPath,
                                monitor);
+               
                if (size >= 0) {
                        if (Options.onlyDownload) {
                                System.out.println(" done.");
@@ -674,7 +676,9 @@ public class InstallManager {
                        removeAllPackages(monitor);
                } else {
                        // remove missing packages
-                       removeMissingPackages(monitor);
+                       if (!packageManager.isRepoPackagesEmpty()) {
+                               removeMissingPackages(monitor);
+                       }
 
                        // remove conflict packages
                        if (!removeConflictPackages(installablePackages, monitor)) {
@@ -1214,7 +1218,7 @@ public class InstallManager {
                Log.log("InstallManager packages remove success. return => " + true);
                return true;
        }
-
+       
        /**
         * Remove all of packages.
         * 
index 2c0559c..98029b8 100644 (file)
@@ -150,7 +150,7 @@ public class Downloader {
                                PathUtil.remove(localPath);
                        }
                        
-                       throw new IMNetworkConnectException(responseCode, responseMessage); 
+                       return ERROR;
                } 
 
                long downloadSize = downloadFile(localPath, monitor);
@@ -942,7 +942,7 @@ public class Downloader {
                        } catch (FileNotFoundException e) {
                                Log.ExceptionLog(e);
                                ErrorController
-                                       .setError(ErrorCode.CONFIG_CANNOT_FIND_PACKAGE_LIST_FILE_IN_REPOSITORY);
+                                       .setError(ErrorCode.CANNOT_FIND_FILE_IN_REPOSITROY);
 
                        } catch (SSLHandshakeException e) {
                                Log.ExceptionLog(e);
index 6c4c7be..ccdce1a 100644 (file)
@@ -44,7 +44,7 @@ public class ErrorController {
         */
        public enum ErrorCode {
                CANNOT_FIND_CONFIG_FILE("The installmanager.conf file not found."),
-               CANNOT_FIND_FILE_IN_REPOSITROY("Cannot connect to SDK package server."),
+               CANNOT_FIND_FILE_IN_REPOSITROY("Cannot find file in repository."),
                CANNOT_CREATE_DOWNLOAD_FILE("Download file cannot be created."),
                CANNOT_CHECK_INSTLLED_FILE_LIST("Installed file list cannot be checked."),
                CANNOT_MOVE_FILE_TO_TARGET_DIRECTORY("File cannot be moved to the target directory."),
@@ -85,7 +85,8 @@ public class ErrorController {
                
                //Configuration file error
                CONFIG_CANNOT_PARSING_PACKAGE_LIST("Package list cannot be read. Check the repository or proxy server."),
-               CONFIG_CANNOT_FIND_PACKAGE_LIST_FILE_IN_REPOSITORY("Package list file not found in the repository."),
+               CONFIG_CANNOT_FIND_PACKAGE_LIST_FILE_IN_REPOSITORY("Cannot get the package information. " +
+                               "\nPlease check your repository or SDK image file."),
                CONFIG_CANNOT_REMOVE_CONFLICT_PACKAGES("Conflict package removal failed."),
                CONFIG_CANNOT_REMOVE_UPDATABLE_PACKAGES("Updatable package removal failed."),
                CONFIG_CANNOT_READ_SERVER_TYPE("Server type cannot be read. Check the server type in the installmanager.conf file."),
index 61dca29..d562f74 100644 (file)
@@ -67,7 +67,7 @@ public class IMNetworkException extends Exception {
                if (errorCode != null) {
                        return errorCode.getErrorMessage();
                } else {
-                       if (responseMessage == null || responseMessage.equalsIgnoreCase("OK")) {
+                       if (responseMessage == null || responseMessage.isEmpty() || responseMessage.equalsIgnoreCase("OK")) {
                                return ErrorController.getErrorMessage();
                        } else {
                                return responseMessage;
index ab9874f..3ec4791 100644 (file)
@@ -47,6 +47,7 @@ import org.tizen.installmanager.core.IMFatalException;
 import org.tizen.installmanager.core.InstallManager;
 import org.tizen.installmanager.core.Options;
 import org.tizen.installmanager.core.SDKExtensionInfo;
+import org.tizen.installmanager.core.Config.ServerType;
 import org.tizen.installmanager.lib.Downloader;
 import org.tizen.installmanager.lib.ErrorController;
 import org.tizen.installmanager.lib.Log;
@@ -146,17 +147,6 @@ public abstract class PackageManager {
                }
        }
        
-       /**
-        * Initializes package manager with information of installed packages and packages of repository
-        * @param sectionsInstalled a list of property sections of the installed packages
-        * @param repoToSectionsMap a map from base url of repository to a list of property sections of the repository
-        */
-       protected PackageManager(List<PropertySection> sectionsInstalled, Map<String,List<PropertySection>> repoToSectionsMap) {
-               setInstalledPackageList(sectionsInstalled);
-               setRepoPackages(repoToSectionsMap);
-               getRecentPackages();
-       }
-       
        private void setRepository(String repository) {
                if (installedRepository == null) {
                        installedRepository = repository;
@@ -282,7 +272,7 @@ public abstract class PackageManager {
                if (repoPackages == null) {
                        repoPackages = new PackageSet();
                } else {
-                       if (repoPackages.hasPackageByName("EXTRA")) {
+                       if (repoPackages.hasPackageByName("EXTRAS")) {
                                return;
                        }
                }
@@ -576,6 +566,24 @@ public abstract class PackageManager {
        }
        
        /**
+        * If package set of repository is empty, return true;
+        * @return
+        */
+       public boolean isRepoPackagesEmpty() {
+               if (repoPackages == null || repoPackages.isEmpty()) {
+                       return true;
+               } else if (repoPackages.size() == 1) {
+                       if (repoPackages.getPackageByName("EXTRAS") != null) {
+                               return true;
+                       } else {
+                               return false;
+                       }
+               } else {
+                       return false;
+               }
+       }
+       
+       /**
         * If pkg is installed, return true. else return false
         * @param pkg
         * @return
@@ -594,6 +602,11 @@ public abstract class PackageManager {
                }
        }
        
+       public PackageSet getRecentMetaPackages() {
+               PackageSet recentPackages = union(repoPackages, installedPackages);
+               return rootMeta(recentPackages);
+       }
+       
        /**
         * @return meta packages among installed packages
         */
@@ -601,6 +614,7 @@ public abstract class PackageManager {
                return meta(installedPackages);
        }
        
+       
        /**
         * @return meta packages among all recent packages
         */
index 242fe78..95fc3d1 100644 (file)
@@ -243,7 +243,7 @@ public class InstallableListPage extends PackageListPage {
                }
 
                try {
-                       loadPackagesToTreeViewer(viewController.getRootMetaPackageListOfRepository());
+                       loadPackagesToTreeViewer(viewController.getInstallableMetaPackageList());
                        viewController.loadSdkExtension();
                        addExtensionPackagesToExtra(viewController.getRootMetaPackageListOfExtension());
                        
index e8efc1f..31bc729 100644 (file)
@@ -75,7 +75,7 @@ public class UpdatableListPage extends PackageListPage {
                getItems().clear();
 
                try {
-                       loadPackagesToTreeViewer(viewController.getRootMetaPackageListOfRepository());
+                       loadPackagesToTreeViewer(viewController.getInstallableMetaPackageList());
                        viewController.loadSdkExtension();
                        addExtensionPackagesToExtra(viewController.getRootMetaPackageListOfExtension());
                        
index 3328fd0..6655513 100644 (file)
@@ -141,6 +141,14 @@ public class ViewController {
                }
        }
        
+       public PackageSet getTreeMetaPackageListOfRepository() {
+               if (packageManager == null) {
+                       return null;
+               } else {
+                       return packageManager.getRecentMetaPackages();
+               }
+       }
+       
        public PackageSet getRootMetaPackageListOfExtension() {
                if (packageManager == null) {
                        return null;
@@ -269,8 +277,7 @@ public class ViewController {
                                Log.ExceptionLog(e);
                                
                                //retry dialog.
-                               String errorMsg = "Network connection is not available.\nWould you like to retry?\n(" + 
-                                       e.getMessage() + ")";
+                               String errorMsg = e.getMessage() + "\nWould you like to retry?";
                                int ret = MessageBoxDlg.showDlg(
                                                InstallManagerWindow.getInstallManagerWindow().getShell(),
                                                "Warning",
@@ -387,6 +394,7 @@ public class ViewController {
                }
                
                //get all meta packages (installable packages)
+               //TODO : show all packages. (installable, installed)
                PackageSet metaPackageSet = packageManager.getRootMetaPackagesOfRepository();           
                
                return makeTreeItem(metaPackageSet);