You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2010/10/05 21:59:14 UTC
svn commit: r1004793 - in
/cxf/branches/2.2.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment:
AbstractPolicyProvider.java reference/RemoteReferenceResolver.java
Author: dkulp
Date: Tue Oct 5 19:59:14 2010
New Revision: 1004793
URL: http://svn.apache.org/viewvc?rev=1004793&view=rev
Log:
[CXF-3036] Port some fixes from trunk to 2.2.x related to remote/external policy references
Modified:
cxf/branches/2.2.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/AbstractPolicyProvider.java
cxf/branches/2.2.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/reference/RemoteReferenceResolver.java
Modified: cxf/branches/2.2.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/AbstractPolicyProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/AbstractPolicyProvider.java?rev=1004793&r1=1004792&r2=1004793&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/AbstractPolicyProvider.java (original)
+++ cxf/branches/2.2.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/AbstractPolicyProvider.java Tue Oct 5 19:59:14 2010
@@ -80,11 +80,11 @@ public abstract class AbstractPolicyProv
}
protected Policy resolveExternal(PolicyReference ref, String baseURI) {
- ReferenceResolver resolver = new RemoteReferenceResolver(baseURI, builder);
Policy resolved = registry.lookup(ref.getURI());
if (null != resolved) {
return resolved;
}
+ ReferenceResolver resolver = new RemoteReferenceResolver(baseURI, builder);
return resolver.resolveReference(ref.getURI());
}
Modified: cxf/branches/2.2.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/reference/RemoteReferenceResolver.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/reference/RemoteReferenceResolver.java?rev=1004793&r1=1004792&r2=1004793&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/reference/RemoteReferenceResolver.java (original)
+++ cxf/branches/2.2.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/reference/RemoteReferenceResolver.java Tue Oct 5 19:59:14 2010
@@ -46,7 +46,7 @@ public class RemoteReferenceResolver imp
public Policy resolveReference(String uri) {
int pos = uri.indexOf('#');
- String documentURI = uri.substring(0, pos);
+ String documentURI = pos == -1 ? uri : uri.substring(0, pos);
ExtendedURIResolver resolver = new ExtendedURIResolver();
InputSource is = resolver.resolve(documentURI, baseURI);
if (null == is) {
@@ -60,16 +60,20 @@ public class RemoteReferenceResolver imp
} finally {
resolver.close();
}
- String id = uri.substring(pos + 1);
- for (Element elem : PolicyConstants
- .findAllPolicyElementsOfLocalName(doc,
- PolicyConstants.POLICY_ELEM_NAME)) {
-
- if (id.equals(elem.getAttributeNS(PolicyConstants.WSU_NAMESPACE_URI,
- PolicyConstants.WSU_ID_ATTR_NAME))) {
- return builder.getPolicy(elem);
+ if (pos == -1) {
+ return builder.getPolicy(doc.getDocumentElement());
+ } else {
+ String id = uri.substring(pos + 1);
+ for (Element elem : PolicyConstants
+ .findAllPolicyElementsOfLocalName(doc,
+ PolicyConstants.POLICY_ELEM_NAME)) {
+
+ if (id.equals(elem.getAttributeNS(PolicyConstants.WSU_NAMESPACE_URI,
+ PolicyConstants.WSU_ID_ATTR_NAME))) {
+ return builder.getPolicy(elem);
+ }
}
- }
+ }
return null;
}