[Title] added error message when on-demand install is failed.
authorGun Kim <gune.kim@samsung.com>
Tue, 7 May 2013 03:49:48 +0000 (12:49 +0900)
committerGun Kim <gune.kim@samsung.com>
Wed, 26 Jun 2013 09:52:58 +0000 (18:52 +0900)
[Type]
[Module]
[Priority]
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

Change-Id: Id9e1ca0182b05dbb8d8ce1605cdb0b5fb3d87175

Conflicts:

org.tizen.common.connection/src/org/tizen/common/connection/debugtools/OnDemandInstall.java

org.tizen.common.connection/src/org/tizen/common/connection/debugtools/OnDemandInstall.java
org.tizen.common.connection/src/org/tizen/common/connection/debugtools/OnDemandInstallMessages.java
org.tizen.common.connection/src/org/tizen/common/connection/debugtools/OnDemandInstallMessages.properties

index b72c828..894474d 100644 (file)
@@ -35,6 +35,7 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IConfigurationElement;
 import org.eclipse.core.runtime.IExtensionRegistry;
@@ -46,9 +47,11 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.tizen.common.TizenPlatformConstants;
 import org.tizen.common.core.application.InstallPathConfig;
+import org.tizen.common.util.DialogUtil;
 import org.tizen.common.util.FileUtil;
 import org.tizen.common.util.IOUtil;
 import org.tizen.sdblib.Arch;
+import org.tizen.common.util.SWTUtil;
 import org.tizen.sdblib.IDevice;
 import org.tizen.sdblib.receiver.MultiLineReceiver;
 import org.tizen.sdblib.service.SyncResult;
@@ -199,17 +202,14 @@ public class OnDemandInstall {
         device = pDevice;
     }
 
-    private boolean copyPackage(String source, String destination) throws IOException {
+    private void copyPackage(String source, String destination) throws IOException {
         SyncService syncService = null;
         try {
             syncService = device.getSyncService();
             SyncResult result = syncService.push(source, device.getFileEntry( destination ).getParent() );
             
-            if ( result.getCode() == RESULT_OK ) {
-                return true;
-            }
-            else {
-                return false;
+            if ( result.getCode() != RESULT_OK ) {
+                throw new IOException(result.getMessage());
             }
         } finally {
             IOUtil.tryClose(syncService);
@@ -229,7 +229,7 @@ public class OnDemandInstall {
         }
 
         monitor.worked(10);
-
+        List<String> failedFileList = new ArrayList<String>();
         for (DebugTool dt : debugTools) {
             // get package list to install
             verbose("Verifying: " + dt);
@@ -242,12 +242,31 @@ public class OnDemandInstall {
                 continue;
             }
 
-            deployPackage(dt);
+            if (!deployPackage(dt)) {
+                failedFileList.add(dt.getBinaryname());
+            }
+        }
+        
+        if ( !failedFileList.isEmpty() ) {
+            openErrorDialog(failedFileList);
         }
+        
         monitor.done();
     }
+    
+    private void openErrorDialog(List<String> messageList) {
+        if ( !messageList.isEmpty() ) {
+            final String messageStr = messageList.toString();
+            SWTUtil.asyncExec(new Runnable() {
+                @Override
+                public void run() {
+                    DialogUtil.openErrorDialog(NLS.bind(OnDemandInstallMessages.CANNOT_ON_DEMAND_INSTALL, messageStr));
+                }
+            });
+        }
+    }
 
-    private final void deployPackage(DebugTool tool) {
+    private final boolean deployPackage(DebugTool tool) {
         String local = TOOLS_HOST_PATH + "/" + tool.getSourcepath() + "/" + tool.getBinaryname();
         String remote = TizenPlatformConstants.TOOLS_TARGET_PATH + "/" + tool.getBinaryname();
         String cmd = "";
@@ -255,12 +274,10 @@ public class OnDemandInstall {
 
         verbose("Deploying: " + tool);
         try {
-            if (copyPackage(local, remote) == false) {
-                throw new IOException();
-            }
+            copyPackage(local, remote);
         } catch (IOException e) {
             logger.error(NLS.bind(OnDemandInstallMessages.CANNOT_COPY_FILE, tool.getBinaryname()), e);
-            return;
+            return false;
         }
 
         if (RPM_PACKAGE_TYPE.equals(tool.getPackagetype())) {
@@ -272,12 +289,16 @@ public class OnDemandInstall {
             result = getResult(cmd);
             if (CMD_RESULT_SUCCESS.equals(result) == false) {
                 logger.error(NLS.bind(OnDemandInstallMessages.CANNOT_INSTALL_TOOL, tool, cmd + " (exitcode: " + result + ")"));
+                return false;
             } else {
                 verbose("Deployed: " + tool);
             }
         } catch (Exception e) {
             logger.error(NLS.bind(OnDemandInstallMessages.ERROR_EXECUTE_COMMAND, cmd), e);
+            return false;
         }
+        
+        return true;
     }
 
     private void verbose(String message) {
index c78b443..0045a73 100644 (file)
@@ -41,4 +41,5 @@ public class OnDemandInstallMessages extends NLS {
     public static String CANNOT_REMOVE_CONTROLFILE;\r
     public static String CANNOT_INSTALL_TOOL;\r
     public static String ERROR_EXECUTE_COMMAND;\r
+    public static String CANNOT_ON_DEMAND_INSTALL;\r
 }\r
index 272004a..07d1ec9 100644 (file)
@@ -5,4 +5,6 @@ CANNOT_CHECK_INSTALLED=Cannot check installed tools ''{0}''
 CANNOT_COPY_FILE=Cannot copy the file ''{0}''\r
 CANNOT_REMOVE_CONTROLFILE=Cannot delete the file\r
 CANNOT_INSTALL_TOOL=Cannot install ''{0}'' due to : {1}\r
-ERROR_EXECUTE_COMMAND=Error occurred while executing command : {0}
\ No newline at end of file
+CANNOT_ON_DEMAND_INSTALL=On-demand install is failed. {0}\n\\r
+Please restart your IDE or reconnect your target.\r
+ERROR_EXECUTE_COMMAND=Error occurred while executing command : {0}\r