cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1210115 - in /cxf/branches/2.4.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Date Sun, 04 Dec 2011 14:17:49 GMT
Author: sergeyb
Date: Sun Dec  4 14:17:48 2011
New Revision: 1210115

URL: http://svn.apache.org/viewvc?rev=1210115&view=rev
Log:
Merged revisions 1210114 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1210114 | sergeyb | 2011-12-04 14:15:28 +0000 (Sun, 04 Dec 2011) | 1 line
  
  [CXF-3950] Adding basic processing of href attributes if any
........

Modified:
    cxf/branches/2.4.x-fixes/   (props changed)
    cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
    cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java

Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Dec  4 14:17:48 2011
@@ -1 +1 @@
-/cxf/trunk:1209588,1209728
+/cxf/trunk:1209588,1209728,1210114

Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java?rev=1210115&r1=1210114&r2=1210115&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
Sun Dec  4 14:17:48 2011
@@ -348,11 +348,7 @@ public class JAXBElementProvider extends
     
     protected static void setNamespaceMapper(Marshaller ms, Map<String, String> map)
throws Exception {
         NamespaceMapper nsMapper = new NamespaceMapper(map);
-        try {
-            ms.setProperty("com.sun.xml.bind.namespacePrefixMapper", nsMapper);
-        } catch (PropertyException ex) {
-            ms.setProperty("com.sun.xml.internal.bind.namespacePrefixMapper", nsMapper);
-        }
+        setMarshallerProp(ms, nsMapper, "namespacePrefixMapper");
     }
     
     protected void marshal(Object obj, Class<?> cls, Type genericType, 
@@ -381,16 +377,26 @@ public class JAXBElementProvider extends
         XMLInstruction pi = AnnotationUtils.getAnnotation(anns, XMLInstruction.class);
         if (pi != null) {
             String value = pi.value();
-            // Should we even consider adding a base URI here ?
-            // Relative references may be resolved OK, to be verified
-            try {
-                ms.setProperty("com.sun.xml.bind.xmlHeaders", value);
-            } catch (PropertyException ex) {
-                ms.setProperty("com.sun.xml.internal.bind.xmlHeaders", value);
+            int ind = value.indexOf("href='");
+            if (ind > 0 && getContext() != null) {
+                String relRef = value.substring(ind + 6, value.length() - 3);
+                String absRef = 
+                    getContext().getUriInfo().getBaseUriBuilder().path(relRef).build().toString();
+                value = value.substring(0, ind + 6) + absRef + "'?>";
             }
+            setMarshallerProp(ms, value, "xmlHeaders");
         }
     }
     
+    private static void setMarshallerProp(Marshaller ms, Object value, String name) throws
Exception {
+        try {
+            ms.setProperty("com.sun.xml.bind." + name, value);
+        } catch (PropertyException ex) {
+            ms.setProperty("com.sun.xml.internal.bind." + name, value);
+        }
+        
+    }
+    
     protected void addAttachmentMarshaller(Marshaller ms) {
         Collection<Attachment> attachments = getAttachments(true);
         if (attachments != null) {

Modified: cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=1210115&r1=1210114&r2=1210115&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
(original)
+++ cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Sun Dec  4 14:17:48 2011
@@ -135,15 +135,14 @@ public class JAXRSClientServerBookTest e
     
     @Test
     public void testProcessingInstruction() throws Exception {
-        
-        String endpointAddress =
-            "http://localhost:" + PORT + "/bookstore/name-in-query"; 
+        String base = "http://localhost:" + PORT;
+        String endpointAddress = base + "/bookstore/name-in-query"; 
         WebClient wc = WebClient.create(endpointAddress);
         String name = "Many        spaces";
         wc.query("name", name);
         String content = wc.get(String.class);
         assertTrue(content.contains("<!DOCTYPE Something SYSTEM 'my.dtd'>"));
-        assertTrue(content.contains("<?xmlstylesheet href='common.css'?>"));
+        assertTrue(content.contains("<?xmlstylesheet href='" + base + "/common.css'?>"));
     }
     
     @Test



Mime
View raw message