[jbosstools-commits] JBoss Tools SVN: r35456 - trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Fri Oct 7 00:07:42 EDT 2011


Author: rob.stryker at jboss.com
Date: 2011-10-07 00:07:42 -0400 (Fri, 07 Oct 2011)
New Revision: 35456

Modified:
   trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java
Log:
JBIDE-9856 - Mostly-stub implementation to get started and intergrate with andre's expectations

Modified: trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java
===================================================================
--- trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java	2011-10-07 01:06:17 UTC (rev 35455)
+++ trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java	2011-10-07 04:07:42 UTC (rev 35456)
@@ -2,9 +2,13 @@
 
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.wst.server.core.IRuntime;
 import org.eclipse.wst.server.core.IServer;
 import org.eclipse.wst.server.core.IServerAttributes;
 import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+import org.jboss.ide.eclipse.as.core.util.RuntimeUtils;
+import org.jboss.ide.eclipse.as.core.util.ServerCreationUtils;
 
 /**
  * This class holds the attribute names whose values will be
@@ -72,5 +76,89 @@
 		wc.setAttribute(ATTRIBUTE_PASSWORD, val);
 		return wc.save(false, new NullProgressMonitor());
 	}
+	
+	
+	/**
+	 * To be used if you must create a local runtime adapter 
+	 * as the user does not have one in their workspace yet
+	 * 
+	 * @param host
+	 * @param username
+	 * @param password
+	 * @param domain
+	 * @param app
+	 * @param sourceOrBinary
+	 * @param localRuntimeHomeDir
+	 * @return
+	 * @throws CoreException
+	 */
+	public static IServer createAS7OpenshiftServer(
+			String host, String username, String password, 
+			String domain, String app, String sourceOrBinary,
+			String localRuntimeHomeDir) throws CoreException {
+		IServer server = createServerAndRuntime(IJBossToolingConstants.AS_70,
+				IJBossToolingConstants.SERVER_AS_70, 
+				localRuntimeHomeDir, /* irrelevant */ "default");
+		return fillServerWithOpenshiftDetails(server, host, username, password, domain, app, sourceOrBinary);
+	}
+	
+	/**
+	 * To be used if a runtime is already provided, for example if a user has 
+	 * selected the proper as7 local runtime delegate from a combo box
+	 * 
+	 * @param host
+	 * @param username
+	 * @param password
+	 * @param domain
+	 * @param app
+	 * @param sourceOrBinary
+	 * @param runtime
+	 * @return
+	 * @throws CoreException
+	 */
+	public static IServer createAS7OpenshiftServer(
+			String host, String username, String password, 
+			String domain, String app, String sourceOrBinary,
+			IRuntime runtime) throws CoreException {
+		IServer server = createServer(runtime, IJBossToolingConstants.SERVER_AS_70);
+		return fillServerWithOpenshiftDetails(server, host, username, password, domain, app, sourceOrBinary);
+	}
+	
+	/**
+	 * Fills an already-created server with the proper openshift details. 
+	 * 
+	 * @param server
+	 * @param host
+	 * @param username
+	 * @param password
+	 * @param domain
+	 * @param app
+	 * @param sourceOrBinary
+	 * @return
+	 * @throws CoreException
+	 */
+	public static IServer fillServerWithOpenshiftDetails(IServer server,
+			String host, String username, String password, 
+			String domain, String app, String sourceOrBinary) throws CoreException {
+		IServerWorkingCopy wc = server.createWorkingCopy();
+		wc.setHost(host);
+		wc.setAttribute(ATTRIBUTE_USERNAME, username);
+		wc.setAttribute(ATTRIBUTE_PASSWORD, password);
+		wc.setAttribute(ATTRIBUTE_DOMAIN, domain);
+		wc.setAttribute(ATTRIBUTE_APPLICATION, app);
+		wc.setAttribute(ATTRIBUTE_EXPRESS_MODE, sourceOrBinary);
+		return wc.save(true, new NullProgressMonitor());
+	}
+	
+	
+	public static IServer createServerAndRuntime(String runtimeID, String serverID,
+			String location, String configuration) throws CoreException {
+		IRuntime runtime = RuntimeUtils.createRuntime(runtimeID, location, configuration);
+		return createServer(runtime, serverID);
+	}
+	
+	public static IServer createServer(IRuntime runtime, String serverID) throws CoreException {
+		return ServerCreationUtils.createServer2(runtime, serverID);
+	}
 
 }



More information about the jbosstools-commits mailing list