geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sppa...@apache.org
Subject svn commit: r414706 - in /geronimo/devtools/eclipse-plugin/trunk/plugins: org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/ org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/internal/ org.apache.geronimo.st.ui/src/org/apache/geroni...
Date Thu, 15 Jun 2006 23:59:43 GMT
Author: sppatel
Date: Thu Jun 15 16:59:42 2006
New Revision: 414706

URL: http://svn.apache.org/viewvc?rev=414706&view=rev
Log:
fix version checking

Modified:
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GenericGeronimoServerRuntime.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/internal/Messages.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/internal/Messages.properties
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/GeronimoServerRuntimeWizardFragment.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/Messages.properties
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v1.core/serverdef/geronimo10.serverdef
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/serverdef/geronimo11.serverdef

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GenericGeronimoServerRuntime.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GenericGeronimoServerRuntime.java?rev=414706&r1=414705&r2=414706&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GenericGeronimoServerRuntime.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GenericGeronimoServerRuntime.java
Thu Jun 15 16:59:42 2006
@@ -21,12 +21,20 @@
 import java.net.URL;
 import java.net.URLClassLoader;
 
+import org.apache.geronimo.st.core.internal.Messages;
+import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.jst.server.generic.core.internal.GenericServerRuntime;
+import org.eclipse.osgi.util.NLS;
 
-public class GenericGeronimoServerRuntime extends GenericServerRuntime
-		implements IGeronimoRuntime {
+public class GenericGeronimoServerRuntime extends GenericServerRuntime implements IGeronimoRuntime
{
+
+	public static final int NO_IMAGE = 0;
+
+	public static final int INCORRECT_VERSION = 1;
+
+	public static final int PARTIAL_IMAGE = 2;
 
 	/*
 	 * (non-Javadoc)
@@ -34,13 +42,45 @@
 	 * @see org.eclipse.wst.server.core.model.RuntimeDelegate#validate()
 	 */
 	public IStatus validate() {
-		/*String version = detectVersion();
-		if (!getRuntime().getRuntimeType().getVersion().equals(version))
-			return new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, null, null);*/
-		return super.validate();
+		IStatus status = super.validate();
+
+		if (!status.isOK()) {
+			return status;
+		}
+
+		IPath runtimeLoc = getRuntime().getLocation();
+
+		// check for server file structure
+		int count = 0;
+		count = runtimeLoc.append("bin/server.jar").toFile().exists() ? ++count : count;
+		count = runtimeLoc.append("bin/deployer.jar").toFile().exists() ? ++count : count;
+		count = runtimeLoc.append("lib").toFile().exists() ? ++count : ++count;
+		count = runtimeLoc.append("repository").toFile().exists() ? ++count : count;
+
+		if (count == 0)
+			return new Status(IStatus.ERROR, Activator.PLUGIN_ID, NO_IMAGE, null, null);
+
+		if (count < 4) {
+			// part of a server image was found, don't let install happen
+			return new Status(IStatus.ERROR, Activator.PLUGIN_ID, PARTIAL_IMAGE, Messages.missingContent,
null);
+		}
+
+		String detectedVersion = detectVersion();
+		if (detectedVersion == null)
+			return new Status(IStatus.WARNING, Activator.PLUGIN_ID, INCORRECT_VERSION, Messages.noVersion,
null);
+
+		if (!detectedVersion.startsWith(getRuntime().getRuntimeType().getVersion())) {
+			String message = NLS.bind(Messages.incorrectVersion, new String[] {
+					getRuntime().getRuntimeType().getVersion(),
+					detectedVersion });
+			return new Status(IStatus.ERROR, Activator.PLUGIN_ID, INCORRECT_VERSION, message, null);
+		}
+
+		return Status.OK_STATUS;
 	}
 
 	public String detectVersion() {
+		
 		File libDir = getRuntime().getLocation().append("lib").toFile();
 		if (libDir.exists()) {
 			File[] libs = libDir.listFiles();
@@ -55,13 +95,15 @@
 					}
 				}
 			}
-			URLClassLoader cl = new URLClassLoader(new URL[] { systemjarURL });
-			try {
-				Class clazz = cl.loadClass("org.apache.geronimo.system.serverinfo.ServerConstants");
-				Method method = clazz.getMethod("getVersion", new Class[] {});
-				return (String) method.invoke(null, null);
-			} catch (Exception e) {
-				e.printStackTrace();
+			if (systemjarURL != null) {
+				URLClassLoader cl = new URLClassLoader(new URL[] { systemjarURL });
+				try {
+					Class clazz = cl.loadClass("org.apache.geronimo.system.serverinfo.ServerConstants");
+					Method method = clazz.getMethod("getVersion", new Class[] {});
+					return (String) method.invoke(null, null);
+				} catch (Exception e) {
+					e.printStackTrace();
+				}
 			}
 		}
 		return null;

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/internal/Messages.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/internal/Messages.java?rev=414706&r1=414705&r2=414706&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/internal/Messages.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/internal/Messages.java
Thu Jun 15 16:59:42 2006
@@ -35,5 +35,9 @@
 	
 	public static String target10runtime;
 	public static String target11runtime;
+	
+	public static String incorrectVersion;
+	public static String noVersion;
+	public static String missingContent;
 
 }

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/internal/Messages.properties
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/internal/Messages.properties?rev=414706&r1=414705&r2=414706&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/internal/Messages.properties
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/internal/Messages.properties
Thu Jun 15 16:59:42 2006
@@ -6,4 +6,8 @@
 DM_CONNECTION_FAIL=Connection to deployment manager failed.  See log for details.
 
 target10runtime=Geronimo v1.0 Runtime
-target11runtime=Geronimo v1.1 Runtime
\ No newline at end of file
+target11runtime=Geronimo v1.1 Runtime
+
+incorrectVersion=An incorrect version of Geronimo was detected.  Version {0} was expected,
but version {1} was found.
+noVersion=A geronimo installation was detected, however the version could not be verified.
+missingContent=A geronimo installation was detected, however parts of the server seem to
be missing.
\ No newline at end of file

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/GeronimoServerRuntimeWizardFragment.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/GeronimoServerRuntimeWizardFragment.java?rev=414706&r1=414705&r2=414706&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/GeronimoServerRuntimeWizardFragment.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/GeronimoServerRuntimeWizardFragment.java
Thu Jun 15 16:59:42 2006
@@ -21,6 +21,7 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.geronimo.st.core.GenericGeronimoServerRuntime;
 import org.apache.geronimo.st.ui.Activator;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
@@ -65,16 +66,18 @@
 import org.eclipse.wst.server.core.model.RuntimeDelegate;
 import org.eclipse.wst.server.ui.wizard.IWizardHandle;
 
-public class GeronimoServerRuntimeWizardFragment extends
-		ServerDefinitionTypeAwareWizardFragment {
+public class GeronimoServerRuntimeWizardFragment extends ServerDefinitionTypeAwareWizardFragment
{
 
 	private static final String G_WITH_TOMCAT_ID = "org.apache.geronimo.runtime.tomcat.10";
+
 	private static final String G_WITH_JETTY_ID = "org.apache.geronimo.runtime.jetty.10";
 
 	private GenericServerCompositeDecorator[] fDecorators;
+
 	protected Text installDir;
 
 	private Button tomcat;
+
 	private Button jetty;
 
 	private Group group;
@@ -205,9 +208,7 @@
 									: gWithJetty;
 							final Path installPath = new Path(installDir.getText());
 							IRunnableWithProgress runnable = new IRunnableWithProgress() {
-								public void run(IProgressMonitor monitor)
-										throws InvocationTargetException,
-										InterruptedException {
+								public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException
{
 									try {
 										installable.install(installPath, monitor);
 									} catch (CoreException e) {
@@ -253,15 +254,17 @@
 	public boolean isComplete() {
 		IRuntimeWorkingCopy runtimeWC = getRuntimeDelegate().getRuntimeWorkingCopy();
 		IStatus status = runtimeWC.validate(null);
-		return status == null || status.isOK();
+		return status == null || status.getSeverity() != IStatus.ERROR;
 	}
 
 	protected void validate() {
 
 		IRuntime runtime = getRuntimeDelegate().getRuntime();
-
+		
+		IWizardHandle wizard = getWizard();
+		
 		if (runtime == null) {
-			getWizard().setMessage("", IMessageProvider.ERROR);
+			wizard.setMessage("", IMessageProvider.ERROR);
 			return;
 		}
 
@@ -271,47 +274,52 @@
 
 		if (installDir.getText() == null || installDir.getText().length() == 0) {
 			// installDir field has not been entered
-			getWizard().setMessage(Messages.installDirInfo, IMessageProvider.ERROR);
+			wizard.setMessage(Messages.installDirInfo, IMessageProvider.NONE);
 		} else {
 			IStatus status = runtimeWC.validate(null);
 			if (status == null || status.isOK()) {
-				getWizard().setMessage(null, IMessageProvider.NONE);
+				//a valid install found
+				wizard.setMessage(null, IMessageProvider.NONE);
+				group.setEnabled(false);
+			} else if(status.getCode() == GenericGeronimoServerRuntime.INCORRECT_VERSION) {
 				group.setEnabled(false);
+				if(status.getSeverity() == IStatus.ERROR) {
+					wizard.setMessage(status.getMessage(), IMessageProvider.ERROR);
+					return;
+				} 
+				wizard.setMessage(status.getMessage(), IMessageProvider.WARNING);
+			} else if(status.getCode() == GenericGeronimoServerRuntime.PARTIAL_IMAGE) {
+				wizard.setMessage(status.getMessage(), IMessageProvider.ERROR);
+				return;
 			} else {
 				File file = new Path(installDir.getText()).toFile();
+				boolean enableGroup = file.isDirectory() && file.canWrite() ? true : false;
+				group.setEnabled(enableGroup);
 				if (file.isDirectory()) {
-					boolean canWrite = file.canWrite();
-					String message = canWrite ? Messages.noImageFound
-							: Messages.cannotInstallAtLocation;
-					if (canWrite)
-						group.setEnabled(true);
-					getWizard().setMessage(message, IMessageProvider.ERROR);
+					String message = file.canWrite() ? Messages.noImageFound : Messages.cannotInstallAtLocation;
+					wizard.setMessage(message, IMessageProvider.ERROR);
 				} else {
-					group.setEnabled(false);
-					getWizard().setMessage(Messages.noSuchDir, IMessageProvider.ERROR);
+					wizard.setMessage(Messages.noSuchDir, IMessageProvider.ERROR);
 				}
 				return;
 			}
+			
+			//wizard.setMessage(null, IMessageProvider.NONE);
 
-			if (!isValidVM()) {
-				getWizard().setMessage(Messages.jvmWarning, IMessageProvider.WARNING);
-				return;
-			}
-
-			getWizard().setMessage(null, IMessageProvider.NONE);
+			if (!isValidVM()) 
+				wizard.setMessage(Messages.jvmWarning, IMessageProvider.WARNING);
 		}
-
-		// validateDecorators();
 	}
 
 	private boolean isValidVM() {
 		String javaVersion = null;
 		IVMInstall vmInstall = getRuntimeDelegate().getVMInstall();
-		if (vmInstall instanceof IVMInstall2) 
+		if (vmInstall instanceof IVMInstall2)
 			javaVersion = ((IVMInstall2) vmInstall).getJavaVersion();
 		return javaVersion != null && javaVersion.startsWith("1.4");
-		//This returns false on MacOSX due to do no IVMInstall2.getJavaVersion() implementation
-		//on Mac, fixed in Eclipse 3.2
+		// This returns false on MacOSX due to do no
+		// IVMInstall2.getJavaVersion() implementation
+		// on Mac, fixed in Eclipse 3.2
 	}
 
 	private void validateDecorators() {

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/Messages.properties
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/Messages.properties?rev=414706&r1=414705&r2=414706&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/Messages.properties
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/Messages.properties
Thu Jun 15 16:59:42 2006
@@ -161,8 +161,8 @@
 installDir=Application Server Installation Directory:
 installDirInfo=Please enter the directory where Geronimo is currently installed or where
you would like it to be installed.
 noSuchDir=The specified directory does not exist.
-noImageFound=A Geronimo installation does not exist at this location.
-cannotInstallAtLocation=A Geronimo installation does not exist and cannot be installed at
this location.
+noImageFound=A Geronimo installation does not exist at this location.  You can install an
image at this location.
+cannotInstallAtLocation=A Geronimo installation cannot be found nor can it be installed at
this location.
 downloadOptions=Download Options
 chooseWebContainer=Select a web container:
 gWithTomcat=Geronimo with Tomcat

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v1.core/serverdef/geronimo10.serverdef
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v1.core/serverdef/geronimo10.serverdef?rev=414706&r1=414705&r2=414706&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v1.core/serverdef/geronimo10.serverdef
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v1.core/serverdef/geronimo10.serverdef
Thu Jun 15 16:59:42 2006
@@ -85,16 +85,8 @@
 		<classpathReference>geronimo.server</classpathReference>
 	</start>
 
-	<classpath id="geronimo.server">
-		<archive path="${serverRootDirectory}/bin/server.jar" />
-	</classpath>
-
-	<classpath id="geronimo.deploy">
-		<archive path="${serverRootDirectory}/bin/deployer.jar" />
-	</classpath>
-
 	<classpath id="geronimo.project">
-		<archive path="${serverRootDirectory}/repository/org.apache.geronimo.specs/jars" />
+		<archive path="${serverRootDirectory}/repository" />
 		<archive path="${serverRootDirectory}/lib" />
 	</classpath>
 	

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/serverdef/geronimo11.serverdef
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/serverdef/geronimo11.serverdef?rev=414706&r1=414705&r2=414706&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/serverdef/geronimo11.serverdef
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/serverdef/geronimo11.serverdef
Thu Jun 15 16:59:42 2006
@@ -77,17 +77,9 @@
 		<classpathReference>geronimo.server</classpathReference>
 	</start>
 
-	<classpath id="geronimo.server">
-		<archive path="${serverRootDirectory}/bin/server.jar" />
-	</classpath>
-
-	<classpath id="geronimo.deploy">
-		<archive path="${serverRootDirectory}/bin/deployer.jar" />
-	</classpath>
-
 	<classpath id="geronimo.project">
-		<archive path="${serverRootDirectory}/repository/org/apache/geronimo/specs/geronimo-j2ee_1.4_spec/1.1"
/>
-		<archive path="${serverRootDirectory}/lib" />
+		<archive path="${serverRootDirectory}/repository"/>
+		<archive path="${serverRootDirectory}/lib"/>
 	</classpath>
 	
 	<jndiConnection>



Mime
View raw message