use of com.sun.xml.ws.policy.AssertionSet in project metro-jax-ws by eclipse-ee4j.
the class FastInfosetFeatureConfigurator method getFeatures.
/**
* Process FastInfoset policy assertions.
*
* @param key Key to identify the endpoint scope.
* @param policyMap the policy map.
* @throws PolicyException If retrieving the policy triggered an exception.
*/
public Collection<WebServiceFeature> getFeatures(final PolicyMapKey key, final PolicyMap policyMap) throws PolicyException {
final Collection<WebServiceFeature> features = new LinkedList<>();
if ((key != null) && (policyMap != null)) {
Policy policy = policyMap.getEndpointEffectivePolicy(key);
if (null != policy && policy.contains(EncodingConstants.OPTIMIZED_FI_SERIALIZATION_ASSERTION)) {
Iterator<AssertionSet> assertions = policy.iterator();
while (assertions.hasNext()) {
AssertionSet assertionSet = assertions.next();
Iterator<PolicyAssertion> policyAssertion = assertionSet.iterator();
while (policyAssertion.hasNext()) {
PolicyAssertion assertion = policyAssertion.next();
if (EncodingConstants.OPTIMIZED_FI_SERIALIZATION_ASSERTION.equals(assertion.getName())) {
String value = assertion.getAttributeValue(enabled);
boolean isFastInfosetEnabled = Boolean.valueOf(value.trim());
features.add(new FastInfosetFeature(isFastInfosetEnabled));
}
// end-if non optional fast infoset assertion found
}
// next assertion
}
// next alternative
}
// end-if policy contains fast infoset assertion
}
return features;
}
use of com.sun.xml.ws.policy.AssertionSet in project metro-jax-ws by eclipse-ee4j.
the class PolicyModelTranslator method normalizeRawAssertion.
private List<PolicyAssertion> normalizeRawAssertion(final RawAssertion assertion) throws PolicyException {
List<PolicyAssertion> parameters;
if (assertion.parameters.isEmpty()) {
parameters = null;
} else {
parameters = new ArrayList<>(assertion.parameters.size());
for (ModelNode parameterNode : assertion.parameters) {
parameters.add(createPolicyAssertionParameter(parameterNode));
}
}
final List<AssertionSet> nestedAlternatives = new LinkedList<>();
if (assertion.nestedAlternatives != null && !assertion.nestedAlternatives.isEmpty()) {
final Queue<RawAlternative> nestedAlternativeQueue = new LinkedList<>(assertion.nestedAlternatives);
RawAlternative rawAlternative;
while ((rawAlternative = nestedAlternativeQueue.poll()) != null) {
nestedAlternatives.addAll(normalizeRawAlternative(rawAlternative));
}
// if there is only a single result, we can add it direclty to the content base collection
// more elements in the result indicate that we will have to create combinations
}
final List<PolicyAssertion> assertionOptions = new LinkedList<>();
final boolean nestedAlternativesAvailable = !nestedAlternatives.isEmpty();
if (nestedAlternativesAvailable) {
for (AssertionSet nestedAlternative : nestedAlternatives) {
assertionOptions.add(createPolicyAssertion(assertion.originalNode.getNodeData(), parameters, nestedAlternative));
}
} else {
assertionOptions.add(createPolicyAssertion(assertion.originalNode.getNodeData(), parameters, null));
}
return assertionOptions;
}
use of com.sun.xml.ws.policy.AssertionSet in project metro-jax-ws by eclipse-ee4j.
the class CompactModelGenerator method translate.
@Override
protected ModelNode translate(final ModelNode parentAssertion, final NestedPolicy policy) {
final ModelNode nestedPolicyRoot = parentAssertion.createChildPolicyNode();
final AssertionSet set = policy.getAssertionSet();
translate(nestedPolicyRoot, set);
return nestedPolicyRoot;
}
use of com.sun.xml.ws.policy.AssertionSet in project metro-jax-ws by eclipse-ee4j.
the class NormalizedModelGenerator method translate.
@Override
public PolicySourceModel translate(final Policy policy) throws PolicyException {
LOGGER.entering(policy);
PolicySourceModel model = null;
if (policy == null) {
LOGGER.fine(LocalizationMessages.WSP_0047_POLICY_IS_NULL_RETURNING());
} else {
model = this.sourceModelCreator.create(policy);
final ModelNode rootNode = model.getRootNode();
final ModelNode exactlyOneNode = rootNode.createChildExactlyOneNode();
for (AssertionSet set : policy) {
final ModelNode alternativeNode = exactlyOneNode.createChildAllNode();
for (PolicyAssertion assertion : set) {
final AssertionData data = AssertionData.createAssertionData(assertion.getName(), assertion.getValue(), assertion.getAttributes(), assertion.isOptional(), assertion.isIgnorable());
final ModelNode assertionNode = alternativeNode.createChildAssertionNode(data);
if (assertion.hasNestedPolicy()) {
translate(assertionNode, assertion.getNestedPolicy());
}
if (assertion.hasParameters()) {
translate(assertionNode, assertion.getParametersIterator());
}
}
}
}
LOGGER.exiting(model);
return model;
}
use of com.sun.xml.ws.policy.AssertionSet in project metro-jax-ws by eclipse-ee4j.
the class AddressingFeatureConfigurator method getFeatures.
public Collection<WebServiceFeature> getFeatures(final PolicyMapKey key, final PolicyMap policyMap) throws PolicyException {
LOGGER.entering(key, policyMap);
final Collection<WebServiceFeature> features = new LinkedList<>();
if ((key != null) && (policyMap != null)) {
final Policy policy = policyMap.getEndpointEffectivePolicy(key);
for (QName addressingAssertionQName : ADDRESSING_ASSERTIONS) {
if ((policy != null) && policy.contains(addressingAssertionQName)) {
final Iterator<AssertionSet> assertions = policy.iterator();
while (assertions.hasNext()) {
final AssertionSet assertionSet = assertions.next();
final Iterator<PolicyAssertion> policyAssertion = assertionSet.iterator();
while (policyAssertion.hasNext()) {
final PolicyAssertion assertion = policyAssertion.next();
if (assertion.getName().equals(addressingAssertionQName)) {
final WebServiceFeature feature = AddressingVersion.getFeature(addressingAssertionQName.getNamespaceURI(), true, !assertion.isOptional());
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine("Added addressing feature \"" + feature + "\" for element \"" + key + "\"");
}
features.add(feature);
}
// end-if non optional wsa assertion found
}
// next assertion
}
// next alternative
}
// end-if policy contains wsa assertion
}
// Deal with WS-Addressing 1.0 Metadata assertions
if (policy != null && policy.contains(W3CAddressingMetadataConstants.WSAM_ADDRESSING_ASSERTION)) {
for (AssertionSet assertions : policy) {
for (PolicyAssertion assertion : assertions) {
if (assertion.getName().equals(W3CAddressingMetadataConstants.WSAM_ADDRESSING_ASSERTION)) {
NestedPolicy nestedPolicy = assertion.getNestedPolicy();
boolean requiresAnonymousResponses = false;
boolean requiresNonAnonymousResponses = false;
if (nestedPolicy != null) {
requiresAnonymousResponses = nestedPolicy.contains(W3CAddressingMetadataConstants.WSAM_ANONYMOUS_NESTED_ASSERTION);
requiresNonAnonymousResponses = nestedPolicy.contains(W3CAddressingMetadataConstants.WSAM_NONANONYMOUS_NESTED_ASSERTION);
}
if (requiresAnonymousResponses && requiresNonAnonymousResponses) {
throw new WebServiceException("Only one among AnonymousResponses and NonAnonymousResponses can be nested in an Addressing assertion");
}
final WebServiceFeature feature;
try {
if (requiresAnonymousResponses) {
feature = new AddressingFeature(true, !assertion.isOptional(), AddressingFeature.Responses.ANONYMOUS);
} else if (requiresNonAnonymousResponses) {
feature = new AddressingFeature(true, !assertion.isOptional(), AddressingFeature.Responses.NON_ANONYMOUS);
} else {
feature = new AddressingFeature(true, !assertion.isOptional());
}
} catch (NoSuchMethodError e) {
throw LOGGER.logSevereException(new PolicyException(ModelerMessages.RUNTIME_MODELER_ADDRESSING_RESPONSES_NOSUCHMETHOD(toJar(Which.which(AddressingFeature.class))), e));
}
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine("Added addressing feature \"" + feature + "\" for element \"" + key + "\"");
}
features.add(feature);
}
}
}
}
}
LOGGER.exiting(features);
return features;
}
Aggregations