[358870] Annotation Properties view causes IllegalArgumentException when quickly setting annotations
diff --git a/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/JAXWSCoreMessages.java b/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/JAXWSCoreMessages.java
index 704772e..9bf1320 100644
--- a/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/JAXWSCoreMessages.java
+++ b/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/JAXWSCoreMessages.java
@@ -76,6 +76,7 @@
public static String WEBSERVICE_DEFAULT_PACKAGE_TARGET_NAMESPACE;
public static String WEBSERVICE_WSDL_LOCATION_UNABLE_TO_LOCATE;
+ public static String WEBSERVICE_WSDL_LOCATION_UNABLE_TO_READ;
public static String WEBSERVICE_WSDL_LOCATION_NO_PORT_NAME;
public static String WEBSERVICE_WSDL_LOCATION_NO_SERVICE_NAME;
public static String WEBSERVICE_WSDL_LOCATION_NO_OPERTATION_NAME;
diff --git a/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/JAXWSCoreMessages.properties b/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/JAXWSCoreMessages.properties
index 7d0ff2f..449fa62 100644
--- a/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/JAXWSCoreMessages.properties
+++ b/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/JAXWSCoreMessages.properties
@@ -63,6 +63,7 @@
LOCAL_NAME_ATTRIBUTES_MUST_BE_UNIQUE=The wrapper bean localName attributes must be unique : ''{0}''
INVALID_NCNAME_ATTRIBUTE=The @{0} {1} attribute value ''{2}'' contains invalid characters
WEBSERVICE_WSDL_LOCATION_UNABLE_TO_LOCATE=Unable to locate wsdl at wsdlLocation: ''{0}''
+WEBSERVICE_WSDL_LOCATION_UNABLE_TO_READ=Unable to read wsdl file at wsdlLocation: ''{0}''
WEBSERVICE_WSDL_LOCATION_NO_PORT_NAME=No wsdl:port matching the portName ''{0}'' can be found in the WSDL ''{1}''
WEBSERVICE_WSDL_LOCATION_NO_SERVICE_NAME=No wsdl:service matching the serviceName ''{0}'' can be found in the WSDL ''{1}''
WEBSERVICE_WSDL_LOCATION_NO_OPERTATION_NAME=No @WebMethod matching the wsdl:operation ''{0}'' can be found
diff --git a/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/annotations/validation/WebServiceWSDLLocationRule.java b/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/annotations/validation/WebServiceWSDLLocationRule.java
index fb7db74..8e9d267 100644
--- a/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/annotations/validation/WebServiceWSDLLocationRule.java
+++ b/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/internal/jaxws/core/annotations/validation/WebServiceWSDLLocationRule.java
@@ -21,8 +21,11 @@
import static org.eclipse.jst.ws.internal.jaxws.core.utils.JAXWSUtils.TARGET_NAMESPACE;
import static org.eclipse.jst.ws.internal.jaxws.core.utils.JAXWSUtils.WSDL_LOCATION;
+import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.util.Collection;
import java.util.HashMap;
@@ -85,7 +88,7 @@
if (wsdlLocationValue != null) {
String wsdlLocation = wsdlLocationValue.getValue().toString().trim();
if (wsdlLocation.length() > 0) {
- if (wsdlLocation.endsWith(".wsdl")) { //$NON-NLS-1$
+ if (!wsdlLocation.startsWith("file:/") && wsdlLocation.endsWith(".wsdl")) { //$NON-NLS-1$
URL relativeURL = getRelativeURL(classDeclaration, wsdlLocation);
if (relativeURL != null) {
validateWSDL(relativeURL.toString(), webService, classDeclaration, wsdlLocationValue);
@@ -168,8 +171,7 @@
new Object[] {serviceQName.getLocalPart(), wsdlLocation}));
}
} else {
- printWarning(wsdlLocationValue.getPosition(), JAXWSCoreMessages.bind(
- JAXWSCoreMessages.WEBSERVICE_WSDL_LOCATION_UNABLE_TO_LOCATE, wsdlLocation));
+ printWarning(wsdlLocationValue.getPosition(), getMessage(wsdlURL, wsdlLocation));
}
} catch (MalformedURLException murle) {
printError(wsdlLocationValue.getPosition(), murle.getLocalizedMessage());
@@ -179,6 +181,22 @@
}
}
+ private String getMessage(URL wsdlURL, String wsdlLocation) {
+ String message = JAXWSCoreMessages.bind(JAXWSCoreMessages.WEBSERVICE_WSDL_LOCATION_UNABLE_TO_LOCATE, wsdlLocation);
+ try {
+ URI uri = wsdlURL.toURI();
+ if (uri.getScheme().equals("file")) {
+ File file = new File(uri);
+ if (file.exists()) {
+ message = JAXWSCoreMessages.bind(JAXWSCoreMessages.WEBSERVICE_WSDL_LOCATION_UNABLE_TO_READ, wsdlLocation);
+ }
+ }
+ } catch (URISyntaxException urise) {
+ JAXWSCorePlugin.log(urise);
+ }
+ return message;
+ }
+
private void validateBinding(Binding binding, ClassDeclaration classDeclaration,
AnnotationMirror webService, String wsdlLocation) {
String style = javax.jws.soap.SOAPBinding.Style.DOCUMENT.name();
diff --git a/tests/org.eclipse.jst.ws.jaxws.dom.runtime.tests/src/org/eclipse/jst/ws/jaxws/dom/runtime/tests/dom/validation/WsValidationTest.java b/tests/org.eclipse.jst.ws.jaxws.dom.runtime.tests/src/org/eclipse/jst/ws/jaxws/dom/runtime/tests/dom/validation/WsValidationTest.java
index e665043..652ce67 100755
--- a/tests/org.eclipse.jst.ws.jaxws.dom.runtime.tests/src/org/eclipse/jst/ws/jaxws/dom/runtime/tests/dom/validation/WsValidationTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.dom.runtime.tests/src/org/eclipse/jst/ws/jaxws/dom/runtime/tests/dom/validation/WsValidationTest.java
@@ -133,11 +133,66 @@
{
final IFolder webInf = testProject.getProject().getFolder("WebContent").getFolder("WEB-INF");
IFile file = webInf.getFile("Test.wsdl");
- file.create(new StringInputStreamAdapter(""), true, null);
+ file.create(new StringInputStreamAdapter(getWsdlContent()), true, null);
setContents(wsType.getCompilationUnit(), "@javax.jws.WebService(name=\"Test\", wsdlLocation=\"WEB-INF/Test.wsdl\") public class Ws {}");
assertNoValidationErrors(wsType.getResource(), VALIDATION_PROBLEM_MARKER_ID);
}
+
+ private String getWsdlContent()
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+ builder.append("<wsdl:definitions name=\"WsService\" targetNamespace=\"http://test/\"\n");
+ builder.append(" xmlns:wsdl=\"http://schemas.xmlsoap.org/wsdl/\" xmlns:tns=\"http://test/\"\n");
+ builder.append(" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/wsdl/soap/\">\n");
+ builder.append(" <wsdl:portType name=\"Ws\">\n");
+ builder.append(" </wsdl:portType>\n");
+ builder.append(" <wsdl:binding name=\"WsServiceSoapBinding\" type=\"tns:Ws\">\n");
+ builder.append(" <soap:binding style=\"document\" transport=\"http://schemas.xmlsoap.org/soap/http\"/>\n");
+ builder.append(" </wsdl:binding>\n");
+ builder.append(" <wsdl:service name=\"WsService\">\n");
+ builder.append(" <wsdl:port name=\"WsPort\" binding=\"tns:WsServiceSoapBinding\">\n");
+ builder.append(" <soap:address location=\"http://localhost:9090/WsPort\"/>\n");
+ builder.append(" </wsdl:port>\n");
+ builder.append(" </wsdl:service>\n");
+ builder.append("</wsdl:definitions>\n");
+ return builder.toString();
+ }
+
+ public void testWarningReadingWsdlLocation() throws CoreException
+ {
+ final IFolder webInf = testProject.getProject().getFolder("WebContent").getFolder("WEB-INF");
+ IFile file = webInf.getFile("Test.wsdl");
+ file.create(new StringInputStreamAdapter(""), true, null);
+
+ setContents(wsType.getCompilationUnit(), "@javax.jws.WebService(name=\"Test\", wsdlLocation=\"WEB-INF/Test.wsdl\") public class Ws {}");
+
+ final Map<String, Object> markerAttributes = new HashMap<String, Object>();
+ markerAttributes.put(IMarker.CHAR_START, 62);
+ markerAttributes.put(IMarker.CHAR_END, 81);
+ markerAttributes.put(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
+ markerAttributes.put(IMarker.MESSAGE, MessageFormat.format(JAXWSCoreMessages.WEBSERVICE_WSDL_LOCATION_UNABLE_TO_READ, file.getLocationURI().toString()));
+ final MarkerData markerData = new MarkerData(wsType.getResource(), VALIDATION_PROBLEM_MARKER_ID, markerAttributes);
+ validateResourceMarkers(wsType.getResource(), markerData);
+ }
+
+ public void testWarningLocatingWsdlLocation() throws CoreException
+ {
+ final IFolder webInf = testProject.getProject().getFolder("WebContent").getFolder("WEB-INF");
+ IFile file = webInf.getFile("Test.wsdl");
+ file.create(new StringInputStreamAdapter(""), true, null);
+
+ setContents(wsType.getCompilationUnit(), "@javax.jws.WebService(name=\"Test\", wsdlLocation=\"WEB-INF/Test3.wsdl\") public class Ws {}");
+
+ final Map<String, Object> markerAttributes = new HashMap<String, Object>();
+ markerAttributes.put(IMarker.CHAR_START, 62);
+ markerAttributes.put(IMarker.CHAR_END, 82);
+ markerAttributes.put(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
+ markerAttributes.put(IMarker.MESSAGE, MessageFormat.format(JAXWSCoreMessages.WEBSERVICE_WSDL_LOCATION_UNABLE_TO_LOCATE, "WEB-INF/Test3.wsdl"));
+ final MarkerData markerData = new MarkerData(wsType.getResource(), VALIDATION_PROBLEM_MARKER_ID, markerAttributes);
+ validateResourceMarkers(wsType.getResource(), markerData);
+ }
public void testWsdlLocationEmpty() throws CoreException
{