[Title] modified RdsDeploy class for modularization. 47/11447/1
authorGun Kim <gune.kim@samsung.com>
Mon, 28 Oct 2013 07:49:51 +0000 (16:49 +0900)
committerGun Kim <gune.kim@samsung.com>
Mon, 28 Oct 2013 07:50:01 +0000 (16:50 +0900)
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: Ide4fa124d0bb8c81d6e2fdc1541128ebd635422a
Signed-off-by: Gun Kim <gune.kim@samsung.com>
org.tizen.common/src/org/tizen/common/rds/RdsDeployer.java

index 2cb97a5..8b296cb 100644 (file)
@@ -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<DeltaResourceInfo> 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<DeltaResourceInfo> 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<DeltaResourceInfo> getInterestDelta() {
+        List<DeltaResourceInfo> 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<DeltaResourceInfo> list) {