Return-Path: Delivered-To: apmail-incubator-cxf-commits-archive@locus.apache.org Received: (qmail 75093 invoked from network); 20 Feb 2008 20:42:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 Feb 2008 20:42:06 -0000 Received: (qmail 88954 invoked by uid 500); 20 Feb 2008 20:42:00 -0000 Delivered-To: apmail-incubator-cxf-commits-archive@incubator.apache.org Received: (qmail 88907 invoked by uid 500); 20 Feb 2008 20:42:00 -0000 Mailing-List: contact cxf-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cxf-dev@incubator.apache.org Delivered-To: mailing list cxf-commits@incubator.apache.org Received: (qmail 88898 invoked by uid 99); 20 Feb 2008 20:42:00 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Feb 2008 12:42:00 -0800 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.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Feb 2008 20:41:34 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 83DF11A983A; Wed, 20 Feb 2008 12:41:43 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r629609 [1/3] - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/ws/policy/ api/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/ api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/ api/src/main/java/org/apache/cxf/ws/... Date: Wed, 20 Feb 2008 20:40:46 -0000 To: cxf-commits@incubator.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080220204143.83DF11A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dkulp Date: Wed Feb 20 12:40:27 2008 New Revision: 629609 URL: http://svn.apache.org/viewvc?rev=629609&view=rev Log: [CXF-1411] Big policy patch from Sergey applied. Thanks! Added: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptorProvider.java - copied, changed from r629582, incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProviderImpl.java incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyAssertion.java (with props) incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/AddressingAnonymousPolicyTest.java (with props) incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr-anon-client.xml (with props) incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr-anon-server.xml (with props) incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr-external-anonymous-client.xml (with props) incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr-external-anonymous-server.xml (with props) Removed: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProviderImpl.java Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AlternativeSelector.java incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionBuilder.java incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionBuilderRegistry.java incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfo.java incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfoMap.java incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/EffectivePolicy.java incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/EndpointPolicy.java incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/Intersector.java incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyEngine.java incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProvider.java incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProviderRegistry.java incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertion.java incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertionBuilder.java incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertion.java incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionBuilder.java incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertion.java incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertionBuilder.java incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XMLPrimitiveAssertionBuilder.java incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XmlPrimitiveAssertion.java incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/util/PolicyComparator.java incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/AssertionInfoMapTest.java incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertionBuilderTest.java incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionBuilderTest.java incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionTest.java incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/HTTPClientAssertionBuilder.java incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/HTTPServerAssertionBuilder.java incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/PolicyUtils.java incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/PolicyUtilsTest.java incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/policy/AddressingAssertionBuilder.java incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/policy/AddressingPolicyInterceptorProvider.java incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/AssertionBuilderRegistryImpl.java incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInFaultInterceptor.java incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInInterceptor.java incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyOutInterceptor.java incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EffectivePolicyImpl.java incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyImpl.java incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyBuilderImpl.java incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngineImpl.java incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProviderRegistryImpl.java incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyUtils.java incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyInInterceptor.java incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutFaultInterceptor.java incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutInterceptor.java incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/mtom/MTOMAssertionBuilder.java incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/mtom/MTOMPolicyInterceptorProvider.java incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/selector/FirstAlternativeSelector.java incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/selector/MaximalAlternativeSelector.java incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/selector/MinimalAlternativeSelector.java incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EffectivePolicyImplTest.java incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EndpointPolicyImplTest.java incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyExtensionsTest.java incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyInterceptorsTest.java incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/TestAssertion.java incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProviderTest.java incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionTest.java incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/selector/FirstAlternativeSelectorTest.java incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/selector/MinimalMaximalAlternativeSelectorTest.java incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMEndpoint.java incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/policy/RMAssertionBuilder.java incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/policy/RMPolicyInterceptorProvider.java incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/AbstractRMInterceptorTest.java incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMEndpointTest.java incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/PolicyLoggingInterceptor.java incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/RMPolicyWsdlTest.java incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr-external.xml Copied: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptorProvider.java (from r629582, incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProviderImpl.java) URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptorProvider.java?p2=incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptorProvider.java&p1=incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProviderImpl.java&r1=629582&r2=629609&rev=629609&view=diff ============================================================================== --- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProviderImpl.java (original) +++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptorProvider.java Wed Feb 20 12:40:27 2008 @@ -20,24 +20,49 @@ package org.apache.cxf.ws.policy; import java.util.Collection; +import java.util.Collections; +import java.util.List; import javax.xml.namespace.QName; import org.apache.cxf.interceptor.AbstractAttributedInterceptorProvider; +import org.apache.cxf.interceptor.Interceptor; +import org.apache.cxf.message.Message; /** * */ -public class PolicyInterceptorProviderImpl extends AbstractAttributedInterceptorProvider +public abstract class AbstractPolicyInterceptorProvider extends AbstractAttributedInterceptorProvider implements PolicyInterceptorProvider { private Collection assertionTypes; - PolicyInterceptorProviderImpl(Collection at) { + public AbstractPolicyInterceptorProvider(QName type) { + this(Collections.singletonList(type)); + } + + public AbstractPolicyInterceptorProvider(Collection at) { assertionTypes = at; } public Collection getAssertionTypes() { return assertionTypes; + } + + public List provideInFaultInterceptors(Message m) { + return getInFaultInterceptors(); + } + + public List provideInInterceptors(Message m) { + return getInInterceptors(); + } + + public List provideOutFaultInterceptors(Message m) { + return getOutFaultInterceptors(); + } + + public List provideOutInterceptors(Message m) { + return getOutInterceptors(); } + } Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AlternativeSelector.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AlternativeSelector.java?rev=629609&r1=629608&r2=629609&view=diff ============================================================================== --- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AlternativeSelector.java (original) +++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AlternativeSelector.java Wed Feb 20 12:40:27 2008 @@ -21,7 +21,6 @@ import java.util.Collection; -import org.apache.neethi.Assertion; import org.apache.neethi.Policy; /** @@ -29,6 +28,6 @@ */ public interface AlternativeSelector { - Collection selectAlternative(Policy policy, PolicyEngine engine, Assertor assertor); + Collection selectAlternative(Policy policy, PolicyEngine engine, Assertor assertor); } Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionBuilder.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionBuilder.java?rev=629609&r1=629608&r2=629609&view=diff ============================================================================== --- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionBuilder.java (original) +++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionBuilder.java Wed Feb 20 12:40:27 2008 @@ -25,8 +25,6 @@ import org.w3c.dom.Element; -import org.apache.neethi.Assertion; - /** * AssertionBuilder is an interface used to build an Assertion object from a @@ -46,7 +44,7 @@ * @param element the element from which to build an assertion * @return an Assertion built from the given element */ - Assertion build(Element element); + PolicyAssertion build(Element element); /** @@ -62,5 +60,5 @@ * Returns a new assertion that is compatible with the two specified * assertions or null if no compatible assertion can be built. */ - Assertion buildCompatible(Assertion a, Assertion b); + PolicyAssertion buildCompatible(PolicyAssertion a, PolicyAssertion b); } Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionBuilderRegistry.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionBuilderRegistry.java?rev=629609&r1=629608&r2=629609&view=diff ============================================================================== --- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionBuilderRegistry.java (original) +++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionBuilderRegistry.java Wed Feb 20 12:40:27 2008 @@ -22,10 +22,7 @@ import javax.xml.namespace.QName; import org.w3c.dom.Element; - import org.apache.cxf.extension.Registry; -import org.apache.neethi.Assertion; - /** * AssertionBuilderRegistry is used to manage AssertionBuilders and @@ -39,7 +36,7 @@ * @param element the element from which to build an Assertion. * @return an Assertion that is built using the specified element. */ - Assertion build(Element element); + PolicyAssertion build(Element element); /** * Indicates if unknown assertions should simply be ignored. Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfo.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfo.java?rev=629609&r1=629608&r2=629609&view=diff ============================================================================== --- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfo.java (original) +++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfo.java Wed Feb 20 12:40:27 2008 @@ -19,7 +19,6 @@ package org.apache.cxf.ws.policy; -import org.apache.neethi.Assertion; /** * @@ -27,9 +26,9 @@ public class AssertionInfo { private boolean asserted; - private final Assertion assertion; + private final PolicyAssertion assertion; - public AssertionInfo(Assertion a) { + public AssertionInfo(PolicyAssertion a) { assertion = a; } public boolean isAsserted() { @@ -38,7 +37,7 @@ public void setAsserted(boolean a) { asserted = a; } - public Assertion getAssertion() { + public PolicyAssertion getAssertion() { return assertion; } } Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfoMap.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfoMap.java?rev=629609&r1=629608&r2=629609&view=diff ============================================================================== --- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfoMap.java (original) +++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfoMap.java Wed Feb 20 12:40:27 2008 @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -31,61 +32,69 @@ import org.apache.cxf.common.i18n.BundleUtils; import org.apache.cxf.common.i18n.Message; import org.apache.cxf.helpers.CastUtils; -import org.apache.neethi.Assertion; import org.apache.neethi.Policy; +import org.apache.neethi.PolicyComponent; +import org.apache.neethi.PolicyOperator; -/** - * - */ public class AssertionInfoMap extends HashMap> { private static final ResourceBundle BUNDLE = BundleUtils.getBundle(AssertionInfoMap.class, "APIMessages"); - public AssertionInfoMap(Collection assertions) { + public AssertionInfoMap(Policy p) { + this(getAssertions(p)); + } + + public AssertionInfoMap(Collection assertions) { super(assertions.size()); - for (Assertion a : assertions) { - AssertionInfo ai = new AssertionInfo(a); - Collection ais = get(a.getName()); - if (null == ais) { - ais = new ArrayList(); - put(a.getName(), ais); - } - ais.add(ai); + for (PolicyAssertion a : assertions) { + putAssertionInfo(a); } } - public boolean supportsAlternative(Collection alternative) { - for (Assertion a : alternative) { - boolean asserted = false; - Collection ais = get(a.getName()); - if (null != ais) { - for (AssertionInfo ai : ais) { - // if (ai.getAssertion() == a && ai.isAsserted()) { - if (ai.getAssertion().equal(a) && ai.isAsserted()) { - asserted = true; - break; - } - } + private void putAssertionInfo(PolicyAssertion a) { + Policy p = a.getPolicy(); + if (p != null) { + for (PolicyAssertion na : getAssertions(p)) { + putAssertionInfo(na); } - if (!asserted) { + } + AssertionInfo ai = new AssertionInfo(a); + Collection ail = get(a.getName()); + if (ail == null) { + ail = new ArrayList(); + put(a.getName(), ail); + } + ail.add(ai); + } + + public Collection getAssertionInfo(QName name) { + Collection ail = get(name); + return ail != null ? ail + : CastUtils.cast(Collections.EMPTY_LIST, AssertionInfo.class); + + } + + public boolean supportsAlternative(Collection alternative) { + for (PolicyAssertion a : alternative) { + if (!a.isAsserted(this)) { return false; } } - return true; } public void checkEffectivePolicy(Policy policy) { Iterator alternatives = policy.getAlternatives(); while (alternatives.hasNext()) { - List alternative = CastUtils.cast((List)alternatives.next(), Assertion.class); + List alternative = CastUtils.cast((List)alternatives.next(), + PolicyAssertion.class); if (supportsAlternative(alternative)) { return; } } throw new PolicyException(new Message("NO_ALTERNATIVE_EXC", BUNDLE)); } - + public void check() { for (Collection ais : values()) { for (AssertionInfo ai : ais) { @@ -95,5 +104,18 @@ } } } + } + + private static Collection getAssertions(PolicyOperator p) { + List pcs = + CastUtils.cast(p.getPolicyComponents(), PolicyComponent.class); + if (pcs.size() == 0 || pcs.get(0) instanceof PolicyAssertion) { + return CastUtils.cast(pcs, PolicyAssertion.class); + } + Collection assertions = new ArrayList(); + for (PolicyComponent pc : pcs) { + assertions.addAll(getAssertions((PolicyOperator)pc)); + } + return assertions; } } Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/EffectivePolicy.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/EffectivePolicy.java?rev=629609&r1=629608&r2=629609&view=diff ============================================================================== --- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/EffectivePolicy.java (original) +++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/EffectivePolicy.java Wed Feb 20 12:40:27 2008 @@ -23,7 +23,6 @@ import java.util.List; import org.apache.cxf.interceptor.Interceptor; -import org.apache.neethi.Assertion; import org.apache.neethi.Policy; /** @@ -33,7 +32,7 @@ Policy getPolicy(); - Collection getChosenAlternative(); + Collection getChosenAlternative(); List getInterceptors(); } Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/EndpointPolicy.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/EndpointPolicy.java?rev=629609&r1=629608&r2=629609&view=diff ============================================================================== --- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/EndpointPolicy.java (original) +++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/EndpointPolicy.java Wed Feb 20 12:40:27 2008 @@ -23,7 +23,6 @@ import java.util.List; import org.apache.cxf.interceptor.Interceptor; -import org.apache.neethi.Assertion; import org.apache.neethi.Policy; /** @@ -37,11 +36,11 @@ Policy getPolicy(); EndpointPolicy updatePolicy(Policy p); - Collection getChosenAlternative(); + Collection getChosenAlternative(); - Collection getVocabulary(); + Collection getVocabulary(); - Collection getFaultVocabulary(); + Collection getFaultVocabulary(); List getInterceptors(); Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/Intersector.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/Intersector.java?rev=629609&r1=629608&r2=629609&view=diff ============================================================================== --- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/Intersector.java (original) +++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/Intersector.java Wed Feb 20 12:40:27 2008 @@ -26,7 +26,6 @@ import org.apache.cxf.helpers.CastUtils; import org.apache.neethi.All; -import org.apache.neethi.Assertion; import org.apache.neethi.ExactlyOne; import org.apache.neethi.Policy; @@ -54,7 +53,7 @@ strict = s; } - boolean compatibleAssertions(Assertion a1, Assertion a2) { + boolean compatibleAssertions(PolicyAssertion a1, PolicyAssertion a2) { AssertionBuilder ab = assertionBuilderRegistry.get(a1.getName()); if (null == ab) { return false; @@ -62,17 +61,18 @@ return null != ab.buildCompatible(a1, a2); } - boolean compatibleAlternatives(Collection alt1, Collection alt2) { + boolean compatibleAlternatives(Collection alt1, + Collection alt2) { if (alt1.isEmpty() || alt2.isEmpty()) { return true; } if (strict) { - for (Assertion a1 : alt1) { + for (PolicyAssertion a1 : alt1) { if (null == findCompatibleAssertion(a1, alt2)) { return false; } } - for (Assertion a2 : alt2) { + for (PolicyAssertion a2 : alt2) { if (null == findCompatibleAssertion(a2, alt1)) { return false; } @@ -87,10 +87,12 @@ boolean compatiblePolicies(Policy p1, Policy p2) { Iterator i1 = p1.getAlternatives(); while (i1.hasNext()) { - Collection alt1 = CastUtils.cast((Collection)i1.next(), Assertion.class); + Collection alt1 = + CastUtils.cast((Collection)i1.next(), PolicyAssertion.class); Iterator i2 = p2.getAlternatives(); while (i2.hasNext()) { - Collection alt2 = CastUtils.cast((Collection)i2.next(), Assertion.class); + Collection alt2 = + CastUtils.cast((Collection)i2.next(), PolicyAssertion.class); if (compatibleAlternatives(alt1, alt2)) { return true; } @@ -100,7 +102,7 @@ return true; } - public Assertion intersect(Assertion a1, Assertion a2) { + public PolicyAssertion intersect(PolicyAssertion a1, PolicyAssertion a2) { AssertionBuilder ab = assertionBuilderRegistry.get(a1.getName()); if (null == ab) { return null; @@ -108,12 +110,13 @@ return ab.buildCompatible(a1, a2); } - public Collection intersect(Collection alt1, - Collection alt2) { + public Collection intersect(Collection alt1, + Collection alt2) { if (!compatibleAlternatives(alt1, alt2)) { return null; } - Collection intersection = new ArrayList(); + Collection intersection = + new ArrayList(); intersection.addAll(alt1); intersection.addAll(alt2); return intersection; @@ -129,10 +132,12 @@ Iterator i1 = p1.getAlternatives(); while (i1.hasNext()) { - List alt1 = CastUtils.cast((List)i1.next(), Assertion.class); + List alt1 = + CastUtils.cast((List)i1.next(), PolicyAssertion.class); Iterator i2 = p2.getAlternatives(); while (i2.hasNext()) { - List alt2 = CastUtils.cast((List)i2.next(), Assertion.class); + List alt2 = + CastUtils.cast((List)i2.next(), PolicyAssertion.class); if (compatibleAlternatives(alt1, alt2)) { All all = new All(); all.addPolicyComponents(alt1); @@ -149,9 +154,10 @@ return compatible; } - private Assertion findCompatibleAssertion(Assertion assertion, Collection alt) { - for (Assertion a : alt) { - Assertion compatible = intersect(assertion, a); + private PolicyAssertion findCompatibleAssertion( + PolicyAssertion assertion, Collection alt) { + for (PolicyAssertion a : alt) { + PolicyAssertion compatible = intersect(assertion, a); if (null != compatible) { return compatible; } Added: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyAssertion.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyAssertion.java?rev=629609&view=auto ============================================================================== --- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyAssertion.java (added) +++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyAssertion.java Wed Feb 20 12:40:27 2008 @@ -0,0 +1,28 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.cxf.ws.policy; + +import org.apache.neethi.Assertion; +import org.apache.neethi.Policy; + +public interface PolicyAssertion extends Assertion { + boolean isAsserted(AssertionInfoMap aim); + Policy getPolicy(); +} Propchange: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyAssertion.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyAssertion.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyEngine.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyEngine.java?rev=629609&r1=629608&r2=629609&view=diff ============================================================================== --- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyEngine.java (original) +++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyEngine.java Wed Feb 20 12:40:27 2008 @@ -26,7 +26,6 @@ import org.apache.cxf.service.model.EndpointInfo; import org.apache.cxf.transport.Conduit; import org.apache.cxf.transport.Destination; -import org.apache.neethi.Assertion; import org.apache.neethi.PolicyRegistry; /** @@ -50,7 +49,7 @@ // - boolean supportsAlternative(Collection alterative, Assertor assertor); + boolean supportsAlternative(Collection alterative, Assertor assertor); // available throughout the outbound path Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProvider.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProvider.java?rev=629609&r1=629608&r2=629609&view=diff ============================================================================== --- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProvider.java (original) +++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProvider.java Wed Feb 20 12:40:27 2008 @@ -20,10 +20,13 @@ package org.apache.cxf.ws.policy; import java.util.Collection; +import java.util.List; import javax.xml.namespace.QName; +import org.apache.cxf.interceptor.Interceptor; import org.apache.cxf.interceptor.InterceptorProvider; +import org.apache.cxf.message.Message; /** * @@ -36,4 +39,13 @@ * @return collection of QNames of known assertion types */ Collection getAssertionTypes(); + + List provideInInterceptors(Message m); + + List provideOutInterceptors(Message m); + + List provideOutFaultInterceptors(Message m); + + List provideInFaultInterceptors(Message m); + } Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProviderRegistry.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProviderRegistry.java?rev=629609&r1=629608&r2=629609&view=diff ============================================================================== --- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProviderRegistry.java (original) +++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProviderRegistry.java Wed Feb 20 12:40:27 2008 @@ -26,7 +26,6 @@ import org.apache.cxf.extension.Registry; import org.apache.cxf.interceptor.Interceptor; -import org.apache.neethi.Assertion; /** @@ -36,6 +35,6 @@ public interface PolicyInterceptorProviderRegistry extends Registry { - List getInterceptors(Collection alterative, boolean out, boolean fault); + List getInterceptors(Collection alterative, boolean out, boolean fault); } Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertion.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertion.java?rev=629609&r1=629608&r2=629609&view=diff ============================================================================== --- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertion.java (original) +++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertion.java Wed Feb 20 12:40:27 2008 @@ -21,8 +21,8 @@ import javax.xml.namespace.QName; +import org.apache.cxf.ws.policy.PolicyAssertion; import org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertion; -import org.apache.neethi.Assertion; import org.apache.neethi.PolicyComponent; @@ -58,19 +58,19 @@ return data; } - protected Assertion cloneMandatory() { + protected PolicyAssertion cloneMandatory() { JaxbAssertion a = new JaxbAssertion(getName(), false); a.setData(data); return a; } @SuppressWarnings("unchecked") - public static JaxbAssertion cast(Assertion a) { + public static JaxbAssertion cast(PolicyAssertion a) { return (JaxbAssertion)a; } @SuppressWarnings("unchecked") - public static JaxbAssertion cast(Assertion a, Class type) { + public static JaxbAssertion cast(PolicyAssertion a, Class type) { return (JaxbAssertion)a; } Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertionBuilder.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertionBuilder.java?rev=629609&r1=629608&r2=629609&view=diff ============================================================================== --- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertionBuilder.java (original) +++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertionBuilder.java Wed Feb 20 12:40:27 2008 @@ -37,7 +37,7 @@ import org.apache.cxf.common.util.PackageUtils; import org.apache.cxf.jaxb.JAXBUtils; import org.apache.cxf.ws.policy.AssertionBuilder; -import org.apache.neethi.Assertion; +import org.apache.cxf.ws.policy.PolicyAssertion; import org.apache.neethi.Constants; public class JaxbAssertionBuilder implements AssertionBuilder { @@ -104,7 +104,7 @@ unmarshaller = context.createUnmarshaller(); } - public Assertion build(Element element) { + public PolicyAssertion build(Element element) { QName name = new QName(element.getNamespaceURI(), element.getLocalName()); JaxbAssertion assertion = buildAssertion(); assertion.setName(name); @@ -118,7 +118,7 @@ } @SuppressWarnings("unchecked") - public Assertion buildCompatible(Assertion a, Assertion b) { + public PolicyAssertion buildCompatible(PolicyAssertion a, PolicyAssertion b) { if (a.equal(b)) { JaxbAssertion ja = (JaxbAssertion)a; JaxbAssertion compatible = buildAssertion(); Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertion.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertion.java?rev=629609&r1=629608&r2=629609&view=diff ============================================================================== --- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertion.java (original) +++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertion.java Wed Feb 20 12:40:27 2008 @@ -19,6 +19,8 @@ package org.apache.cxf.ws.policy.builder.primitive; + +import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.ResourceBundle; @@ -31,14 +33,17 @@ import org.apache.cxf.common.i18n.BundleUtils; import org.apache.cxf.common.i18n.Message; import org.apache.cxf.helpers.CastUtils; +import org.apache.cxf.ws.policy.AssertionInfo; +import org.apache.cxf.ws.policy.AssertionInfoMap; +import org.apache.cxf.ws.policy.PolicyAssertion; import org.apache.cxf.ws.policy.PolicyBuilder; import org.apache.cxf.ws.policy.PolicyConstants; import org.apache.cxf.ws.policy.PolicyException; import org.apache.neethi.All; -import org.apache.neethi.Assertion; import org.apache.neethi.ExactlyOne; import org.apache.neethi.Policy; import org.apache.neethi.PolicyComponent; +import org.apache.neethi.PolicyOperator; /** * Implementation of an assertion that required exactly one (possibly empty) child element @@ -49,13 +54,27 @@ private static final ResourceBundle BUNDLE = BundleUtils.getBundle(NestedPrimitiveAssertion.class); private Policy nested; + private boolean assertionRequired = true; + public NestedPrimitiveAssertion(QName name, boolean optional) { + this(name, optional, null, true); + } - protected NestedPrimitiveAssertion(QName name, boolean optional) { + public NestedPrimitiveAssertion(QName name, boolean optional, + Policy p, boolean assertionRequired) { super(name, optional); + this.assertionRequired = assertionRequired; + this.nested = p; + } + + public NestedPrimitiveAssertion(Element elem, PolicyBuilder builder, + PolicyConstants constants) { + this(elem, builder, constants, true); } - public NestedPrimitiveAssertion(Element elem, PolicyBuilder builder, PolicyConstants constants) { + public NestedPrimitiveAssertion(Element elem, PolicyBuilder builder, + PolicyConstants constants, boolean assertionRequired) { super(elem, constants); + this.assertionRequired = assertionRequired; // expect exactly one child element of type Policy @@ -93,7 +112,8 @@ Iterator alternatives = normalisedNested.getAlternatives(); while (alternatives.hasNext()) { All all = new All(); - List alternative = CastUtils.cast((List)alternatives.next(), Assertion.class); + List alternative = + CastUtils.cast((List)alternatives.next(), PolicyAssertion.class); NestedPrimitiveAssertion a = new NestedPrimitiveAssertion(getName(), false); a.nested = new Policy(); ExactlyOne nea = new ExactlyOne(); @@ -107,22 +127,69 @@ return p; } - public Policy getNested() { - return nested; - } - @Override public boolean equal(PolicyComponent policyComponent) { + if (!super.equal(policyComponent)) { return false; } NestedPrimitiveAssertion other = (NestedPrimitiveAssertion)policyComponent; - return getNested().equal(other.getNested()); + return getPolicy().equal(other.getPolicy()); } - protected void setNested(Policy n) { + protected void setPolicy(Policy n) { nested = n; } + @Override + public Policy getPolicy() { + return nested; + } + + @Override + public boolean isAsserted(AssertionInfoMap aim) { + + if (assertionRequired) { + Collection ail = aim.getAssertionInfo(name); + for (AssertionInfo ai : ail) { + if (ai.isAsserted() && isPolicyAsserted(nested, aim)) { + return true; + } + } + return false; + } + + return isPolicyAsserted(nested, aim); + } + protected boolean isPolicyAsserted(PolicyOperator p, AssertionInfoMap aim) { + if (p == null) { + return true; + } + List pcs = + CastUtils.cast(p.getPolicyComponents(), PolicyComponent.class); + if (pcs.size() == 0) { + return true; + } + + if (pcs.get(0) instanceof PolicyAssertion) { + List assertions = + CastUtils.cast(pcs, PolicyAssertion.class); + for (PolicyAssertion pa : assertions) { + if (!pa.isAsserted(aim)) { + return false; + } + } + return true; + } else { + List assertions = + CastUtils.cast(pcs, PolicyOperator.class); + for (PolicyOperator po : assertions) { + if (isPolicyAsserted(po, aim)) { + return true; + } + } + return false; + } + } } Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionBuilder.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionBuilder.java?rev=629609&r1=629608&r2=629609&view=diff ============================================================================== --- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionBuilder.java (original) +++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionBuilder.java Wed Feb 20 12:40:27 2008 @@ -23,8 +23,8 @@ import org.apache.cxf.ws.policy.AssertionBuilderRegistry; import org.apache.cxf.ws.policy.Intersector; +import org.apache.cxf.ws.policy.PolicyAssertion; import org.apache.cxf.ws.policy.PolicyBuilder; -import org.apache.neethi.Assertion; import org.apache.neethi.Policy; public class NestedPrimitiveAssertionBuilder extends PrimitiveAssertionBuilder { @@ -41,7 +41,7 @@ } @Override - public Assertion build(Element elem) { + public PolicyAssertion build(Element elem) { return new NestedPrimitiveAssertion(elem, builder, getPolicyConstants()); } @@ -51,7 +51,7 @@ * . * The compatible policy is optional iff both assertions are optional. */ - public Assertion buildCompatible(Assertion a, Assertion b) { + public PolicyAssertion buildCompatible(PolicyAssertion a, PolicyAssertion b) { if (!getKnownElements().contains(a.getName()) || !a.getName().equals(b.getName())) { return null; } @@ -66,14 +66,14 @@ Intersector intersector = new Intersector(assertionBuilderRegistry); - Policy nested = intersector.intersect(na.getNested(), nb.getNested()); + Policy nested = intersector.intersect(na.getPolicy(), nb.getPolicy()); if (null == nested) { return null; } NestedPrimitiveAssertion compatible = new NestedPrimitiveAssertion(a.getName(), a.isOptional() && b.isOptional()); - compatible.setNested(nested); + compatible.setPolicy(nested); return compatible; } Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertion.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertion.java?rev=629609&r1=629608&r2=629609&view=diff ============================================================================== --- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertion.java (original) +++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertion.java Wed Feb 20 12:40:27 2008 @@ -19,6 +19,8 @@ package org.apache.cxf.ws.policy.builder.primitive; +import java.util.Collection; + import javax.xml.namespace.QName; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; @@ -26,9 +28,11 @@ import org.w3c.dom.Attr; import org.w3c.dom.Element; +import org.apache.cxf.ws.policy.AssertionInfo; +import org.apache.cxf.ws.policy.AssertionInfoMap; +import org.apache.cxf.ws.policy.PolicyAssertion; import org.apache.cxf.ws.policy.PolicyConstants; import org.apache.neethi.All; -import org.apache.neethi.Assertion; import org.apache.neethi.Constants; import org.apache.neethi.ExactlyOne; import org.apache.neethi.Policy; @@ -37,7 +41,7 @@ /** * */ -public class PrimitiveAssertion implements Assertion { +public class PrimitiveAssertion implements PolicyAssertion { protected QName name; protected boolean optional; @@ -68,7 +72,7 @@ if (policyComponent.getType() != Constants.TYPE_ASSERTION) { return false; } - return getName().equals(((Assertion)policyComponent).getName()); + return getName().equals(((PolicyAssertion)policyComponent).getName()); } public short getType() { @@ -111,7 +115,21 @@ public void serialize(XMLStreamWriter writer) throws XMLStreamException { } - protected Assertion cloneMandatory() { + protected PolicyAssertion cloneMandatory() { return new PrimitiveAssertion(name, false); + } + + public Policy getPolicy() { + return null; + } + + public boolean isAsserted(AssertionInfoMap aim) { + Collection ail = aim.getAssertionInfo(name); + for (AssertionInfo ai : ail) { + if (ai.isAsserted() && ai.getAssertion().equal(this)) { + return true; + } + } + return false; } } Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertionBuilder.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertionBuilder.java?rev=629609&r1=629608&r2=629609&view=diff ============================================================================== --- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertionBuilder.java (original) +++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertionBuilder.java Wed Feb 20 12:40:27 2008 @@ -24,13 +24,12 @@ import javax.xml.namespace.QName; - import org.w3c.dom.Element; import org.apache.cxf.Bus; import org.apache.cxf.ws.policy.AssertionBuilder; +import org.apache.cxf.ws.policy.PolicyAssertion; import org.apache.cxf.ws.policy.PolicyConstants; -import org.apache.neethi.Assertion; public class PrimitiveAssertionBuilder implements AssertionBuilder { @@ -41,7 +40,7 @@ bus = b; } - public Assertion build(Element element) { + public PolicyAssertion build(Element element) { return new PrimitiveAssertion(element, getPolicyConstants()); } @@ -57,7 +56,7 @@ * If the two assertions are equal, they are also compatible. * The compatible policy is optional iff both assertions are optional. */ - public Assertion buildCompatible(Assertion a, Assertion b) { + public PolicyAssertion buildCompatible(PolicyAssertion a, PolicyAssertion b) { if (knownElements.contains(a.getName()) && a.getName().equals(b.getName())) { return new PrimitiveAssertion(a.getName(), a.isOptional() && b.isOptional()); } Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XMLPrimitiveAssertionBuilder.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XMLPrimitiveAssertionBuilder.java?rev=629609&r1=629608&r2=629609&view=diff ============================================================================== --- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XMLPrimitiveAssertionBuilder.java (original) +++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XMLPrimitiveAssertionBuilder.java Wed Feb 20 12:40:27 2008 @@ -21,12 +21,12 @@ import org.w3c.dom.Element; +import org.apache.cxf.ws.policy.PolicyAssertion; import org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertionBuilder; -import org.apache.neethi.Assertion; public class XMLPrimitiveAssertionBuilder extends PrimitiveAssertionBuilder { - public Assertion build(Element element) { + public PolicyAssertion build(Element element) { return new XmlPrimitiveAssertion(element, getPolicyConstants()); } } Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XmlPrimitiveAssertion.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XmlPrimitiveAssertion.java?rev=629609&r1=629608&r2=629609&view=diff ============================================================================== --- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XmlPrimitiveAssertion.java (original) +++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XmlPrimitiveAssertion.java Wed Feb 20 12:40:27 2008 @@ -21,9 +21,9 @@ import org.w3c.dom.Element; +import org.apache.cxf.ws.policy.PolicyAssertion; import org.apache.cxf.ws.policy.PolicyConstants; import org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertion; -import org.apache.neethi.Assertion; import org.apache.neethi.PolicyComponent; /** @@ -65,7 +65,7 @@ throw new UnsupportedOperationException(); } - protected Assertion cloneMandatory() { + protected PolicyAssertion cloneMandatory() { Element e = (Element)element.cloneNode(true); if (isOptional()) { e.removeAttributeNode(e.getAttributeNodeNS(constants.getNamespace(), Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/util/PolicyComparator.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/util/PolicyComparator.java?rev=629609&r1=629608&r2=629609&view=diff ============================================================================== --- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/util/PolicyComparator.java (original) +++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/util/PolicyComparator.java Wed Feb 20 12:40:27 2008 @@ -22,6 +22,7 @@ import java.util.Iterator; import java.util.List; +import org.apache.cxf.ws.policy.PolicyAssertion; import org.apache.neethi.All; import org.apache.neethi.Assertion; import org.apache.neethi.ExactlyOne; @@ -72,8 +73,8 @@ } else if (arg1 instanceof ExactlyOne) { return compare((ExactlyOne) arg1, (ExactlyOne) arg2); - } else if (arg1 instanceof Assertion) { - return compare((Assertion) arg1, (Assertion) arg2); + } else if (arg1 instanceof PolicyAssertion) { + return compare((PolicyAssertion)arg1, (PolicyAssertion)arg2); } else { // TODO should I throw an exception .. Modified: incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/AssertionInfoMapTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/AssertionInfoMapTest.java?rev=629609&r1=629608&r2=629609&view=diff ============================================================================== --- incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/AssertionInfoMapTest.java (original) +++ incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/AssertionInfoMapTest.java Wed Feb 20 12:40:27 2008 @@ -27,9 +27,9 @@ import javax.xml.namespace.QName; import org.apache.cxf.helpers.CastUtils; +import org.apache.cxf.ws.policy.builder.primitive.NestedPrimitiveAssertion; import org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertion; import org.apache.neethi.All; -import org.apache.neethi.Assertion; import org.apache.neethi.ExactlyOne; import org.apache.neethi.Policy; import org.easymock.classextension.EasyMock; @@ -52,18 +52,19 @@ @Test public void testAlternativeSupported() { - Assertion a1 = control.createMock(Assertion.class); + PolicyAssertion a1 = control.createMock(PolicyAssertion.class); QName aqn = new QName("http://x.y.z", "a"); EasyMock.expect(a1.getName()).andReturn(aqn).anyTimes(); - Assertion a2 = control.createMock(Assertion.class); + PolicyAssertion a2 = control.createMock(PolicyAssertion.class); EasyMock.expect(a2.getName()).andReturn(aqn).anyTimes(); - Assertion b = control.createMock(Assertion.class); + PolicyAssertion b = control.createMock(PolicyAssertion.class); QName bqn = new QName("http://x.y.z", "b"); EasyMock.expect(b.getName()).andReturn(bqn).anyTimes(); - Assertion c = control.createMock(Assertion.class); + PolicyAssertion c = control.createMock(PolicyAssertion.class); QName cqn = new QName("http://x.y.z", "c"); EasyMock.expect(c.getName()).andReturn(cqn).anyTimes(); - AssertionInfoMap aim = new AssertionInfoMap(CastUtils.cast(Collections.EMPTY_LIST, Assertion.class)); + AssertionInfoMap aim = new AssertionInfoMap(CastUtils.cast(Collections.EMPTY_LIST, + PolicyAssertion.class)); AssertionInfo ai1 = new AssertionInfo(a1); AssertionInfo ai2 = new AssertionInfo(a2); Collection ais = new ArrayList(); @@ -82,12 +83,16 @@ EasyMock.expect(b.equal(b)).andReturn(true).anyTimes(); EasyMock.expect(c.equal(c)).andReturn(true).anyTimes(); + EasyMock.expect(a2.isAsserted(aim)).andReturn(true).anyTimes(); + EasyMock.expect(b.isAsserted(aim)).andReturn(true).anyTimes(); + EasyMock.expect(c.isAsserted(aim)).andReturn(true).anyTimes(); - List alt1 = new ArrayList(); + + List alt1 = new ArrayList(); alt1.add(a1); alt1.add(b); - List alt2 = new ArrayList(); + List alt2 = new ArrayList(); alt2.add(a2); alt2.add(c); @@ -101,11 +106,11 @@ public void testCheckEffectivePolicy() { Policy p = new Policy(); QName aqn = new QName("http://x.y.z", "a"); - Assertion a = new PrimitiveAssertion(aqn); + PolicyAssertion a = new PrimitiveAssertion(aqn); QName bqn = new QName("http://x.y.z", "b"); - Assertion b = new PrimitiveAssertion(bqn); + PolicyAssertion b = new PrimitiveAssertion(bqn); QName cqn = new QName("http://x.y.z", "c"); - Assertion c = new PrimitiveAssertion(cqn); + PolicyAssertion c = new PrimitiveAssertion(cqn); All alt1 = new All(); alt1.addAssertion(a); alt1.addAssertion(b); @@ -115,7 +120,8 @@ ea.addPolicyComponent(alt1); ea.addPolicyComponent(alt2); p.addPolicyComponent(ea); - AssertionInfoMap aim = new AssertionInfoMap(CastUtils.cast(Collections.EMPTY_LIST, Assertion.class)); + AssertionInfoMap aim = new AssertionInfoMap(CastUtils.cast(Collections.EMPTY_LIST, + PolicyAssertion.class)); AssertionInfo ai = new AssertionInfo(a); AssertionInfo bi = new AssertionInfo(b); AssertionInfo ci = new AssertionInfo(c); @@ -139,8 +145,8 @@ @Test public void testCheck() throws PolicyException { QName aqn = new QName("http://x.y.z", "a"); - Assertion a = new PrimitiveAssertion(aqn); - Collection assertions = new ArrayList(); + PolicyAssertion a = new PrimitiveAssertion(aqn); + Collection assertions = new ArrayList(); assertions.add(a); AssertionInfoMap aim = new AssertionInfoMap(assertions); try { @@ -151,5 +157,61 @@ } aim.get(aqn).iterator().next().setAsserted(true); aim.check(); + } + + @Test + public void testAllAssertionsIn() { + + Policy nested = new Policy(); + PolicyAssertion nb = new PrimitiveAssertion( + new QName("http://x.y.z", "b")); + nested.addAssertion(nb); + + Policy p = new Policy(); + PolicyAssertion a1 = new PrimitiveAssertion( + new QName("http://x.y.z", "a")); + PolicyAssertion a2 = new PrimitiveAssertion( + new QName("http://x.y.z", "a")); + PolicyAssertion b = new PrimitiveAssertion( + new QName("http://x.y.z", "b")); + PolicyAssertion c = new NestedPrimitiveAssertion( + new QName("http://x.y.z", "c"), false, nested, true); + + All alt1 = new All(); + alt1.addAssertion(a1); + alt1.addAssertion(b); + All alt2 = new All(); + alt1.addAssertion(a2); + alt2.addAssertion(c); + ExactlyOne ea = new ExactlyOne(); + ea.addPolicyComponent(alt1); + ea.addPolicyComponent(alt2); + p.addPolicyComponent(ea); + + AssertionInfoMap aim = new AssertionInfoMap(p); + + Collection listA = + aim.getAssertionInfo(new QName("http://x.y.z", "a")); + assertEquals("2 A assertions should've been added", 2, listA.size()); + AssertionInfo[] ais = listA.toArray(new AssertionInfo[] {}); + assertTrue("Two different A instances should be added", + ais[0].getAssertion() == a1 && ais[1].getAssertion() == a2 + || ais[0].getAssertion() == a2 && ais[1].getAssertion() == a1); + + Collection listB = + aim.getAssertionInfo(new QName("http://x.y.z", "b")); + assertEquals("2 B assertions should've been added", 2, listB.size()); + ais = listB.toArray(new AssertionInfo[] {}); + assertTrue("Two different B instances should be added", + ais[0].getAssertion() == nb && ais[1].getAssertion() == b + || ais[0].getAssertion() == b && ais[1].getAssertion() == nb); + + Collection listC = + aim.getAssertionInfo(new QName("http://x.y.z", "c")); + assertEquals("1 C assertion should've been added", 1, listC.size()); + ais = listC.toArray(new AssertionInfo[] {}); + assertSame("One C instances should be added", + ais[0].getAssertion(), c); + } } Modified: incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertionBuilderTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertionBuilderTest.java?rev=629609&r1=629608&r2=629609&view=diff ============================================================================== --- incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertionBuilderTest.java (original) +++ incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertionBuilderTest.java Wed Feb 20 12:40:27 2008 @@ -28,7 +28,7 @@ import org.apache.cxf.helpers.DOMUtils; import org.apache.cxf.test.assertions.foo.FooType; -import org.apache.neethi.Assertion; +import org.apache.cxf.ws.policy.PolicyAssertion; import org.junit.Assert; import org.junit.Test; @@ -70,7 +70,7 @@ Document doc = DOMUtils.readXml(is); Element elem = (Element)doc.getDocumentElement() .getElementsByTagNameNS("http://cxf.apache.org/test/assertions/foo", "foo").item(0); - Assertion a = ab.build(elem); + PolicyAssertion a = ab.build(elem); JaxbAssertion jba = JaxbAssertion.cast(a, FooType.class); FooType foo = jba.getData(); assertEquals("CXF", foo.getName()); Modified: incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionBuilderTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionBuilderTest.java?rev=629609&r1=629608&r2=629609&view=diff ============================================================================== --- incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionBuilderTest.java (original) +++ incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionBuilderTest.java Wed Feb 20 12:40:27 2008 @@ -30,10 +30,10 @@ import org.apache.cxf.Bus; import org.apache.cxf.helpers.DOMUtils; import org.apache.cxf.ws.policy.AssertionBuilderRegistry; +import org.apache.cxf.ws.policy.PolicyAssertion; import org.apache.cxf.ws.policy.PolicyBuilder; import org.apache.cxf.ws.policy.PolicyConstants; import org.apache.cxf.ws.policy.PolicyException; -import org.apache.neethi.Assertion; import org.apache.neethi.Policy; import org.easymock.classextension.EasyMock; import org.easymock.classextension.IMocksControl; @@ -96,7 +96,7 @@ control.replay(); NestedPrimitiveAssertion npc = (NestedPrimitiveAssertion)npab.build(getElement(data)); assertEquals(TEST_NAME1, npc.getName()); - assertSame(nested, npc.getNested()); + assertSame(nested, npc.getPolicy()); assertTrue(npc.isOptional()); control.verify(); } @@ -121,7 +121,7 @@ npab.setBus(bus); NestedPrimitiveAssertion npc = (NestedPrimitiveAssertion)npab.build(getElement(data)); assertEquals(TEST_NAME1, npc.getName()); - assertSame(nested, npc.getNested()); + assertSame(nested, npc.getPolicy()); assertTrue(npc.isOptional()); control.verify(); } @@ -130,7 +130,8 @@ public void testBuildCompatibleNoRegistry() { npab.setAssertionBuilderRegistry(null); Policy[] policies = NestedPrimitiveAssertionTest.buildTestPolicies(); - Assertion a = (Assertion)policies[4].getFirstPolicyComponent(); + PolicyAssertion a = + (PolicyAssertion)policies[4].getFirstPolicyComponent(); assertNull("Should not have been able to build compatible policy.", npab.buildCompatible(a, a)); } @@ -146,8 +147,9 @@ EasyMock.expect(reg.get(TEST_NAME3)).andReturn(ab2).anyTimes(); control.replay(); - Assertion a = (Assertion)policies[2].getFirstPolicyComponent(); - Assertion compatible = npab.buildCompatible(a, a); + PolicyAssertion a = + (PolicyAssertion)policies[2].getFirstPolicyComponent(); + PolicyAssertion compatible = npab.buildCompatible(a, a); assertNotNull("assertion in policy 2 should be compatible with itself.", compatible); control.verify(); } @@ -165,23 +167,27 @@ control.replay(); for (int i = 0; i < policies.length; i++) { - Assertion a = (Assertion)policies[i].getFirstPolicyComponent(); - Assertion compatible = npab.buildCompatible(a, a); + PolicyAssertion a = + (PolicyAssertion)policies[i].getFirstPolicyComponent(); + PolicyAssertion compatible = npab.buildCompatible(a, a); assertNotNull("assertion in policy " + i + " should be compatible with itself.", compatible); } for (int i = 1; i < 5; i++) { - Assertion a = (Assertion)policies[0].getFirstPolicyComponent(); - Assertion b = (Assertion)policies[i].getFirstPolicyComponent(); - Assertion compatible = npab.buildCompatible(a, b); + PolicyAssertion a = + (PolicyAssertion)policies[0].getFirstPolicyComponent(); + PolicyAssertion b = (PolicyAssertion)policies[i].getFirstPolicyComponent(); + PolicyAssertion compatible = npab.buildCompatible(a, b); assertNotNull("assertion in policy 0 should be compatible with assertion in policy " + i + ".", compatible); } for (int i = 2; i < 5; i++) { - Assertion a = (Assertion)policies[1].getFirstPolicyComponent(); - Assertion b = (Assertion)policies[i].getFirstPolicyComponent(); - Assertion compatible = npab.buildCompatible(a, b); + PolicyAssertion a = + (PolicyAssertion)policies[1].getFirstPolicyComponent(); + PolicyAssertion b = + (PolicyAssertion)policies[i].getFirstPolicyComponent(); + PolicyAssertion compatible = npab.buildCompatible(a, b); assertNotNull("assertion in policy " + 1 + " should be compatible with assertion in policy i.", compatible); } Modified: incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionTest.java?rev=629609&r1=629608&r2=629609&view=diff ============================================================================== --- incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionTest.java (original) +++ incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionTest.java Wed Feb 20 12:40:27 2008 @@ -19,11 +19,21 @@ package org.apache.cxf.ws.policy.builder.primitive; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + import javax.xml.namespace.QName; +import org.apache.cxf.ws.policy.AssertionInfo; +import org.apache.cxf.ws.policy.AssertionInfoMap; +import org.apache.cxf.ws.policy.PolicyAssertion; +import org.apache.neethi.All; import org.apache.neethi.Assertion; import org.apache.neethi.ExactlyOne; import org.apache.neethi.Policy; +import org.apache.neethi.PolicyComponent; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -39,6 +49,23 @@ private static final QName TEST_NAME2 = new QName(TEST_NAMESPACE, "AnonymousResponses"); private static final QName TEST_NAME3 = new QName(TEST_NAMESPACE, "NonAnonymousResponses"); + public class CustomPrimitiveAssertion extends PrimitiveAssertion { + private int x; + public CustomPrimitiveAssertion(QName type, int x) { + super(type, false); + this.x = x; + } + + @Override + public boolean equal(PolicyComponent pc) { + if (!(pc instanceof CustomPrimitiveAssertion) + || !super.equal(pc)) { + return false; + } + return x == ((CustomPrimitiveAssertion)pc).x; + } + } + private Policy[] policies; @@ -48,10 +75,124 @@ } @Test + public void testNoNeedToAssertWithEmptyPolicy() { + PolicyAssertion a = new NestedPrimitiveAssertion( + new QName("abc"), false, null, false); + AssertionInfoMap aim = new AssertionInfoMap( + Collections.singletonList(a)); + assertTrue("No need to assert", a.isAsserted(aim)); + a = new NestedPrimitiveAssertion(new QName("abc"), + false, + null, + false); + assertTrue("No need to assert", a.isAsserted(aim)); + } + + + @Test + public void testNoNeedToAssertWithNonEmptyPolicy() { + PolicyAssertion a = new NestedPrimitiveAssertion( + new QName("abc"), false, null, false); + AssertionInfoMap aim = new AssertionInfoMap( + Collections.singletonList(a)); + assertTrue("No need to assert", a.isAsserted(aim)); + Policy p = new Policy(); + p.addAssertion(new PrimitiveAssertion(new QName("abc"), false)); + a = new NestedPrimitiveAssertion(new QName("abc"), + false, + p, + false); + assertFalse("Primitive Assertions need to be asserted", + a.isAsserted(aim)); + + p = new Policy(); + p.addAssertion(new NestedPrimitiveAssertion(new QName("abc"), + false, + null, + false)); + a = new NestedPrimitiveAssertion(new QName("abc"), + false, + p, + false); + assertTrue("No need to assert", a.isAsserted(aim)); + } + + + @Test + public void testAsserted() { + PolicyAssertion a1 = + new CustomPrimitiveAssertion(new QName("abc"), 1); + PolicyAssertion a2 = + new CustomPrimitiveAssertion(new QName("abc"), 2); + Policy nested = new Policy(); + All all = new All(); + all.addAssertion(a2); + nested.addPolicyComponent(all); + + NestedPrimitiveAssertion na = new NestedPrimitiveAssertion(new QName("nested"), + false, + nested, + true); + List ais = + new ArrayList(); + + ais.add(a1); + ais.add(a2); + ais.add(na); + + AssertionInfoMap aim = new AssertionInfoMap(ais); + + assertFalse("Assertion has been asserted even though nether na nor a2 have been", + na.isAsserted(aim)); + + assertAssertion(aim, new QName("nested"), true, true); + assertFalse("Assertion has been asserted even though a2 has not been", + na.isAsserted(aim)); + + // assert a1 only + assertAssertion(aim, new QName("abc"), true, false); + assertFalse("Assertion has been asserted even though a2 has not been", + na.isAsserted(aim)); + // assert a2 tpp + assertAssertion(aim, new QName("abc"), true, true); + assertTrue("Assertion has not been asserted even though both na nad a2 have been", + na.isAsserted(aim)); + + PolicyAssertion a3 = new CustomPrimitiveAssertion(new QName("abc"), 3); + all.addAssertion(a3); + aim.getAssertionInfo(new QName("abc")).add(new AssertionInfo(a3)); + + assertFalse("Assertion has been asserted even though a3 has not been", + na.isAsserted(aim)); + + assertAssertion(aim, new QName("abc"), true, true); + assertTrue("Assertion has not been asserted even though na,a2,a3 have been", + na.isAsserted(aim)); + + } + + private void assertAssertion(AssertionInfoMap aim, + QName type, + boolean value, + boolean all) { + Collection aic = aim.getAssertionInfo(type); + if (!all) { + AssertionInfo ai = aic.iterator().next(); + ai.setAsserted(value); + } else { + for (AssertionInfo ai : aic) { + ai.setAsserted(value); + } + } + } + + + @Test public void testEqual() { - Assertion other = new PrimitiveAssertion(new QName("abc")); + PolicyAssertion other = new PrimitiveAssertion(new QName("abc")); for (int i = 0; i < policies.length; i++) { - Assertion a = (Assertion)policies[i].getFirstPolicyComponent(); + PolicyAssertion a = + (PolicyAssertion)policies[i].getFirstPolicyComponent(); assertTrue("Assertion " + i + " should equal itself.", a.equal(a)); assertTrue("Assertion " + i + " should not equal other.", !a.equal(other)); for (int j = i + 1; j < policies.length; j++) { @@ -72,19 +213,19 @@ p[i] = new Policy(); NestedPrimitiveAssertion a = new NestedPrimitiveAssertion(TEST_NAME1, true); Policy nested = new Policy(); - a.setNested(nested); + a.setPolicy(nested); p[i++].addPolicyComponent(a); p[i] = new Policy(); a = new NestedPrimitiveAssertion(TEST_NAME1, false); nested = new Policy(); - a.setNested(nested); + a.setPolicy(nested); p[i++].addPolicyComponent(a); p[i] = new Policy(); a = new NestedPrimitiveAssertion(TEST_NAME1, false); nested = new Policy(); - a.setNested(nested); + a.setPolicy(nested); nested.addPolicyComponent(new PrimitiveAssertion(TEST_NAME2, true)); nested.addPolicyComponent(new PrimitiveAssertion(TEST_NAME3, true)); p[i++].addPolicyComponent(a); @@ -92,7 +233,7 @@ p[i] = new Policy(); a = new NestedPrimitiveAssertion(TEST_NAME1, false); nested = new Policy(); - a.setNested(nested); + a.setPolicy(nested); ExactlyOne eo = new ExactlyOne(); nested.addPolicyComponent(eo); eo.addPolicyComponent(new PrimitiveAssertion(TEST_NAME2)); @@ -102,7 +243,7 @@ p[i] = new Policy(); a = new NestedPrimitiveAssertion(TEST_NAME1, false); nested = new Policy(); - a.setNested(nested); + a.setPolicy(nested); nested.addPolicyComponent(new PrimitiveAssertion(TEST_NAME3)); p[i++].addPolicyComponent(a); Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/HTTPClientAssertionBuilder.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/HTTPClientAssertionBuilder.java?rev=629609&r1=629608&r2=629609&view=diff ============================================================================== --- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/HTTPClientAssertionBuilder.java (original) +++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/HTTPClientAssertionBuilder.java Wed Feb 20 12:40:27 2008 @@ -22,9 +22,9 @@ import javax.xml.bind.JAXBException; import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; +import org.apache.cxf.ws.policy.PolicyAssertion; import org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion; import org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertionBuilder; -import org.apache.neethi.Assertion; import org.apache.neethi.Constants; import org.apache.neethi.PolicyComponent; @@ -38,7 +38,7 @@ } @Override - public Assertion buildCompatible(Assertion a, Assertion b) { + public PolicyAssertion buildCompatible(PolicyAssertion a, PolicyAssertion b) { if (PolicyUtils.HTTPCLIENTPOLICY_ASSERTION_QNAME.equals(a.getName()) && PolicyUtils.HTTPCLIENTPOLICY_ASSERTION_QNAME.equals(b.getName())) { @@ -70,15 +70,15 @@ @Override public boolean equal(PolicyComponent policyComponent) { if (policyComponent.getType() != Constants.TYPE_ASSERTION - || !getName().equals(((Assertion)policyComponent).getName())) { + || !getName().equals(((PolicyAssertion)policyComponent).getName())) { return false; } - JaxbAssertion other = JaxbAssertion.cast((Assertion)policyComponent); + JaxbAssertion other = JaxbAssertion.cast((PolicyAssertion)policyComponent); return PolicyUtils.equals(this.getData(), other.getData()); } @Override - protected Assertion cloneMandatory() { + protected PolicyAssertion cloneMandatory() { HTTPClientPolicyAssertion a = new HTTPClientPolicyAssertion(); a.setData(getData()); return a; Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/HTTPServerAssertionBuilder.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/HTTPServerAssertionBuilder.java?rev=629609&r1=629608&r2=629609&view=diff ============================================================================== --- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/HTTPServerAssertionBuilder.java (original) +++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/HTTPServerAssertionBuilder.java Wed Feb 20 12:40:27 2008 @@ -22,9 +22,9 @@ import javax.xml.bind.JAXBException; import org.apache.cxf.transports.http.configuration.HTTPServerPolicy; +import org.apache.cxf.ws.policy.PolicyAssertion; import org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion; import org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertionBuilder; -import org.apache.neethi.Assertion; import org.apache.neethi.Constants; import org.apache.neethi.PolicyComponent; @@ -38,7 +38,7 @@ } @Override - public Assertion buildCompatible(Assertion a, Assertion b) { + public PolicyAssertion buildCompatible(PolicyAssertion a, PolicyAssertion b) { if (PolicyUtils.HTTPSERVERPOLICY_ASSERTION_QNAME.equals(a.getName()) && PolicyUtils.HTTPSERVERPOLICY_ASSERTION_QNAME.equals(b.getName())) { @@ -70,15 +70,15 @@ @Override public boolean equal(PolicyComponent policyComponent) { if (policyComponent.getType() != Constants.TYPE_ASSERTION - || !getName().equals(((Assertion)policyComponent).getName())) { + || !getName().equals(((PolicyAssertion)policyComponent).getName())) { return false; } - JaxbAssertion other = JaxbAssertion.cast((Assertion)policyComponent); + JaxbAssertion other = JaxbAssertion.cast((PolicyAssertion)policyComponent); return PolicyUtils.equals(this.getData(), other.getData()); } @Override - protected Assertion cloneMandatory() { + protected PolicyAssertion cloneMandatory() { HTTPServerPolicyAssertion a = new HTTPServerPolicyAssertion(); a.setData(getData()); return a; Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/PolicyUtils.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/PolicyUtils.java?rev=629609&r1=629608&r2=629609&view=diff ============================================================================== --- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/PolicyUtils.java (original) +++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/PolicyUtils.java Wed Feb 20 12:40:27 2008 @@ -36,10 +36,10 @@ import org.apache.cxf.transports.http.configuration.HTTPServerPolicy; import org.apache.cxf.ws.policy.AssertionInfo; import org.apache.cxf.ws.policy.AssertionInfoMap; +import org.apache.cxf.ws.policy.PolicyAssertion; import org.apache.cxf.ws.policy.PolicyEngine; import org.apache.cxf.ws.policy.PolicyException; import org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion; -import org.apache.neethi.Assertion; /** * @@ -81,7 +81,7 @@ if (null == ais) { return confPolicy; } - Collection alternative = new ArrayList(); + Collection alternative = new ArrayList(); for (AssertionInfo ai : ais) { alternative.add(ai.getAssertion()); } @@ -116,7 +116,7 @@ if (null == ais) { return confPolicy; } - Collection alternative = new ArrayList(); + Collection alternative = new ArrayList(); for (AssertionInfo ai : ais) { alternative.add(ai.getAssertion()); } @@ -143,9 +143,9 @@ * @throws PolicyException if no compatible HTTPClientPolicy can be determined */ public static HTTPClientPolicy getClient(PolicyEngine pe, EndpointInfo ei, Conduit c) { - Collection alternative = pe.getClientEndpointPolicy(ei, c).getChosenAlternative(); + Collection alternative = pe.getClientEndpointPolicy(ei, c).getChosenAlternative(); HTTPClientPolicy compatible = null; - for (Assertion a : alternative) { + for (PolicyAssertion a : alternative) { if (HTTPCLIENTPOLICY_ASSERTION_QNAME.equals(a.getName())) { HTTPClientPolicy p = JaxbAssertion.cast(a, HTTPClientPolicy.class).getData(); if (null == compatible) { @@ -173,9 +173,9 @@ * @throws PolicyException if no compatible HTTPServerPolicy can be determined */ public static HTTPServerPolicy getServer(PolicyEngine pe, EndpointInfo ei, Destination d) { - Collection alternative = pe.getServerEndpointPolicy(ei, d).getChosenAlternative(); + Collection alternative = pe.getServerEndpointPolicy(ei, d).getChosenAlternative(); HTTPServerPolicy compatible = null; - for (Assertion a : alternative) { + for (PolicyAssertion a : alternative) { if (HTTPSERVERPOLICY_ASSERTION_QNAME.equals(a.getName())) { HTTPServerPolicy p = JaxbAssertion.cast(a, HTTPServerPolicy.class).getData(); if (null == compatible) { @@ -615,9 +615,9 @@ return s1 == null || s2 == null || s1.equals(s2); } - private static HTTPClientPolicy getClient(Collection alternative) { + private static HTTPClientPolicy getClient(Collection alternative) { HTTPClientPolicy compatible = null; - for (Assertion a : alternative) { + for (PolicyAssertion a : alternative) { if (HTTPCLIENTPOLICY_ASSERTION_QNAME.equals(a.getName())) { HTTPClientPolicy p = JaxbAssertion.cast(a, HTTPClientPolicy.class).getData(); if (null == compatible) { @@ -637,9 +637,9 @@ return compatible; } - private static HTTPServerPolicy getServer(Collection alternative) { + private static HTTPServerPolicy getServer(Collection alternative) { HTTPServerPolicy compatible = null; - for (Assertion a : alternative) { + for (PolicyAssertion a : alternative) { if (HTTPSERVERPOLICY_ASSERTION_QNAME.equals(a.getName())) { HTTPServerPolicy p = JaxbAssertion.cast(a, HTTPServerPolicy.class).getData(); if (null == compatible) { Modified: incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/PolicyUtilsTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/PolicyUtilsTest.java?rev=629609&r1=629608&r2=629609&view=diff ============================================================================== --- incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/PolicyUtilsTest.java (original) +++ incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/PolicyUtilsTest.java Wed Feb 20 12:40:27 2008 @@ -30,8 +30,8 @@ import org.apache.cxf.transports.http.configuration.HTTPServerPolicy; import org.apache.cxf.ws.policy.AssertionInfo; import org.apache.cxf.ws.policy.AssertionInfoMap; +import org.apache.cxf.ws.policy.PolicyAssertion; import org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion; -import org.apache.neethi.Assertion; import org.easymock.classextension.EasyMock; import org.easymock.classextension.IMocksControl; import org.junit.Assert; @@ -171,7 +171,7 @@ control.verify(); control.reset(); - Collection as = new ArrayList(); + Collection as = new ArrayList(); AssertionInfoMap aim = new AssertionInfoMap(as); EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(aim); control.replay(); @@ -216,7 +216,8 @@ AssertionInfo cmai = new AssertionInfo(cma); AssertionInfo icmai = new AssertionInfo(icma); - AssertionInfoMap aim = new AssertionInfoMap(CastUtils.cast(Collections.EMPTY_LIST, Assertion.class)); + AssertionInfoMap aim = new AssertionInfoMap(CastUtils.cast(Collections.EMPTY_LIST, + PolicyAssertion.class)); Collection ais = new ArrayList(); ais.add(eai); ais.add(cmai); @@ -275,7 +276,8 @@ AssertionInfo cmai = new AssertionInfo(cma); AssertionInfo icmai = new AssertionInfo(icma); - AssertionInfoMap aim = new AssertionInfoMap(CastUtils.cast(Collections.EMPTY_LIST, Assertion.class)); + AssertionInfoMap aim = new AssertionInfoMap(CastUtils.cast(Collections.EMPTY_LIST, + PolicyAssertion.class)); Collection ais = new ArrayList(); ais.add(eai); ais.add(mai);