From: Gun Kim Date: Wed, 23 Oct 2013 07:11:32 +0000 (+0900) Subject: [Title] modified RdsDeploy class for modularization. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F47%2F11247%2F1;p=sdk%2Fide%2Fcommon-eplugin.git [Title] modified RdsDeploy class for modularization. It must be merged with webapp-eplugin and nativecommon-eplugin that are applied this commit. [Type] [Module] [Priority] [Jira#] [Redmine#] [Problem] [Cause] [Solution] [TestCase] Change-Id: Icf79eb3695f4382e9cdb180c426fb26a34f2d776 Signed-off-by: Gun Kim --- diff --git a/org.tizen.common/src/org/tizen/common/rds/RdsDeployer.java b/org.tizen.common/src/org/tizen/common/rds/RdsDeployer.java index 2cb97a5..8b296cb 100644 --- a/org.tizen.common/src/org/tizen/common/rds/RdsDeployer.java +++ b/org.tizen.common/src/org/tizen/common/rds/RdsDeployer.java @@ -36,6 +36,7 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Status; import org.eclipse.osgi.util.NLS; import org.slf4j.Logger; @@ -96,11 +97,12 @@ public abstract class RdsDeployer implements Closeable { */ protected abstract String getPkgId(); /** - * Deploys using RDS. + * Signs project incrementally. + * This method is called by {@link RdsDeployer#deploy()}. * - * @return boolean + * @return If this method returns false, {@link RdsDeployer#deploy()} fails and returns false. */ - public abstract boolean deploy() throws CoreException; + protected abstract boolean sign( List deltaInfoList) throws CoreException, IOException, IllegalStateException; public RdsDeployer( IProject project, IDevice device, ISdbCommandHelper tizenCommand, ITizenConsoleManager console, String pkgType, IProgressMonitor monitor) { this.project = project; @@ -111,7 +113,91 @@ public abstract class RdsDeployer implements Closeable { this.pkgType = pkgType; this.strAppInstallPath = getAppInstallPath(); deltaDetector = new RdsDeltaDetector(device, project, strAppInstallPath); + } + + /** + * Executes job that is needed before {@link RdsDeployer#deploy()} is executed. + * This method works as soon as the {@link RdsDeployer#deploy()} is executed. + * If you doesn't implement it in your subclass, returns true. + * + * @return If this method returns false, {@link RdsDeployer#deploy()} doesn't execute and returns false. + */ + protected boolean preDeploy() throws CoreException { + return true; + } + + /** + * Deploys using RDS. + * + * @return boolean + */ + public boolean deploy() throws CoreException { + if ( !preDeploy() ) { + return false; + } + + // finds interestDelta for sign + List deltaInfoList = getInterestDelta(); + if ( deltaInfoList == null ) { + return false; + } + if ( deltaInfoList.isEmpty()) { + return true; + } + final String failToSignMsg = "failed to sign for RDS"; + try { + if ( !sign(deltaInfoList) ) { + printInfo(failToSignMsg); + return false; + } + } catch (Exception e) { + printInfo(failToSignMsg); + logger.error(failToSignMsg, e); + return false; + } + + // finds interestDelta for to deploy project with RDS mode + cleanDeltaInfo(); + deltaInfoList = getInterestDelta(); + if ( deltaInfoList == null ) { + return false; + } + + if ( deltaInfoList.isEmpty()) { + return true; + } + + try { + partialInstall(deltaInfoList); + } + catch ( CoreException e ) { + logger.error(RdsMessages.CANNOT_PARTIALLY_INSTALL, e); + printInfo(RdsDeployer.makeRdsLog(RdsMessages.CANNOT_PARTIALLY_INSTALL)); + return false; + } + return true; + } + + /** + * Returns a delta list interested. + */ + private List getInterestDelta() { + List deltaInfoList = null; + try { + project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); + deltaInfoList = getDelta(); + if ( deltaInfoList == null ) { + newCoreException(RdsMessages.CANNOT_FIND_DELTA, null); + } + + deltaInfoList = getInterestDelta(deltaInfoList); + } catch (CoreException e) { + printInfo(RdsDeployer.makeRdsLog(RdsMessages.CANNOT_FIND_DELTA)); + return null; + } + + return deltaInfoList; } public void setInterestList( List list) {