[jbosstools-commits] JBoss Tools SVN: r23030 - trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/context.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Fri Jun 25 07:16:47 EDT 2010


Author: scabanovich
Date: 2010-06-25 07:16:43 -0400 (Fri, 25 Jun 2010)
New Revision: 23030

Modified:
   trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/context/Messages.java
   trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/context/RegisterServerContext.java
   trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/context/RegisterServerContext.properties
Log:
https://jira.jboss.org/browse/JBIDE-6514

Modified: trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/context/Messages.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/context/Messages.java	2010-06-25 11:00:42 UTC (rev 23029)
+++ trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/context/Messages.java	2010-06-25 11:16:43 UTC (rev 23030)
@@ -13,6 +13,8 @@
 	public static String ERR_APP_NAME_IS_NOT_SPECIFIED;
 	public static String ERR_SERVLET_VERSION_IS_NOT_SET;
 	public static String ERR_SERVLET_VERSION_IS_NOT_VALID;
+	public static String ERR_SERVLET_VERSION_IS_NOT_SUPPORTED;
+	public static String ERR_SERVLET_VERSION_IS_NOT_SUPPORTED_BY_RUNTIME;
 
 	static {
 		NLS.initializeMessages(BUNDLE_NAME, Messages.class);

Modified: trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/context/RegisterServerContext.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/context/RegisterServerContext.java	2010-06-25 11:00:42 UTC (rev 23029)
+++ trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/context/RegisterServerContext.java	2010-06-25 11:16:43 UTC (rev 23030)
@@ -11,10 +11,16 @@
 package org.jboss.tools.jst.web.context;
 
 import java.text.MessageFormat;
+import java.util.Iterator;
+import java.util.Set;
 import java.util.StringTokenizer;
 
 import org.eclipse.core.resources.IProject;
 import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.eclipse.wst.common.project.facet.core.runtime.RuntimeManager;
 import org.eclipse.wst.server.core.IModule;
 import org.eclipse.wst.server.core.IRuntime;
 import org.eclipse.wst.server.core.IServer;
@@ -177,7 +183,7 @@
 				IModule module = RegistrationHelper.findModule(project);
 				boolean isFakeModule = false;
 				if(module == null) {
-					if(serverErrorCache != null) {
+					if(serverErrorCache != null && serverErrorCache.length() > 0) {
 						return serverErrorCache;
 					}
 					ModuleFactory f = ServerPlugin.findModuleFactory("org.eclipse.jst.j2ee.server"); //$NON-NLS-1$
@@ -186,7 +192,7 @@
 				} else {
 					serverErrorCache = null;
 				}
-				for (int i = 0; i < targetServers.length; i++) {
+				if(serverErrorCache == null) for (int i = 0; i < targetServers.length; i++) {
 					if(RegistrationHelper.isRegistered(applicationName, targetServers[i])) {
 						return NLS.bind(WebUIMessages.APPLICATION_IS_ALREADY_REGISTERED, applicationName, targetServers[i].getName());
 					}
@@ -205,12 +211,30 @@
 						}
 					}
 				}
+				serverErrorCache = ""; //$NON-NLS-1$
 			}
 			if(servletVersion != null && servletVersion.length() == 0) {
 				return Messages.ERR_SERVLET_VERSION_IS_NOT_SET; 
 			} else if(!checkServletVersionFormat()) {
 				return Messages.ERR_SERVLET_VERSION_IS_NOT_VALID;				 
 			}
+			if(runtime != null) {
+				IProjectFacet f = ProjectFacetsManager.getProjectFacet("jst.web"); //$NON-NLS-1$
+				if(f != null) {
+					IProjectFacetVersion v = f.getVersion(servletVersion);
+					if (v == null) return NLS.bind(Messages.ERR_SERVLET_VERSION_IS_NOT_SUPPORTED, servletVersion);
+					org.eclipse.wst.common.project.facet.core.runtime.IRuntime facetRuntime = null;
+					Set<?> set = RuntimeManager.getRuntimes();
+					Iterator<?> it = set.iterator();
+					while(it.hasNext()) {
+						org.eclipse.wst.common.project.facet.core.runtime.IRuntime r = (org.eclipse.wst.common.project.facet.core.runtime.IRuntime)it.next();
+						if(runtimeName.equals(r.getName())) facetRuntime = r;
+					}
+					if(facetRuntime != null && !facetRuntime.supports(v)) {
+						return NLS.bind(Messages.ERR_SERVLET_VERSION_IS_NOT_SUPPORTED_BY_RUNTIME, runtimeName, servletVersion);
+					}
+				}
+			}
 			return null;
 		}
 		
@@ -226,7 +250,7 @@
 			try {
 				Integer.parseInt(t);
 			} catch (NumberFormatException e) {
-				WebModelPlugin.getPluginLog().logError(e);
+				//Do not log! This is the validation of user input!
 				return false;
 			}
 		}			

Modified: trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/context/RegisterServerContext.properties
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/context/RegisterServerContext.properties	2010-06-25 11:00:42 UTC (rev 23029)
+++ trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/context/RegisterServerContext.properties	2010-06-25 11:16:43 UTC (rev 23030)
@@ -4,3 +4,5 @@
 ERR_APP_NAME_IS_NOT_SPECIFIED=Application Name is not specified.
 ERR_SERVLET_VERSION_IS_NOT_SET=Servlet version is not specified.
 ERR_SERVLET_VERSION_IS_NOT_VALID=Servlet version is not valid.
+ERR_SERVLET_VERSION_IS_NOT_SUPPORTED=Servlet version {0} is not supported.
+ERR_SERVLET_VERSION_IS_NOT_SUPPORTED_BY_RUNTIME=Runtime {0} does not support servlet version {1}.



More information about the jbosstools-commits mailing list