sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From romb...@apache.org
Subject svn commit: r1526674 - in /sling/branches/tooling-ide-vlt/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np: AbstractNewSlingApplicationWizard.java SetupServerWizardPage.java
Date Thu, 26 Sep 2013 20:39:29 GMT
Author: rombert
Date: Thu Sep 26 20:39:29 2013
New Revision: 1526674

URL: http://svn.apache.org/r1526674
Log:
SLING-3120 - Allow installing/updating the install support bundle from
the servers view

New bundle creation wizard - record the version of the support bundle,
if installed.

Modified:
    sling/branches/tooling-ide-vlt/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/AbstractNewSlingApplicationWizard.java
    sling/branches/tooling-ide-vlt/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/SetupServerWizardPage.java

Modified: sling/branches/tooling-ide-vlt/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/AbstractNewSlingApplicationWizard.java
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/AbstractNewSlingApplicationWizard.java?rev=1526674&r1=1526673&r2=1526674&view=diff
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/AbstractNewSlingApplicationWizard.java
(original)
+++ sling/branches/tooling-ide-vlt/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/AbstractNewSlingApplicationWizard.java
Thu Sep 26 20:39:29 2013
@@ -131,6 +131,9 @@ public abstract class AbstractNewSlingAp
 	 * using wizard as execution context.
 	 */
 	public boolean performFinish() {
+
+        // TODO - should probably rely on exception handling here
+        final boolean[] success = new boolean[0];
         try {
 			getContainer().run(false, true, new IRunnableWithProgress() {
 
@@ -138,14 +141,14 @@ public abstract class AbstractNewSlingAp
 				public void run(IProgressMonitor monitor)
 						throws InvocationTargetException, InterruptedException {
 					try {
-						performFinish(monitor);
+                        success[0] = performFinish(monitor);
 					} catch (Exception e) {
                         throw new InvocationTargetException(e);
 					}
 				}
 				
 			});
-			return true;
+            return success[0];
         } catch (InterruptedException e) {
             Thread.currentThread().interrupt();
         	return false;
@@ -170,7 +173,7 @@ public abstract class AbstractNewSlingAp
 		if (monitor.isCanceled()) {
 			return false;
 		}
-		IServer server = setupServerWizardPage.getOrCreateServer();
+        IServer server = setupServerWizardPage.getOrCreateServer(monitor);
 		monitor.worked(1);
         if (monitor.isCanceled() || server == null) {
 			return false;

Modified: sling/branches/tooling-ide-vlt/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/SetupServerWizardPage.java
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/SetupServerWizardPage.java?rev=1526674&r1=1526673&r2=1526674&view=diff
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/SetupServerWizardPage.java
(original)
+++ sling/branches/tooling-ide-vlt/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/SetupServerWizardPage.java
Thu Sep 26 20:39:29 2013
@@ -18,7 +18,6 @@ package org.apache.sling.ide.eclipse.ui.
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.net.URL;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -32,7 +31,7 @@ import org.apache.sling.ide.osgi.OsgiCli
 import org.apache.sling.ide.osgi.OsgiClientFactory;
 import org.apache.sling.ide.transport.RepositoryInfo;
 import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.KeyEvent;
@@ -285,20 +284,6 @@ public class SetupServerWizardPage exten
         return newOsgiClient().getBundleVersion(EmbeddedArtifactLocator.SUPPORT_BUNDLE_SYMBOLIC_NAME);
     }
     
-    private void installToolingSupportBundle() throws OsgiClientException, IOException {
-
-        EmbeddedArtifactLocator artifactsLocator = Activator.getDefault().getArtifactsLocator();
-        EmbeddedArtifact toolingSupportBundle = artifactsLocator.loadToolingSupportBundle();
-
-        InputStream contents = null;
-        try {
-            contents = toolingSupportBundle.openInputStream();
-            newOsgiClient().installBundle(contents, toolingSupportBundle.getName());
-        } finally {
-            IOUtils.closeQuietly(contents);
-        }
-    }
-
     private OsgiClient newOsgiClient() {
 
         String hostname = getHostname();
@@ -311,7 +296,7 @@ public class SetupServerWizardPage exten
                 + "/"));
     }
 	
-	IServer getOrCreateServer() {
+    IServer getOrCreateServer(IProgressMonitor monitor) {
 		if (useExistingServer.getSelection()) {
 			String key = existingServerCombo.getItem(existingServerCombo.getSelectionIndex());
 			return serversMap.get(key);
@@ -327,9 +312,9 @@ public class SetupServerWizardPage exten
 				}
 			}
 			
+            Version finalVersion = null;
+			
 			if (installToolingSupportBundle.getSelection()) {
-                // TODO - read from manifest instead of hardcoding
-                Version ourVersion = new Version(0, 0, 1, "SNAPSHOT");
                 Version installedVersion;
                 try {
                     installedVersion = getToolingSupportBundleVersion();
@@ -337,10 +322,23 @@ public class SetupServerWizardPage exten
                     getWizard().reportError(e);
                     return null;
                 }
+                finalVersion = installedVersion;
+                EmbeddedArtifactLocator artifactsLocator = Activator.getDefault().getArtifactsLocator();
+                EmbeddedArtifact toolingSupportBundle = artifactsLocator.loadToolingSupportBundle();
+                Version ourVersion = new Version(toolingSupportBundle.getVersion());
+
                 if (installedVersion == null || ourVersion.compareTo(installedVersion) >
0) {
 					// then auto-install it if possible
 					try {
-                        installToolingSupportBundle();
+
+                        InputStream contents = null;
+                        try {
+                            contents = toolingSupportBundle.openInputStream();
+                            newOsgiClient().installBundle(contents, toolingSupportBundle.getName());
+                        } finally {
+                            IOUtils.closeQuietly(contents);
+                        }
+                        finalVersion = ourVersion;
 					} catch (IOException e) {
                         getWizard().reportError(e);
                         return null;
@@ -352,21 +350,25 @@ public class SetupServerWizardPage exten
 			}
 			
 			IRuntimeType serverRuntime = ServerCore.findRuntimeType("org.apache.sling.ide.launchpadRuntimeType");
-            // TODO progress monitor
 			try {
                 // TODO pass in username and password
-				IRuntime runtime = serverRuntime.createRuntime(null, new NullProgressMonitor());
-				runtime = runtime.createWorkingCopy().save(true, new NullProgressMonitor());
-				IServerWorkingCopy wc = serverType.createServer(null, null, runtime, new NullProgressMonitor());
+                // TODO there should be a nicer API for creating this, and also a central
place for defaults
+                IRuntime runtime = serverRuntime.createRuntime(null, monitor);
+                runtime = runtime.createWorkingCopy().save(true, monitor);
+                IServerWorkingCopy wc = serverType.createServer(null, null, runtime, monitor);
 				wc.setHost(getHostname());
 				wc.setName(newServerName.getText() + " (external)");
 				wc.setAttribute(ISlingLaunchpadServer.PROP_PORT, getPort());
 				wc.setAttribute(ISlingLaunchpadServer.PROP_DEBUG_PORT, Integer.parseInt(newServerDebugPort.getText()));
                 wc.setAttribute(ISlingLaunchpadServer.PROP_INSTALL_LOCALLY, installToolingSupportBundle.getSelection());
-				wc.setAttribute("auto-publish-setting", 2); // 2: automatically publish when resources
change
-				wc.setAttribute("auto-publish-time", 0);    // 0: zero delay after a resource change
(and the builder was kicked, I guess)
+                wc.setAttribute("auto-publish-setting", ISlingLaunchpadServer.PUBLISH_STATE_RESOURCE_CHANGE);
+                wc.setAttribute("auto-publish-time", 0);
+                if (finalVersion != null) {
+                    wc.setAttribute(String.format(ISlingLaunchpadServer.PROP_BUNDLE_VERSION_FORMAT,
+                        EmbeddedArtifactLocator.SUPPORT_BUNDLE_SYMBOLIC_NAME), finalVersion.toString());
+                }
 				wc.setRuntime(runtime);
-				return wc.save(true, new NullProgressMonitor());
+                return wc.save(true, monitor);
 			} catch (CoreException e) {
                 getWizard().reportError(e);
 			}



Mime
View raw message