cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1445284 - in /cxf/trunk: rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/ systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/ systests/ws-security/...
Date Tue, 12 Feb 2013 17:30:20 GMT
Author: dkulp
Date: Tue Feb 12 17:30:20 2013
New Revision: 1445284

URL: http://svn.apache.org/r1445284
Log:
If the DescriptionInfo doesn't have a baseURI, create one to avoid policy fragments poluting
from one wsdl to another.

Modified:
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServiceModelPolicyUpdater.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java
    cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/JavaFirstPolicyServiceTest.java
    cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/server/JavaFirstPolicyServer.java

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServiceModelPolicyUpdater.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServiceModelPolicyUpdater.java?rev=1445284&r1=1445283&r2=1445284&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServiceModelPolicyUpdater.java
(original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServiceModelPolicyUpdater.java
Tue Feb 12 17:30:20 2013
@@ -51,6 +51,7 @@ import javax.xml.namespace.QName;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.service.model.BindingMessageInfo;
 import org.apache.cxf.service.model.BindingOperationInfo;
@@ -126,6 +127,10 @@ public class ServiceModelPolicyUpdater {
         if (ei.getService().getDescription() == null) {
             DescriptionInfo description = new DescriptionInfo();
             description.setName(ei.getService().getName());
+            if (!StringUtils.isEmpty(ei.getAddress())) {
+                description.setBaseURI(ei.getAddress() + "?wsdl");
+            }
+            
             ei.getService().setDescription(description);
         }
         ei.getService().getDescription().addExtensor(uee);

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java?rev=1445284&r1=1445283&r2=1445284&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java
(original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java
Tue Feb 12 17:30:20 2013
@@ -187,7 +187,11 @@ public class Wsdl11AttachmentPolicyProvi
                             Policy policy = builder.getPolicy(e.getElement());
                             String fragement = "#" + uri;
                             registry.register(fragement, policy);
-                            registry.register(di.getBaseURI() + fragement, policy);
+                            if (di.getBaseURI() == null) {
+                                registry.register(Integer.toString(di.hashCode()) + fragement,
policy);
+                            } else {
+                                registry.register(di.getBaseURI() + fragement, policy);
+                            }
                         } catch (Exception policyEx) {
                             //ignore the policy can not be built
                             LOG.warning("Failed to build the policy '" + uri + "':" + policyEx.getMessage());
@@ -257,7 +261,11 @@ public class Wsdl11AttachmentPolicyProvi
     Policy resolveReference(PolicyReference ref, DescriptionInfo di) {
         Policy p = null;
         if (isExternal(ref)) {
-            p = resolveExternal(ref, di.getBaseURI());
+            String uri = di.getBaseURI();
+            if (uri == null) {
+                uri = Integer.toString(di.hashCode());
+            }
+            p = resolveExternal(ref, uri);
         } else {
             p = resolveLocal(ref, di);
         }
@@ -267,7 +275,12 @@ public class Wsdl11AttachmentPolicyProvi
     
     Policy resolveLocal(PolicyReference ref, DescriptionInfo di) {
         String uri = ref.getURI().substring(1);
-        String absoluteURI = di.getBaseURI() + ref.getURI();
+        String absoluteURI = di.getBaseURI();
+        if (absoluteURI == null) {
+            absoluteURI = Integer.toString(di.hashCode()) + ref.getURI();
+        } else {
+            absoluteURI = absoluteURI + ref.getURI();
+        }
         Policy resolved = registry.lookup(absoluteURI);
         if (null != resolved) {
             return resolved;

Modified: cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/JavaFirstPolicyServiceTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/JavaFirstPolicyServiceTest.java?rev=1445284&r1=1445283&r2=1445284&view=diff
==============================================================================
--- cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/JavaFirstPolicyServiceTest.java
(original)
+++ cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/JavaFirstPolicyServiceTest.java
Tue Feb 12 17:30:20 2013
@@ -55,9 +55,9 @@ import org.junit.Test;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 public class JavaFirstPolicyServiceTest extends AbstractBusClientServerTestBase {
-    static final String PORT = allocatePort(JavaFirstPolicyServer.class);
-    static final String PORT2 = allocatePort(JavaFirstPolicyServer.class, 2);
-    static final String PORT3 = allocatePort(JavaFirstPolicyServer.class, 3);
+    static final String PORT = JavaFirstPolicyServer.PORT;
+    static final String PORT2 = JavaFirstPolicyServer.PORT2;
+    static final String PORT3 = JavaFirstPolicyServer.PORT3;
 
     private static final String WSDL_NAMESPACE = "http://schemas.xmlsoap.org/wsdl/";
 

Modified: cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/server/JavaFirstPolicyServer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/server/JavaFirstPolicyServer.java?rev=1445284&r1=1445283&r2=1445284&view=diff
==============================================================================
--- cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/server/JavaFirstPolicyServer.java
(original)
+++ cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/server/JavaFirstPolicyServer.java
Tue Feb 12 17:30:20 2013
@@ -29,6 +29,9 @@ import org.apache.cxf.testutil.common.Ab
 import org.junit.Assert;
 
 public class JavaFirstPolicyServer extends AbstractBusTestServerBase {
+    public static final String PORT = allocatePort(JavaFirstPolicyServer.class);
+    public static final String PORT2 = allocatePort(JavaFirstPolicyServer.class, 2);
+    public static final String PORT3 = allocatePort(JavaFirstPolicyServer.class, 3);
 
     public JavaFirstPolicyServer() {
 
@@ -47,4 +50,8 @@ public class JavaFirstPolicyServer exten
             e.printStackTrace();
         }
     }
+    
+    public static void main(String args[]) {
+        new JavaFirstPolicyServer().start();
+    }
 }



Mime
View raw message