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;
*/
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;
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) {