Author: ningjiang Date: Mon Dec 3 23:13:10 2007 New Revision: 600814 URL: http://svn.apache.org/viewvc?rev=600814&view=rev Log: Merged revisions 600115-600506,600508-600671,600673-600685,600687-600700,600702-600726,600728-600799 via svnmerge from https://svn.apache.org/repos/asf/incubator/cxf/trunk
........ r600115 | mmao | 2007-12-01 21:13:34 +0800 (Sat, 01 Dec 2007) | 3 lines * Update the version ........ r600138 | mmao | 2007-12-01 22:14:03 +0800 (Sat, 01 Dec 2007) | 3 lines Remove the jdee plugin, moved to http://code.google.com/p/m2jdee/ ........ r600749 | bimargulies | 2007-12-04 08:44:10 +0800 (Tue, 04 Dec 2007) | 2 lines Fix 1227 some more, and don't just ignore bogus charsets. Complain. ........ r600756 | bimargulies | 2007-12-04 09:01:16 +0800 (Tue, 04 Dec 2007) | 2 lines Don't yammer if there is no charset at all, only if there's an incomprehensible one. ........ r600757 | bimargulies | 2007-12-04 09:04:30 +0800 (Tue, 04 Dec 2007) | 2 lines And while here, why not lose a fight with PMD? ........ r600758 | bimargulies | 2007-12-04 09:12:02 +0800 (Tue, 04 Dec 2007) | 2 lines Get unit test into sync. ........ r600761 | bimargulies | 2007-12-04 09:17:54 +0800 (Tue, 04 Dec 2007) | 2 lines keep trying to check in something trivial.. ........ r600799 | ningjiang | 2007-12-04 14:17:10 +0800 (Tue, 04 Dec 2007) | 1 line Fixed the extensionManagerTest testActivateViaNS ........ Removed: incubator/cxf/branches/2.0.x-fixes/tools/jdee/ Modified: incubator/cxf/branches/2.0.x-fixes/ (props changed) incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/HttpHeaderHelper.java incubator/cxf/branches/2.0.x-fixes/common/common/src/test/java/org/apache/cxf/helpers/HttpHeaderHelperTest.java incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java incubator/cxf/branches/2.0.x-fixes/rt/core/src/test/java/org/apache/cxf/bus/extension/ExtensionManagerTest.java incubator/cxf/branches/2.0.x-fixes/rt/core/src/test/java/org/apache/cxf/bus/extension/MySetterService.java incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/Messages.properties incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Messages.properties incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/Messages.properties incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java Propchange: incubator/cxf/branches/2.0.x-fixes/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/HttpHeaderHelper.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/HttpHeaderHelper.java?rev=600814&r1=600813&r2=600814&view=diff ============================================================================== --- incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/HttpHeaderHelper.java (original) +++ incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/HttpHeaderHelper.java Mon Dec 3 23:13:10 2007 @@ -28,7 +28,6 @@ import java.util.concurrent.ConcurrentHashMap; public final class HttpHeaderHelper { - public static final String CONTENT_TYPE = "Content-Type"; public static final String CONTENT_ID = "Content-ID"; public static final String CONTENT_TRANSFER_ENCODING = "Content-Transfer-Encoding"; @@ -38,6 +37,7 @@ public static final String CONNECTION = "Connection"; public static final String CLOSE = "close"; public static final String AUTHORIZATION = "Authorization"; + private static final Charset UTF8 = Charset.forName("utf-8"); private static Map<String, String> internalHeaders = new HashMap<String, String>(); @@ -72,7 +72,14 @@ //into something that is actually supported by Java and the Stax parsers and such. public static String mapCharset(String enc) { if (enc == null) { - return null; + return UTF8.name(); + } + // Charsets can be quoted. But it's quite certain that they can't have escaped quoted or + // anything like that. + enc = enc.replace("\"", ""); + enc = enc.replace("'", ""); + if ("".equals(enc)) { + return UTF8.name(); } String newenc = encodings.get(enc); if (newenc == null) { Modified: incubator/cxf/branches/2.0.x-fixes/common/common/src/test/java/org/apache/cxf/helpers/HttpHeaderHelperTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/common/common/src/test/java/org/apache/cxf/helpers/HttpHeaderHelperTest.java?rev=600814&r1=600813&r2=600814&view=diff ============================================================================== --- incubator/cxf/branches/2.0.x-fixes/common/common/src/test/java/org/apache/cxf/helpers/HttpHeaderHelperTest.java (original) +++ incubator/cxf/branches/2.0.x-fixes/common/common/src/test/java/org/apache/cxf/helpers/HttpHeaderHelperTest.java Mon Dec 3 23:13:10 2007 @@ -22,8 +22,6 @@ import java.nio.charset.Charset; import org.junit.Test; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - /** * @@ -35,7 +33,11 @@ String cs = HttpHeaderHelper.mapCharset("utf-8"); assertEquals(Charset.forName("utf-8").name(), cs); cs = HttpHeaderHelper.mapCharset(null); - assertNull(cs); + assertEquals("UTF-8", cs); + cs = HttpHeaderHelper.mapCharset("\"utf-8\""); + assertEquals(Charset.forName("utf-8").name(), cs); + cs = HttpHeaderHelper.mapCharset("'utf-8'"); + assertEquals(Charset.forName("utf-8").name(), cs); } } Modified: incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java?rev=600814&r1=600813&r2=600814&view=diff ============================================================================== --- incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java (original) +++ incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java Mon Dec 3 23:13:10 2007 @@ -21,6 +21,7 @@ import java.io.IOException; import java.io.InputStream; +import java.lang.reflect.Method; import java.net.URL; import java.util.ArrayList; import java.util.Collection; @@ -40,6 +41,7 @@ public static final String EXTENSIONMANAGER_PROPERTY_NAME = "extensionManager"; public static final String ACTIVATION_NAMESPACES_PROPERTY_NAME = "activationNamespaces"; + public static final String ACTIVATION_NAMESPACES_SETTER_METHOD_NAME = "setActivationNamespaces"; public static final String BUS_EXTENSION_RESOURCE = "META-INF/bus-extensions.xml"; private final ClassLoader loader; @@ -153,9 +155,13 @@ resourceManager.addResourceResolver(namespacesResolver); } + // Since we need to support spring2.5 by removing @Resource("activationNamespaces") + // Now we call the setActivationNamespaces method directly here + invockSetterActivationNSMethod(obj, e.getNamespaces()); + ResourceInjector injector = new ResourceInjector(resourceManager); - try { + try { injector.inject(obj); injector.construct(obj); } finally { @@ -195,6 +201,28 @@ return null; } - + private void invockSetterActivationNSMethod(Object target, Object value) { + Class clazz = target.getClass(); + String methodName = ACTIVATION_NAMESPACES_SETTER_METHOD_NAME; + while (clazz != Object.class) { + Method[] methods = clazz.getMethods(); + for (int i = 0; i < methods.length; i++) { + Method method = methods[i]; + Class params[] = method.getParameterTypes(); + if (method.getName().equals(methodName) && params.length == 1) { + Class paramType = params[0]; + if (paramType.isInstance(value)) { + try { + method.invoke(target, new Object[] {value}); + } catch (Exception e) { + // do nothing here + } + return; + } + } + } + clazz = clazz.getSuperclass(); + } + } } Modified: incubator/cxf/branches/2.0.x-fixes/rt/core/src/test/java/org/apache/cxf/bus/extension/ExtensionManagerTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/core/src/test/java/org/apache/cxf/bus/extension/ExtensionManagerTest.java?rev=600814&r1=600813&r2=600814&view=diff ============================================================================== --- incubator/cxf/branches/2.0.x-fixes/rt/core/src/test/java/org/apache/cxf/bus/extension/ExtensionManagerTest.java (original) +++ incubator/cxf/branches/2.0.x-fixes/rt/core/src/test/java/org/apache/cxf/bus/extension/ExtensionManagerTest.java Mon Dec 3 23:13:10 2007 @@ -85,7 +85,7 @@ public void verifyActivateViaNS(String extensionClass, String ns) { Extension e = new Extension(); - e.setClassname(MyResourceService.class.getName()); + e.setClassname(extensionClass); e.getNamespaces().add(ns); e.setDeferred(true); manager.processExtension(e); @@ -97,7 +97,7 @@ // second activation should be a no-op - MyService first = myService; + MyService first = myService; manager.activateViaNS(ns); assertSame(first, myService); myService = null; Modified: incubator/cxf/branches/2.0.x-fixes/rt/core/src/test/java/org/apache/cxf/bus/extension/MySetterService.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/core/src/test/java/org/apache/cxf/bus/extension/MySetterService.java?rev=600814&r1=600813&r2=600814&view=diff ============================================================================== --- incubator/cxf/branches/2.0.x-fixes/rt/core/src/test/java/org/apache/cxf/bus/extension/MySetterService.java (original) +++ incubator/cxf/branches/2.0.x-fixes/rt/core/src/test/java/org/apache/cxf/bus/extension/MySetterService.java Mon Dec 3 23:13:10 2007 @@ -34,6 +34,7 @@ public MySetterService() { } + public void setActivationNamespaces(Collection<String> avNamespaces) { activationNamespaces = avNamespaces; } Modified: incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java?rev=600814&r1=600813&r2=600814&view=diff ============================================================================== --- incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java (original) +++ incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java Mon Dec 3 23:13:10 2007 @@ -255,7 +255,14 @@ inMessage.put(HTTP_RESPONSE, resp); inMessage.put(Message.HTTP_REQUEST_METHOD, req.getMethod()); inMessage.put(Message.PATH_INFO, req.getContextPath() + req.getPathInfo()); - inMessage.put(Message.ENCODING, HttpHeaderHelper.mapCharset(req.getCharacterEncoding())); + String normalizedEncoding = HttpHeaderHelper.mapCharset(req.getCharacterEncoding()); + if (normalizedEncoding == null) { + String m = new org.apache.cxf.common.i18n.Message("INVALID_ENCODING_MSG", + LOG, req.getCharacterEncoding()).toString(); + LOG.log(Level.WARNING, m); + throw new IOException(m); + } + inMessage.put(Message.ENCODING, normalizedEncoding); inMessage.put(Message.QUERY_STRING, req.getQueryString()); inMessage.put(Message.CONTENT_TYPE, req.getContentType()); if (!StringUtils.isEmpty(endpointInfo.getAddress())) { Modified: incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/Messages.properties URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/Messages.properties?rev=600814&r1=600813&r2=600814&view=diff ============================================================================== --- incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/Messages.properties (original) +++ incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/Messages.properties Mon Dec 3 23:13:10 2007 @@ -24,3 +24,4 @@ CAN_NOT_FIND_HANDLER_MSG = Could not find the handler to remove for context url {0} FAILED_TO_SHUTDOWN_ENGINE_MSG = Failed to shutdown Jetty server: {0} because it is still in use UNKNOWN_CONNECTOR_MSG = Unknown connector type {0}, can't set the socket reuseAddress flag. +INVALID_ENCODING_MSG = Invalid character set {0} in request. \ No newline at end of file Modified: incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java?rev=600814&r1=600813&r2=600814&view=diff ============================================================================== --- incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java (original) +++ incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java Mon Dec 3 23:13:10 2007 @@ -123,7 +123,7 @@ engine.setPort(9000); try { engine.finalizeConfig(); - fail("We should get the connector not set with TSLServerParament exception "); + fail("We should get the connector not set with TSLServerParameter exception."); } catch (Exception ex) { // expect the excepion } @@ -135,9 +135,9 @@ engine.setPort(9000); try { engine.finalizeConfig(); - fail("We should get the connector not set right port exception "); + fail("We should get the connector not set right port exception."); } catch (Exception ex) { - // expect the excepion + // expect the exception } engine = new JettyHTTPServerEngine(); @@ -146,15 +146,9 @@ engine.setConnector(conn); engine.setPort(9003); engine.setTlsServerParameters(new TLSServerParameters()); - try { - engine.finalizeConfig(); - } catch (Exception ex) { - fail("We should not throw exception here"); - } + engine.finalizeConfig(); } - - @Test public void testaddServants() throws Exception { String urlStr = "http://localhost:9234/hello/test"; @@ -165,28 +159,16 @@ JettyHTTPTestHandler handler2 = new JettyHTTPTestHandler("string2"); engine.addServant(new URL(urlStr), handler1); String response = null; - try { - response = getResponse(urlStr); - } catch (Exception ex) { - fail("Can't get the response from the server " + ex); - } + response = getResponse(urlStr); assertEquals("The jetty http handler did not take effect", response, "string1"); engine.addServant(new URL(urlStr), handler2); - try { - response = getResponse(urlStr); - } catch (Exception ex) { - fail("Can't get the response from the server " + ex); - } + response = getResponse(urlStr); assertEquals("The jetty http handler did not take effect", response, "string1string2"); engine.addServant(new URL(urlStr2), handler2); engine.removeServant(new URL(urlStr)); engine.shutdown(); - try { - response = getResponse(urlStr2); - } catch (Exception ex) { - fail("Server should still work, even if we call the shutdown" + ex); - } + response = getResponse(urlStr2); assertEquals("The jetty http handler did not take effect", response, "string2"); // set the get request factory.destroyForPort(9234); @@ -256,5 +238,4 @@ IOUtils.copy(in, buffer); return buffer.toString(); } - } Modified: incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java?rev=600814&r1=600813&r2=600814&view=diff ============================================================================== --- incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java (original) +++ incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java Mon Dec 3 23:13:10 2007 @@ -1927,8 +1927,17 @@ enc = enc.substring(0, enc.indexOf(";")); } } - inMessage.put(Message.ENCODING, HttpHeaderHelper.mapCharset(enc)); + String normalizedEncoding = HttpHeaderHelper.mapCharset(enc); + if (normalizedEncoding == null) { + String m = new org.apache.cxf.common.i18n.Message("INVALID_ENCODING_MSG", + LOG, enc).toString(); + LOG.log(Level.WARNING, m); + throw new IOException(m); + } + + inMessage.put(Message.ENCODING, normalizedEncoding); + if (maintainSession) { String cookieStr = connection.getHeaderField("Set-Cookie"); sessionCookies = Cookie.handleSetCookie(sessionCookies, cookieStr); Modified: incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Messages.properties URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Messages.properties?rev=600814&r1=600813&r2=600814&view=diff ============================================================================== --- incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Messages.properties (original) +++ incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Messages.properties Mon Dec 3 23:13:10 2007 @@ -19,6 +19,7 @@ # # UNEXPECTED_RESPONSE_TYPE_MSG = Unexpected response type {0} +INVALID_ENCODING_MSG = Invalid character set {0} in request. NULL_RESPONSE_MSG = Response object is null DECOUPLED_RESPONSE_FAILED_MSG = Decouple response failed MISSING_PATH_INFO = PATH_INFO not present in message context, multiplex id is unavailable. Ensure the portName passed to getCurrentEndpointReferenceId is correct if the service has multiple ports Modified: incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/Messages.properties URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/Messages.properties?rev=600814&r1=600813&r2=600814&view=diff ============================================================================== --- incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/Messages.properties (original) +++ incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/Messages.properties Mon Dec 3 23:13:10 2007 @@ -26,3 +26,4 @@ UNEXPECTED_RESPONSE_TYPE_MSG = Unexpected response type {0} DECOUPLED_RESPONSE_FAILED_MSG = Decouple response failed FAILED_TO_LOAD_SPRING_BUS = Failed to load the spring bus: {0} +INVALID_ENCODING_MSG = Invalid character set {0} in request. Modified: incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java?rev=600814&r1=600813&r2=600814&view=diff ============================================================================== --- incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java (original) +++ incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java Mon Dec 3 23:13:10 2007 @@ -245,8 +245,16 @@ if (enc != null && enc.endsWith("\"")) { enc = enc.substring(0, enc.length() - 1); } + + String normalizedEncoding = HttpHeaderHelper.mapCharset(enc); + if (normalizedEncoding == null) { + String m = new org.apache.cxf.common.i18n.Message("INVALID_ENCODING_MSG", + LOG, enc).toString(); + LOG.log(Level.WARNING, m); + throw new IOException(m); + } - inMessage.put(Message.ENCODING, HttpHeaderHelper.mapCharset(enc)); + inMessage.put(Message.ENCODING, normalizedEncoding); SSLUtils.propogateSecureSession(request, inMessage); ExchangeImpl exchange = new ExchangeImpl();
