From cb03a09f2e87a46beb7ecdabd83e001105eea7cc Mon Sep 17 00:00:00 2001 From: Gun Kim Date: Tue, 7 May 2013 12:49:48 +0900 Subject: [PATCH] [Title] added error message when on-demand install is failed. [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 --- .../connection/debugtools/OnDemandInstall.java | 47 ++++++++++++++++------ .../debugtools/OnDemandInstallMessages.java | 1 + .../debugtools/OnDemandInstallMessages.properties | 4 +- 3 files changed, 38 insertions(+), 14 deletions(-) diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/debugtools/OnDemandInstall.java b/org.tizen.common.connection/src/org/tizen/common/connection/debugtools/OnDemandInstall.java index b72c828..894474d 100644 --- a/org.tizen.common.connection/src/org/tizen/common/connection/debugtools/OnDemandInstall.java +++ b/org.tizen.common.connection/src/org/tizen/common/connection/debugtools/OnDemandInstall.java @@ -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 failedFileList = new ArrayList(); 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 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) { diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/debugtools/OnDemandInstallMessages.java b/org.tizen.common.connection/src/org/tizen/common/connection/debugtools/OnDemandInstallMessages.java index c78b443..0045a73 100644 --- a/org.tizen.common.connection/src/org/tizen/common/connection/debugtools/OnDemandInstallMessages.java +++ b/org.tizen.common.connection/src/org/tizen/common/connection/debugtools/OnDemandInstallMessages.java @@ -41,4 +41,5 @@ public class OnDemandInstallMessages extends NLS { public static String CANNOT_REMOVE_CONTROLFILE; public static String CANNOT_INSTALL_TOOL; public static String ERROR_EXECUTE_COMMAND; + public static String CANNOT_ON_DEMAND_INSTALL; } diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/debugtools/OnDemandInstallMessages.properties b/org.tizen.common.connection/src/org/tizen/common/connection/debugtools/OnDemandInstallMessages.properties index 272004a..07d1ec9 100644 --- a/org.tizen.common.connection/src/org/tizen/common/connection/debugtools/OnDemandInstallMessages.properties +++ b/org.tizen.common.connection/src/org/tizen/common/connection/debugtools/OnDemandInstallMessages.properties @@ -5,4 +5,6 @@ CANNOT_CHECK_INSTALLED=Cannot check installed tools ''{0}'' CANNOT_COPY_FILE=Cannot copy the file ''{0}'' CANNOT_REMOVE_CONTROLFILE=Cannot delete the file CANNOT_INSTALL_TOOL=Cannot install ''{0}'' due to : {1} -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\ +Please restart your IDE or reconnect your target. +ERROR_EXECUTE_COMMAND=Error occurred while executing command : {0} -- 2.7.4