Return-Path: Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: (qmail 7055 invoked from network); 12 Aug 2008 18:45:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Aug 2008 18:45:44 -0000 Received: (qmail 83910 invoked by uid 500); 12 Aug 2008 18:45:42 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 83863 invoked by uid 500); 12 Aug 2008 18:45:42 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 83854 invoked by uid 99); 12 Aug 2008 18:45:42 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Aug 2008 11:45:42 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Aug 2008 18:44:54 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id E0F262388892; Tue, 12 Aug 2008 11:45:22 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r685261 - /cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java Date: Tue, 12 Aug 2008 18:45:22 -0000 To: commits@cxf.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080812184522.E0F262388892@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dkulp Date: Tue Aug 12 11:45:22 2008 New Revision: 685261 URL: http://svn.apache.org/viewvc?rev=685261&view=rev Log: [CXF-1730] More attempts at getting the needed information into the message Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java?rev=685261&r1=685260&r2=685261&view=diff ============================================================================== --- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java (original) +++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java Tue Aug 12 11:45:22 2008 @@ -75,6 +75,20 @@ } + private static String updatePath(String path, String address) { + if (path.startsWith(address)) { + path = path.substring(address.length()); + if (!path.startsWith("/")) { + path = "/" + path; + } + } + + if (!path.endsWith("/")) { + path = path + "/"; + } + return path; + } + private void processRequest(Message message) { RequestPreprocessor rp = ProviderFactory.getInstance().getRequestPreprocessor(); @@ -96,18 +110,7 @@ address = address.substring(idx); } } - - if (path.startsWith(address)) { - path = path.substring(address.length()); - if (!path.startsWith("/")) { - path = "/" + path; - } - } - - if (!path.endsWith("/")) { - path = path + "/"; - } - + path = updatePath(path, address); //1. Matching target resource class Service service = message.getExchange().get(Service.class); @@ -118,6 +121,8 @@ acceptTypes = "*/*"; message.put(Message.ACCEPT_CONTENT_TYPE, acceptTypes); } + List acceptContentTypes = JAXRSUtils.sortMediaTypes(acceptTypes); + message.getExchange().put(Message.ACCEPT_CONTENT_TYPE, acceptContentTypes); MultivaluedMap values = new MetadataMap(); ClassResourceInfo resource = JAXRSUtils.selectResourceClass(resources, path, values); @@ -127,47 +132,58 @@ BUNDLE, path); LOG.severe(errorMsg.toString()); - acceptTypes = (String)message.get(Message.ACCEPT_CONTENT_TYPE); - List acceptContentTypes = JAXRSUtils.sortMediaTypes(acceptTypes); - message.getExchange().put(Message.ACCEPT_CONTENT_TYPE, acceptContentTypes); throw new WebApplicationException(404); } message.getExchange().put(ROOT_RESOURCE_CLASS, resource); + OperationResourceInfo ori = null; + List> shs = ProviderFactory.getInstance().getRequestHandlers(); for (ProviderInfo sh : shs) { + String newAcceptTypes = (String)message.get(Message.ACCEPT_CONTENT_TYPE); + if (!acceptTypes.equals(newAcceptTypes) || ori == null) { + acceptTypes = newAcceptTypes; + acceptContentTypes = JAXRSUtils.sortMediaTypes(newAcceptTypes); + message.getExchange().put(Message.ACCEPT_CONTENT_TYPE, acceptContentTypes); + + if (ori != null) { + values = new MetadataMap(); + resource = JAXRSUtils.selectResourceClass(resources, path, values); + } + ori = JAXRSUtils.findTargetMethod(resource, values.getFirst(URITemplate.FINAL_MATCH_GROUP), + httpMethod, values, requestContentType, acceptContentTypes); + message.getExchange().put(OperationResourceInfo.class, ori); + } Response response = sh.getProvider().handleRequest(message, resource); if (response != null) { message.getExchange().put(Response.class, response); - acceptTypes = (String)message.get(Message.ACCEPT_CONTENT_TYPE); - List acceptContentTypes = JAXRSUtils.sortMediaTypes(acceptTypes); - message.getExchange().put(Message.ACCEPT_CONTENT_TYPE, acceptContentTypes); - OperationResourceInfo ori = - JAXRSUtils.findTargetMethod(resource, values.getFirst(URITemplate.FINAL_MATCH_GROUP), - httpMethod, values, requestContentType, acceptContentTypes); - message.getExchange().put(OperationResourceInfo.class, ori); - return; } } - acceptTypes = (String)message.get(Message.ACCEPT_CONTENT_TYPE); - List acceptContentTypes = JAXRSUtils.sortMediaTypes(acceptTypes); - message.getExchange().put(Message.ACCEPT_CONTENT_TYPE, acceptContentTypes); + String newAcceptTypes = (String)message.get(Message.ACCEPT_CONTENT_TYPE); + if (!acceptTypes.equals(newAcceptTypes) || ori == null) { + acceptTypes = newAcceptTypes; + acceptContentTypes = JAXRSUtils.sortMediaTypes(acceptTypes); + message.getExchange().put(Message.ACCEPT_CONTENT_TYPE, acceptContentTypes); + if (ori != null) { + values = new MetadataMap(); + resource = JAXRSUtils.selectResourceClass(resources, path, values); + } + ori = JAXRSUtils.findTargetMethod(resource, values.getFirst(URITemplate.FINAL_MATCH_GROUP), + httpMethod, values, requestContentType, acceptContentTypes); + message.getExchange().put(OperationResourceInfo.class, ori); + } + LOG.fine("Request path is: " + path); LOG.fine("Request HTTP method is: " + httpMethod); LOG.fine("Request contentType is: " + requestContentType); LOG.fine("Accept contentType is: " + acceptTypes); - - OperationResourceInfo ori = - JAXRSUtils.findTargetMethod(resource, values.getFirst(URITemplate.FINAL_MATCH_GROUP), - httpMethod, values, requestContentType, acceptContentTypes); - if (ori == null) { org.apache.cxf.common.i18n.Message errorMsg = new org.apache.cxf.common.i18n.Message("NO_OP_EXC",