Author: bmaxwell
Date: 2011-05-03 11:14:05 -0400 (Tue, 03 May 2011)
New Revision: 14229
Modified:
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EffectivePolicyImpl.java
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyImpl.java
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyUtils.java
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/mtom/MTOMPolicyInterceptor.java
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EffectivePolicyImplTest.java
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EndpointPolicyImplTest.java
Log:
[JBPAPP-6440] fix cxf policy ref issues
Modified:
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EffectivePolicyImpl.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EffectivePolicyImpl.java 2011-05-03
14:13:08 UTC (rev 14228)
+++
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EffectivePolicyImpl.java 2011-05-03
15:14:05 UTC (rev 14229)
@@ -131,7 +131,7 @@
if (null != bmi) {
policy = policy.merge(engine.getAggregatedMessagePolicy(bmi));
}
- policy = (Policy)policy.normalize(true);
+ policy = (Policy)policy.normalize(engine.getRegistry(), true);
return assertor;
}
@@ -140,7 +140,7 @@
policy = engine.getServerEndpointPolicy(ei, (Destination)null).getPolicy();
policy = policy.merge(engine.getAggregatedOperationPolicy(boi));
policy = policy.merge(engine.getAggregatedFaultPolicy(bfi));
- policy = (Policy)policy.normalize(true);
+ policy = (Policy)policy.normalize(engine.getRegistry(), true);
}
void chooseAlternative(PolicyEngineImpl engine, Assertor assertor) {
Modified:
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyImpl.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyImpl.java 2011-05-03
14:13:08 UTC (rev 14228)
+++
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyImpl.java 2011-05-03
15:14:05 UTC (rev 14229)
@@ -88,8 +88,17 @@
public EndpointPolicy updatePolicy(Policy p) {
EndpointPolicyImpl epi = createEndpointPolicy();
- Policy np = (Policy)p.normalize(true);
- epi.setPolicy(getPolicy().merge(np));
+
+ if (!PolicyUtils.isEmptyPolicy(p)) {
+ Policy normalizedPolicy
+ = (Policy)p.normalize(engine == null ? null : engine.getRegistry(),
true);
+ epi.setPolicy(getPolicy().merge(normalizedPolicy));
+ } else {
+ Policy clonedPolicy = new Policy();
+ clonedPolicy.addPolicyComponents(getPolicy().getPolicyComponents());
+ epi.setPolicy(clonedPolicy);
+ }
+
epi.checkExactlyOnes();
epi.finalizeConfig();
return epi;
@@ -141,7 +150,8 @@
policy = engine.getAggregatedServicePolicy(ei.getService());
policy = policy.merge(engine.getAggregatedEndpointPolicy(ei));
if (!policy.isEmpty()) {
- policy = (Policy)policy.normalize(true);
+ policy = (Policy)policy.normalize(engine == null ? null :
engine.getRegistry(),
+ true);
}
}
Modified:
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyUtils.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyUtils.java 2011-05-03
14:13:08 UTC (rev 14228)
+++
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyUtils.java 2011-05-03
15:14:05 UTC (rev 14229)
@@ -28,6 +28,7 @@
import org.apache.cxf.ws.policy.builder.primitive.NestedPrimitiveAssertion;
import org.apache.neethi.Assertion;
import org.apache.neethi.Constants;
+import org.apache.neethi.Policy;
import org.apache.neethi.PolicyComponent;
import org.apache.neethi.PolicyOperator;
@@ -42,6 +43,45 @@
}
/**
+ * Checks if a given policy contains no policy components
+ * or if it has only empty ExactlyOne or All components
+ * containing no assertions
+ *
+ * @param p the policy
+ * @return true if the policy is empty
+ */
+ public static boolean isEmptyPolicy(Policy p) {
+
+ return isEmptyPolicyOperator(p);
+ }
+
+ /**
+ * Checks if a given policy operator has no policy components
+ * or if it has only empty ExactlyOne or All components
+ * containing no assertions
+ *
+ * @param p the policy operator
+ * @return true if this policy operator is empty
+ */
+ public static boolean isEmptyPolicyOperator(PolicyOperator p) {
+
+ if (p.isEmpty()) {
+ return true;
+ }
+
+ List components = p.getPolicyComponents();
+
+ for (Object component : components) {
+ if (!(component instanceof PolicyOperator)
+ || !isEmptyPolicyOperator((PolicyOperator)component)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
* Determine if a collection of assertions contains a given assertion, using
* the equal method from the Assertion interface.
*
Modified:
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/mtom/MTOMPolicyInterceptor.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/mtom/MTOMPolicyInterceptor.java 2011-05-03
14:13:08 UTC (rev 14228)
+++
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/mtom/MTOMPolicyInterceptor.java 2011-05-03
15:14:05 UTC (rev 14229)
@@ -23,6 +23,7 @@
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageUtils;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.phase.Phase;
import org.apache.cxf.ws.policy.AssertionInfo;
@@ -40,13 +41,18 @@
if (aim != null) {
Collection<AssertionInfo> ais =
aim.get(MetadataConstants.MTOM_ASSERTION_QNAME);
for (AssertionInfo ai : ais) {
-
- // set mtom enabled and assert the policy if we find an mtom request
- String contentType = (String)message.getExchange().getInMessage()
- .get(Message.CONTENT_TYPE);
- if (contentType != null &&
contentType.contains("type=\"application/xop+xml\"")) {
+ if (MessageUtils.isRequestor(message)) {
+ //just turn on MTOM
+ message.put(Message.MTOM_ENABLED, Boolean.TRUE);
ai.setAsserted(true);
- message.put(Message.MTOM_ENABLED, Boolean.TRUE);
+ } else {
+ // set mtom enabled and assert the policy if we find an mtom request
+ String contentType = (String)message.getExchange().getInMessage()
+ .get(Message.CONTENT_TYPE);
+ if (contentType != null &&
contentType.contains("type=\"application/xop+xml\"")) {
+ ai.setAsserted(true);
+ message.put(Message.MTOM_ENABLED, Boolean.TRUE);
+ }
}
}
}
Modified:
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EffectivePolicyImplTest.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EffectivePolicyImplTest.java 2011-05-03
14:13:08 UTC (rev 14228)
+++
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EffectivePolicyImplTest.java 2011-05-03
15:14:05 UTC (rev 14229)
@@ -191,7 +191,7 @@
Policy mp = control.createMock(Policy.class);
EasyMock.expect(engine.getAggregatedMessagePolicy(bmi)).andReturn(mp);
EasyMock.expect(merged.merge(mp)).andReturn(merged);
- EasyMock.expect(merged.normalize(true)).andReturn(merged);
+ EasyMock.expect(merged.normalize(null, true)).andReturn(merged);
control.replay();
EffectivePolicyImpl epi = new EffectivePolicyImpl();
@@ -219,7 +219,7 @@
Policy fp = control.createMock(Policy.class);
EasyMock.expect(engine.getAggregatedFaultPolicy(bfi)).andReturn(fp);
EasyMock.expect(merged.merge(fp)).andReturn(merged);
- EasyMock.expect(merged.normalize(true)).andReturn(merged);
+ EasyMock.expect(merged.normalize(null, true)).andReturn(merged);
control.replay();
EffectivePolicyImpl epi = new EffectivePolicyImpl();
Modified:
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EndpointPolicyImplTest.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EndpointPolicyImplTest.java 2011-05-03
14:13:08 UTC (rev 14228)
+++
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EndpointPolicyImplTest.java 2011-05-03
15:14:05 UTC (rev 14229)
@@ -131,7 +131,7 @@
EasyMock.expect(engine.getAggregatedEndpointPolicy(ei)).andReturn(ep);
Policy merged = control.createMock(Policy.class);
EasyMock.expect(sp.merge(ep)).andReturn(merged);
- EasyMock.expect(merged.normalize(true)).andReturn(merged);
+ EasyMock.expect(merged.normalize(null, true)).andReturn(merged);
control.replay();
EndpointPolicyImpl epi = new EndpointPolicyImpl(ei, engine, true, null);
@@ -189,7 +189,7 @@
p2.addAssertion(mockAssertion(aqn2, 5, true));
control.replay();
- epi.setPolicy((Policy)p1.normalize(true));
+ epi.setPolicy((Policy)p1.normalize(null, true));
Policy ep = epi.updatePolicy(p2).getPolicy();
Show replies by date