Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkchong2015-04-01 21:10:19 +0000
committerkchong2015-04-01 21:10:19 +0000
commit74af31d9eb25cd5375553cd3c8f10d4a72e06139 (patch)
treef0b1d4d5b2f958f85d9eabae0c72b8ac3adad137
parent383803de8a65143979efa140053bf095151e0646 (diff)
downloadwebtools.webservices-74af31d9eb25cd5375553cd3c8f10d4a72e06139.tar.gz
webtools.webservices-74af31d9eb25cd5375553cd3c8f10d4a72e06139.tar.xz
webtools.webservices-74af31d9eb25cd5375553cd3c8f10d4a72e06139.zip
[463126] JAX-RS Facet Install Page servlet-class field validation is too
strict
-rw-r--r--bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSFacetInstallDataModelProvider.java12
-rw-r--r--bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSJ2EEUtils.java12
-rw-r--r--bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSJEEUtils.java30
-rw-r--r--bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSUtils.java8
-rw-r--r--bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/JAXRSFacetInstallPage.java15
-rw-r--r--bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/JAXRSLibraryPropertyPage.java20
6 files changed, 74 insertions, 23 deletions
diff --git a/bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSFacetInstallDataModelProvider.java b/bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSFacetInstallDataModelProvider.java
index bfc8da6e0..da5e6efef 100644
--- a/bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSFacetInstallDataModelProvider.java
+++ b/bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSFacetInstallDataModelProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2014 IBM Corporation and others.
+ * Copyright (c) 2009, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -17,7 +17,8 @@
* 20100519 313576 ericdp@ca.ibm.com - Eric D. Peters, JAX-RS tools- validation problems
* 20110817 355026 kchong@ca.ibm.com - Keith Chong, [JAXRS] JAXRSFacetInstallDataModelProvider dispose method does not remove all listeners it adds
* 20120214 371661 jenyoung@ca.ibm.com - Jennifer Young, [JAXRS] Performance issue since dispose method is not being called
- * 20140709 431081 jgwest@ca.ibm.com - Jonathan West, "Further Configuration" state when adding JAX-RS Facet should be "available", not "required"
+ * 20140709 431081 jgwest@ca.ibm.com - Jonathan West, "Further Configuration" state when adding JAX-RS Facet should be "available", not "required"
+ * 20150325 463126 jgwest@ca.ibm.com - Jonathan West, JAX-RS Facet Install Page servlet-class field validation is too strict
*******************************************************************************/
package org.eclipse.jst.ws.jaxrs.core.internal.project.facet;
@@ -202,14 +203,13 @@ public class JAXRSFacetInstallDataModelProvider extends
}
private IStatus validateServletInfo(String servletName, String servletClassName) {
+
if (servletName == null || servletName.trim().length() == 0) {
errorMessage = Messages.JAXRSFacetInstallDataModelProvider_ValidateServletName;
return createErrorStatus(errorMessage);
}
- if (servletClassName == null || servletClassName.trim().length() == 0) {
- errorMessage = Messages.JAXRSFacetInstallDataModelProvider_ValidateServletClassName;
- return createErrorStatus(errorMessage);
- }
+
+ // ServletClassName is not required in some cases, for example, if servlet name is a javax.ws.rs.core.Application.
return OK_STATUS;
}
diff --git a/bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSJ2EEUtils.java b/bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSJ2EEUtils.java
index c8d3e0237..0add6ff1f 100644
--- a/bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSJ2EEUtils.java
+++ b/bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSJ2EEUtils.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010 IBM Corporation and others.
+ * Copyright (c) 2009, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,6 +14,7 @@
* 20100325 307059 ericdp@ca.ibm.com - Eric D. Peters, JAX-RS properties page- fields empty or incorrect
* 20100408 308565 kchong@ca.ibm.com - Keith Chong, JAX-RS: Servlet name and class not updated
* 20100618 307059 ericdp@ca.ibm.com - Eric D. Peters, JAX-RS properties page- fields empty or incorrect
+ * 20150325 463126 jgwest@ca.ibm.com - Jonathan West, JAX-RS Facet Install Page servlet-class field validation is too strict
*******************************************************************************/
package org.eclipse.jst.ws.jaxrs.core.internal.project.facet;
@@ -158,12 +159,15 @@ public class JAXRSJ2EEUtils extends JAXRSUtils {
* @return Servlet servlet - if passed servlet was null, will return created
* servlet
*/
- @SuppressWarnings("unchecked")
- public static Servlet createOrUpdateServletRef(final WebApp webApp,
- final IDataModel config, Servlet servlet) {
+ public static Servlet createOrUpdateServletRef(final WebApp webApp, final IDataModel config, Servlet servlet) {
String displayName = getDisplayName(config);
String className = getServletClassname(config);
+
+ // For 2.3 and 2.4, return empty element rather than null
+ if(className == null || className.trim().length() == 0 ) {
+ className = JAXRSUtils.JAXRS_SERVLET_CLASS; // The default name of the JAX-RS servlet class
+ }
return createOrUpdateServletRef(webApp, displayName, className, servlet);
}
diff --git a/bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSJEEUtils.java b/bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSJEEUtils.java
index 1a5ebb88c..e37f99be4 100644
--- a/bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSJEEUtils.java
+++ b/bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSJEEUtils.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2014 IBM Corporation and others.
+ * Copyright (c) 2009, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -17,6 +17,7 @@
* 20100408 308565 kchong@ca.ibm.com - Keith Chong, JAX-RS: Servlet name and class not updated
* 20100618 307059 ericdp@ca.ibm.com - Eric D. Peters, JAX-RS properties page- fields empty or incorrect
* 20140813 441729 kchong@ca.ibm.com - Keith Chong, JAX-RS Facet install may fail to update the web.xml with servlet info.
+ * 20150325 463126 jgwest@ca.ibm.com - Jonathan West, JAX-RS Facet Install Page servlet-class field validation is too strict
*******************************************************************************/
package org.eclipse.jst.ws.jaxrs.core.internal.project.facet;
@@ -123,17 +124,22 @@ public class JAXRSJEEUtils extends JAXRSUtils {
* @return Servlet servlet - if passed servlet was null, will return created
* servlet
*/
- @SuppressWarnings("unchecked")
public static Servlet createOrUpdateServletRef(final WebApp webApp,
final IDataModel config, org.eclipse.jst.javaee.web.Servlet servlet) {
String displayName = getDisplayName(config);
String className = getServletClassname(config);
+
+ // For Web 3.0+, return null, rather than empty, as the className is not required in some scenarios.
+ if(className == null || className.trim().length() == 0) {
+ if(isWebApp30orHigher(webApp)) {
+ className = null;
+ }
+ }
return createOrUpdateServletRef(webApp, displayName, className, servlet);
}
- @SuppressWarnings("unchecked")
public static Servlet createOrUpdateServletRef(final WebApp webApp,
String displayName, String className, org.eclipse.jst.javaee.web.Servlet servlet) {
@@ -231,6 +237,24 @@ public class JAXRSJEEUtils extends JAXRSUtils {
return false;
}
+ public static boolean isWebApp30orHigher(final Object webAppObj) {
+
+ if (webAppObj instanceof WebApp) {
+ WebApp w = (WebApp)webAppObj;
+
+ if(w.getVersion() == WebAppVersionType._30_LITERAL) {
+ return true;
+ }
+
+ if(w.getVersion() == WebAppVersionType._31) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+
/**
* Creates servlet-mappings for the servlet for 2.5 WebModules or greater
*
diff --git a/bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSUtils.java b/bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSUtils.java
index 89db24bb4..d0cf25308 100644
--- a/bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSUtils.java
+++ b/bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSUtils.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010 IBM Corporation and others.
+ * Copyright (c) 2009, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,6 +13,7 @@
* 20100325 307059 ericdp@ca.ibm.com - Eric D. Peters, JAX-RS properties page- fields empty or incorrect
* 20100408 308565 kchong@ca.ibm.com - Keith Chong, JAX-RS: Servlet name and class not updated
* 20100618 307059 ericdp@ca.ibm.com - Eric D. Peters, JAX-RS properties page- fields empty or incorrect
+ * 20150325 463126 jgwest@ca.ibm.com - Jonathan West, JAX-RS Facet Install Page servlet-class field validation is too strict
*******************************************************************************/
package org.eclipse.jst.ws.jaxrs.core.internal.project.facet;
@@ -69,8 +70,11 @@ public abstract class JAXRSUtils {
protected static String getServletClassname(IDataModel config) {
String className = config
.getStringProperty(IJAXRSFacetInstallDataModelProperties.SERVLET_CLASSNAME);
- if (className == null || className.trim().equals("")) //$NON-NLS-1$
+
+ if (className == null || className.trim().equals("")) { //$NON-NLS-1$
className = JAXRS_SERVLET_CLASS;
+ }
+
return className.trim();
}
diff --git a/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/JAXRSFacetInstallPage.java b/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/JAXRSFacetInstallPage.java
index d34803777..66d03d89e 100644
--- a/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/JAXRSFacetInstallPage.java
+++ b/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/JAXRSFacetInstallPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2014 IBM Corporation and others.
+ * Copyright (c) 2009, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -24,7 +24,8 @@
* 20110822 349541 atosak@ca.ibm.com - Atosa Khoddamhazrati, JAX-RS Facet assumes a project has a runtime when enabling the facet
* 20120206 365103 jenyoung@ca.ibm.com - Jennifer Young, JAX-RS configuration UI should have the Update Deployment descriptor check box available
* 20120427 377916 jenyoung@ca.ibm.com - Jennifer Young, The JAX-RS install operation config should be updated whenever there are provider set changes
- * 20140709 431081 jgwest@ca.ibm.com - Jonathan West, "Further Configuration" state when adding JAX-RS Facet should be "available", not "required" *
+ * 20140709 431081 jgwest@ca.ibm.com - Jonathan West, "Further Configuration" state when adding JAX-RS Facet should be "available", not "required" *
+ * 20150325 463126 jgwest@ca.ibm.com - Jonathan West, JAX-RS Facet Install Page servlet-class field validation is too strict
*******************************************************************************/
package org.eclipse.jst.ws.jaxrs.ui.internal.project.facet;
@@ -381,6 +382,16 @@ private void initializeValues()
private String getJAXRSServletClassname()
{
+ String text = servletInfoGroup.txtJAXRSServletClassName.getText();
+
+ if(text == null || text.trim().length() == 0) {
+ if(isJEE6orGreater()) {
+ return null;
+ } else {
+ return "";
+ }
+ }
+
return servletInfoGroup.txtJAXRSServletClassName.getText().trim();
}
diff --git a/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/JAXRSLibraryPropertyPage.java b/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/JAXRSLibraryPropertyPage.java
index 2ac7680de..84f513d83 100644
--- a/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/JAXRSLibraryPropertyPage.java
+++ b/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/JAXRSLibraryPropertyPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2014 IBM Corporation and others.
+ * Copyright (c) 2009, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -21,6 +21,7 @@
* 20100618 307059 ericdp@ca.ibm.com - Eric D. Peters, JAX-RS properties page- fields empty or incorrect
* 20110823 349718 kchong@ca.ibm.com - Keith Chong, Upon selection, the JAX-RS Configuration page is blank when Project Facets page has unapplied changes
* 20140813 441729 kchong@ca.ibm.com - Keith Chong, JAX-RS Facet install may fail to update the web.xml with servlet info.
+ * 20150325 463126 jgwest@ca.ibm.com - Jonathan West, JAX-RS Facet Install Page servlet-class field validation is too strict
*******************************************************************************/
package org.eclipse.jst.ws.jaxrs.ui.internal.project.facet;
@@ -264,7 +265,16 @@ implements IJAXRSFacetInstallDataModelProperties
List<String> listOfMappings = Arrays.asList(servletInfoGroup.lstJAXRSServletURLPatterns.getItems());
if (JAXRSJEEUtils.isWebApp25orHigher(webAppObj))
{
- provider.modify(new UpdateWebXMLForJavaEE(project, initialInstallDelegateLibraryProviderID , servletInfoGroup.txtJAXRSServletName.getText(), servletInfoGroup.txtJAXRSServletClassName.getText(), listOfMappings),
+
+ String className = servletInfoGroup.txtJAXRSServletClassName.getText();
+ if(JAXRSJEEUtils.isWebApp30orHigher(webAppObj)) {
+ // For Web 3.0+, return null, rather than empty, as the className is not required in some scenarios.
+ if(className == null || className.trim().length() == 0) {
+ className = null;
+ }
+ }
+
+ provider.modify(new UpdateWebXMLForJavaEE(project, initialInstallDelegateLibraryProviderID , servletInfoGroup.txtJAXRSServletName.getText(), className, listOfMappings),
IModelProvider.FORCESAVE);
}
else
@@ -288,10 +298,8 @@ implements IJAXRSFacetInstallDataModelProperties
String errorMessage = Messages.JAXRSFacetInstallDataModelProvider_ValidateServletName;
return createErrorStatus(errorMessage);
}
- if (ServletClassName == null || ServletClassName.trim().length() == 0) {
- String errorMessage = Messages.JAXRSFacetInstallDataModelProvider_ValidateServletClassName;
- return createErrorStatus(errorMessage);
- }
+
+ // ServletClassName is not required in some cases, for example, if servlet name is a javax.ws.rs.core.Application.
return Status.OK_STATUS;
}
private IStatus createErrorStatus(String msg) {

Back to the top